Rev 7243 | Rev 7783 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7225 | leency | 1 | :struct more_less_box |
2 | { |
||
3 | unsigned value, min, max; |
||
4 | dword text; |
||
7227 | leency | 5 | int click_delta; |
7243 | leency | 6 | int x,y; |
7 | unsigned id_inc, id_dec; |
||
8 | void check_values(); |
||
7225 | leency | 9 | bool click(); |
7243 | leency | 10 | bool inc(); |
11 | bool dec(); |
||
7225 | leency | 12 | void draw(); |
7243 | leency | 13 | void redraw(); |
7225 | leency | 14 | }; |
15 | |||
7243 | leency | 16 | :void more_less_box::check_values() |
17 | { |
||
18 | if (!id_inc) id_inc = GetFreeButtonId(); |
||
19 | if (!id_dec) id_dec = GetFreeButtonId(); |
||
20 | if (!click_delta) click_delta = 1; |
||
21 | } |
||
22 | |||
7225 | leency | 23 | :bool more_less_box::click(unsigned id) |
24 | { |
||
7243 | leency | 25 | if (id==id_dec) { value = math.max(value-click_delta, min); redraw(); return 1; } |
26 | if (id==id_inc) { value = math.min(value+click_delta, max); redraw(); return 1; } |
||
7225 | leency | 27 | return 0; |
28 | } |
||
29 | |||
7243 | leency | 30 | :bool more_less_box::inc() |
7225 | leency | 31 | { |
7243 | leency | 32 | click(id_inc); |
33 | } |
||
7225 | leency | 34 | |
7243 | leency | 35 | :bool more_less_box::dec() |
36 | { |
||
37 | click(id_dec); |
||
7225 | leency | 38 | } |
39 | |||
7243 | leency | 40 | :void more_less_box::draw(dword _x,_y) |
7225 | leency | 41 | { |
42 | #define VALUE_FIELD_W 34 |
||
43 | #define SIZE 18 |
||
44 | dword value_text = itoa(value); |
||
45 | |||
7243 | leency | 46 | check_values(); |
47 | x=_x; y=_y; |
||
48 | |||
7225 | leency | 49 | DrawRectangle(x, y, VALUE_FIELD_W+1, SIZE, system.color.work_graph); |
50 | DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff); |
||
51 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff); |
||
52 | WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text); |
||
53 | |||
7243 | leency | 54 | DrawCaptButton(VALUE_FIELD_W + x + 1, y, SIZE, SIZE, id_inc, system.color.work_button, system.color.work_button_text, "+"); |
55 | DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, id_dec, system.color.work_button, system.color.work_button_text, "-"); |
||
7373 | leency | 56 | WriteTextWithBg(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -7, 0xD0, system.color.work_text, text, system.color.work); |
7225 | leency | 57 | DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,system.color.work_dark,system.color.work_light); |
58 | } |
||
7243 | leency | 59 | |
60 | :void more_less_box::redraw() |
||
61 | { |
||
62 | draw(x,y); |
||
63 | } |
||
64 |