Subversion Repositories Kolibri OS

Rev

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

Rev 6806 Rev 7226
Line 1... Line 1...
1
#define MEMSIZE 0x2EE80
1
#define MEMSIZE 0x2EE80
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
 
-
 
6
#define PANELH 28
5
 
7
#define WIN_W 490
Line 6... Line 8...
6
#define PANELH 30
8
#define WIN_H 315
7
proc_info Form;
9
proc_info Form;
8
 
10
 
9
enum { 
11
enum { 
Line -... Line 12...
-
 
12
	STRONG_BTN=10, SMOOTH_BTN, 
-
 
13
	PHRASE_TAB=20, CHARS_TAB
-
 
14
};
-
 
15
 
Line 10... Line 16...
10
	STRONG_BTN=10, SMOOTH_BTN, 
16
_tabs tabs = { 0,0, WIN_W, WIN_H, PHRASE_TAB};
11
	PHRASE_TAB=20, CHARS_TAB
17
 
12
};
18
rect preview;
13
 
19
 
14
 
20
 
15
void main()
21
void main()
16
{   
-
 
17
	int btn;
22
{   
18
	char title[4196];
23
	int btn;
19
	if (!param) strcpy(#param, DEFAULT_FONT);
24
	char title[4196];
20
	kfont.init(#param);
25
	if (!param) strcpy(#param, DEFAULT_FONT);
21
	tabs.active_tab=PHRASE_TAB;
26
	kfont.init(#param);
Line 30... Line 35...
30
			if (btn==SMOOTH_BTN) kfont.smooth ^=1;
35
			if (btn==SMOOTH_BTN) kfont.smooth ^=1;
31
			if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn);
36
			if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn);
32
			goto _DRAW_WINDOW_CONTENT;
37
			goto _DRAW_WINDOW_CONTENT;
33
		case evReDraw:
38
		case evReDraw:
34
			system.color.get();
39
			system.color.get();
35
			DefineAndDrawWindow(215,100,500,320+skin_height,0x74,0xFFFFFF,#title,0);
40
			DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_height+5,0x74,0xFFFFFF,#title,0);
36
			GetProcessInfo(#Form, SelfInfo);
41
			GetProcessInfo(#Form, SelfInfo);
37
			if (Form.status_window>2) break;
42
			if (Form.status_window>2) break;
38
			_DRAW_WINDOW_CONTENT:
43
			_DRAW_WINDOW_CONTENT:
-
 
44
 
39
			DrawBar(0, 0, Form.cwidth, PANELH-1, system.color.work);
45
			DrawBar(0, 0, Form.cwidth, PANELH-1, system.color.work);
-
 
46
			DrawBar(0, PANELH-1,Form.cwidth,1,system.color.work_graph);
40
			CheckBox(10, 8, STRONG_BTN, "Bold",  kfont.bold);
47
			CheckBox(10, 8, STRONG_BTN, "Bold",  kfont.bold);
41
			CheckBox(83,8, SMOOTH_BTN, "Smooth",  kfont.smooth);
48
			CheckBox(83,8, SMOOTH_BTN, "Smooth",  kfont.smooth);
-
 
49
 
42
			tabs.draw(Form.cwidth-150, PANELH, PHRASE_TAB, "Phrase");
50
			tabs.draw_button(Form.cwidth-130, PHRASE_TAB, "Phrase");
43
			tabs.draw(Form.cwidth-70, PANELH, CHARS_TAB, "Chars");
51
			tabs.draw_button(Form.cwidth-60, CHARS_TAB, "Chars");
-
 
52
 
-
 
53
			preview.x = tabs.x;
-
 
54
			preview.y = PANELH;
-
 
55
			preview.w = Form.cwidth;
44
			DrawBar(0, PANELH-1,Form.cwidth,1,system.color.work_graph);
56
			preview.h = Form.cheight - PANELH;
-
 
57
 
45
			if (!kfont.font)
58
			if (!kfont.font)
46
			{
59
			{
47
				DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
60
				DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff);
48
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
61
				WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
49
				break;
62
				break;
50
			}
63
			}
51
			if (tabs.active_tab==PHRASE_TAB) DrawPreviewPhrase();
64
			if (tabs.active_tab==PHRASE_TAB) DrawPreviewPhrase();
52
			if (tabs.active_tab==CHARS_TAB) DrawPreviewChars();
65
			if (tabs.active_tab==CHARS_TAB) DrawPreviewChars();
Line 62... Line 75...
62
	{
75
	{
63
		sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
76
		sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
64
		kfont.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line);
77
		kfont.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line);
65
	}
78
	}
66
	if (kfont.smooth) kfont.ApplySmooth();
79
	if (kfont.smooth) kfont.ApplySmooth();
67
	kfont.ShowBuffer(0, PANELH);
80
	kfont.ShowBuffer(preview.x, preview.y);
68
}
81
}
Line 69... Line 82...
69
 
82
 
70
void DrawPreviewChars()
83
void DrawPreviewChars()
71
{
84
{
Line 76... Line 89...
76
	for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length
89
	for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length
77
	{
90
	{
78
		line[0]=i;
91
		line[0]=i;
79
		kfont.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line);
92
		kfont.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line);
80
		x+= kfont.height+2;
93
		x+= kfont.height+2;
81
		if (x>=Form.cwidth-30) { 
94
		if (x>=preview.w-30) { 
82
			x=20;
95
			x=20;
83
			y+=kfont.height+2;
96
			y+=kfont.height+2;
84
		}
97
		}
85
	}
98
	}
86
	if (kfont.smooth) kfont.ApplySmooth();
99
	if (kfont.smooth) kfont.ApplySmooth();
87
	kfont.ShowBuffer(0, PANELH);
100
	kfont.ShowBuffer(preview.x, preview.y);
88
}
101
}