Rev 7909 | Rev 7989 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7909 | Rev 7984 | ||
---|---|---|---|
1 | #define MEMSIZE 0x2EE80 |
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 490 |
7 | #define WIN_W 490 |
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 | proc_info Form; |
- | |
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 | ||
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 }; |
16 | checkbox smooth = { "Smooth", true }; |
15 | checkbox smooth = { "Smooth", true }; |
17 | checkbox colored = { "Colored", true }; |
16 | checkbox colored = { "Colored", true }; |
18 | 17 | ||
19 | void main() |
18 | void main() |
20 | { |
19 | { |
- | 20 | proc_info Form; |
|
- | 21 | char title[1024]; |
|
21 | int btn; |
22 | int btn; |
22 | char title[4196]; |
- | |
- | 23 | ||
23 | if (!param) strcpy(#param, DEFAULT_FONT); |
24 | if (!param) strcpy(#param, DEFAULT_FONT); |
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: |
34 | btn = GetButtonID(); |
35 | btn = @GetButtonID(); |
35 | if (btn==1) ExitProcess(); |
36 | if (btn==1) @ExitProcess(); |
36 | bold.click(btn); |
37 | bold.click(btn); |
37 | smooth.click(btn); |
38 | smooth.click(btn); |
38 | colored.click(btn); |
39 | colored.click(btn); |
39 | tabs.click(btn); |
40 | tabs.click(btn); |
40 | goto _DRAW_WINDOW_CONTENT; |
41 | GOTO _DRAW_WINDOW_CONTENT; |
- | 42 | ||
41 | case evReDraw: |
43 | case evReDraw: |
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); |
44 | GetProcessInfo(#Form, SelfInfo); |
46 | GetProcessInfo(#Form, SelfInfo); |
45 | if (Form.status_window>2) break; |
47 | if (Form.status_window>2) break; |
46 | _DRAW_WINDOW_CONTENT: |
48 | _DRAW_WINDOW_CONTENT: |
47 | 49 | ||
48 | kfont.bold = bold.checked; |
50 | kfont.bold = bold.checked; |
49 | kfont.smooth = smooth.checked; |
51 | kfont.smooth = smooth.checked; |
50 | 52 | ||
51 | DrawBar(0, 0, Form.cwidth, 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); |
|
- | 55 | ||
- | 56 | if (!kfont.font) { |
|
- | 57 | DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff); |
|
- | 58 | WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); |
|
52 | DrawBar(0, PANELH-1,Form.cwidth,1,sc.work_graph); |
59 | } else { |
53 | bold.draw(10, 8); |
60 | bold.draw(10, 8); |
54 | smooth.draw(83,8); |
61 | smooth.draw(83,8); |
55 | colored.draw(170,8); |
62 | colored.draw(170,8); |
56 | - | ||
57 | tabs.draw(); |
63 | tabs.draw(); |
58 | tabs.draw_active_tab(); |
64 | tabs.draw_active_tab(); |
59 | - | ||
60 | if (!kfont.font) |
- | |
61 | { |
- | |
62 | DrawBar(preview.x, preview.y, preview.w, preview.h, 0xFFFfff); |
- | |
63 | WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); |
- | |
64 | break; |
- | |
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, |
70 | 0xE000CC, 0x0498F9, 0xC3A9F5, 0xFFC200, 0xFF5836, 0xA086BA, 0 }; |
71 | 0,0,0,0,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); |
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)); |
82 | strcat(#line, itoa(i)); |
84 | strcat(#line, " ¯¨ªá¥«¥©/px."); |
83 | strcat(#line, " ¯¨ªá¥«¥©/px."); |
85 | kfont.WriteIntoBuffer(14,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, c, i, #line); |
84 | kfont.WriteIntoBuffer(14,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, c, i, #line); |
86 | } |
85 | } |
87 | if (kfont.smooth) kfont.ApplySmooth(); |
86 | if (kfont.smooth) kfont.ApplySmooth(); |
88 | kfont.ShowBuffer(preview.x, preview.y); |
87 | kfont.ShowBuffer(preview.x, preview.y); |
89 | } |
88 | } |
90 | 89 | ||
91 | void DrawPreviewChars() |
90 | void DrawPreviewChars() |
92 | { |
91 | { |
93 | dword i, x=20, y=0; |
92 | dword i, x=20, y=0; |
94 | char line[2]; |
93 | char line[2]=0; |
95 | line[1]=NULL; |
- | |
96 | kfont.raw_size = free(kfont.raw); |
94 | kfont.raw_size = free(kfont.raw); |
97 | 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 |
98 | { |
96 | { |
99 | line[0]=i; |
97 | line[0]=i; |
100 | kfont.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line); |
98 | kfont.WriteIntoBuffer(x,y,WIN_W,WIN_H-PANELH, 0xFFFFFF, 0, 16, #line); |
101 | x+= kfont.height+2; |
99 | x+= kfont.height+2; |
102 | if (x>=preview.w-30) { |
100 | if (x>=preview.w-30) { |
103 | x=20; |
101 | x=20; |
104 | y+=kfont.height+2; |
102 | y+=kfont.height+2; |
105 | } |
103 | } |
106 | } |
104 | } |
107 | if (kfont.smooth) kfont.ApplySmooth(); |
105 | if (kfont.smooth) kfont.ApplySmooth(); |
108 | kfont.ShowBuffer(preview.x, preview.y); |
106 | kfont.ShowBuffer(preview.x, preview.y); |
109 | }255;>22;> |
107 | }255;>22;> |