2018-10-11 16:32:24 +02:00
|
|
|
#ifndef INCLUDE_CHECKBOX
|
|
|
|
#define INCLUDE_CHECKBOX
|
|
|
|
|
2018-04-19 22:12:07 +02:00
|
|
|
struct checkbox
|
2018-04-19 16:16:32 +02:00
|
|
|
{
|
2018-04-19 22:12:07 +02:00
|
|
|
dword text;
|
|
|
|
bool checked;
|
|
|
|
bool disabled;
|
|
|
|
dword x,y, id;
|
|
|
|
bool click();
|
|
|
|
void draw();
|
|
|
|
void redraw();
|
|
|
|
};
|
|
|
|
|
|
|
|
:bool checkbox::click(dword _id)
|
|
|
|
{
|
|
|
|
if (disabled) return 0;
|
|
|
|
if (_id == id) {
|
|
|
|
checked^=1;
|
|
|
|
redraw();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
:void checkbox::draw(dword _x,_y)
|
|
|
|
{
|
|
|
|
#define SIZE 14
|
2021-12-22 02:26:10 +01:00
|
|
|
static dword checkbox_flag;
|
2020-04-18 01:52:24 +02:00
|
|
|
dword text_col = sc.work_text;
|
2018-04-19 22:12:07 +02:00
|
|
|
if (!id) id = GetFreeButtonId();
|
|
|
|
x=_x; y=_y;
|
|
|
|
|
2021-12-24 21:07:57 +01:00
|
|
|
DefineHiddenButton(x-1, y-1, strlen(text)*8 + SIZE + 17, SIZE+2, id+BT_NOFRAME);
|
|
|
|
UnsafeDefineButton(x, y, SIZE, SIZE, id, 0);
|
2020-04-18 01:52:24 +02:00
|
|
|
DrawRectangle(x, y, SIZE, SIZE, sc.work_graph);
|
2018-10-13 23:20:17 +02:00
|
|
|
if (disabled)
|
|
|
|
{
|
|
|
|
DrawRectangle(x+1, y+1, SIZE-2, SIZE-2, 0xffffff);
|
|
|
|
DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xCCCccc);
|
2020-04-18 01:52:24 +02:00
|
|
|
text_col = MixColors(sc.work, sc.work_text, 128);
|
2018-10-13 23:20:17 +02:00
|
|
|
}
|
2019-04-22 20:19:43 +02:00
|
|
|
else if (checked == false)
|
2018-04-19 16:16:32 +02:00
|
|
|
{
|
2018-04-19 22:12:07 +02:00
|
|
|
DrawRectangle3D(x+1, y+1, SIZE-2, SIZE-2, 0xDDDddd, 0xffffff);
|
|
|
|
DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xffffff);
|
2018-04-19 16:16:32 +02:00
|
|
|
}
|
2019-04-22 20:19:43 +02:00
|
|
|
else if (checked == true)
|
2018-04-19 16:16:32 +02:00
|
|
|
{
|
2021-12-22 02:26:10 +01:00
|
|
|
if (!checkbox_flag) checkbox_flag = memopen("CHECKBOX", NULL, SHM_READ);
|
|
|
|
if (checkbox_flag) _PutImage(x+1, y+1, 13, 13, checkbox_flag);
|
|
|
|
else DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0x58C33C);
|
2018-04-19 16:16:32 +02:00
|
|
|
}
|
2020-04-18 01:52:24 +02:00
|
|
|
if (text) WriteTextWithBg(x+SIZE+8, SIZE / 2 + y -7, 0xD0, text_col, text, sc.work);
|
|
|
|
DrawRectangle3D(x-1,y-1,SIZE+2,SIZE+2,sc.work_dark,sc.work_light);
|
2018-04-19 22:12:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
:void checkbox::redraw()
|
|
|
|
{
|
|
|
|
draw(x,y);
|
2018-04-19 16:16:32 +02:00
|
|
|
}
|
2018-10-11 16:32:24 +02:00
|
|
|
|
|
|
|
#endif
|