Rev 7989 | Rev 9597 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7989 | Rev 8946 | ||
---|---|---|---|
1 | #define MEMSIZE 1024*30 |
1 | #define MEMSIZE 1024*30 |
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 520 |
7 | #define WIN_W 520 |
8 | #define WIN_H 315 |
8 | #define WIN_H 315 |
9 | #define BASE_TAB_BUTTON_ID 97 |
9 | #define BASE_TAB_BUTTON_ID 97 |
10 | 10 | ||
11 | _tabs tabs = { WIN_W-130, 0, NULL, BASE_TAB_BUTTON_ID }; |
11 | _tabs tabs = { WIN_W-130, 0, NULL, BASE_TAB_BUTTON_ID }; |
12 | 12 | ||
13 | block preview = { 0, PANELH, WIN_W, WIN_H - PANELH }; |
13 | block preview = { 0, PANELH, WIN_W, WIN_H - PANELH }; |
14 | checkbox bold = { "Bold", false }; |
14 | checkbox bold = { "Bold", false }; |
15 | checkbox smooth = { "Smooth", true }; |
15 | checkbox smooth = { "Smooth", true }; |
16 | checkbox colored = { "Colored", true }; |
16 | checkbox colored = { "Colored", true }; |
17 | 17 | ||
18 | void main() |
18 | void main() |
19 | { |
19 | { |
20 | proc_info Form; |
20 | proc_info Form; |
21 | char title[1024]; |
21 | char title[1024]; |
22 | int btn; |
22 | int btn; |
23 | 23 | ||
24 | if (!param) strcpy(#param, DEFAULT_FONT); |
24 | if (!param) strcpy(#param, DEFAULT_FONT); |
25 | kfont.init(#param); |
25 | kfont.init(#param); |
26 | strcpy(#title, "Font preview: "); |
26 | strcpy(#title, "Font preview: "); |
27 | strcat(#title, #param); |
27 | strcat(#title, #param); |
28 | 28 | ||
29 | tabs.add("Phrase", #DrawPreviewPhrase); |
29 | tabs.add("Phrase", #DrawPreviewPhrase); |
30 | tabs.add("Chars", #DrawPreviewChars); |
30 | tabs.add("Chars", #DrawPreviewChars); |
31 | 31 | ||
32 | loop() switch(@WaitEvent()) |
32 | loop() switch(@WaitEvent()) |
33 | { |
33 | { |
34 | case evButton: |
34 | case evButton: |
35 | btn = @GetButtonID(); |
35 | btn = @GetButtonID(); |
36 | if (btn==1) @ExitProcess(); |
36 | if (btn==1) @ExitProcess(); |
37 | bold.click(btn); |
37 | bold.click(btn); |
38 | smooth.click(btn); |
38 | smooth.click(btn); |
39 | colored.click(btn); |
39 | colored.click(btn); |
40 | tabs.click(btn); |
40 | tabs.click(btn); |
41 | GOTO _DRAW_WINDOW_CONTENT; |
41 | GOTO _DRAW_WINDOW_CONTENT; |
42 | 42 | ||
43 | case evReDraw: |
43 | case evReDraw: |
44 | sc.get(); |
44 | sc.get(); |
45 | 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); |
46 | GetProcessInfo(#Form, SelfInfo); |
47 | if (Form.status_window>2) break; |
47 | if (Form.status_window&ROLLED_UP) break; |
48 | _DRAW_WINDOW_CONTENT: |
48 | _DRAW_WINDOW_CONTENT: |
49 | 49 | ||
50 | kfont.bold = bold.checked; |
50 | kfont.bold = bold.checked; |
51 | kfont.smooth = smooth.checked; |
51 | kfont.smooth = smooth.checked; |
52 | 52 | ||
53 | DrawBar(0, 0, WIN_W, PANELH-1, sc.work); |
53 | DrawBar(0, 0, WIN_W, PANELH-1, sc.work); |
54 | DrawBar(0, PANELH-1,WIN_W,1,sc.work_graph); |
54 | DrawBar(0, PANELH-1,WIN_W,1,sc.work_graph); |
55 | 55 | ||
56 | if (!kfont.font) { |
56 | if (!kfont.font) { |
57 | DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff); |
57 | DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff); |
58 | WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); |
58 | WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); |
59 | } else { |
59 | } else { |
60 | bold.draw(10, 8); |
60 | bold.draw(10, 8); |
61 | smooth.draw(83,8); |
61 | smooth.draw(83,8); |
62 | colored.draw(170,8); |
62 | colored.draw(170,8); |
63 | tabs.draw(); |
63 | tabs.draw(); |
64 | tabs.draw_active_tab(); |
64 | tabs.draw_active_tab(); |
65 | } |
65 | } |
66 | } |
66 | } |
67 | } |
67 | } |
68 | 68 | ||
69 | dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266, |
69 | dword pal[] = { 0x4E4153, 0x57417C, 0x89633B, 0x819156, 0x00CCCC, 0x2AD266, |
70 | 0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA, 0 }; |
70 | 0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA, 0 }; |
71 | 71 | ||
72 | void DrawPreviewPhrase() |
72 | void DrawPreviewPhrase() |
73 | { |
73 | { |
74 | dword i, y; |
74 | dword i, y; |
75 | dword c; |
75 | dword c; |
76 | char line[256]; |
76 | char line[256]; |
77 | kfont.raw_size = free(kfont.raw); |
77 | kfont.raw_size = free(kfont.raw); |
78 | 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 |
79 | { |
79 | { |
80 | if (colored.checked) c = pal[i-10]; else c=0; |
80 | if (colored.checked) c = pal[i-10]; else c=0; |
81 | strcpy(#line, " §¬¥à èà¨äâ /font size is "); |
81 | strcpy(#line, " §¬¥à èà¨äâ /font size is "); |
82 | strcat(#line, itoa(i)); |
82 | strcat(#line, itoa(i)); |
83 | strcat(#line, " ¯¨ªá¥«¥©/px."); |
83 | strcat(#line, " ¯¨ªá¥«¥©/px."); |
84 | kfont.WriteIntoBuffer(14,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, c, i, #line); |
84 | kfont.WriteIntoBuffer(14,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, c, i, #line); |
85 | } |
85 | } |
86 | if (kfont.smooth) kfont.ApplySmooth(); |
86 | if (kfont.smooth) kfont.ApplySmooth(); |
87 | kfont.ShowBuffer(preview.x, preview.y); |
87 | kfont.ShowBuffer(preview.x, preview.y); |
88 | } |
88 | } |
89 | 89 | ||
90 | void DrawPreviewChars() |
90 | void DrawPreviewChars() |
91 | { |
91 | { |
92 | dword i, x=20, y=0; |
92 | dword i, x=20, y=0; |
93 | char line[2]=0; |
93 | char line[2]=0; |
94 | kfont.raw_size = free(kfont.raw); |
94 | kfont.raw_size = free(kfont.raw); |
95 | for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length |
95 | for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length |
96 | { |
96 | { |
97 | line[0]=i; |
97 | line[0]=i; |
98 | kfont.WriteIntoBuffer(x,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, 0, 16, #line); |
98 | kfont.WriteIntoBuffer(x,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, 0, 16, #line); |
99 | x+= kfont.height+2; |
99 | x+= kfont.height+2; |
100 | if (x>=preview.w-30) { |
100 | if (x>=preview.w-30) { |
101 | x=20; |
101 | x=20; |
102 | y+=kfont.height+2; |
102 | y+=kfont.height+2; |
103 | } |
103 | } |
104 | } |
104 | } |
105 | if (kfont.smooth) kfont.ApplySmooth(); |
105 | if (kfont.smooth) kfont.ApplySmooth(); |
106 | kfont.ShowBuffer(preview.x, preview.y); |
106 | kfont.ShowBuffer(preview.x, preview.y); |
107 | }255;>22;> |
107 | }255;>22;> |