Rev 7783 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7783 | Rev 7806 | ||
---|---|---|---|
1 | :struct more_less_box |
1 | :struct more_less_box |
2 | { |
2 | { |
3 | unsigned value, min, max; |
3 | unsigned value, min, max; |
4 | dword text; |
4 | dword text; |
5 | int click_delta; |
5 | int click_delta; |
6 | int x,y; |
6 | int x,y; |
7 | unsigned id_inc, id_dec; |
7 | unsigned id_inc, id_dec; |
8 | bool disabled; |
8 | bool disabled; |
9 | void check_values(); |
9 | void check_values(); |
10 | bool click(); |
10 | bool click(); |
11 | bool inc(); |
11 | bool inc(); |
12 | bool dec(); |
12 | bool dec(); |
13 | void draw(); |
13 | void draw(); |
14 | void redraw(); |
14 | void redraw(); |
15 | }; |
15 | }; |
16 | 16 | ||
17 | :void more_less_box::check_values() |
17 | :void more_less_box::check_values() |
18 | { |
18 | { |
19 | if (!id_inc) id_inc = GetFreeButtonId(); |
19 | if (!id_inc) id_inc = GetFreeButtonId(); |
20 | if (!id_dec) id_dec = GetFreeButtonId(); |
20 | if (!id_dec) id_dec = GetFreeButtonId(); |
21 | if (!click_delta) click_delta = 1; |
21 | if (!click_delta) click_delta = 1; |
22 | } |
22 | } |
23 | 23 | ||
24 | :bool more_less_box::click(unsigned id) |
24 | :bool more_less_box::click(unsigned id) |
25 | { |
25 | { |
26 | if (disabled) return 0; |
26 | if (disabled) return 0; |
27 | if (id==id_dec) { value = math.max(value-click_delta, min); redraw(); return 1; } |
27 | if (id==id_dec) { value = math.max(value-click_delta, min); redraw(); return 1; } |
28 | if (id==id_inc) { value = math.min(value+click_delta, max); redraw(); return 1; } |
28 | if (id==id_inc) { value = math.min(value+click_delta, max); redraw(); return 1; } |
29 | return 0; |
29 | return 0; |
30 | } |
30 | } |
31 | 31 | ||
32 | :bool more_less_box::inc() |
32 | :bool more_less_box::inc() |
33 | { |
33 | { |
34 | click(id_inc); |
34 | click(id_inc); |
35 | } |
35 | } |
36 | 36 | ||
37 | :bool more_less_box::dec() |
37 | :bool more_less_box::dec() |
38 | { |
38 | { |
39 | click(id_dec); |
39 | click(id_dec); |
40 | } |
40 | } |
41 | 41 | ||
42 | :void more_less_box::draw(dword _x,_y) |
42 | :void more_less_box::draw(dword _x,_y) |
43 | { |
43 | { |
44 | #define VALUE_FIELD_W 34 |
44 | #define VALUE_FIELD_W 34 |
45 | #define SIZE 18 |
45 | #define SIZE 18 |
46 | dword text_col; |
46 | dword text_col; |
47 | dword value_text = itoa(value); |
47 | dword value_text = itoa(value); |
48 | 48 | ||
49 | check_values(); |
49 | check_values(); |
50 | x=_x; y=_y; |
50 | x=_x; y=_y; |
51 | 51 | ||
52 | DrawRectangle(x, y, VALUE_FIELD_W+1, SIZE, system.color.work_graph); |
52 | DrawRectangle(x, y, VALUE_FIELD_W+1, SIZE, sc.work_graph); |
53 | DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff); |
53 | DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff); |
54 | 54 | ||
55 | if (disabled) |
55 | if (disabled) |
56 | { |
56 | { |
57 | DrawRectangle(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xffffff); |
57 | DrawRectangle(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xffffff); |
58 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xCCCccc); |
58 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xCCCccc); |
59 | text_col = system.color.work_graph; |
59 | text_col = sc.work_graph; |
60 | } |
60 | } |
61 | else |
61 | else |
62 | { |
62 | { |
63 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff); |
63 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff); |
64 | text_col = system.color.work_text; |
64 | text_col = sc.work_text; |
65 | } |
65 | } |
66 | 66 | ||
67 | WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text); |
67 | WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text); |
68 | 68 | ||
69 | DrawCaptButton(VALUE_FIELD_W + x + 1, y, SIZE, SIZE, id_inc, system.color.work_button, system.color.work_button_text, "+"); |
69 | DrawCaptButton(VALUE_FIELD_W + x + 1, y, SIZE, SIZE, id_inc, sc.button, sc.button_text, "+"); |
70 | DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, id_dec, system.color.work_button, system.color.work_button_text, "-"); |
70 | DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, id_dec, sc.button, sc.button_text, "-"); |
71 | WriteTextWithBg(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -7, 0xD0, text_col, text, system.color.work); |
71 | WriteTextWithBg(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -7, 0xD0, text_col, text, sc.work); |
72 | DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,system.color.work_dark,system.color.work_light); |
72 | DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,sc.work_dark,sc.work_light); |
73 | } |
73 | } |
74 | 74 | ||
75 | :void more_less_box::redraw() |
75 | :void more_less_box::redraw() |
76 | { |
76 | { |
77 | draw(x,y); |
77 | draw(x,y); |
78 | } |
78 | } |