Determin menu bar height dynamically.

Minor sample changes.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-09-30 10:40:52 +00:00
parent 5c3e4ed256
commit 0edfce279c
6 changed files with 42 additions and 11 deletions

View File

@@ -84,6 +84,7 @@ public:
virtual void OnInternalIdle(); virtual void OnInternalIdle();
bool m_menuBarDetached; bool m_menuBarDetached;
int m_menuBarHeight;
bool m_toolBarDetached; bool m_toolBarDetached;
protected: protected:

View File

@@ -84,6 +84,7 @@ public:
virtual void OnInternalIdle(); virtual void OnInternalIdle();
bool m_menuBarDetached; bool m_menuBarDetached;
int m_menuBarHeight;
bool m_toolBarDetached; bool m_toolBarDetached;
protected: protected:

View File

@@ -851,6 +851,12 @@ void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) )
dc.SetTextForeground(wxGetApp().m_canvasTextColour); dc.SetTextForeground(wxGetApp().m_canvasTextColour);
dc.SetBackgroundMode(wxTRANSPARENT); dc.SetBackgroundMode(wxTRANSPARENT);
dc.DrawText("wxWindows common dialogs test application", 10, 10); dc.DrawText("wxWindows common dialogs test application", 10, 10);
dc.SetPen( *wxRED_PEN );
dc.DrawLine( 10,40,200,40 );
dc.SetPen( *wxBLACK_PEN );
dc.DrawLine( 10,50,200,50 );
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -366,7 +366,7 @@ bool MyPrintout::OnPrintPage(int page)
wxChar buf[200]; wxChar buf[200];
wxSprintf(buf, wxT("PAGE %d"), page); wxSprintf(buf, wxT("PAGE %d"), page);
dc->DrawText(buf, 10, 10); // dc->DrawText(buf, 10, 10);
return TRUE; return TRUE;
} }
@@ -432,6 +432,7 @@ void MyPrintout::DrawPageOne(wxDC *dc)
// Set the scale and origin // Set the scale and origin
dc->SetUserScale(actualScale, actualScale); dc->SetUserScale(actualScale, actualScale);
dc->SetDeviceOrigin( (long)posX, (long)posY ); dc->SetDeviceOrigin( (long)posX, (long)posY );
//dc->SetUserScale(1.0, 1.0);
frame->Draw(*dc); frame->Draw(*dc);
} }

View File

@@ -45,7 +45,6 @@
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 27;
const int wxSTATUS_HEIGHT = 25; const int wxSTATUS_HEIGHT = 25;
const int wxPLACE_HOLDER = 0; const int wxPLACE_HOLDER = 0;
@@ -206,6 +205,7 @@ void wxFrame::Init()
{ {
m_menuBarDetached = FALSE; m_menuBarDetached = FALSE;
m_toolBarDetached = FALSE; m_toolBarDetached = FALSE;
m_menuBarHeight = 2;
} }
bool wxFrame::Create( wxWindow *parent, bool wxFrame::Create( wxWindow *parent,
@@ -245,7 +245,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
(*height) -= wxMENU_HEIGHT; (*height) -= m_menuBarHeight;
else else
(*height) -= wxPLACE_HOLDER; (*height) -= wxPLACE_HOLDER;
} }
@@ -292,7 +292,7 @@ void wxFrame::DoSetClientSize( int width, int height )
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
height += wxMENU_HEIGHT; height += m_menuBarHeight;
else else
height += wxPLACE_HOLDER; height += wxPLACE_HOLDER;
} }
@@ -396,7 +396,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
int xx = m_miniEdge; int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle; int yy = m_miniEdge + m_miniTitle;
int ww = m_width - 2*m_miniEdge; int ww = m_width - 2*m_miniEdge;
int hh = wxMENU_HEIGHT; int hh = m_menuBarHeight;
if (m_menuBarDetached) hh = wxPLACE_HOLDER; if (m_menuBarDetached) hh = wxPLACE_HOLDER;
m_frameMenuBar->m_x = xx; m_frameMenuBar->m_x = xx;
m_frameMenuBar->m_y = yy; m_frameMenuBar->m_y = yy;
@@ -419,7 +419,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
yy += wxMENU_HEIGHT; yy += m_menuBarHeight;
else else
yy += wxPLACE_HOLDER; yy += wxPLACE_HOLDER;
} }
@@ -578,6 +578,17 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
} }
m_frameMenuBar->Show( TRUE ); m_frameMenuBar->Show( TRUE );
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;
}
else
{
m_menuBarHeight = 2;
} }
// resize window in OnInternalIdle // resize window in OnInternalIdle

View File

@@ -45,7 +45,6 @@
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const int wxMENU_HEIGHT = 27;
const int wxSTATUS_HEIGHT = 25; const int wxSTATUS_HEIGHT = 25;
const int wxPLACE_HOLDER = 0; const int wxPLACE_HOLDER = 0;
@@ -206,6 +205,7 @@ void wxFrame::Init()
{ {
m_menuBarDetached = FALSE; m_menuBarDetached = FALSE;
m_toolBarDetached = FALSE; m_toolBarDetached = FALSE;
m_menuBarHeight = 2;
} }
bool wxFrame::Create( wxWindow *parent, bool wxFrame::Create( wxWindow *parent,
@@ -245,7 +245,7 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
(*height) -= wxMENU_HEIGHT; (*height) -= m_menuBarHeight;
else else
(*height) -= wxPLACE_HOLDER; (*height) -= wxPLACE_HOLDER;
} }
@@ -292,7 +292,7 @@ void wxFrame::DoSetClientSize( int width, int height )
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
height += wxMENU_HEIGHT; height += m_menuBarHeight;
else else
height += wxPLACE_HOLDER; height += wxPLACE_HOLDER;
} }
@@ -396,7 +396,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
int xx = m_miniEdge; int xx = m_miniEdge;
int yy = m_miniEdge + m_miniTitle; int yy = m_miniEdge + m_miniTitle;
int ww = m_width - 2*m_miniEdge; int ww = m_width - 2*m_miniEdge;
int hh = wxMENU_HEIGHT; int hh = m_menuBarHeight;
if (m_menuBarDetached) hh = wxPLACE_HOLDER; if (m_menuBarDetached) hh = wxPLACE_HOLDER;
m_frameMenuBar->m_x = xx; m_frameMenuBar->m_x = xx;
m_frameMenuBar->m_y = yy; m_frameMenuBar->m_y = yy;
@@ -419,7 +419,7 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y),
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
if (!m_menuBarDetached) if (!m_menuBarDetached)
yy += wxMENU_HEIGHT; yy += m_menuBarHeight;
else else
yy += wxPLACE_HOLDER; yy += wxPLACE_HOLDER;
} }
@@ -578,6 +578,17 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
} }
m_frameMenuBar->Show( TRUE ); m_frameMenuBar->Show( TRUE );
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;
}
else
{
m_menuBarHeight = 2;
} }
// resize window in OnInternalIdle // resize window in OnInternalIdle