2015-09-02 15:15:32 +02:00
# define MEMSIZE 0x2EE80
2015-08-27 10:33:51 +02:00
# include "../lib/font.h"
# include "../lib/gui.h"
2015-09-02 15:15:32 +02:00
# define PANELH 30
2016-02-20 14:06:19 +01:00
proc_info Form ;
enum {
2016-12-21 11:56:06 +01:00
STRONG_BTN = 10 , SMOOTH_BTN ,
2016-02-20 14:06:19 +01:00
PHRASE_TAB = 20 , CHARS_TAB
} ;
2015-09-02 15:15:32 +02:00
2015-08-27 10:33:51 +02:00
void main ( )
{
2016-02-20 14:06:19 +01:00
int btn ;
char title [ 4196 ] ;
2015-12-17 20:15:49 +01:00
if ( ! param ) strcpy ( # param , DEFAULT_FONT ) ;
2015-12-18 22:10:45 +01:00
label . init ( # param ) ;
2016-02-20 14:06:19 +01:00
tabs . active_tab = PHRASE_TAB ;
2015-11-06 15:49:37 +01:00
strcpy ( # title , " Font preview: " ) ;
2015-08-27 10:33:51 +02:00
strcat ( # title , # param ) ;
2016-02-20 14:06:19 +01:00
loop ( ) switch ( WaitEvent ( ) )
2015-08-27 10:33:51 +02:00
{
case evButton :
btn = GetButtonID ( ) ;
if ( btn = = 1 ) ExitProcess ( ) ;
2016-02-20 14:06:19 +01:00
if ( btn = = STRONG_BTN ) label . bold ^ = 1 ;
if ( btn = = SMOOTH_BTN ) label . smooth ^ = 1 ;
if ( btn = = PHRASE_TAB ) | | ( btn = = CHARS_TAB ) tabs . click ( btn ) ;
2015-09-02 15:15:32 +02:00
goto _DRAW_WINDOW_CONTENT ;
2015-08-27 10:33:51 +02:00
case evReDraw :
2016-02-11 14:46:53 +01:00
system . color . get ( ) ;
2016-11-23 12:37:13 +01:00
DefineAndDrawWindow ( 215 , 100 , 500 , 320 + skin_height , 0x74 , 0xFFFFFF , # title , 0 ) ;
2015-09-02 15:15:32 +02:00
GetProcessInfo ( # Form , SelfInfo ) ;
2015-12-18 22:10:45 +01:00
if ( Form . status_window > 2 ) break ;
2015-09-02 15:15:32 +02:00
_DRAW_WINDOW_CONTENT :
2016-02-20 14:06:19 +01:00
DrawBar ( 0 , 0 , Form . cwidth , PANELH - 1 , system . color . work ) ;
CheckBox ( 10 , 8 , STRONG_BTN , " Bold " , label . bold ) ;
2016-12-21 11:56:06 +01:00
CheckBox ( 83 , 8 , SMOOTH_BTN , " Smooth " , label . smooth ) ;
2016-02-20 14:06:19 +01:00
tabs . draw ( Form . cwidth - 150 , PANELH , PHRASE_TAB , " Phrase " ) ;
tabs . draw ( Form . cwidth - 70 , PANELH , CHARS_TAB , " Chars " ) ;
DrawBar ( 0 , PANELH - 1 , Form . cwidth , 1 , system . color . work_graph ) ;
2015-12-18 22:10:45 +01:00
if ( ! label . font )
2015-08-27 10:33:51 +02:00
{
2015-12-17 20:15:49 +01:00
DrawBar ( 0 , PANELH , Form . cwidth , Form . cheight - PANELH , 0xFFFfff ) ;
WriteText ( 10 , 50 , 0x82 , 0xFF00FF , " Font is not loaded. " ) ;
2016-02-20 14:06:19 +01:00
break ;
2015-09-02 15:15:32 +02:00
}
2016-02-20 14:06:19 +01:00
if ( tabs . active_tab = = PHRASE_TAB ) DrawPreviewPhrase ( ) ;
if ( tabs . active_tab = = CHARS_TAB ) DrawPreviewChars ( ) ;
}
}
void DrawPreviewPhrase ( )
{
dword i , y ;
char line [ 256 ] ;
label . raw_size = free ( label . raw ) ;
for ( i = 10 , y = 5 ; i < 22 ; i + + , y + = label . height ; ) //not flexible, need to calculate font count and max line length
{
sprintf ( # line , " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> /size font %d <20> <> <EFBFBD> ᥫ<EFBFBD> <E1A5AB> ." , i ) ;
2016-12-21 11:56:06 +01:00
label . WriteIntoBuffer ( 10 , y , Form . cwidth , Form . cheight - PANELH , 0xFFFFFF , 0 , i , # line ) ;
2016-02-20 14:06:19 +01:00
}
2016-12-21 11:56:06 +01:00
if ( label . smooth ) label . ApplySmooth ( ) ;
2016-02-20 14:06:19 +01:00
label . show_buf ( 0 , PANELH ) ;
}
void DrawPreviewChars ( )
{
dword i , x = 20 , y = 0 ;
char line [ 2 ] ;
line [ 1 ] = NULL ;
label . raw_size = free ( label . raw ) ;
for ( i = 0 ; i < 255 ; i + + ) //not flexible, need to calculate font count and max line length
{
line [ 0 ] = i ;
2016-12-21 11:56:06 +01:00
label . WriteIntoBuffer ( x , y , Form . cwidth , Form . cheight - PANELH , 0xFFFFFF , 0 , 16 , # line ) ;
2016-02-20 14:06:19 +01:00
x + = label . height + 2 ;
if ( x > = Form . cwidth - 30 ) {
x = 20 ;
y + = label . height + 2 ;
}
2015-08-27 10:33:51 +02:00
}
2016-12-21 11:56:06 +01:00
if ( label . smooth ) label . ApplySmooth ( ) ;
2016-02-20 14:06:19 +01:00
label . show_buf ( 0 , PANELH ) ;
2015-08-27 10:33:51 +02:00
}