+ wxWindowID id,
+ const wxString& title,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+ if ( parent )
+ parent->AddChild(this);
+ else
+ wxTopLevelWindows.Append(this);
+
+ wxModelessWindows.Append(this);
+
+ SetName(name);
+
+ m_windowStyle = style;
+
+ m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
+ m_foregroundColour = *wxBLACK;
+ m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
+
+ if ( id > -1 )
+ m_windowId = id;
+ else
+ m_windowId = (int)NewControlId();
+
+ int x = pos.x, y = pos.y;
+ int width = size.x, height = size.y;
+
+ // Set reasonable values for position and size if defaults have been
+ // requested
+ //
+ // MB TODO: something better than these arbitrary values ?
+ // VZ should use X resources for this...
+ if ( width == -1 )
+ width = 400;
+ if ( height == -1 )
+ height = 400;
+
+ int displayW, displayH;
+ wxDisplaySize( &displayW, &displayH );
+
+ if ( x == -1 )
+ {
+ x = (displayW - width) / 2;
+ if (x < 10) x = 10;
+ }
+ if ( y == -1 )
+ {
+ y = (displayH - height) / 2;
+ if (y < 10) y = 10;
+ }
+
+ // VZ: what does this do??
+ if (wxTopLevelUsed)
+ {
+ // Change suggested by Matthew Flatt
+ m_frameShell = (WXWidget)XtAppCreateShell
+ (
+ name,
+ wxTheApp->GetClassName(),
+ topLevelShellWidgetClass,
+ (Display*) wxGetDisplay(),
+ NULL,
+ 0
+ );
+ }
+ else
+ {
+ m_frameShell = wxTheApp->GetTopLevelWidget();
+ wxTopLevelUsed = TRUE;
+ }
+
+ XtVaSetValues((Widget) m_frameShell,
+ // Allows menu to resize
+ XmNallowShellResize, True,
+ XmNdeleteResponse, XmDO_NOTHING,
+ XmNmappedWhenManaged, False,
+ XmNiconic, (style & wxICONIZE) ? TRUE : FALSE,
+ NULL);
+
+ if (!title.IsEmpty())
+ XtVaSetValues((Widget) m_frameShell,
+ XmNtitle, title.c_str(),
+ NULL);
+
+ m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
+ xmMainWindowWidgetClass, (Widget) m_frameShell,
+ XmNresizePolicy, XmRESIZE_NONE,
+ NULL);
+
+ m_workArea = (WXWidget) XtVaCreateWidget("form",
+ xmFormWidgetClass, (Widget) m_frameWidget,
+ XmNresizePolicy, XmRESIZE_NONE,
+ NULL);
+
+ m_clientArea = (WXWidget) XtVaCreateWidget("client",
+ xmBulletinBoardWidgetClass, (Widget) m_workArea,
+ XmNmarginWidth, 0,
+ XmNmarginHeight, 0,
+ XmNrightAttachment, XmATTACH_FORM,
+ XmNleftAttachment, XmATTACH_FORM,
+ XmNtopAttachment, XmATTACH_FORM,
+ XmNbottomAttachment, XmATTACH_FORM,
+ // XmNresizePolicy, XmRESIZE_ANY,
+ NULL);
+
+ wxLogTrace(wxTRACE_Messages,
+ "Created frame (0x%08x) with work area 0x%08x and client "
+ "area 0x%08x", m_frameWidget, m_workArea, m_clientArea);
+
+ XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE,
+ wxUniversalRepaintProc, (XtPointer) this);
+
+ XtAddEventHandler((Widget) m_clientArea,
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
+ FALSE,
+ wxFrameEventHandler,
+ (XtPointer)this);
+
+ XtVaSetValues((Widget) m_frameWidget,
+ XmNworkWindow, (Widget) m_workArea,
+ NULL);
+
+ XtManageChild((Widget) m_clientArea);
+ XtManageChild((Widget) m_workArea);
+
+ wxAddWindowToTable((Widget) m_workArea, this);
+ wxAddWindowToTable((Widget) m_clientArea, this);
+
+ XtTranslations ptr;
+
+ XtOverrideTranslations((Widget) m_workArea,
+ ptr = XtParseTranslationTable("<Configure>: resize()"));
+
+ XtFree((char *)ptr);
+
+ XtAddCallback((Widget) m_workArea, XmNfocusCallback,
+ (XtCallbackProc)wxFrameFocusProc, (XtPointer)this);
+
+ /* Part of show-&-hide fix */
+ XtAddEventHandler((Widget) m_frameShell, StructureNotifyMask,
+ False, (XtEventHandler)wxFrameMapProc,
+ (XtPointer)m_workArea);
+
+ if (x > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL);
+ if (y > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL);
+ if (width > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNwidth, width, NULL);
+ if (height > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNheight, height, NULL);
+
+ m_mainWidget = m_frameWidget;
+
+ ChangeFont(FALSE);
+
+ // This patch comes from Torsten Liermann lier@lier1.muc.de
+ if (XmIsMotifWMRunning( (Widget) m_frameShell ))
+ {
+ int decor = 0;
+ if (style & wxRESIZE_BORDER)
+ decor |= MWM_DECOR_RESIZEH;
+ if (style & wxSYSTEM_MENU)
+ decor |= MWM_DECOR_MENU;
+ if ((style & wxCAPTION) ||
+ (style & wxTINY_CAPTION_HORIZ) ||
+ (style & wxTINY_CAPTION_VERT))
+ decor |= MWM_DECOR_TITLE;
+ if (style & wxTHICK_FRAME)
+ decor |= MWM_DECOR_BORDER;
+ if (style & wxTHICK_FRAME)
+ decor |= MWM_DECOR_BORDER;
+ if (style & wxMINIMIZE_BOX)
+ decor |= MWM_DECOR_MINIMIZE;
+ if (style & wxMAXIMIZE_BOX)
+ decor |= MWM_DECOR_MAXIMIZE;
+ XtVaSetValues((Widget) m_frameShell,XmNmwmDecorations,decor,NULL);
+ }
+ // This allows non-Motif window managers to support at least the
+ // no-decorations case.
+ else
+ {
+ if (style == 0)
+ XtVaSetValues((Widget) m_frameShell,XmNoverrideRedirect,TRUE,NULL);
+ }
+ XtRealizeWidget((Widget) m_frameShell);