Subversion Repositories Kolibri OS

Rev

Rev 7636 | Rev 7806 | 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
{
7783 leency 26
	if (disabled) return 0;
7243 leency 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; }
7225 leency 29
	return 0;
30
}
31
 
7243 leency 32
:bool more_less_box::inc()
7225 leency 33
{
7243 leency 34
	click(id_inc);
35
}
7225 leency 36
 
7243 leency 37
:bool more_less_box::dec()
38
{
39
	click(id_dec);
7225 leency 40
}
41
 
7243 leency 42
:void more_less_box::draw(dword _x,_y)
7225 leency 43
{
44
	#define VALUE_FIELD_W 34
45
	#define SIZE 18
7783 leency 46
	dword text_col;
7225 leency 47
	dword value_text = itoa(value);
48
 
7243 leency 49
	check_values();
50
	x=_x; y=_y;
51
 
7225 leency 52
	DrawRectangle(x, y, VALUE_FIELD_W+1, SIZE, system.color.work_graph);
53
	DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff);
7636 leency 54
 
55
	if (disabled)
56
	{
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);
7783 leency 59
		text_col = system.color.work_graph;
7636 leency 60
	}
61
	else
62
	{
63
		DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff);
7783 leency 64
		text_col = system.color.work_text;
7636 leency 65
	}
66
 
7225 leency 67
	WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text);
68
 
7243 leency 69
	DrawCaptButton(VALUE_FIELD_W + x + 1,    y, SIZE, SIZE, id_inc, system.color.work_button, system.color.work_button_text, "+");
70
	DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, id_dec, system.color.work_button, system.color.work_button_text, "-");
7636 leency 71
	WriteTextWithBg(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -7, 0xD0, text_col, text, system.color.work);
7225 leency 72
	DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,system.color.work_dark,system.color.work_light);
73
}
7243 leency 74
 
75
:void more_less_box::redraw()
76
{
77
	draw(x,y);
78
}
79