mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-23 01:24:11 +00:00
hack
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@586 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
48
examples/basic/colorpicker.c
Normal file
48
examples/basic/colorpicker.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/* $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);
|
||||
}
|
||||
Reference in New Issue
Block a user