Rev 7227 | Rev 7647 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7227 | Rev 7244 | ||
---|---|---|---|
1 | #define MEMSIZE 0x2EE80 |
1 | #define MEMSIZE 0x2EE80 |
2 | 2 | ||
3 | #include "../lib/kfont.h" |
3 | #include "../lib/kfont.h" |
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 |
8 | #define WIN_H 315 |
9 | proc_info Form; |
9 | proc_info Form; |
10 | 10 | ||
11 | enum { |
11 | enum { |
12 | STRONG_BTN=10, SMOOTH_BTN, |
- | |
13 | PHRASE_TAB=20, CHARS_TAB |
12 | PHRASE_TAB=20, CHARS_TAB |
14 | }; |
13 | }; |
15 | 14 | ||
16 | _tabs tabs = { 0,0, WIN_W, WIN_H, PHRASE_TAB}; |
15 | _tabs tabs = { 0,0, WIN_W, WIN_H, PHRASE_TAB}; |
17 | 16 | ||
18 | block preview = { 0, PANELH, WIN_W, WIN_H - PANELH }; |
17 | block preview = { 0, PANELH, WIN_W, WIN_H - PANELH }; |
19 | - | ||
- | 18 | checkbox bold = { "Bold", false }; |
|
- | 19 | checkbox smooth = { "Smooth", true }; |
|
20 | 20 | ||
21 | void main() |
21 | void main() |
22 | { |
22 | { |
23 | int btn; |
23 | int btn; |
24 | char title[4196]; |
24 | char title[4196]; |
25 | if (!param) strcpy(#param, DEFAULT_FONT); |
25 | if (!param) strcpy(#param, DEFAULT_FONT); |
26 | kfont.init(#param); |
26 | kfont.init(#param); |
27 | strcpy(#title, "Font preview: "); |
27 | strcpy(#title, "Font preview: "); |
28 | strcat(#title, #param); |
28 | strcat(#title, #param); |
29 | loop() switch(WaitEvent()) |
29 | loop() switch(WaitEvent()) |
30 | { |
30 | { |
31 | case evButton: |
31 | case evButton: |
32 | btn = GetButtonID(); |
32 | btn = GetButtonID(); |
33 | if (btn==1) ExitProcess(); |
33 | if (btn==1) ExitProcess(); |
34 | if (btn==STRONG_BTN) kfont.bold ^=1; |
34 | if (bold.click(btn)) kfont.bold = bold.checked; |
35 | if (btn==SMOOTH_BTN) kfont.smooth ^=1; |
35 | if (smooth.click(btn)) kfont.smooth = smooth.checked; |
36 | if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn); |
36 | if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn); |
37 | goto _DRAW_WINDOW_CONTENT; |
37 | goto _DRAW_WINDOW_CONTENT; |
38 | case evReDraw: |
38 | case evReDraw: |
39 | system.color.get(); |
39 | system.color.get(); |
40 | DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_height+5,0x74,0xFFFFFF,#title,0); |
40 | DefineAndDrawWindow(215,100,WIN_W+9,WIN_H+skin_height+5,0x74,0xFFFFFF,#title,0); |
41 | GetProcessInfo(#Form, SelfInfo); |
41 | GetProcessInfo(#Form, SelfInfo); |
42 | if (Form.status_window>2) break; |
42 | if (Form.status_window>2) break; |
43 | _DRAW_WINDOW_CONTENT: |
43 | _DRAW_WINDOW_CONTENT: |
44 | 44 | ||
45 | 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); |
46 | DrawBar(0, PANELH-1,Form.cwidth,1,system.color.work_graph); |
47 | CheckBox(10, 8, STRONG_BTN, "Bold", kfont.bold); |
47 | bold.draw(10, 8); |
48 | CheckBox(83,8, SMOOTH_BTN, "Smooth", kfont.smooth); |
48 | smooth.draw(83,8); |
49 | 49 | ||
50 | tabs.draw_button(Form.cwidth-130, PHRASE_TAB, "Phrase"); |
50 | tabs.draw_button(Form.cwidth-130, PHRASE_TAB, "Phrase"); |
51 | tabs.draw_button(Form.cwidth-60, CHARS_TAB, "Chars"); |
51 | tabs.draw_button(Form.cwidth-60, CHARS_TAB, "Chars"); |
52 | 52 | ||
53 | if (!kfont.font) |
53 | if (!kfont.font) |
54 | { |
54 | { |
55 | DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff); |
55 | DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff); |
56 | WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); |
56 | WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); |
57 | break; |
57 | break; |
58 | } |
58 | } |
59 | if (tabs.active_tab==PHRASE_TAB) DrawPreviewPhrase(); |
59 | if (tabs.active_tab==PHRASE_TAB) DrawPreviewPhrase(); |
60 | if (tabs.active_tab==CHARS_TAB) DrawPreviewChars(); |
60 | if (tabs.active_tab==CHARS_TAB) DrawPreviewChars(); |
61 | } |
61 | } |
62 | } |
62 | } |
63 | 63 | ||
64 | void DrawPreviewPhrase() |
64 | void DrawPreviewPhrase() |
65 | { |
65 | { |
66 | dword i, y; |
66 | dword i, y; |
67 | char line[256]; |
67 | char line[256]; |
68 | kfont.raw_size = free(kfont.raw); |
68 | kfont.raw_size = free(kfont.raw); |
69 | for (i=10, y=5; i<22; i++, y+=kfont.height;) //not flexible, need to calculate font count and max line length |
69 | for (i=10, y=5; i<22; i++, y+=kfont.height;) //not flexible, need to calculate font count and max line length |
70 | { |
70 | { |
71 | sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i); |
71 | sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i); |
72 | kfont.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); |
72 | kfont.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); |
73 | } |
73 | } |
74 | if (kfont.smooth) kfont.ApplySmooth(); |
74 | if (kfont.smooth) kfont.ApplySmooth(); |
75 | kfont.ShowBuffer(preview.x, preview.y); |
75 | kfont.ShowBuffer(preview.x, preview.y); |
76 | } |
76 | } |
77 | 77 | ||
78 | void DrawPreviewChars() |
78 | void DrawPreviewChars() |
79 | { |
79 | { |
80 | dword i, x=20, y=0; |
80 | dword i, x=20, y=0; |
81 | char line[2]; |
81 | char line[2]; |
82 | line[1]=NULL; |
82 | line[1]=NULL; |
83 | kfont.raw_size = free(kfont.raw); |
83 | kfont.raw_size = free(kfont.raw); |
84 | for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length |
84 | for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length |
85 | { |
85 | { |
86 | line[0]=i; |
86 | line[0]=i; |
87 | kfont.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line); |
87 | kfont.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line); |
88 | x+= kfont.height+2; |
88 | x+= kfont.height+2; |
89 | if (x>=preview.w-30) { |
89 | if (x>=preview.w-30) { |
90 | x=20; |
90 | x=20; |
91 | y+=kfont.height+2; |
91 | y+=kfont.height+2; |
92 | } |
92 | } |
93 | } |
93 | } |
94 | if (kfont.smooth) kfont.ApplySmooth(); |
94 | if (kfont.smooth) kfont.ApplySmooth(); |
95 | kfont.ShowBuffer(preview.x, preview.y); |
95 | kfont.ShowBuffer(preview.x, preview.y); |
96 | }255;>22;> |
96 | }255;>22;> |