/*FILE HEADER**************************************************************
 *
 *  File name		: $Id$
 *  RCS Revision Number	: $Revision: 1.1 $
 *  Last Modified	: $Date: 94/10/28 09:23:35 $
 *  CSCI name		: Real-Time Graphics System - Applications Interface
 *  CSC name		: All functions
 *  Notes:
 *      This file contains code used to debug and test the SVME-770 RTGS.
 *      This code is provided as an example of how to call the RTGS functions
 *      from a host application.
 *  History		:
 *      Created 94/01/17 by Jeff Sanderson
 *
 *END FILE HEADER*********************************************************/

#include "dy4std.h"
#include "es.h"
#include "css.h"

#include "rtgs_ai.h"
#include "video.h"
#include "colours.h"

#include "test.h"


void test_textspac( void );
/*-----------------------------------------------------------------------*/



void test_textspac( void )
{
    int i;
    char *str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    char *gcc_str;
    point_t *gcc_sz;
    point_t sz;
    int     x,y;

    init( "Text spacing text" );

    gcc_str = ( char * )Gcc_malloc(( strlen( str ) + 4 ), 0 );
    malloc_check( gcc_str );
    Copy_string_to_gcc( (char *)str, (char *)gcc_str, strlen( str ) + 4 );

    gcc_sz = ( point_t * )Gcc_malloc( sizeof( point_t ), 0 );
    malloc_check( gcc_sz );

    Set_text_font( 4 );

    Inquire_text_extent( gcc_str, gcc_sz );
    Gcc_sync();
    sz.x = gcc_sz->x;
    sz.y = gcc_sz->y;
    

    Set_foreground_colour( WHITE );
    Set_background_colour( BLACK );
    for( i = 1; i < 20 ; i++ )
    {
        x = 20;
        y = 20;

        Clear_screen( BLACK, 0, 0 );
        Draw_grid( 0x10 );

        Set_transparency_mode( TRANSPARENT );
        Set_text_spacing( 1 );

	Inquire_text_extent( gcc_str, gcc_sz );
	Gcc_sync();
	sz.x = gcc_sz->x;
	sz.y = gcc_sz->y;

	Set_foreground_colour( RED );
        Draw_filled_rectangle( x, y, x + sz.x, y + sz.y );
	Set_foreground_colour( WHITE );

        Draw_text( x, y, gcc_str );
        y += sz.y;

        Set_text_spacing( i );

	Inquire_text_extent( gcc_str, gcc_sz );
	Gcc_sync();
	sz.x = gcc_sz->x;
	sz.y = gcc_sz->y;

	Set_foreground_colour( RED );
        Draw_filled_rectangle( x, y, x + sz.x, y + sz.y );
	Set_foreground_colour( WHITE );

        Draw_text( x, y, gcc_str );
        y += sz.y;

        Set_transparency_mode( OPAQUE );
	Set_foreground_colour( RED );
        Draw_filled_rectangle( x, y, x + sz.x, y + sz.y );
	Set_foreground_colour( WHITE );

        Draw_text( x, y, gcc_str );
  
        Key_wait();
	Clear_screen( BLACK,0,0 );
    }
}

