Subversion Repositories Kolibri OS

Rev

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

Rev 9597 Rev 9601
Line 1... Line 1...
1
#define MEMSIZE 1024*30
1
#define MEMSIZE 1024*30
-
 
2
#define ENTRY_POINT #main
Line 2... Line 3...
2
 
3
 
3
#include "../lib/kfont.h"
4
#include "../lib/kfont.h"
Line 4... Line 5...
4
#include "../lib/gui.h"
5
#include "../lib/gui.h"
5
 
6
 
6
#define PANELH 28
7
#define BARH 28
7
#define WIN_W 520
-
 
8
#define WIN_H 315
-
 
9
#define BASE_TAB_BUTTON_ID 97
-
 
10
 
8
#define WINW 528
11
_tabs tabs = { WIN_W-130, 0, NULL, BASE_TAB_BUTTON_ID };
-
 
12
 
9
#define WINH 315
13
block preview = { 0, PANELH, WIN_W, WIN_H - PANELH };
10
 
14
checkbox bold = { "Bold", false };
11
char active_tab = 0;
Line 15... Line 12...
15
checkbox smooth = { "Smooth", true };
12
char colored = true;
16
checkbox colored = { "Colored", true };
13
dword checkbox_flag;
17
 
14
 
-
 
15
void main()
18
void main()
16
{   
19
{   
17
	proc_info Form;
Line 20... Line 18...
20
	proc_info Form;
18
 
21
	char title[1024];
19
	mem_init();
22
	int btn;
20
	checkbox_flag = memopen("CHECKBOX", NULL, SHM_READ);
23
 
21
 
Line 24... Line -...
24
	if (!param) strcpy(#param, DEFAULT_FONT);
-
 
25
	kfont.init(#param);
-
 
26
	strcpy(#title, "Font preview: ");
-
 
27
	strcat(#title, #param);
22
	if (!param) strcpy(#param, DEFAULT_FONT);
28
 
23
	kfont.init(#param);
-
 
24
	strcpy(#title, "Font preview: ");
-
 
25
	strcat(#title, #param);
-
 
26
 
-
 
27
	loop() switch(@WaitEvent())
-
 
28
	{
-
 
29
		case evKey:
-
 
30
			@GetKey();
-
 
31
			EAX >>= 16;
-
 
32
			if (AL == SCAN_CODE_ESC) ExitProcess();
-
 
33
			if (AL == SCAN_CODE_TAB) {
29
	tabs.add("Phrase", #DrawPreviewPhrase);
34
				active_tab^=1;
30
	tabs.add("Chars", #DrawPreviewChars);
35
				goto _DRAW_WINDOW_CONTENT;
31
 
36
			}
32
	loop() switch(@WaitEvent())
37
			break;
-
 
38
 
33
	{
39
		case evButton:
34
		case evButton:
40
			@GetButtonID();
35
			btn = @GetButtonID();
41
			if (EAX==1) ExitProcess();
36
			if (btn==1) @ExitProcess();
42
			if (EAX==2) kfont.bold^=1;
Line 37... Line 43...
37
			bold.click(btn); 
43
			if (EAX==3) kfont.smooth^=1;
38
			smooth.click(btn);
44
			if (EAX==4) colored^=1;
39
			colored.click(btn);
45
			if (EAX==5) active_tab=0;
40
			tabs.click(btn);
46
			if (EAX==6) active_tab=1;
41
			GOTO _DRAW_WINDOW_CONTENT;
47
			GOTO _DRAW_WINDOW_CONTENT;
42
 
48
 
Line 43... Line -...
43
		case evReDraw:
-
 
44
			sc.get();
-
 
45
			DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_h+5,0x74,0xFFFFFF,#title,0);
-
 
46
			GetProcessInfo(#Form, SelfInfo);
49
		case evReDraw:
47
			if (Form.status_window&ROLLED_UP) break;
50
			sc.get();
Line 48... Line 51...
48
			_DRAW_WINDOW_CONTENT:
51
			DefineAndDrawWindow(215,100,WINW+9,WINH+GetSkinHeight()+4,0x74,0xFFFFFF,#title,0);
49
 
52
			GetProcessInfo(#Form, SelfInfo);
50
			kfont.bold = bold.checked;
53
			if (Form.status_window&ROLLED_UP) break;
51
			kfont.smooth = smooth.checked;
54
			_DRAW_WINDOW_CONTENT:
-
 
55
 
-
 
56
			DrawBar(0, 0, WINW, BARH-1, sc.work);
-
 
57
			DrawBar(0, BARH-1,WINW,1,sc.work_graph);
-
 
58
 
-
 
59
			if (!kfont.font) {
-
 
60
				DrawBar(0, BARH, WINW, WINH - BARH, 0xFFFfff);
52
 
61
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
-
 
62
			} else {
-
 
63
				draw_checkbox(9, kfont.bold);
-
 
64
				draw_checkbox(81, kfont.smooth);
-
 
65
				draw_checkbox(169, colored);
53
			DrawBar(0, 0, WIN_W, PANELH-1, sc.work);
66
				WriteText(30, 8, 0x90, sc.work_text, "Bold     Smooth     Colored            Phrase   Chars");
54
			DrawBar(0, PANELH-1,WIN_W,1,sc.work_graph);
67
				UnsafeDefineButton(0, 3, 70, 24, 2+BT_HIDE+BT_NOFRAME, ESI);
-
 
68
				$inc edx //11
55
 
69
				$add ebx, 80 << 16
56
			if (!kfont.font) {
70
				$int 64
-
 
71
				$inc edx //12
-
 
72
				$add ebx, 88 << 16
-
 
73
				$int 64
57
				DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff);
74
				$inc edx //13
58
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
75
				$add ebx, 162 << 16
59
			} else {
76
				$int 64
Line 60... Line 77...
60
				bold.draw(10, 8);
77
				$inc edx //14
61
				smooth.draw(83,8);
78
				$add ebx, 70 << 16
Line 62... Line 79...
62
				colored.draw(170,8);
79
				$int 64
63
				tabs.draw();
80
				DrawBar(active_tab*70+335, BARH-4, 60, 4, 0xE44C9C);
64
				tabs.draw_active_tab();
81
				if (!active_tab) DrawPreviewPhrase(); else DrawPreviewChars();
65
			}
-
 
66
	}
82
			}
67
}
83
	}
68
 
84
}
69
dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266, 
85
 
70
	0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA, 0 };
-
 
71
 
86
dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266, 
72
void DrawPreviewPhrase()
87
	0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA, 0 };
73
{
88
 
74
	dword i, y;
89
void DrawPreviewPhrase()
-
 
90
{
75
	dword c;
91
	dword i, y=12;
76
	char line[256];
-
 
77
	kfont.raw_size = free(kfont.raw);
92
	dword line[64];
78
	for (i=10, y=12; i<22; i++, y+=kfont.height+3;) //not flexible, need to calculate font count and max line length
93
	kfont.raw_size = free(kfont.raw);
Line 79... Line 94...
79
	{
94
	for (i=10; i<22; i++) //not flexible, need to calculate font count and max line length
80
		if (colored.checked) c = pal[i-10]; else c=0;
95
	{
81
		strcpy(#line, " §¬¥à èà¨äâ /font size is ");
96
		strcpy(#line, " §¬¥à èà¨äâ /font size is ");
82
		strcat(#line, itoa(i));
97
		itoa_(#line+27, i);
83
		strcat(#line, " ¯¨ªá¥«¥©/px.");
98
		strcat(#line, " ¯¨ªá¥«¥©/px.");
84
		kfont.WriteIntoBuffer(14,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, c, i, #line);
99
		kfont.WriteIntoBuffer(14,y,WINW,WINH-BARH, 0xFFFFFF, pal[i-10]*colored, i, #line);
85
	}
100
		y+=kfont.height+3;
86
	if (kfont.smooth) kfont.ApplySmooth();
101
	}
87
	kfont.ShowBuffer(preview.x, preview.y);
102
	DrawBuf();
88
}
103
}
89
 
104
 
90
void DrawPreviewChars()
105
void DrawPreviewChars()
91
{
106
{
92
	dword i, x=20, y=0;
107
	dword i, x=20, y=0;
93
	char line[2]=0;
108
	char line[2];
-
 
109
	kfont.raw_size = free(kfont.raw);
-
 
110
	for (i=0; i<255; i++)
-
 
111
	{
-
 
112
		line[0]=i;
-
 
113
		kfont.WriteIntoBuffer(x,y,WINW,WINH-BARH, 0xFFFFFF, 0, 16, #line);
94
	kfont.raw_size = free(kfont.raw);
114
		x+= kfont.height+2;
95
	for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length
115
		if (x>=WINW-30) { 
-
 
116
			x=20;
-
 
117
			y+=kfont.height+2;
-
 
118
		}
-
 
119
	}
-
 
120
	DrawBuf();
-
 
121
}
-
 
122
 
-
 
123
void DrawBuf()
-
 
124
{
-
 
125
	if (kfont.smooth) kfont.ApplySmooth();
-
 
126
	kfont.ShowBuffer(0, BARH);
-
 
127
}
-
 
128
 
96
	{
129
void draw_checkbox(dword _x, _checked)
-
 
130
{
-
 
131
	#define SIZE 14
-
 
132
	#define CHBOXY 7
-
 
133
	DrawRectangle3D(_x, CHBOXY, SIZE, SIZE, sc.work_graph, sc.work_graph);
97
		line[0]=i;
134
	if (_checked == false)