git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@209 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-08 08:46:56 +00:00
parent 951dcc054a
commit fc3450ae03
19 changed files with 192 additions and 80 deletions

46
src/widget/checkbox.c Normal file
View File

@@ -0,0 +1,46 @@
/* $Id: button.c 168 2025-10-04 19:30:58Z nishi $ */
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNchecked, 0);
return 0;
}
static void draw(MwWidget handle) {
MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
r.x = 0;
r.y = 0;
r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight);
MwDrawFrame(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0);
MwDrawRect(handle, &r, base);
if(handle->pressed || MwGetInteger(handle, MwNchecked)){
/* TODO: write check mark */
}
MwLLFreeColor(base);
}
static void click(MwWidget handle) {
MwSetInteger(handle, MwNchecked, MwGetInteger(handle, MwNchecked) ? 0 : 1);
MwDispatchUserHandler(handle, MwNchangedHandler, NULL);
}
MwClassRec MwCheckBoxClassRec = {
create, /* create */
NULL, /* destroy */
draw, /* draw */
click, /* click */
NULL, /* parent_resize */
NULL, /* mouse_move */
MwForceRender, /* mouse_up */
MwForceRender /* mouse_down */
};
MwClass MwCheckBoxClass = &MwCheckBoxClassRec;