X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b8b7f03cef9f028fc95301ac2ba506e4efa49f59..7acf6a921e69c3382706c2cfc35e826d08004231:/src/gtk/frame.cpp diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 7ff1880195..c6043a88c6 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -15,12 +15,16 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "frame.h" #endif +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + #include "wx/defs.h" +#include "wx/frame.h" #include "wx/dialog.h" #include "wx/control.h" #include "wx/app.h" @@ -45,7 +49,6 @@ // constants // ---------------------------------------------------------------------------- -const int wxMENU_HEIGHT = 27; const int wxSTATUS_HEIGHT = 25; const int wxPLACE_HOLDER = 0; @@ -148,7 +151,7 @@ static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidge /* 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 wxWindows requires different ways to insert + * virtual function here as wxWidgets requires different ways to insert * a child in container classes. */ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) @@ -165,7 +168,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) 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 @@ -193,7 +196,7 @@ static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) child->m_width, child->m_height ); } - + // Resize on OnInternalIdle parent->GtkUpdateSize(); } @@ -206,6 +209,7 @@ void wxFrame::Init() { m_menuBarDetached = FALSE; m_toolBarDetached = FALSE; + m_menuBarHeight = 2; } bool wxFrame::Create( wxWindow *parent, @@ -216,9 +220,10 @@ bool wxFrame::Create( wxWindow *parent, long style, const wxString &name ) { - bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, + bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, style, name); m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; + return rt; } @@ -235,7 +240,7 @@ wxFrame::~wxFrame() void wxFrame::DoGetClientSize( int *width, int *height ) const { wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - + wxTopLevelWindow::DoGetClientSize( width, height ); if (height) @@ -245,7 +250,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const if (m_frameMenuBar) { if (!m_menuBarDetached) - (*height) -= wxMENU_HEIGHT; + (*height) -= m_menuBarHeight; else (*height) -= wxPLACE_HOLDER; } @@ -253,7 +258,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const #if wxUSE_STATUSBAR // status bar - if (m_frameStatusBar && m_frameStatusBar->IsShown()) + if (m_frameStatusBar && m_frameStatusBar->IsShown()) (*height) -= wxSTATUS_HEIGHT; #endif // wxUSE_STATUSBAR @@ -292,7 +297,7 @@ void wxFrame::DoSetClientSize( int width, int height ) if (m_frameMenuBar) { if (!m_menuBarDetached) - height += wxMENU_HEIGHT; + height += m_menuBarHeight; else height += wxPLACE_HOLDER; } @@ -396,7 +401,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int xx = m_miniEdge; int yy = m_miniEdge + m_miniTitle; int ww = m_width - 2*m_miniEdge; - int hh = wxMENU_HEIGHT; + int hh = m_menuBarHeight; if (m_menuBarDetached) hh = wxPLACE_HOLDER; m_frameMenuBar->m_x = xx; m_frameMenuBar->m_y = yy; @@ -419,7 +424,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), if (m_frameMenuBar) { if (!m_menuBarDetached) - yy += wxMENU_HEIGHT; + yy += m_menuBarHeight; else yy += wxPLACE_HOLDER; } @@ -443,7 +448,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), ww = m_width - 2*m_miniEdge; hh = m_toolBarDetached ? wxPLACE_HOLDER : m_frameToolBar->m_height; - + client_area_y_offset += hh; } @@ -485,7 +490,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), } #endif // wxUSE_STATUSBAR - GtkUpdateSize(); + m_sizeSet = TRUE; // send size event to frame wxSizeEvent event( wxSize(m_width,m_height), GetId() ); @@ -507,7 +512,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), void wxFrame::OnInternalIdle() { - wxTopLevelWindow::OnInternalIdle(); + wxFrameBase::OnInternalIdle(); #if wxUSE_MENUS_NATIVE if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle(); @@ -516,7 +521,20 @@ void wxFrame::OnInternalIdle() if (m_frameToolBar) m_frameToolBar->OnInternalIdle(); #endif #if wxUSE_STATUSBAR - if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle(); + if (m_frameStatusBar) + { + m_frameStatusBar->OnInternalIdle(); + + // There may be controls in the status bar that + // need to be updated + for ( wxWindowList::compatibility_iterator node = m_frameStatusBar->GetChildren().GetFirst(); + node; + node = node->GetNext() ) + { + wxWindow *child = node->GetData(); + child->OnInternalIdle(); + } + } #endif } @@ -576,11 +594,34 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); } + + gtk_widget_show( m_frameMenuBar->m_widget ); - m_frameMenuBar->Show( TRUE ); + UpdateMenuBarSize(); } + else + { + m_menuBarHeight = 2; + GtkUpdateSize(); // resize window in OnInternalIdle + } +} + +void wxFrame::UpdateMenuBarSize() +{ + GtkRequisition req; + + req.width = 2; + req.height = 2; + + // this is called after Remove with a NULL m_frameMenuBar + if ( m_frameMenuBar ) + (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_frameMenuBar->m_widget) )->size_request ) + (m_frameMenuBar->m_widget, &req ); + + m_menuBarHeight = req.height; + + // resize window in OnInternalIdle - // resize window in OnInternalIdle GtkUpdateSize(); } @@ -648,6 +689,16 @@ wxStatusBar* wxFrame::CreateStatusBar(int number, 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 )