+ wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
+
+ if (show && !m_sizeSet)
+ {
+ /* by calling GtkOnSize here, we don't have to call
+ either after showing the frame, which would entail
+ much ugly flicker or from within the size_allocate
+ handler, because GTK 1.1.X forbids that. */
+
+ GtkOnSize( m_x, m_y, m_width, m_height );
+ }
+
+ return wxWindow::Show( show );
+}
+
+bool wxFrame::Destroy()
+{
+ wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
+
+ if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
+
+ return TRUE;
+}
+
+void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
+{
+ wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
+
+ /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
+ wxASSERT_MSG( (m_wxwindow != NULL), _T("invalid frame") );
+
+ /* avoid recursions */
+ if (m_resizing) return;
+ m_resizing = TRUE;
+
+ int old_x = m_x;
+ int old_y = m_y;
+ int old_width = m_width;
+ int old_height = m_height;
+
+ if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
+ {
+ if (x != -1) m_x = x;
+ if (y != -1) m_y = y;
+ if (width != -1) m_width = width;
+ if (height != -1) m_height = height;
+ }
+ else
+ {
+ m_x = x;
+ m_y = y;
+ m_width = width;
+ m_height = height;
+ }
+
+ if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
+ {
+ if (width == -1) m_width = 80;
+ }
+
+ if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
+ {
+ if (height == -1) m_height = 26;
+ }
+
+ if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
+ if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
+ if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+ if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
+
+ if ((m_x != -1) || (m_y != -1))
+ {
+ if ((m_x != old_x) || (m_y != old_y))
+ {
+ gtk_widget_set_uposition( m_widget, m_x, m_y );
+ }
+ }
+
+ if ((m_width != old_width) || (m_height != old_height))
+ {
+ /* we set the size in GtkOnSize, i.e. mostly the actual resizing is
+ done either directly before the frame is shown or in idle time
+ so that different calls to SetSize() don't lead to flicker. */
+ m_sizeSet = FALSE;
+ }
+
+ m_resizing = FALSE;
+}
+
+void wxFrame::Centre( int direction )
+{
+ wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
+
+ int x = 0;
+ int y = 0;
+
+ if ((direction & wxHORIZONTAL) == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
+ if ((direction & wxVERTICAL) == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
+
+ Move( x, y );
+}
+
+void wxFrame::DoGetClientSize( int *width, int *height ) const
+{
+ wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
+
+ wxWindow::DoGetClientSize( width, height );
+ if (height)
+ {
+ /* menu bar */
+ if (m_frameMenuBar)
+ {
+ if (!m_menuBarDetached)
+ (*height) -= wxMENU_HEIGHT;
+ else
+ (*height) -= wxPLACE_HOLDER;
+ }
+
+#if wxUSE_STATUSBAR
+ /* status bar */
+ if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
+#endif
+
+#if wxUSE_TOOLBAR
+ /* tool bar */
+ if (m_frameToolBar)
+ {
+ if (!m_toolBarDetached)
+ {
+ int y = 0;
+ m_frameToolBar->GetSize( (int *) NULL, &y );
+ (*height) -= y;
+ }
+ else
+ (*height) -= wxPLACE_HOLDER;
+ }
+#endif
+
+ /* mini edge */
+ (*height) -= m_miniEdge*2 + m_miniTitle;
+ }
+ if (width)
+ {
+ (*width) -= m_miniEdge*2;
+ }
+}
+
+void wxFrame::DoSetClientSize( int width, int height )
+{
+ wxASSERT_MSG( (m_widget != NULL), _T("invalid frame") );
+
+ /* menu bar */
+ if (m_frameMenuBar)
+ {
+ if (!m_menuBarDetached)
+ height += wxMENU_HEIGHT;
+ else
+ height += wxPLACE_HOLDER;
+ }
+
+#if wxUSE_STATUSBAR
+ /* status bar */
+ if (m_frameStatusBar) height += wxSTATUS_HEIGHT;
+#endif
+
+#if wxUSE_TOOLBAR
+ /* tool bar */
+ if (m_frameToolBar)
+ {
+ if (!m_toolBarDetached)
+ {
+ int y = 0;
+ m_frameToolBar->GetSize( (int *) NULL, &y );
+ height += y;
+ }
+ else
+ height += wxPLACE_HOLDER;
+ }
+#endif
+
+ wxWindow::DoSetClientSize( width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle );
+}
+
+void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height )
+{
+ // due to a bug in gtk, x,y are always 0
+ // m_x = x;
+ // m_y = y;
+
+ /* avoid recursions */
+ if (m_resizing) return;
+ m_resizing = TRUE;
+
+ /* this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow */
+ wxASSERT_MSG( (m_wxwindow != NULL), _T("invalid frame") );
+
+ m_width = width;
+ m_height = height;
+
+ /* space occupied by m_frameToolBar and m_frameMenuBar */
+ int client_area_y_offset = 0;
+
+ /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
+ wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
+ set in wxFrame::Create so it is used to check what kind of frame we
+ have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
+ skip the part which handles m_frameMenuBar, m_frameToolBar and (most
+ importantly) m_mainWidget */
+
+ if (m_mainWidget)
+ {
+ /* check if size is in legal range */
+ if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
+ if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
+ if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+ if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
+
+ /* I revert back to wxGTK's original behaviour. m_mainWidget holds the
+ * menubar, the toolbar and the client area, which is represented by
+ * m_wxwindow.
+ * this hurts in the eye, but I don't want to call SetSize()
+ * because I don't want to call any non-native functions here. */
+
+ if (m_frameMenuBar)
+ {
+ int xx = m_miniEdge;
+ int yy = m_miniEdge + m_miniTitle;
+ int ww = m_width - 2*m_miniEdge;
+ int hh = wxMENU_HEIGHT;
+ if (m_menuBarDetached) hh = wxPLACE_HOLDER;
+ m_frameMenuBar->m_x = xx;
+ m_frameMenuBar->m_y = yy;
+ m_frameMenuBar->m_width = ww;
+ m_frameMenuBar->m_height = hh;
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ m_frameMenuBar->m_widget,
+ xx, yy, ww, hh );
+ client_area_y_offset += hh;
+ }
+
+#if wxUSE_TOOLBAR
+ if (m_frameToolBar)
+ {
+ int xx = m_miniEdge;
+ int yy = m_miniEdge + m_miniTitle;
+ if (m_frameMenuBar)
+ {
+ if (!m_menuBarDetached)
+ yy += wxMENU_HEIGHT;
+ else
+ yy += wxPLACE_HOLDER;
+ }
+ int ww = m_width - 2*m_miniEdge;
+ int hh = m_frameToolBar->m_height;
+ if (m_toolBarDetached) hh = wxPLACE_HOLDER;
+ m_frameToolBar->m_x = xx;
+ m_frameToolBar->m_y = yy;
+ /* m_frameToolBar->m_height = hh; don't change the toolbar's height */
+ m_frameToolBar->m_width = ww;
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ m_frameToolBar->m_widget,
+ xx, yy, ww, hh );
+ client_area_y_offset += hh;
+ }
+#endif
+
+ int client_x = m_miniEdge;
+ int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
+ int client_w = m_width - 2*m_miniEdge;
+ int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ m_wxwindow,
+ client_x, client_y, client_w, client_h );
+ }
+ else
+ {
+ /* if there is no m_mainWidget between m_widget and m_wxwindow there
+ is no need to set the size or position of m_wxwindow. */
+ }
+
+#if wxUSE_STATUSBAR
+ if (m_frameStatusBar)
+ {
+ int xx = 0 + m_miniEdge;
+ int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
+ int ww = m_width - 2*m_miniEdge;
+ int hh = wxSTATUS_HEIGHT;
+ m_frameStatusBar->m_x = xx;
+ m_frameStatusBar->m_y = yy;
+ m_frameStatusBar->m_width = ww;
+ m_frameStatusBar->m_height = hh;
+ gtk_myfixed_set_size( GTK_MYFIXED(m_wxwindow),
+ m_frameStatusBar->m_widget,
+ xx, yy, ww, hh );
+ }
+#endif
+
+ /* we actually set the size of a frame here and no-where else */
+ gtk_widget_set_usize( m_widget, m_width, m_height );
+
+ m_sizeSet = TRUE;
+
+ /* send size event to frame */