+ m_windowStyle = style;
+ m_modalShowing = FALSE;
+ m_dialogTitle = title;
+
+ m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+ m_foregroundColour = *wxBLACK;
+
+ SetName(name);
+
+ if (!parent)
+ wxTopLevelWindows.Append(this);
+
+ if (parent) parent->AddChild(this);
+
+ if ( id == -1 )
+ m_windowId = (int)NewControlId();
+ else
+ m_windowId = id;
+
+ Widget parentWidget = (Widget) 0;
+ if (parent)
+ parentWidget = (Widget) parent->GetTopWidget();
+ if (!parent)
+ parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
+
+ wxASSERT_MSG( (parentWidget != (Widget) 0), "Could not find a suitable parent shell for dialog." );
+
+ Arg args[2];
+ XtSetArg (args[0], XmNdefaultPosition, False);
+ XtSetArg (args[1], XmNautoUnmanage, False);
+ Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 2);
+ m_mainWidget = (WXWidget) dialogShell;
+
+ // We don't want margins, since there is enough elsewhere.
+ XtVaSetValues(dialogShell,
+ XmNmarginHeight, 0,
+ XmNmarginWidth, 0,
+ XmNresizePolicy, XmRESIZE_NONE,
+ NULL) ;
+
+ Widget shell = XtParent(dialogShell) ;
+ if (!title.IsNull())
+ {
+ XmString str = XmStringCreateSimple((char*) (const char*)title);
+ XtVaSetValues(dialogShell,
+ XmNdialogTitle, str,
+ NULL);
+ XmStringFree(str);
+ }
+
+ m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
+ ChangeFont(FALSE);
+
+ wxAddWindowToTable(dialogShell, this);
+
+ // Intercept CLOSE messages from the window manager
+ Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);
+
+ /* Remove and add WM_DELETE_WINDOW so ours is only handler */
+ /* Why do we have to do this for wxDialog, but not wxFrame? */
+ XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1);
+ XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1);
+ XmActivateWMProtocol(shell, WM_DELETE_WINDOW);
+
+ // Modified Steve Hammes for Motif 2.0
+#if (XmREVISION > 1 || XmVERSION > 1)
+ XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (XtPointer)this);
+#elif XmREVISION == 1
+ XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (caddr_t)this);
+#else
+ XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (void (*)())wxCloseDialogCallback, (caddr_t)this);
+#endif
+
+ XtTranslations ptr ;
+ XtOverrideTranslations(dialogShell,
+ ptr = XtParseTranslationTable("<Configure>: resize()"));
+ XtFree((char *)ptr);
+
+ // Can't remember what this was about... but I think it's necessary.
+
+ if (wxUSE_INVISIBLE_RESIZE)
+ {
+ if (pos.x > -1)
+ XtVaSetValues(dialogShell, XmNx, pos.x,
+ NULL);
+ if (pos.y > -1)
+ XtVaSetValues(dialogShell, XmNy, pos.y,
+ NULL);
+
+ if (size.x > -1)
+ XtVaSetValues(dialogShell, XmNwidth, size.x, NULL);
+ if (size.y > -1)
+ XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
+ }
+
+ // This patch come from Torsten Liermann lier@lier1.muc.de
+ if (XmIsMotifWMRunning(shell))
+ {
+ int decor = 0 ;
+ if (m_windowStyle & wxRESIZE_BORDER)
+ decor |= MWM_DECOR_RESIZEH ;
+ if (m_windowStyle & wxSYSTEM_MENU)
+ decor |= MWM_DECOR_MENU;
+ if ((m_windowStyle & wxCAPTION) ||
+ (m_windowStyle & wxTINY_CAPTION_HORIZ) ||
+ (m_windowStyle & wxTINY_CAPTION_VERT))
+ decor |= MWM_DECOR_TITLE;
+ if (m_windowStyle & wxTHICK_FRAME)
+ decor |= MWM_DECOR_BORDER;
+ if (m_windowStyle & wxMINIMIZE_BOX)
+ decor |= MWM_DECOR_MINIMIZE;
+ if (m_windowStyle & wxMAXIMIZE_BOX)
+ decor |= MWM_DECOR_MAXIMIZE;
+
+ XtVaSetValues(shell,XmNmwmDecorations,decor,NULL) ;
+ }
+ // This allows non-Motif window managers to support at least the
+ // no-decorations case.
+ else
+ {
+ if ((m_windowStyle & wxCAPTION) != wxCAPTION)
+ XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL);
+ }
+
+ XtRealizeWidget(dialogShell);
+
+ XtAddCallback(dialogShell,XmNunmapCallback,
+ (XtCallbackProc)wxUnmapBulletinBoard,this) ;
+
+ // Positioning of the dialog doesn't work properly unless the dialog
+ // is managed, so we manage without mapping to the screen.
+ // To show, we map the shell (actually it's parent).
+ if (!wxUSE_INVISIBLE_RESIZE)
+ XtVaSetValues(shell, XmNmappedWhenManaged, FALSE, NULL);
+
+ if (!wxUSE_INVISIBLE_RESIZE)
+ {
+ XtManageChild(dialogShell);
+ SetSize(pos.x, pos.y, size.x, size.y);
+ }
+ XtAddEventHandler(dialogShell,ExposureMask,FALSE,
+ wxDialogBoxRepaintProc, (XtPointer) this);
+
+ XtAddEventHandler(dialogShell,
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
+ FALSE,
+ wxDialogBoxEventHandler,
+ (XtPointer)this);
+
+ ChangeBackgroundColour();
+
+ return TRUE;