Files
milsko/examples/basic/color_picker.c
NishiOwO 971ef1b827 closes #10
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@570 b9cfdab3-6d41-4d17-bbe4-086880011989
2025-11-02 19:15:38 +00:00

35 lines
916 B
C

/* $Id$ */
#include <Mw/Milsko.h>
MwWidget cpicker;
MwWidget window;
MwWidget button;
void color_callback(MwRGB rgb) {
char hexColor[8];
sprintf(hexColor, "#%02X%02X%02X", rgb.r, rgb.g, rgb.b);
MwSetText(window, MwNbackground, hexColor);
}
void color_picker(MwWidget handle, void* user_data, void* call_data) {
MwWidget cpicker = MwColorPicker(window, "cpicker", color_callback);
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);
}