Reputation: 55
I am trying to add static text to my wxWidgets toolbar, but I can't figure out how to horizontally align it.
The code I am using is:
wxToolBar *m_toolbar;
wxStaticText *txt;
m_toolbar = CreateToolBar();
m_toolbar->SetToolBitmapSize( wxSize( 24, 24 ) );
txt = new wxStaticText( m_toolbar
, wxID_ANY
, "Sample Text"
, wxDefaultPosition
, wxDefaultSize
, wxALIGN_CENTRE );
m_toolbar->AddControl(txt);
I have seen a few posts about creating a custom version of wxStaticText::DoGetBestSize() but that hasn't helped either.
Upvotes: 0
Views: 459
Reputation: 1987
Since 2.9.1 there is wxToolBar::AddStretchableSpace().
Call that before and after adding txt
.
Upvotes: 1