add separator

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@733 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-11-16 00:33:44 +00:00
parent d4936ead0d
commit 8d0cefd133
4 changed files with 81 additions and 0 deletions

54
src/widget/separator.c Normal file
View File

@@ -0,0 +1,54 @@
/* $Id$ */
#include <Mw/Milsko.h>
static int create(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNorientation, MwVERTICAL);
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);
MwDrawRect(handle, &r, base);
if(MwGetInteger(handle, MwNorientation) == MwVERTICAL) {
r.x = (r.width - MwDefaultBorderWidth(handle) * 2) / 2;
r.width = MwDefaultBorderWidth(handle) * 2;
} else if(MwGetInteger(handle, MwNorientation) == MwHORIZONTAL) {
r.y = (r.height - MwDefaultBorderWidth(handle) * 2) / 2;
r.height = MwDefaultBorderWidth(handle) * 2;
}
MwDrawWidgetBack(handle, &r, base, 0, 1);
MwLLFreeColor(base);
}
static void prop_change(MwWidget handle, const char* key) {
if(strcmp(key, MwNorientation) == 0) MwForceRender(handle);
}
MwClassRec MwSeparatorClassRec = {
create, /* create */
NULL, /* destroy */
draw, /* draw */
NULL, /* click */
NULL, /* parent_resize */
prop_change, /* prop_change */
NULL, /* mouse_move */
NULL, /* mouse_up */
NULL, /* mouse_down */
NULL, /* key */
NULL, /* execute */
NULL, /* tick */
NULL,
NULL,
NULL};
MwClass MwSeparatorClass = &MwSeparatorClassRec;