From: Paul Cornett Date: Thu, 18 Oct 2007 17:20:38 +0000 (+0000) Subject: simplify toolbar and statusbar create/set code X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/383144c756be2e3aa7b58a3db1d8789584763708 simplify toolbar and statusbar create/set code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49231 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index 726cce187b..b93964dd5f 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -54,18 +54,10 @@ public: virtual ~wxFrame(); #if wxUSE_STATUSBAR - virtual wxStatusBar* CreateStatusBar(int number = 1, - long style = wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE, - wxWindowID id = 0, - const wxString& name = wxStatusLineNameStr); - void SetStatusBar(wxStatusBar *statbar); #endif // wxUSE_STATUSBAR #if wxUSE_TOOLBAR - virtual wxToolBar* CreateToolBar(long style = -1, - wxWindowID id = -1, - const wxString& name = wxToolBarNameStr); void SetToolBar(wxToolBar *toolbar); #endif // wxUSE_TOOLBAR @@ -87,10 +79,6 @@ protected: // common part of all ctors void Init(); -#if wxUSE_STATUSBAR - virtual void PositionStatusBar(); -#endif // wxUSE_STATUSBAR - // override wxWindow methods to take into account tool/menu/statusbars virtual void DoGetClientSize( int *width, int *height ) const; diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 48b111dc80..910ff36947 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -110,55 +110,6 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge } #endif // wxUSE_TOOLBAR - -// ---------------------------------------------------------------------------- -// wxFrame itself -// ---------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// InsertChild for wxFrame -//----------------------------------------------------------------------------- - -#if wxUSE_TOOLBAR - -/* Callback for wxFrame. This very strange beast has to be used because - * C++ has no virtual methods in a constructor. We have to emulate a - * virtual function here as wxWidgets requires different ways to insert - * a child in container classes. */ - -static void wxInsertChildInFrame(wxWindow* parent, wxWindow* child) -{ - wxASSERT( GTK_IS_WIDGET(child->m_widget) ); - - // These are outside the client area - wxFrame* frame = wx_static_cast(wxFrame*, parent); - gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget), - child->m_widget, - child->m_x, - child->m_y, - child->m_width, - child->m_height ); - -#if wxUSE_TOOLBAR_NATIVE - // We connect to these events for recalculating the client area - // space when the toolbar is floating - if (wxIS_KIND_OF(child,wxToolBar)) - { - if (child->HasFlag(wxTB_DOCKABLE)) - { - g_signal_connect (child->m_widget, "child_attached", - G_CALLBACK (gtk_toolbar_attached_callback), - parent); - g_signal_connect (child->m_widget, "child_detached", - G_CALLBACK (gtk_toolbar_detached_callback), - parent); - } - } -#endif // wxUSE_TOOLBAR_NATIVE -} - -#endif // wxUSE_TOOLBAR - // ---------------------------------------------------------------------------- // wxFrame creation // ---------------------------------------------------------------------------- @@ -598,24 +549,8 @@ bool wxFrame::HasVisibleMenubar() const #if wxUSE_TOOLBAR -wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - InsertChildFunction save = m_insertCallback; - m_insertCallback = wxInsertChildInFrame; - m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name ); - m_insertCallback = save; - - GtkUpdateSize(); - - return m_frameToolBar; -} - void wxFrame::SetToolBar(wxToolBar *toolbar) { - bool hadTbar = m_frameToolBar != NULL; - wxFrameBase::SetToolBar(toolbar); if ( m_frameToolBar ) @@ -627,51 +562,28 @@ void wxFrame::SetToolBar(wxToolBar *toolbar) GetChildren().DeleteObject( m_frameToolBar ); gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget ); - GtkUpdateSize(); } - } - else // toolbar unset - { - // still need to update size if it had been there before - if ( hadTbar ) +#if wxUSE_TOOLBAR_NATIVE + if (m_frameToolBar->HasFlag(wxTB_DOCKABLE)) { - GtkUpdateSize(); + g_signal_connect(m_frameToolBar->m_widget, "child_attached", + G_CALLBACK(gtk_toolbar_attached_callback), this); + g_signal_connect(m_frameToolBar->m_widget, "child_detached", + G_CALLBACK(gtk_toolbar_detached_callback), this); } +#endif // wxUSE_TOOLBAR_NATIVE } + + GtkUpdateSize(); } #endif // wxUSE_TOOLBAR #if wxUSE_STATUSBAR -wxStatusBar* wxFrame::CreateStatusBar(int number, - long style, - wxWindowID id, - const wxString& name) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - // because it will change when toolbar is added - GtkUpdateSize(); - - return wxFrameBase::CreateStatusBar( number, style, id, name ); -} - void wxFrame::SetStatusBar(wxStatusBar *statbar) { - bool hadStatBar = m_frameStatusBar != NULL; - wxFrameBase::SetStatusBar(statbar); - - if (hadStatBar && !m_frameStatusBar) - GtkUpdateSize(); -} - -void wxFrame::PositionStatusBar() -{ - if ( !m_frameStatusBar ) - return; - GtkUpdateSize(); } #endif // wxUSE_STATUSBAR