Subversion Repositories Kolibri OS

Rev

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

Rev 7909 Rev 7984
Line 1... Line 1...
1
#define MEMSIZE 0x2EE80
1
#define MEMSIZE 1024*30
Line 2... Line 2...
2
 
2
 
3
#include "../lib/kfont.h"
3
#include "../lib/kfont.h"
Line 4... Line 4...
4
#include "../lib/gui.h"
4
#include "../lib/gui.h"
5
 
5
 
6
#define PANELH 28
6
#define PANELH 28
7
#define WIN_W 490
7
#define WIN_W 490
8
#define WIN_H 315
-
 
Line 9... Line 8...
9
#define BASE_TAB_BUTTON_ID 97
8
#define WIN_H 315
Line 10... Line 9...
10
proc_info Form;
9
#define BASE_TAB_BUTTON_ID 97
11
 
10
 
12
_tabs tabs = { WIN_W-130, 0, NULL, BASE_TAB_BUTTON_ID };
11
_tabs tabs = { WIN_W-130, 0, NULL, BASE_TAB_BUTTON_ID };
13
 
12
 
Line 14... Line 13...
14
block preview = { 0, PANELH, WIN_W, WIN_H - PANELH };
13
block preview = { 0, PANELH, WIN_W, WIN_H - PANELH };
15
checkbox bold = { "Bold", false };
14
checkbox bold = { "Bold", false };
-
 
15
checkbox smooth = { "Smooth", true };
-
 
16
checkbox colored = { "Colored", true };
16
checkbox smooth = { "Smooth", true };
17
 
17
checkbox colored = { "Colored", true };
-
 
-
 
18
void main()
18
 
19
{   
19
void main()
20
	proc_info Form;
20
{   
21
	char title[1024];
21
	int btn;
22
	int btn;
Line 22... Line 23...
22
	char title[4196];
23
 
23
	if (!param) strcpy(#param, DEFAULT_FONT);
24
	if (!param) strcpy(#param, DEFAULT_FONT);
Line 24... Line 25...
24
	kfont.init(#param);
25
	kfont.init(#param);
25
	strcpy(#title, "Font preview: ");
26
	strcpy(#title, "Font preview: ");
26
	strcat(#title, #param);
27
	strcat(#title, #param);
27
 
28
 
28
	tabs.add("Phrase", #DrawPreviewPhrase);
29
	tabs.add("Phrase", #DrawPreviewPhrase);
29
	tabs.add("Chars", #DrawPreviewChars);
30
	tabs.add("Chars", #DrawPreviewChars);
30
 
31
 
31
	loop() switch(WaitEvent())
32
	loop() switch(@WaitEvent())
32
	{
33
	{
33
		case evButton:
34
		case evButton:
-
 
35
			btn = @GetButtonID();
34
			btn = GetButtonID();
36
			if (btn==1) @ExitProcess();
35
			if (btn==1) ExitProcess();
37
			bold.click(btn); 
36
			bold.click(btn); 
38
			smooth.click(btn);
37
			smooth.click(btn);
39
			colored.click(btn);
38
			colored.click(btn);
40
			tabs.click(btn);
39
			tabs.click(btn);
41
			GOTO _DRAW_WINDOW_CONTENT;
Line 40... Line 42...
40
			goto _DRAW_WINDOW_CONTENT;
42
 
41
		case evReDraw:
43
		case evReDraw:
Line 42... Line 44...
42
			sc.get();
44
			sc.get();
43
			DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_height+5,0x74,0xFFFFFF,#title,0);
45
			DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_height+5,0x74,0xFFFFFF,#title,0);
-
 
46
			GetProcessInfo(#Form, SelfInfo);
-
 
47
			if (Form.status_window>2) break;
-
 
48
			_DRAW_WINDOW_CONTENT:
-
 
49
 
-
 
50
			kfont.bold = bold.checked;
44
			GetProcessInfo(#Form, SelfInfo);
51
			kfont.smooth = smooth.checked;
45
			if (Form.status_window>2) break;
52
 
46
			_DRAW_WINDOW_CONTENT:
53
			DrawBar(0, 0, WIN_W, PANELH-1, sc.work);
47
 
-
 
48
			kfont.bold = bold.checked;
54
			DrawBar(0, PANELH-1,WIN_W,1,sc.work_graph);
49
			kfont.smooth = smooth.checked;
55
 
50
 
-
 
51
			DrawBar(0, 0, Form.cwidth, PANELH-1, sc.work);
-
 
52
			DrawBar(0, PANELH-1,Form.cwidth,1,sc.work_graph);
-
 
53
			bold.draw(10, 8);
-
 
54
			smooth.draw(83,8);
-
 
55
			colored.draw(170,8);
-
 
56
 
56
			if (!kfont.font) {
57
			tabs.draw();
57
				DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff);
58
			tabs.draw_active_tab();
58
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
Line 59... Line 59...
59
 
59
			} else {
60
			if (!kfont.font)
60
				bold.draw(10, 8);
61
			{
-
 
Line 62... Line 61...
62
				DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff);
61
				smooth.draw(83,8);
63
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
62
				colored.draw(170,8);
64
				break;
63
				tabs.draw();
65
			}
64
				tabs.draw_active_tab();
66
	}
65
			}
67
}
66
	}
68
 
67
}
69
dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266, 
68
 
70
	0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA, 
69
dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266, 
71
	0,0,0,0,0 };
70
	0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA, 0 };
72
 
71
 
73
void DrawPreviewPhrase()
72
void DrawPreviewPhrase()
74
{
73
{
75
	dword i, y;
74
	dword i, y;
76
	dword c;
75
	dword c;
77
	char line[256];
76
	char line[256];
78
	kfont.raw_size = free(kfont.raw);
77
	kfont.raw_size = free(kfont.raw);
Line 79... Line 78...
79
	for (i=10, y=12; i<22; i++, y+=kfont.height+3;) //not flexible, need to calculate font count and max line length
78
	for (i=10, y=12; i<22; i++, y+=kfont.height+3;) //not flexible, need to calculate font count and max line length
80
	{
79
	{
81
		if (colored.checked) c = pal[i-10]; else c=0;
80
		if (colored.checked) c = pal[i-10]; else c=0;
82
		strcpy(#line, " §¬¥à èà¨äâ /forn size is ");
81
		strcpy(#line, " §¬¥à èà¨äâ /font size is ");
83
		strcat(#line, itoa(i));
-
 
84
		strcat(#line, " ¯¨ªá¥«¥©/px.");
82
		strcat(#line, itoa(i));
85
		kfont.WriteIntoBuffer(14,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, c, i, #line);
83
		strcat(#line, " ¯¨ªá¥«¥©/px.");
86
	}
84
		kfont.WriteIntoBuffer(14,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, c, i, #line);
87
	if (kfont.smooth) kfont.ApplySmooth();
85
	}
88
	kfont.ShowBuffer(preview.x, preview.y);
86
	if (kfont.smooth) kfont.ApplySmooth();
89
}
87
	kfont.ShowBuffer(preview.x, preview.y);
90
 
88
}
91
void DrawPreviewChars()
89
 
92
{
90
void DrawPreviewChars()
93
	dword i, x=20, y=0;
91
{