diff options
Diffstat (limited to 'iup/src/iup_dialog.c')
-rwxr-xr-x | iup/src/iup_dialog.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/iup/src/iup_dialog.c b/iup/src/iup_dialog.c index d70e12c..1aaf095 100755 --- a/iup/src/iup_dialog.c +++ b/iup/src/iup_dialog.c @@ -220,11 +220,19 @@ static void iDialogDestroyMethod(Ihandle* ih) iupDlgListRemove(ih); } +static int iDialogSetMenuAttrib(Ihandle* ih, const char* value); + static void iDialogComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *expand) { int decorwidth, decorheight; Ihandle* child = ih->firstchild; + /* if does not have a menu, but the attribute is defined, + try to update the menu before retrieving the decoration. */ + char* value = iupAttribGet(ih, "MENU"); + if (!ih->data->menu && value) + iDialogSetMenuAttrib(ih, value); + iupDialogGetDecorSize(ih, &decorwidth, &decorheight); *w = decorwidth; *h = decorheight; @@ -278,20 +286,22 @@ static void iDialogAfterShow(Ihandle* ih) { Ihandle* old_focus; IFni show_cb; + int show_state; /* process all pending messages */ IupFlush(); old_focus = IupGetFocus(); + show_state = ih->data->show_state; show_cb = (IFni)IupGetCallback(ih, "SHOW_CB"); - if (show_cb && show_cb(ih, ih->data->show_state) == IUP_CLOSE) + if (show_cb && show_cb(ih, show_state) == IUP_CLOSE) { IupExitLoop(); return; } - if (ih->data->show_state == IUP_SHOW) + if (show_state == IUP_SHOW) { if (show_cb) IupFlush(); /* again to update focus */ @@ -718,7 +728,8 @@ Iclass* iupDialogGetClass(void) iupBaseRegisterVisualAttrib(ic); /* Overwrite Visual */ - iupClassRegisterAttribute(ic, "VISIBLE", iupBaseGetVisibleAttrib, iDialogSetVisibleAttrib, IUPAF_SAMEASSYSTEM, "NO", IUPAF_NO_INHERIT); /* the only case where VISIBLE default is NO */ + /* the only case where VISIBLE default is NO, and must not be propagated to the dialog children */ + iupClassRegisterAttribute(ic, "VISIBLE", iupBaseGetVisibleAttrib, iDialogSetVisibleAttrib, IUPAF_SAMEASSYSTEM, "NO", IUPAF_NO_INHERIT); /* IupDialog only */ iupClassRegisterAttribute(ic, "MENU", NULL, iDialogSetMenuAttrib, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT); |