Subversion Repositories Kolibri OS

Rev

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

Rev 5885 Rev 5981
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;
-
 
11
	FONT font_title = 0;
-
 
12
	FONT font_option = 0;
10
	proc_info Form;
13
	word i, y, btn;
11
	word i, y, btn;
14
	char line[256], title[4196];
12
	char line[256], title[4196];
15
	font.no_bg_copy = true;
13
	font.no_bg_copy = true;
16
	font.color = 0;
14
	font.color = 0;
17
	font.bg_color = 0xFFFFFF;
-
 
18
	font.left = 5;
-
 
19
	font.top = SKIN.height+PANELH;
15
	font.bg_color = 0xFFFFFF;
20
	if (!param) strcpy(#param, "/sys/fonts/Tahoma.kf");
16
	if (!param) strcpy(#param, DEFAULT_FONT);
21
	font.load(#param);
-
 
22
	
-
 
23
	font_title.no_bg_copy = true;
-
 
24
	font_title.load("/sys/fonts/Tahoma.kf");
-
 
25
	font_title.size.text = 12;
-
 
26
	font_title.color = 0x444444;
-
 
27
	font_title.weight = 1;
-
 
28
	font_title.use_smooth = 1;
-
 
29
	font_title.bg_color = 0xE1E1E1;
-
 
30
	
-
 
31
	font_option.no_bg_copy = true;
-
 
32
	font_option.load("/sys/fonts/Tahoma.kf");
-
 
33
	font_option.size.text = 13;
-
 
34
	font_option.color = 0x222222;
-
 
35
	font_option.use_smooth = 1;
-
 
36
	font_option.bg_color = 0xDADADA;
-
 
37
	
17
	font.load(#param);
38
	strcpy(#title, "Font preview: ");
18
	strcpy(#title, "Font preview: ");
39
	strcat(#title, #param);
-
 
40
	font_title.prepare(5, 4, #title);
19
	strcat(#title, #param);
41
	loop()
20
	loop()
42
	{
21
	{
43
	  switch(WaitEvent())
22
	  switch(WaitEvent())
44
      {
23
      {
45
		case evButton:
24
		case evButton:
46
			btn = GetButtonID();
25
			btn = GetButtonID();
47
			if (btn==1) ExitProcess();
26
			if (btn==1) ExitProcess();
48
			if (btn==2) font.weight ^=1;
27
			if (btn==2) font.bold ^=1;
49
			if (btn==3) font.italic ^=1;
28
			if (btn==3) font.italic ^=1;
50
			if (btn==4) font.smooth ^=1;
29
			if (btn==4) font.smooth ^=1;
51
			goto _DRAW_WINDOW_CONTENT;
30
			goto _DRAW_WINDOW_CONTENT;
52
		case evReDraw:
31
		case evReDraw:
53
			DefineAndDrawWindow(215,100,500,320,0x04,0xFFFFFF,"");
-
 
54
			font_title.show();
32
			DefineAndDrawWindow(215,100,500,320,0x74,0xFFFFFF,#title);
55
			GetProcessInfo(#Form, SelfInfo);
33
			GetProcessInfo(#Form, SelfInfo);
56
			_DRAW_WINDOW_CONTENT:
34
			_DRAW_WINDOW_CONTENT:
57
			DrawBar(5, SKIN.height, Form.cwidth, PANELH, 0xDADADA);
-
 
58
			
-
 
59
			font_option.italic = font_option.smooth = 0;
-
 
60
			font_option.weight = 1;
-
 
61
			font_option.prepare(30, SKIN.height+7, "Bold");
35
			DrawBar(0, 0, Form.cwidth, PANELH, 0xCCCccc);
62
			CheckBox2(10, SKIN.height+8, 2, "",  font.weight);
-
 
63
			font_option.show();
-
 
64
			
-
 
65
			font_option.weight = font_option.smooth = 0;
-
 
66
			font_option.italic = 1;
-
 
67
			font_option.prepare(90, SKIN.height+7, "Italic");
36
			CheckBox2(10, 8, 2, "Bold",  font.bold);
68
			CheckBox2(70, SKIN.height+8, 3, "",  font.italic);
-
 
69
			font_option.show();
-
 
70
			
-
 
71
			font_option.weight = font_option.italic = 0;
-
 
72
			font_option.smooth = 1;
-
 
73
			font_option.prepare(160, SKIN.height+7, "Smooth");
37
			CheckBox2(70, 8, 3, "Italic",  font.italic);
74
			CheckBox2(140, SKIN.height+8, 4, "Smooth",  font.smooth);
-
 
75
			font_option.show();
-
 
76
			
38
			CheckBox2(140, 8, 4, "Smooth",  font.smooth);
77
			IF(font.buffer)font.buffer_size = 0;
-
 
78
			
39
			font.buffer_size = free(font.buffer);
79
			if (!font.data)
40
			if (!font.data)
80
			{
41
			{
81
				DrawBar(5, SKIN.height+PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
42
				DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
82
				WriteText(15, 50, 0x82, 0xFF00FF, "Font is not loaded.");
43
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
83
			}
44
			}
84
			else for (i=10, y=5; i<22; i++, y+=font.height;) //not flexible, need to calculate font count and max line length
45
			else for (i=10, y=5; i<22; i++, y+=font.height;) //not flexible, need to calculate font count and max line length
85
			{
46
			{
86
				font.size.text = i;
47
				font.size.text = i;
87
				sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
48
				sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
88
				font.prepare_buf(15,SKIN.height+y,Form.cwidth,Form.cheight-PANELH, #line);
49
				font.prepare_buf(10,y,Form.cwidth,Form.cheight-PANELH, #line);
89
			}
50
			}
-
 
51
			if (font.smooth) SmoothFont(font.buffer, font.size.width, font.size.height);
-
 
52
			font.left = 0;
90
			if (font.smooth) SmoothFont(font.buffer, font.size.width, font.size.height);
53
			font.top = PANELH;
91
			font.show();
54
			font.show();
92
	  }
55
	  }
93
	}
56
	}