forked from pyrite-dev/milsko
add checkbox and radiobox demo to periodic table
This commit is contained in:
parent
65f16f3144
commit
2369b96091
6 changed files with 55 additions and 14 deletions
|
|
@ -145,8 +145,8 @@ static void MWAPI menu_handler(MwWidget handle, void* user, void* call) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
MwWidget f, w;
|
||||
int i, j;
|
||||
MwWidget f, w, b;
|
||||
int index;
|
||||
MwMenu m, m2;
|
||||
void* v;
|
||||
|
|
@ -224,6 +224,30 @@ int main() {
|
|||
MwNratio, Columns - 2,
|
||||
NULL));
|
||||
|
||||
for(i = 0; i < 2; i++) {
|
||||
f = frame(i == 0 ? "CheckBox" : "RadioBox", -PaddingContent, -PaddingContent, MwBoxClass,
|
||||
MwNmargin, PaddingContent,
|
||||
NULL);
|
||||
w = child(f);
|
||||
b = MwVaCreateWidget(MwBoxClass, "box1", w, 0, 0, 0, 0,
|
||||
MwNorientation, MwVERTICAL,
|
||||
MwNfixedSize, 16,
|
||||
NULL);
|
||||
for(j = 0; j < 5; j++) MwCreateWidget(i == 0 ? MwCheckBoxClass : MwRadioBoxClass, i == 0 ? "cb" : "rb", b, 0, 0, 0, 0);
|
||||
b = MwVaCreateWidget(MwBoxClass, "box1", w, 0, 0, 0, 0,
|
||||
MwNorientation, MwVERTICAL,
|
||||
NULL);
|
||||
for(j = 0; j < 5; j++) {
|
||||
char buf[32];
|
||||
sprintf(buf, "%sBox %d", i == 0 ? "Check" : "Radio", j + 1);
|
||||
MwVaCreateWidget(MwLabelClass, "label", b, 0, 0, 0, 0,
|
||||
MwNtext, buf,
|
||||
MwNalignment, MwALIGNMENT_BEGINNING,
|
||||
NULL);
|
||||
}
|
||||
add(f);
|
||||
}
|
||||
|
||||
f = frame("ComboBox", -PaddingContent, 24, MwComboBoxClass, NULL);
|
||||
w = child(f);
|
||||
MwComboBoxAdd(w, -1, "Hello!");
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ typedef void (*MwHandlerMouse)(MwWidget handle, void* ptr);
|
|||
typedef void (*MwHandlerExecute)(MwWidget handle, const char* name, void* out, va_list args);
|
||||
typedef void (*MwHandlerClipboardReceived)(MwWidget handle, const char* data);
|
||||
|
||||
typedef void (MWAPI *MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
|
||||
typedef void (MWAPI *MwErrorHandler)(int code, const char* message, void* user_data);
|
||||
typedef void(MWAPI* MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
|
||||
typedef void(MWAPI* MwErrorHandler)(int code, const char* message, void* user_data);
|
||||
|
||||
struct _MwTextKeyValue {
|
||||
char* key;
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ static void MWAPI color_picker_click(MwWidget handle, void* user, void* call) {
|
|||
MwSetText(picker->color_display_text, MwNtext, hexColor);
|
||||
}
|
||||
static void MWAPI color_picker_on_change_value(MwWidget handle, void* user,
|
||||
void* call) {
|
||||
void* call) {
|
||||
color_picker_t* picker = user;
|
||||
|
||||
int value = MwGetInteger(handle, MwNvalue);
|
||||
|
|
@ -207,7 +207,7 @@ static void MWAPI color_picker_on_change_value(MwWidget handle, void* user,
|
|||
}
|
||||
|
||||
static void MWAPI color_picker_tick(MwWidget handle, void* user,
|
||||
void* call) {
|
||||
void* call) {
|
||||
color_picker_t* picker = user;
|
||||
|
||||
(void)handle;
|
||||
|
|
@ -225,7 +225,7 @@ static void color_picker_destroy(color_picker_t* picker) {
|
|||
}
|
||||
|
||||
static void MWAPI color_picker_close(MwWidget handle, void* user,
|
||||
void* call) {
|
||||
void* call) {
|
||||
color_picker_t* picker = user;
|
||||
|
||||
(void)call;
|
||||
|
|
@ -235,7 +235,7 @@ static void MWAPI color_picker_close(MwWidget handle, void* user,
|
|||
}
|
||||
|
||||
static void MWAPI color_display_text_change(MwWidget handle, void* user,
|
||||
void* call) {
|
||||
void* call) {
|
||||
color_picker_t* picker = user;
|
||||
char hexColor[9];
|
||||
char fgColor[9];
|
||||
|
|
@ -266,7 +266,7 @@ static void MWAPI color_display_text_change(MwWidget handle, void* user,
|
|||
}
|
||||
|
||||
static void MWAPI color_picker_finish(MwWidget handle, void* user,
|
||||
void* call) {
|
||||
void* call) {
|
||||
color_picker_t* picker = user;
|
||||
|
||||
(void)call;
|
||||
|
|
|
|||
|
|
@ -237,16 +237,16 @@ void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
|||
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
||||
|
||||
p[0].x = rect->x + rect->width / 2;
|
||||
p[0].y = border;
|
||||
p[0].y = rect->y + border;
|
||||
|
||||
p[1].x = rect->x + rect->width - border;
|
||||
p[1].y = rect->height / 2;
|
||||
p[1].y = rect->y + rect->height / 2;
|
||||
|
||||
p[2].x = rect->x + rect->width / 2;
|
||||
p[2].y = rect->y + rect->height - border;
|
||||
|
||||
p[3].x = rect->x + border;
|
||||
p[3].y = rect->height / 2;
|
||||
p[3].y = rect->y + rect->height / 2;
|
||||
|
||||
MwLLPolygon(handle->lowlevel, p, 4, col);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,15 @@ static void draw(MwWidget handle) {
|
|||
r.y = 0;
|
||||
r.width = MwGetInteger(handle, MwNwidth);
|
||||
r.height = MwGetInteger(handle, MwNheight);
|
||||
MwDrawRect(handle, &r, base);
|
||||
|
||||
if(r.width < r.height) {
|
||||
r.height = r.width;
|
||||
} else {
|
||||
r.width = r.height;
|
||||
}
|
||||
r.x = (MwGetInteger(handle, MwNwidth) - r.width) / 2;
|
||||
r.y = (MwGetInteger(handle, MwNheight) - r.height) / 2;
|
||||
|
||||
MwDrawWidgetBack(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0, MwTRUE);
|
||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||
|
|
@ -50,7 +59,7 @@ MwClassRec MwCheckBoxClassRec = {
|
|||
NULL, /* key */
|
||||
NULL, /* execute */
|
||||
NULL, /* tick */
|
||||
NULL, /* resize */
|
||||
MwForceRender, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
|
|
|
|||
|
|
@ -19,9 +19,17 @@ static void draw(MwWidget handle) {
|
|||
r.y = 0;
|
||||
r.width = MwGetInteger(handle, MwNwidth);
|
||||
r.height = MwGetInteger(handle, MwNheight);
|
||||
|
||||
MwDrawRect(handle, &r, base);
|
||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||
|
||||
if(r.width < r.height) {
|
||||
r.height = r.width;
|
||||
} else {
|
||||
r.width = r.height;
|
||||
}
|
||||
r.x = (MwGetInteger(handle, MwNwidth) - r.width) / 2;
|
||||
r.y = (MwGetInteger(handle, MwNheight) - r.height) / 2;
|
||||
|
||||
MwDrawDiamond(handle, &r, base, (handle->pressed || MwGetInteger(handle, MwNchecked)) ? 1 : 0);
|
||||
|
||||
MwLLFreeColor(base);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue