mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2025-12-31 06:30:52 +00:00
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@586 b9cfdab3-6d41-4d17-bbe4-086880011989
49 lines
1.2 KiB
C
49 lines
1.2 KiB
C
/* $Id$ */
|
|
|
|
#include <Mw/Milsko.h>
|
|
|
|
MwWidget cpicker;
|
|
MwWidget window;
|
|
MwWidget button;
|
|
|
|
void color_callback(MwWidget handle, void* user_data, void* call_data) {
|
|
char hexColor[8];
|
|
MwRGB* rgb = call_data;
|
|
|
|
(void)handle;
|
|
(void)user_data;
|
|
|
|
rgb->red &= 0xff;
|
|
rgb->green &= 0xff;
|
|
rgb->blue &= 0xff;
|
|
sprintf(hexColor, "#%02X%02X%02X", rgb->red, rgb->green, rgb->blue);
|
|
MwSetText(window, MwNbackground, hexColor);
|
|
}
|
|
|
|
void color_picker(MwWidget handle, void* user_data, void* call_data) {
|
|
MwWidget cpicker = MwColorPicker(window, "cpicker");
|
|
|
|
(void)handle;
|
|
(void)user_data;
|
|
(void)call_data;
|
|
|
|
MwAddUserHandler(cpicker, MwNcolorChosenHandler, color_callback, NULL);
|
|
|
|
MwSetText(cpicker, MwNbackground, MwDefaultBackground);
|
|
}
|
|
|
|
int main() {
|
|
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT,
|
|
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
|
|
MwSetText(window, MwNbackground, "#000000");
|
|
|
|
button = MwVaCreateWidget(MwButtonClass, "button", window, 160, 180, 320, 120,
|
|
MwNtext, "change window background",
|
|
NULL);
|
|
MwSetText(button, MwNbackground, MwDefaultBackground);
|
|
|
|
MwAddUserHandler(button, MwNactivateHandler, color_picker, NULL);
|
|
|
|
MwLoop(window);
|
|
}
|