Rev 9465 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9465 | Rev 9602 | ||
---|---|---|---|
1 | #ifndef INCLUDE_CHECKBOX |
1 | #ifndef INCLUDE_CHECKBOX |
2 | #define INCLUDE_CHECKBOX |
2 | #define INCLUDE_CHECKBOX |
3 | 3 | ||
4 | struct checkbox |
4 | struct checkbox |
5 | { |
5 | { |
6 | dword text; |
6 | dword text; |
7 | bool checked; |
7 | bool checked; |
8 | bool disabled; |
8 | bool disabled; |
9 | dword x,y, id; |
9 | dword x,y, id; |
10 | bool click(); |
10 | bool click(); |
11 | void draw(); |
11 | void draw(); |
12 | void redraw(); |
12 | void redraw(); |
13 | }; |
13 | }; |
14 | 14 | ||
15 | :bool checkbox::click(dword _id) |
15 | :bool checkbox::click(dword _id) |
16 | { |
16 | { |
17 | if (disabled) return 0; |
17 | if (disabled) return 0; |
18 | if (_id == id) { |
18 | if (_id == id) { |
19 | checked^=1; |
19 | checked^=1; |
20 | redraw(); |
20 | redraw(); |
21 | return 1; |
21 | return 1; |
22 | } |
22 | } |
23 | return 0; |
23 | return 0; |
24 | } |
24 | } |
25 | 25 | ||
26 | :void checkbox::draw(dword _x,_y) |
26 | :void checkbox::draw(dword _x,_y) |
27 | { |
27 | { |
28 | #define SIZE 14 |
28 | #define SIZE 14 |
29 | static dword checkbox_flag; |
29 | static dword checkbox_flag; |
30 | dword text_col = sc.work_text; |
30 | dword text_col = sc.work_text; |
31 | if (!id) id = GetFreeButtonId(); |
31 | if (!id) id = GetFreeButtonId(); |
32 | x=_x; y=_y; |
32 | x=_x; y=_y; |
33 | 33 | ||
34 | DefineHiddenButton(x-1, y-1, strlen(text)*8 + SIZE + 17, SIZE+2, id+BT_NOFRAME); |
34 | DefineHiddenButton(x-1, y-1, strlen(text)*8 + SIZE + 17, SIZE+2, id+BT_NOFRAME); |
35 | UnsafeDefineButton(x, y, SIZE, SIZE, id, 0); |
35 | UnsafeDefineButton(x, y, SIZE, SIZE, id, 0); |
36 | DrawRectangle(x, y, SIZE, SIZE, sc.work_graph); |
36 | DrawRectangle(x, y, SIZE, SIZE, sc.line); |
37 | if (disabled) |
37 | if (disabled) |
38 | { |
38 | { |
39 | DrawRectangle(x+1, y+1, SIZE-2, SIZE-2, 0xffffff); |
39 | DrawRectangle(x+1, y+1, SIZE-2, SIZE-2, 0xffffff); |
40 | DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xCCCccc); |
40 | DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xCCCccc); |
41 | text_col = MixColors(sc.work, sc.work_text, 128); |
41 | text_col = MixColors(sc.work, sc.work_text, 128); |
42 | } |
42 | } |
43 | else if (checked == false) |
43 | else if (checked == false) |
44 | { |
44 | { |
45 | DrawRectangle3D(x+1, y+1, SIZE-2, SIZE-2, 0xDDDddd, 0xffffff); |
45 | DrawRectangle3D(x+1, y+1, SIZE-2, SIZE-2, 0xDDDddd, 0xffffff); |
46 | DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xffffff); |
46 | DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xffffff); |
47 | } |
47 | } |
48 | else if (checked == true) |
48 | else if (checked == true) |
49 | { |
49 | { |
50 | if (!checkbox_flag) checkbox_flag = memopen("CHECKBOX", NULL, SHM_READ); |
50 | if (!checkbox_flag) checkbox_flag = memopen("CHECKBOX", NULL, SHM_READ); |
51 | if (checkbox_flag) _PutImage(x+1, y+1, 13, 13, checkbox_flag); |
51 | if (checkbox_flag) PutImage(x+1, y+1, 13, 13, checkbox_flag); |
52 | else DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0x58C33C); |
52 | else DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0x58C33C); |
53 | } |
53 | } |
54 | if (text) WriteTextWithBg(x+SIZE+8, SIZE / 2 + y -7, 0xD0, text_col, text, sc.work); |
54 | if (text) WriteTextWithBg(x+SIZE+8, SIZE / 2 + y -7, 0xD0, text_col, text, sc.work); |
55 | DrawRectangle3D(x-1,y-1,SIZE+2,SIZE+2,sc.work_dark,sc.work_light); |
55 | DrawRectangle3D(x-1,y-1,SIZE+2,SIZE+2,sc.dark,sc.light); |
56 | } |
56 | } |
57 | 57 | ||
58 | :void checkbox::redraw() |
58 | :void checkbox::redraw() |
59 | { |
59 | { |
60 | draw(x,y); |
60 | draw(x,y); |
61 | } |
61 | } |
62 | 62 | ||
63 | #endif |
63 | #endif |