simplify toolbar and statusbar create/set code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49231 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -54,18 +54,10 @@ public:
|
|||||||
virtual ~wxFrame();
|
virtual ~wxFrame();
|
||||||
|
|
||||||
#if wxUSE_STATUSBAR
|
#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);
|
void SetStatusBar(wxStatusBar *statbar);
|
||||||
#endif // wxUSE_STATUSBAR
|
#endif // wxUSE_STATUSBAR
|
||||||
|
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
virtual wxToolBar* CreateToolBar(long style = -1,
|
|
||||||
wxWindowID id = -1,
|
|
||||||
const wxString& name = wxToolBarNameStr);
|
|
||||||
void SetToolBar(wxToolBar *toolbar);
|
void SetToolBar(wxToolBar *toolbar);
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
|
||||||
@@ -87,10 +79,6 @@ protected:
|
|||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
#if wxUSE_STATUSBAR
|
|
||||||
virtual void PositionStatusBar();
|
|
||||||
#endif // wxUSE_STATUSBAR
|
|
||||||
|
|
||||||
// override wxWindow methods to take into account tool/menu/statusbars
|
// override wxWindow methods to take into account tool/menu/statusbars
|
||||||
virtual void DoGetClientSize( int *width, int *height ) const;
|
virtual void DoGetClientSize( int *width, int *height ) const;
|
||||||
|
|
||||||
|
@@ -110,55 +110,6 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_TOOLBAR
|
#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
|
// wxFrame creation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -598,24 +549,8 @@ bool wxFrame::HasVisibleMenubar() const
|
|||||||
|
|
||||||
#if wxUSE_TOOLBAR
|
#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)
|
void wxFrame::SetToolBar(wxToolBar *toolbar)
|
||||||
{
|
{
|
||||||
bool hadTbar = m_frameToolBar != NULL;
|
|
||||||
|
|
||||||
wxFrameBase::SetToolBar(toolbar);
|
wxFrameBase::SetToolBar(toolbar);
|
||||||
|
|
||||||
if ( m_frameToolBar )
|
if ( m_frameToolBar )
|
||||||
@@ -627,51 +562,28 @@ void wxFrame::SetToolBar(wxToolBar *toolbar)
|
|||||||
GetChildren().DeleteObject( m_frameToolBar );
|
GetChildren().DeleteObject( m_frameToolBar );
|
||||||
|
|
||||||
gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
|
gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
|
||||||
GtkUpdateSize();
|
|
||||||
}
|
}
|
||||||
}
|
#if wxUSE_TOOLBAR_NATIVE
|
||||||
else // toolbar unset
|
if (m_frameToolBar->HasFlag(wxTB_DOCKABLE))
|
||||||
{
|
|
||||||
// still need to update size if it had been there before
|
|
||||||
if ( hadTbar )
|
|
||||||
{
|
{
|
||||||
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
|
#endif // wxUSE_TOOLBAR
|
||||||
|
|
||||||
#if wxUSE_STATUSBAR
|
#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)
|
void wxFrame::SetStatusBar(wxStatusBar *statbar)
|
||||||
{
|
{
|
||||||
bool hadStatBar = m_frameStatusBar != NULL;
|
|
||||||
|
|
||||||
wxFrameBase::SetStatusBar(statbar);
|
wxFrameBase::SetStatusBar(statbar);
|
||||||
|
|
||||||
if (hadStatBar && !m_frameStatusBar)
|
|
||||||
GtkUpdateSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxFrame::PositionStatusBar()
|
|
||||||
{
|
|
||||||
if ( !m_frameStatusBar )
|
|
||||||
return;
|
|
||||||
|
|
||||||
GtkUpdateSize();
|
GtkUpdateSize();
|
||||||
}
|
}
|
||||||
#endif // wxUSE_STATUSBAR
|
#endif // wxUSE_STATUSBAR
|
||||||
|
Reference in New Issue
Block a user