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