Subversion Repositories Kolibri OS

Rev

Rev 7373 | 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;
7636 leency 8
	bool disabled;
7243 leency 9
	void check_values();
7225 leency 10
	bool click();
7243 leency 11
	bool inc();
12
	bool dec();
7225 leency 13
	void draw();
7243 leency 14
	void redraw();
7225 leency 15
};
16
 
7243 leency 17
:void more_less_box::check_values()
18
{
19
	if (!id_inc) id_inc = GetFreeButtonId();
20
	if (!id_dec) id_dec = GetFreeButtonId();
21
	if (!click_delta) click_delta = 1;
22
}
23
 
7225 leency 24
:bool more_less_box::click(unsigned id)
25
{
7243 leency 26
	if (id==id_dec) { value = math.max(value-click_delta, min); redraw(); return 1; }
27
	if (id==id_inc) { value = math.min(value+click_delta, max); redraw(); return 1; }
7225 leency 28
	return 0;
29
}
30
 
7243 leency 31
:bool more_less_box::inc()
7225 leency 32
{
7243 leency 33
	click(id_inc);
34
}
7225 leency 35
 
7243 leency 36
:bool more_less_box::dec()
37
{
38
	click(id_dec);
7225 leency 39
}
40
 
7243 leency 41
:void more_less_box::draw(dword _x,_y)
7225 leency 42
{
43
	#define VALUE_FIELD_W 34
44
	#define SIZE 18
7636 leency 45
	dword text_col = system.color.work_text;
7225 leency 46
	dword value_text = itoa(value);
47
 
7243 leency 48
	check_values();
49
	x=_x; y=_y;
50
 
7225 leency 51
	DrawRectangle(x, y, VALUE_FIELD_W+1, SIZE, system.color.work_graph);
52
	DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff);
7636 leency 53
 
54
	if (disabled)
55
	{
56
		DrawRectangle(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xffffff);
57
		DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xCCCccc);
58
		text_col = MixColors(system.color.work, system.color.work_text, 128);
59
	}
60
	else
61
	{
62
		DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff);
63
	}
64
 
7225 leency 65
	WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text);
66
 
7243 leency 67
	DrawCaptButton(VALUE_FIELD_W + x + 1,    y, SIZE, SIZE, id_inc, system.color.work_button, system.color.work_button_text, "+");
68
	DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, id_dec, system.color.work_button, system.color.work_button_text, "-");
7636 leency 69
	WriteTextWithBg(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -7, 0xD0, text_col, text, system.color.work);
7225 leency 70
	DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,system.color.work_dark,system.color.work_light);
71
}
7243 leency 72
 
73
:void more_less_box::redraw()
74
{
75
	draw(x,y);
76
}
77