Subversion Repositories Kolibri OS

Rev

Rev 7806 | Rev 9465 | Go to most recent revision | 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
 
34
	DefineButton(x-1, y-1, strlen(text)*8 + SIZE + 17, SIZE+2, id+BT_HIDE+BT_NOFRAME, 0);
7806 leency 35
	DrawRectangle(x, y, SIZE, SIZE, sc.work_graph);
7458 leency 36
	if (disabled)
7243 leency 37
	{
7458 leency 38
		DrawRectangle(x+1, y+1, SIZE-2, SIZE-2, 0xffffff);
39
		DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xCCCccc);
7806 leency 40
		text_col = MixColors(sc.work, sc.work_text, 128);
7458 leency 41
	}
7636 leency 42
	else if (checked == false)
7458 leency 43
	{
7244 leency 44
		DrawRectangle3D(x+1, y+1, SIZE-2, SIZE-2, 0xDDDddd, 0xffffff);
45
		DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xffffff);
7243 leency 46
	}
7636 leency 47
	else if (checked == true)
7243 leency 48
	{
9455 leency 49
		if (!checkbox_flag) checkbox_flag = memopen("CHECKBOX", NULL, SHM_READ);
50
		if (checkbox_flag) _PutImage(x+1, y+1, 13, 13, checkbox_flag);
51
		else DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0x58C33C);
7243 leency 52
	}
7806 leency 53
	if (text) WriteTextWithBg(x+SIZE+8, SIZE / 2 + y -7, 0xD0, text_col, text, sc.work);
54
	DrawRectangle3D(x-1,y-1,SIZE+2,SIZE+2,sc.work_dark,sc.work_light);
7243 leency 55
}
7244 leency 56
 
57
:void checkbox::redraw()
58
{
59
	draw(x,y);
60
}
7450 leency 61
 
62
#endif