kolibrios-fun/programs/cmm/lib/gui/checkbox.h
Kirill Lipatov (Leency) c78bc9e513 appearance:
- working screensaver tab
- add "auto" type of wallpapper set
various fixes

git-svn-id: svn://kolibrios.org@9465 a494cfbc-eb01-0410-851d-a64ba20cac60
2021-12-24 20:07:57 +00:00

63 lines
1.4 KiB
C

#ifndef INCLUDE_CHECKBOX
#define INCLUDE_CHECKBOX
struct checkbox
{
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
static dword checkbox_flag;
dword text_col = sc.work_text;
if (!id) id = GetFreeButtonId();
x=_x; y=_y;
DefineHiddenButton(x-1, y-1, strlen(text)*8 + SIZE + 17, SIZE+2, id+BT_NOFRAME);
UnsafeDefineButton(x, y, SIZE, SIZE, id, 0);
DrawRectangle(x, y, SIZE, SIZE, sc.work_graph);
if (disabled)
{
DrawRectangle(x+1, y+1, SIZE-2, SIZE-2, 0xffffff);
DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xCCCccc);
text_col = MixColors(sc.work, sc.work_text, 128);
}
else if (checked == false)
{
DrawRectangle3D(x+1, y+1, SIZE-2, SIZE-2, 0xDDDddd, 0xffffff);
DrawBar(x+2, y+2, SIZE-3, SIZE-3, 0xffffff);
}
else if (checked == true)
{
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);
}
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);
}
:void checkbox::redraw()
{
draw(x,y);
}
#endif