Rev 6197 | Rev 6746 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6197 | Rev 6264 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
3 | #include "../lib/font.h" |
3 | #include "../lib/font.h" |
Line 4... | Line 4... | ||
4 | #include "../lib/gui.h" |
4 | #include "../lib/gui.h" |
- | 5 | ||
- | 6 | #define PANELH 30 |
|
- | 7 | proc_info Form; |
|
- | 8 | ||
- | 9 | enum { |
|
- | 10 | STRONG_BTN=10, ITALIC_BTN, SMOOTH_BTN, |
|
- | 11 | PHRASE_TAB=20, CHARS_TAB |
|
Line 5... | Line 12... | ||
5 | 12 | }; |
|
6 | #define PANELH 30 |
13 | |
7 | - | ||
8 | void main() |
14 | |
9 | { |
15 | void main() |
10 | proc_info Form; |
16 | { |
11 | int i, y, btn; |
17 | int btn; |
- | 18 | char title[4196]; |
|
12 | char line[256], title[4196]; |
19 | if (!param) strcpy(#param, DEFAULT_FONT); |
13 | if (!param) strcpy(#param, DEFAULT_FONT); |
20 | label.init(#param); |
14 | label.init(#param); |
- | |
15 | strcpy(#title, "Font preview: "); |
- | |
16 | strcat(#title, #param); |
21 | tabs.active_tab=PHRASE_TAB; |
17 | loop() |
22 | strcpy(#title, "Font preview: "); |
18 | { |
23 | strcat(#title, #param); |
19 | switch(WaitEvent()) |
24 | loop() switch(WaitEvent()) |
20 | { |
25 | { |
21 | case evButton: |
26 | case evButton: |
22 | btn = GetButtonID(); |
27 | btn = GetButtonID(); |
23 | if (btn==1) ExitProcess(); |
28 | if (btn==1) ExitProcess(); |
- | 29 | if (btn==STRONG_BTN) label.bold ^=1; |
|
24 | if (btn==2) label.bold ^=1; |
30 | if (btn==ITALIC_BTN) label.italic ^=1; |
25 | if (btn==3) label.italic ^=1; |
31 | if (btn==SMOOTH_BTN) label.smooth ^=1; |
26 | if (btn==4) label.smooth ^=1; |
32 | if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn); |
27 | goto _DRAW_WINDOW_CONTENT; |
33 | goto _DRAW_WINDOW_CONTENT; |
28 | case evReDraw: |
34 | case evReDraw: |
29 | system.color.get(); |
35 | system.color.get(); |
30 | DefineAndDrawWindow(215,100,500,320,0x74,0xFFFFFF,#title); |
36 | DefineAndDrawWindow(215,100,500,320+skin_height,0x74,0xFFFFFF,#title); |
31 | GetProcessInfo(#Form, SelfInfo); |
37 | GetProcessInfo(#Form, SelfInfo); |
32 | if (Form.status_window>2) break; |
38 | if (Form.status_window>2) break; |
33 | _DRAW_WINDOW_CONTENT: |
39 | _DRAW_WINDOW_CONTENT: |
34 | DrawBar(0, 0, Form.cwidth, PANELH, system.color.work); |
40 | DrawBar(0, 0, Form.cwidth, PANELH-1, system.color.work); |
- | 41 | CheckBox(10, 8, STRONG_BTN, "Bold", label.bold); |
|
35 | CheckBox(10, 8, 2, "Bold", label.bold); |
42 | CheckBox(83, 8, ITALIC_BTN, "Italic", label.italic); |
- | 43 | CheckBox(170,8, SMOOTH_BTN, "Smooth", label.smooth); |
|
36 | CheckBox(83, 8, 3, "Italic", label.italic); |
44 | tabs.draw(Form.cwidth-150, PANELH, PHRASE_TAB, "Phrase"); |
37 | CheckBox(170, 8, 4, "Smooth", label.smooth); |
45 | tabs.draw(Form.cwidth-70, PANELH, CHARS_TAB, "Chars"); |
38 | label.raw_size = free(label.raw); |
46 | DrawBar(0, PANELH-1,Form.cwidth,1,system.color.work_graph); |
39 | if (!label.font) |
47 | if (!label.font) |
- | 48 | { |
|
- | 49 | DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff); |
|
- | 50 | WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); |
|
- | 51 | break; |
|
40 | { |
52 | } |
- | 53 | if (tabs.active_tab==PHRASE_TAB) DrawPreviewPhrase(); |
|
- | 54 | if (tabs.active_tab==CHARS_TAB) DrawPreviewChars(); |
|
- | 55 | } |
|
- | 56 | } |
|
- | 57 | ||
- | 58 | void DrawPreviewPhrase() |
|
- | 59 | { |
|
41 | DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff); |
60 | dword i, y; |
42 | WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); |
61 | char line[256]; |
43 | } |
62 | label.raw_size = free(label.raw); |
44 | else for (i=10, y=5; i<22; i++, y+=label.height;) //not flexible, need to calculate font count and max line length |
63 | for (i=10, y=5; i<22; i++, y+=label.height;) //not flexible, need to calculate font count and max line length |
45 | { |
64 | { |
46 | sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i); |
65 | sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i); |
47 | label.write_buf(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); |
66 | label.write_buf(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); |
48 | } |
67 | } |
- | 68 | if (label.smooth) label.apply_smooth(); |
|
- | 69 | label.show_buf(0, PANELH); |
|
- | 70 | } |
|
- | 71 | ||
- | 72 | void DrawPreviewChars() |
|
- | 73 | { |
|
- | 74 | dword i, x=20, y=0; |
|
- | 75 | char line[2]; |
|
- | 76 | line[1]=NULL; |
|
- | 77 | label.raw_size = free(label.raw); |
|
- | 78 | for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length |
|
- | 79 | { |
|
- | 80 | line[0]=i; |
|
- | 81 | label.write_buf(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line); |
|
- | 82 | x+= label.height+2; |
|
- | 83 | if (x>=Form.cwidth-30) { |
|
49 | if (label.smooth) label.apply_smooth(); |
84 | x=20; |
- | 85 | y+=label.height+2; |
|
- | 86 | } |
|
50 | label.show_buf(0, PANELH); |
87 | } |