Subversion Repositories Kolibri OS

Rev

Rev 5985 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5985 Rev 5987
Line 6... Line 6...
6
#define PANELH 30
6
#define PANELH 30
Line 7... Line 7...
7
 
7
 
8
void main()
8
void main()
9
{   
9
{   
10
	proc_info Form;
10
	proc_info Form;
11
	word i, y, btn;
11
	int i, y, btn;
12
	char line[256], title[4196];
-
 
13
	font.color = 0;
-
 
14
	font.bg_color = 0xFFFFFF;
12
	char line[256], title[4196];
15
	if (!param) strcpy(#param, DEFAULT_FONT);
13
	if (!param) strcpy(#param, DEFAULT_FONT);
16
	font.load(#param);
14
	label.init(#param);
17
	strcpy(#title, "Font preview: ");
15
	strcpy(#title, "Font preview: ");
18
	strcat(#title, #param);
16
	strcat(#title, #param);
19
	loop()
17
	loop()
20
	{
18
	{
21
	  switch(WaitEvent())
19
	  switch(WaitEvent())
22
      {
20
      {
23
		case evButton:
21
		case evButton:
24
			btn = GetButtonID();
22
			btn = GetButtonID();
25
			if (btn==1) ExitProcess();
23
			if (btn==1) ExitProcess();
26
			if (btn==2) font.bold ^=1;
24
			if (btn==2) label.bold ^=1;
27
			if (btn==3) font.italic ^=1;
25
			if (btn==3) label.italic ^=1;
28
			if (btn==4) font.smooth ^=1;
26
			if (btn==4) label.smooth ^=1;
29
			goto _DRAW_WINDOW_CONTENT;
27
			goto _DRAW_WINDOW_CONTENT;
30
		case evReDraw:
28
		case evReDraw:
31
			DefineAndDrawWindow(215,100,500,320,0x74,0xFFFFFF,#title);
29
			DefineAndDrawWindow(215,100,500,320,0x74,0xFFFFFF,#title);
-
 
30
			GetProcessInfo(#Form, SelfInfo);
32
			GetProcessInfo(#Form, SelfInfo);
31
			if (Form.status_window>2) break;
33
			_DRAW_WINDOW_CONTENT:
32
			_DRAW_WINDOW_CONTENT:
34
			DrawBar(0, 0, Form.cwidth, PANELH, 0xCCCccc);
33
			DrawBar(0, 0, Form.cwidth, PANELH, 0xCCCccc);
35
			CheckBox2(10, 8, 2, "Bold",  font.bold);
34
			CheckBox2(10, 8, 2, "Bold",  label.bold);
36
			CheckBox2(70, 8, 3, "Italic",  font.italic);
35
			CheckBox2(70, 8, 3, "Italic",  label.italic);
37
			CheckBox2(140, 8, 4, "Smooth",  font.smooth);
36
			CheckBox2(140, 8, 4, "Smooth",  label.smooth);
38
			font.buffer_size = free(font.buffer);
37
			label.raw_size = free(label.raw);
39
			if (!font.data)
38
			if (!label.font)
40
			{
39
			{
41
				DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
40
				DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
42
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
41
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
43
			}
42
			}
44
			else for (i=10, y=5; i<22; i++, y+=font.height;) //not flexible, need to calculate font count and max line length
43
			else for (i=10, y=5; i<22; i++, y+=label.height;) //not flexible, need to calculate font count and max line length
45
			{
-
 
46
				font.size.text = i;
44
			{
47
				sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
45
				sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
48
				font.write_buf(10,y,Form.cwidth,Form.cheight-PANELH, #line);
46
				label.write_buf(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line);
49
			}
47
			}
50
			if (font.smooth) font.apply_smooth();
48
			if (label.smooth) label.apply_smooth();
51
			font.show_buf(0, PANELH);
49
			label.show_buf(0, PANELH);
52
	  }
50
	  }
53
	}
51
	}
Line 54... Line 52...
54
}
52
}