X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dfe1eee3bb9ecde8c4490ea69c07b5030d69530c..a8a32ce2cf162a218683c3708109ab58884717b7:/src/motif/frame.cpp diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index 9a57776df7..8cd57cb702 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -50,8 +50,6 @@ #include "wx/motif/private.h" -extern wxHashTable *wxWidgetHashTable; - void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs); void wxFrameFocusProc(Widget workArea, XtPointer clientData, XmAnyCallbackStruct *cbs); @@ -67,12 +65,12 @@ static bool wxTopLevelUsed = FALSE; #if !USE_SHARED_LIBRARY BEGIN_EVENT_TABLE(wxFrame, wxWindow) -EVT_SIZE(wxFrame::OnSize) -EVT_ACTIVATE(wxFrame::OnActivate) -EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) -EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) -EVT_IDLE(wxFrame::OnIdle) -EVT_CLOSE(wxFrame::OnCloseWindow) + EVT_SIZE(wxFrame::OnSize) + EVT_ACTIVATE(wxFrame::OnActivate) + EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) + EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) + EVT_IDLE(wxFrame::OnIdle) + EVT_CLOSE(wxFrame::OnCloseWindow) END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) @@ -146,12 +144,46 @@ bool wxFrame::Create(wxWindow *parent, wxModelessWindows.Append(this); - int x = pos.x; int y = pos.y; - int width = size.x; int height = size.y; + 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; + } if (wxTopLevelUsed) + { // Change suggested by Matthew Flatt - m_frameShell = (WXWidget) XtAppCreateShell(name, wxTheApp->GetClassName(), topLevelShellWidgetClass, (Display*) wxGetDisplay(), NULL, 0); + m_frameShell = (WXWidget)XtAppCreateShell + ( + name, + wxTheApp->GetClassName(), + topLevelShellWidgetClass, + (Display*) wxGetDisplay(), + NULL, + 0 + ); + } else { m_frameShell = wxTheApp->GetTopLevelWidget(); @@ -192,6 +224,9 @@ bool wxFrame::Create(wxWindow *parent, // XmNresizePolicy, XmRESIZE_ANY, NULL); + wxLogDebug("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); @@ -202,9 +237,6 @@ bool wxFrame::Create(wxWindow *parent, XtManageChild((Widget) m_clientArea); XtManageChild((Widget) m_workArea); - wxASSERT_MSG( !wxGetWindowFromTable((Widget)m_workArea), - "Widget table clash in frame.cpp") ; - wxAddWindowToTable((Widget) m_workArea, this); XtTranslations ptr ; @@ -292,6 +324,8 @@ bool wxFrame::Create(wxWindow *parent, wxFrame::~wxFrame() { + m_isBeingDeleted = TRUE; + if (m_clientArea) XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, FALSE, wxUniversalRepaintProc, (XtPointer) this); @@ -366,7 +400,7 @@ wxFrame::~wxFrame() } // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. -void wxFrame::GetClientSize(int *x, int *y) const +void wxFrame::DoGetClientSize(int *x, int *y) const { Dimension xx, yy; XtVaGetValues((Widget) m_workArea, XmNwidth, &xx, XmNheight, &yy, NULL); @@ -454,14 +488,14 @@ void wxFrame::DoSetClientSize(int width, int height) } -void wxFrame::GetSize(int *width, int *height) const +void wxFrame::DoGetSize(int *width, int *height) const { Dimension xx, yy; XtVaGetValues((Widget) m_frameShell, XmNwidth, &xx, XmNheight, &yy, NULL); *width = xx; *height = yy; } -void wxFrame::GetPosition(int *x, int *y) const +void wxFrame::DoGetPosition(int *x, int *y) const { Window parent_window = XtWindow((Widget) m_frameShell), next_parent = XtWindow((Widget) m_frameShell), @@ -483,7 +517,7 @@ void wxFrame::GetPosition(int *x, int *y) const if (y) *y = yy; } -void wxFrame::DoSetSize(int x, int y, int width, int height, int sizeFlags) +void wxFrame::DoSetSize(int x, int y, int width, int height, int WXUNUSED(sizeFlags)) { if (x > -1) XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL); @@ -733,7 +767,7 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) // Default resizing behaviour - if only ONE subwindow, // resize to client rectangle size -void wxFrame::OnSize(wxSizeEvent& event) +void wxFrame::OnSize(wxSizeEvent& WXUNUSED(event)) { // if we're using constraints - do use them #if wxUSE_CONSTRAINTS @@ -778,6 +812,9 @@ void wxFrame::OnSize(wxSizeEvent& event) // subwindow found. void wxFrame::OnActivate(wxActivateEvent& event) { + if (!event.GetActive()) + return; + for(wxNode *node = GetChildren().First(); node; node = node->Next()) { // Find a child that's a subwindow, but not a dialog box. @@ -794,7 +831,7 @@ void wxFrame::OnActivate(wxActivateEvent& event) // The default implementation for the close window event. // OnClose for backward compatibility. -void wxFrame::OnCloseWindow(wxCloseEvent& event) +void wxFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { this->Destroy(); } @@ -1040,8 +1077,8 @@ void wxFrame::Lower(void) XLowerWindow(XtDisplay((Widget) m_frameShell), parent_window); } -void wxFrameFocusProc(Widget workArea, XtPointer clientData, - XmAnyCallbackStruct *cbs) +void wxFrameFocusProc(Widget WXUNUSED(workArea), XtPointer WXUNUSED(clientData), + XmAnyCallbackStruct *WXUNUSED(cbs)) { // wxDebugMsg("focus proc from frame %ld\n",(long)frame); // TODO @@ -1089,7 +1126,7 @@ WXWidget wxFrame::GetClientWidget() const return m_clientArea; } -void wxFrame::ChangeFont(bool keepOriginalSize) +void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize)) { // TODO } @@ -1106,7 +1143,7 @@ void wxFrame::ChangeForegroundColour() DoChangeForegroundColour(GetClientWidget(), m_foregroundColour); } -void wxCloseFrameCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs) +void wxCloseFrameCallback(Widget WXUNUSED(widget), XtPointer client_data, XmAnyCallbackStruct *WXUNUSED(cbs)) { wxFrame *frame = (wxFrame *)client_data;