2025-09-28 13:46:18 +00:00
|
|
|
/* $Id$ */
|
2025-09-29 00:10:20 +00:00
|
|
|
#include <Mw/Milsko.h>
|
2025-09-28 13:46:18 +00:00
|
|
|
|
2025-09-29 00:04:04 +00:00
|
|
|
static void create(MwWidget handle) {
|
|
|
|
|
MwSetDefault(handle);
|
2025-09-28 13:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 00:04:04 +00:00
|
|
|
static void draw(MwWidget handle) {
|
2025-09-29 04:33:53 +00:00
|
|
|
MwRect r;
|
|
|
|
|
MwPoint point;
|
|
|
|
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
|
|
|
|
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
|
|
|
|
const char* str = MwGetText(handle, MwNtext);
|
|
|
|
|
|
|
|
|
|
if(str == NULL) str = "";
|
2025-09-28 14:36:24 +00:00
|
|
|
|
|
|
|
|
r.x = 0;
|
|
|
|
|
r.y = 0;
|
2025-09-29 00:04:04 +00:00
|
|
|
r.width = MwGetInteger(handle, MwNwidth);
|
|
|
|
|
r.height = MwGetInteger(handle, MwNheight);
|
2025-09-28 14:36:24 +00:00
|
|
|
|
2025-09-29 02:54:08 +00:00
|
|
|
MwDrawFrame(handle, &r, base, handle->pressed);
|
|
|
|
|
MwDrawRect(handle, &r, base);
|
2025-09-28 21:15:34 +00:00
|
|
|
|
2025-09-29 02:54:08 +00:00
|
|
|
point.x = r.x + r.width / 2;
|
|
|
|
|
point.y = r.x + r.height / 2;
|
|
|
|
|
|
2025-09-29 04:33:53 +00:00
|
|
|
MwDrawText(handle, &point, str, text);
|
2025-09-29 02:54:08 +00:00
|
|
|
|
|
|
|
|
MwLLFreeColor(text);
|
|
|
|
|
MwLLFreeColor(base);
|
2025-09-28 13:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 00:04:04 +00:00
|
|
|
static void click(MwWidget handle) {
|
|
|
|
|
MwDispatchUserHandler(handle, MwNactivateHandler, NULL);
|
2025-09-28 22:21:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-29 00:04:04 +00:00
|
|
|
MwClassRec MwButtonClassRec = {
|
2025-09-28 13:46:18 +00:00
|
|
|
create, /* create */
|
|
|
|
|
NULL, /* destroy */
|
|
|
|
|
draw, /* draw */
|
2025-09-28 22:21:51 +00:00
|
|
|
click /* click */
|
2025-09-28 13:46:18 +00:00
|
|
|
};
|
2025-09-29 00:04:04 +00:00
|
|
|
MwClass MwButtonClass = &MwButtonClassRec;
|