[ 1550698 ] Bottom aligned toolbar
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41268 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -72,6 +72,7 @@ use this option under Windows XP with true colour:
|
|||||||
2 only). This style must be used with wxTB\_TEXT.}
|
2 only). This style must be used with wxTB\_TEXT.}
|
||||||
\twocolitem{\windowstyle{wxTB\_HORZ\_TEXT}}{Combination of wxTB\_HORZ\_LAYOUT and wxTB\_TEXT.}
|
\twocolitem{\windowstyle{wxTB\_HORZ\_TEXT}}{Combination of wxTB\_HORZ\_LAYOUT and wxTB\_TEXT.}
|
||||||
\twocolitem{\windowstyle{wxTB\_NO\_TOOLTIPS}}{Don't show the short help tooltips for the tools when the mouse hovers over them.}
|
\twocolitem{\windowstyle{wxTB\_NO\_TOOLTIPS}}{Don't show the short help tooltips for the tools when the mouse hovers over them.}
|
||||||
|
\twocolitem{\windowstyle{wxTB\_BOTTOM}}{Align the toolbar at the bottom of parent window.}
|
||||||
\end{twocollist}
|
\end{twocollist}
|
||||||
|
|
||||||
See also \helpref{window styles overview}{windowstyles}. Note that the Win32
|
See also \helpref{window styles overview}{windowstyles}. Note that the Win32
|
||||||
|
@@ -52,7 +52,10 @@ enum
|
|||||||
wxTB_HORZ_TEXT = wxTB_HORZ_LAYOUT | wxTB_TEXT,
|
wxTB_HORZ_TEXT = wxTB_HORZ_LAYOUT | wxTB_TEXT,
|
||||||
|
|
||||||
// don't show the toolbar short help tooltips
|
// don't show the toolbar short help tooltips
|
||||||
wxTB_NO_TOOLTIPS = 0x1000
|
wxTB_NO_TOOLTIPS = 0x1000,
|
||||||
|
|
||||||
|
// lay out toolbar at the bottom of the window
|
||||||
|
wxTB_BOTTOM = 0x2000
|
||||||
};
|
};
|
||||||
|
|
||||||
#if wxUSE_TOOLBAR
|
#if wxUSE_TOOLBAR
|
||||||
|
@@ -97,6 +97,7 @@ public:
|
|||||||
void OnToggleAnotherToolbar(wxCommandEvent& event);
|
void OnToggleAnotherToolbar(wxCommandEvent& event);
|
||||||
void OnToggleHorizontalText(wxCommandEvent& WXUNUSED(event));
|
void OnToggleHorizontalText(wxCommandEvent& WXUNUSED(event));
|
||||||
|
|
||||||
|
void OnBottomToolbar(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnToggleToolbarSize(wxCommandEvent& event);
|
void OnToggleToolbarSize(wxCommandEvent& event);
|
||||||
void OnToggleToolbarOrient(wxCommandEvent& event);
|
void OnToggleToolbarOrient(wxCommandEvent& event);
|
||||||
void OnToggleToolbarRows(wxCommandEvent& event);
|
void OnToggleToolbarRows(wxCommandEvent& event);
|
||||||
@@ -133,6 +134,7 @@ private:
|
|||||||
|
|
||||||
bool m_smallToolbar,
|
bool m_smallToolbar,
|
||||||
m_horzToolbar,
|
m_horzToolbar,
|
||||||
|
m_bottomToolbar,
|
||||||
m_horzText,
|
m_horzText,
|
||||||
m_useCustomDisabled,
|
m_useCustomDisabled,
|
||||||
m_showTooltips;
|
m_showTooltips;
|
||||||
@@ -181,12 +183,13 @@ enum
|
|||||||
IDM_TOOLBAR_SHOW_ICONS,
|
IDM_TOOLBAR_SHOW_ICONS,
|
||||||
IDM_TOOLBAR_SHOW_BOTH,
|
IDM_TOOLBAR_SHOW_BOTH,
|
||||||
IDM_TOOLBAR_CUSTOM_PATH,
|
IDM_TOOLBAR_CUSTOM_PATH,
|
||||||
|
IDM_TOOLBAR_BOTTOM_ORIENTATION,
|
||||||
IDM_TOOLBAR_OTHER_1,
|
IDM_TOOLBAR_OTHER_1,
|
||||||
IDM_TOOLBAR_OTHER_2,
|
IDM_TOOLBAR_OTHER_2,
|
||||||
IDM_TOOLBAR_OTHER_3,
|
IDM_TOOLBAR_OTHER_3,
|
||||||
|
|
||||||
ID_COMBO = 1000
|
ID_COMBO = 1000,
|
||||||
|
ID_SPIN = 1001
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -206,6 +209,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, MyFrame::OnToggleAnotherToolbar)
|
EVT_MENU(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, MyFrame::OnToggleAnotherToolbar)
|
||||||
EVT_MENU(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT, MyFrame::OnToggleHorizontalText)
|
EVT_MENU(IDM_TOOLBAR_TOGGLE_HORIZONTAL_TEXT, MyFrame::OnToggleHorizontalText)
|
||||||
|
|
||||||
|
EVT_MENU(IDM_TOOLBAR_BOTTOM_ORIENTATION, MyFrame::OnBottomToolbar)
|
||||||
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize)
|
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize)
|
||||||
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient)
|
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient)
|
||||||
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows)
|
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows)
|
||||||
@@ -290,7 +294,10 @@ void MyFrame::RecreateToolbar()
|
|||||||
|
|
||||||
SetToolBar(NULL);
|
SetToolBar(NULL);
|
||||||
|
|
||||||
style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_HORZ_LAYOUT);
|
style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_HORZ_LAYOUT);
|
||||||
|
if( m_bottomToolbar )
|
||||||
|
style |= wxTB_BOTTOM;
|
||||||
|
else
|
||||||
style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
|
style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
|
||||||
|
|
||||||
if ( m_showTooltips )
|
if ( m_showTooltips )
|
||||||
@@ -369,6 +376,9 @@ void MyFrame::RecreateToolbar()
|
|||||||
combo->Append(_T("in a"));
|
combo->Append(_T("in a"));
|
||||||
combo->Append(_T("toolbar"));
|
combo->Append(_T("toolbar"));
|
||||||
toolBar->AddControl(combo);
|
toolBar->AddControl(combo);
|
||||||
|
|
||||||
|
//wxSpinCtrl *spin = new wxSpinCtrl( toolBar, ID_SPIN, wxT("0"), wxDefaultPosition, wxSize(80,wxDefaultCoord), 0, 100, 0 );
|
||||||
|
//toolBar->AddControl( spin );
|
||||||
}
|
}
|
||||||
#endif // toolbars which don't support controls
|
#endif // toolbars which don't support controls
|
||||||
|
|
||||||
@@ -440,6 +450,7 @@ MyFrame::MyFrame(wxFrame* parent,
|
|||||||
|
|
||||||
m_smallToolbar = true;
|
m_smallToolbar = true;
|
||||||
m_horzToolbar = true;
|
m_horzToolbar = true;
|
||||||
|
m_bottomToolbar = false;
|
||||||
m_horzText = false;
|
m_horzText = false;
|
||||||
m_useCustomDisabled = false;
|
m_useCustomDisabled = false;
|
||||||
m_showTooltips = true;
|
m_showTooltips = true;
|
||||||
@@ -490,6 +501,9 @@ MyFrame::MyFrame(wxFrame* parent,
|
|||||||
_T("Switch between using system-generated and custom disabled images"));
|
_T("Switch between using system-generated and custom disabled images"));
|
||||||
|
|
||||||
|
|
||||||
|
tbarMenu->AppendCheckItem(IDM_TOOLBAR_BOTTOM_ORIENTATION,
|
||||||
|
_T("Set toolbar at the bottom of the window"),
|
||||||
|
_T("Set toolbar at the bottom of the window"));
|
||||||
tbarMenu->AppendSeparator();
|
tbarMenu->AppendSeparator();
|
||||||
|
|
||||||
tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, _T("&Enable print button\tCtrl-E"));
|
tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, _T("&Enable print button\tCtrl-E"));
|
||||||
@@ -530,9 +544,22 @@ MyFrame::MyFrame(wxFrame* parent,
|
|||||||
// Create the toolbar
|
// Create the toolbar
|
||||||
RecreateToolbar();
|
RecreateToolbar();
|
||||||
|
|
||||||
m_textWindow = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxPoint(0, 0), wxDefaultSize, wxTE_MULTILINE);
|
m_textWindow = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USE_GENERIC_TBAR
|
||||||
|
|
||||||
|
wxToolBar* MyFrame::OnCreateToolBar(long style,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString& name)
|
||||||
|
{
|
||||||
|
return (wxToolBar *)new wxToolBarSimple(this, id,
|
||||||
|
wxDefaultPosition, wxDefaultSize,
|
||||||
|
style, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // USE_GENERIC_TBAR
|
||||||
|
|
||||||
void MyFrame::LayoutChildren()
|
void MyFrame::LayoutChildren()
|
||||||
{
|
{
|
||||||
wxSize size = GetClientSize();
|
wxSize size = GetClientSize();
|
||||||
@@ -652,7 +679,12 @@ void MyFrame::OnToggleCustomDisabled(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void MyFrame::OnToggleToolbarOrient(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnToggleToolbarOrient(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
if( m_bottomToolbar )
|
||||||
|
m_bottomToolbar = false;
|
||||||
m_horzToolbar = !m_horzToolbar;
|
m_horzToolbar = !m_horzToolbar;
|
||||||
|
wxMenuBar *menuBar = GetMenuBar();
|
||||||
|
if( menuBar->IsChecked( IDM_TOOLBAR_BOTTOM_ORIENTATION ) )
|
||||||
|
menuBar->Check( IDM_TOOLBAR_BOTTOM_ORIENTATION, false );
|
||||||
|
|
||||||
RecreateToolbar();
|
RecreateToolbar();
|
||||||
}
|
}
|
||||||
@@ -818,3 +850,13 @@ void MyFrame::OnToggleRadioBtn(wxCommandEvent& event)
|
|||||||
event.GetId() - IDM_TOOLBAR_TOGGLERADIOBTN1, true);
|
event.GetId() - IDM_TOOLBAR_TOGGLERADIOBTN1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void MyFrame::OnBottomToolbar(wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
m_bottomToolbar = !m_bottomToolbar;
|
||||||
|
wxMenuBar *menuBar = GetMenuBar();
|
||||||
|
if( menuBar->IsChecked( IDM_TOOLBAR_TOGGLETOOLBARORIENT ) )
|
||||||
|
menuBar->Check( IDM_TOOLBAR_TOGGLETOOLBARORIENT, false );
|
||||||
|
if( !m_horzToolbar )
|
||||||
|
m_horzToolbar = true;
|
||||||
|
RecreateToolbar();
|
||||||
|
}
|
||||||
|
@@ -421,6 +421,19 @@ void wxFrame::GtkOnSize()
|
|||||||
|
|
||||||
client_area_x_offset += ww;
|
client_area_x_offset += ww;
|
||||||
}
|
}
|
||||||
|
else if( m_frameToolBar->GetWindowStyle() & wxTB_BOTTOM )
|
||||||
|
{
|
||||||
|
xx = m_miniEdge;
|
||||||
|
yy = GetClientSize().y;
|
||||||
|
#if wxUSE_MENUS_NATIVE
|
||||||
|
yy += m_menuBarHeight;
|
||||||
|
#endif // wxUSE_MENU_NATIVE
|
||||||
|
m_frameToolBar->m_x = xx;
|
||||||
|
m_frameToolBar->m_y = yy;
|
||||||
|
ww = m_width - 2*m_miniEdge;
|
||||||
|
hh = m_toolBarDetached ? wxPLACE_HOLDER
|
||||||
|
: m_frameToolBar->m_height;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ww = m_width - 2*m_miniEdge;
|
ww = m_width - 2*m_miniEdge;
|
||||||
|
@@ -366,6 +366,12 @@ void wxFrame::PositionToolBar()
|
|||||||
// have the original client size.
|
// have the original client size.
|
||||||
GetToolBar()->SetSize(tx , ty , tw, ch , wxSIZE_NO_ADJUSTMENTS );
|
GetToolBar()->SetSize(tx , ty , tw, ch , wxSIZE_NO_ADJUSTMENTS );
|
||||||
}
|
}
|
||||||
|
else if (GetToolBar->GetWindowStyleFlag() & wxTB_BOTTOM)
|
||||||
|
{
|
||||||
|
tx = 0;
|
||||||
|
ty = statusY - th;
|
||||||
|
GetToolBar->SetSize(tx, ty, cw, th, wxSIZE_NO_ADJUSTMENTS );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if !wxMAC_USE_NATIVE_TOOLBAR
|
#if !wxMAC_USE_NATIVE_TOOLBAR
|
||||||
|
@@ -248,7 +248,16 @@ void wxFrame::DoGetClientSize(int *x, int *y) const
|
|||||||
|
|
||||||
if ( y )
|
if ( y )
|
||||||
*y -= pt.y;
|
*y -= pt.y;
|
||||||
|
#if wxUSE_TOOLBAR
|
||||||
|
if( y )
|
||||||
|
{
|
||||||
|
wxToolBar *toolbar = GetToolBar();
|
||||||
|
if( toolbar && toolbar->HasFlag( wxTB_BOTTOM ) )
|
||||||
|
{
|
||||||
|
*y -= toolbar->GetClientSize().y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#if wxUSE_STATUSBAR
|
#if wxUSE_STATUSBAR
|
||||||
// adjust client area height to take the status bar into account
|
// adjust client area height to take the status bar into account
|
||||||
if ( y )
|
if ( y )
|
||||||
@@ -315,6 +324,11 @@ void wxFrame::PositionStatusBar()
|
|||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
GetClientSize(&w, &h);
|
GetClientSize(&w, &h);
|
||||||
|
#if wxUSE_TOOLBAR
|
||||||
|
wxToolBar *toolbar = GetToolBar();
|
||||||
|
if( toolbar && toolbar->HasFlag( wxTB_BOTTOM ) )
|
||||||
|
h += toolbar->GetClientRect().height;
|
||||||
|
#endif
|
||||||
int sw, sh;
|
int sw, sh;
|
||||||
m_frameStatusBar->GetSize(&sw, &sh);
|
m_frameStatusBar->GetSize(&sw, &sh);
|
||||||
|
|
||||||
@@ -560,6 +574,7 @@ wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& nam
|
|||||||
|
|
||||||
void wxFrame::PositionToolBar()
|
void wxFrame::PositionToolBar()
|
||||||
{
|
{
|
||||||
|
int x = 0, y = 0;
|
||||||
wxToolBar *toolbar = GetToolBar();
|
wxToolBar *toolbar = GetToolBar();
|
||||||
if ( toolbar && toolbar->IsShown() )
|
if ( toolbar && toolbar->IsShown() )
|
||||||
{
|
{
|
||||||
@@ -581,9 +596,19 @@ void wxFrame::PositionToolBar()
|
|||||||
height -= statbar->GetClientSize().y;
|
height -= statbar->GetClientSize().y;
|
||||||
}
|
}
|
||||||
#endif // wxUSE_STATUSBAR
|
#endif // wxUSE_STATUSBAR
|
||||||
|
int tx, ty, tw, th;
|
||||||
int x = 0;
|
toolbar->GetPosition( &tx, &ty );
|
||||||
int y = 0;
|
toolbar->GetSize( &tw, &th );
|
||||||
|
if( ( toolbar->GetWindowStyleFlag() & wxTB_HORIZONTAL ) || ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) )
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
else if( toolbar->GetWindowStyleFlag() & wxTB_BOTTOM )
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y = height - th;
|
||||||
|
}
|
||||||
#if defined(WINCE_WITH_COMMANDBAR)
|
#if defined(WINCE_WITH_COMMANDBAR)
|
||||||
// We're using a commandbar - so we have to allow for it.
|
// We're using a commandbar - so we have to allow for it.
|
||||||
if (GetMenuBar() && GetMenuBar()->GetCommandBar())
|
if (GetMenuBar() && GetMenuBar()->GetCommandBar())
|
||||||
@@ -593,17 +618,21 @@ void wxFrame::PositionToolBar()
|
|||||||
y = rect.bottom - rect.top;
|
y = rect.bottom - rect.top;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if( ( toolbar->GetWindowStyleFlag() & wxTB_HORIZONTAL ) || ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) )
|
||||||
int tx, ty;
|
{
|
||||||
int tw, th;
|
|
||||||
toolbar->GetPosition(&tx, &ty);
|
|
||||||
toolbar->GetSize(&tw, &th);
|
|
||||||
|
|
||||||
// Adjust
|
// Adjust
|
||||||
if (ty < 0 && (-ty == th))
|
if (ty < 0 && (-ty == th))
|
||||||
ty = 0;
|
ty = 0;
|
||||||
if (tx < 0 && (-tx == tw))
|
if (tx < 0 && (-tx == tw))
|
||||||
tx = 0;
|
tx = 0;
|
||||||
|
}
|
||||||
|
else if( toolbar->GetWindowStyleFlag() & wxTB_BOTTOM )
|
||||||
|
{
|
||||||
|
if( ty < 0 && ( -ty == th ) )
|
||||||
|
ty = height - th;
|
||||||
|
if( tx < 0 && ( -tx == tw ) )
|
||||||
|
tx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int desiredW = tw;
|
int desiredW = tw;
|
||||||
int desiredH = th;
|
int desiredH = th;
|
||||||
@@ -1055,7 +1084,7 @@ wxPoint wxFrame::GetClientAreaOrigin() const
|
|||||||
{
|
{
|
||||||
pt.x += w;
|
pt.x += w;
|
||||||
}
|
}
|
||||||
else
|
else if( !( toolbar->GetWindowStyleFlag() & wxTB_BOTTOM ) )
|
||||||
{
|
{
|
||||||
pt.y += h;
|
pt.y += h;
|
||||||
}
|
}
|
||||||
|
@@ -402,6 +402,9 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||||||
if ( style & wxTB_VERTICAL )
|
if ( style & wxTB_VERTICAL )
|
||||||
msStyle |= CCS_VERT;
|
msStyle |= CCS_VERT;
|
||||||
|
|
||||||
|
if( style & wxTB_BOTTOM )
|
||||||
|
msStyle |= CCS_BOTTOM;
|
||||||
|
|
||||||
return msStyle;
|
return msStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -704,6 +704,15 @@ void wxFrame::PositionToolBar()
|
|||||||
,vTHeight
|
,vTHeight
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else if (pToolBar->GetWindowStyleFlag() & wxTB_BOTTOM )
|
||||||
|
{
|
||||||
|
vWidth = (wxCoord)(vRect.xRight - vRect.xLeft);
|
||||||
|
pToolBar->SetSize( vRect.xLeft - vFRect.xLeft
|
||||||
|
,vRect.yBottom - vTHeight // assuming the vRect contains the client coordinates
|
||||||
|
,vWidth
|
||||||
|
,vHeight
|
||||||
|
);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxCoord vSwidth = 0;
|
wxCoord vSwidth = 0;
|
||||||
|
Reference in New Issue
Block a user