// 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/dialog.h"
// constants
// ----------------------------------------------------------------------------
-const int wxMENU_HEIGHT = 27;
const int wxSTATUS_HEIGHT = 25;
const int wxPLACE_HOLDER = 0;
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
child->m_width,
child->m_height );
}
-
+
// Resize on OnInternalIdle
parent->GtkUpdateSize();
}
{
m_menuBarDetached = FALSE;
m_toolBarDetached = FALSE;
+ m_menuBarHeight = 2;
}
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;
}
void wxFrame::DoGetClientSize( int *width, int *height ) const
{
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
-
+
wxTopLevelWindow::DoGetClientSize( width, height );
if (height)
if (m_frameMenuBar)
{
if (!m_menuBarDetached)
- (*height) -= wxMENU_HEIGHT;
+ (*height) -= m_menuBarHeight;
else
(*height) -= wxPLACE_HOLDER;
}
#if wxUSE_STATUSBAR
// status bar
- if (m_frameStatusBar && m_frameStatusBar->IsShown())
+ if (m_frameStatusBar && m_frameStatusBar->IsShown())
(*height) -= wxSTATUS_HEIGHT;
#endif // wxUSE_STATUSBAR
if (m_frameMenuBar)
{
if (!m_menuBarDetached)
- height += wxMENU_HEIGHT;
+ height += m_menuBarHeight;
else
height += wxPLACE_HOLDER;
}
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;
if (m_frameMenuBar)
{
if (!m_menuBarDetached)
- yy += wxMENU_HEIGHT;
+ yy += m_menuBarHeight;
else
yy += wxPLACE_HOLDER;
}
ww = m_width - 2*m_miniEdge;
hh = m_toolBarDetached ? wxPLACE_HOLDER
: m_frameToolBar->m_height;
-
+
client_area_y_offset += hh;
}
void wxFrame::OnInternalIdle()
{
- wxTopLevelWindow::OnInternalIdle();
+ wxFrameBase::OnInternalIdle();
#if wxUSE_MENUS_NATIVE
if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached",
GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this );
}
-
+
m_frameMenuBar->Show( TRUE );
+
+ UpdateMenuBarSize();
}
+ else
+ {
+ m_menuBarHeight = 2;
+ GtkUpdateSize(); // resize window in OnInternalIdle
+ }
+}
- // resize window in OnInternalIdle
- m_sizeSet = FALSE;
+void wxFrame::UpdateMenuBarSize()
+{
+ wxASSERT_MSG( m_frameMenuBar, _T("Updating non existant menubar?") );
+
+ GtkRequisition req;
+
+ req.width = 2;
+ req.height = 2;
+
+ (* 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
+
+ GtkUpdateSize();
}
#endif // wxUSE_MENUS_NATIVE
m_insertInClientArea = TRUE;
- m_sizeSet = FALSE;
+ GtkUpdateSize();
return m_frameToolBar;
}
void wxFrame::SetToolBar(wxToolBar *toolbar)
{
+ bool hadTbar = m_frameToolBar != NULL;
+
wxFrameBase::SetToolBar(toolbar);
- if (m_frameToolBar)
+ if ( m_frameToolBar )
{
// insert into toolbar area if not already there
if ((m_frameToolBar->m_widget->parent) &&
GtkUpdateSize();
}
}
+ else // toolbar unset
+ {
+ // still need to update size if it had been there before
+ if ( hadTbar )
+ {
+ GtkUpdateSize();
+ }
+ }
}
#endif // wxUSE_TOOLBAR
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
// because it will change when toolbar is added
- m_sizeSet = FALSE;
+ GtkUpdateSize();
return wxFrameBase::CreateStatusBar( number, style, id, name );
}
if ( !m_frameStatusBar )
return;
- m_sizeSet = FALSE;
+ GtkUpdateSize();
}
#endif // wxUSE_STATUSBAR