ensure that wxToolBar has one of wxTB_TOP/LEFT/RIGHT/BOTTOM styles set, otherwise the latest toolbar positioning code breaks down

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-10-31 13:09:08 +00:00
parent 1c10464893
commit d408730ce4
9 changed files with 35 additions and 1 deletions

View File

@@ -564,6 +564,13 @@ protected:
// helper functions // helper functions
// ---------------- // ----------------
// call this from derived class ctor/Create() to ensure that we have either
// wxTB_HORIZONTAL or wxTB_VERTICAL style, there is a lot of existing code
// which randomly checks either one or the other of them and gets confused
// if neither is set (and making one of them 0 is not an option neither as
// then the existing tests would break down)
void FixupStyle();
// un-toggle all buttons in the same radio group // un-toggle all buttons in the same radio group
void UnToggleRadioGroup(wxToolBarToolBase *tool); void UnToggleRadioGroup(wxToolBarToolBase *tool);

View File

@@ -186,7 +186,13 @@ bool wxToolBar::Create( wxWindow *parent,
const wxString& name ) const wxString& name )
{ {
// Call wxControl::Create so we get a wxNonControlNSControl // Call wxControl::Create so we get a wxNonControlNSControl
return wxToolBarBase::Create(parent,winid,pos,size,style,wxDefaultValidator,name); if ( !wxToolBarBase::Create(parent, winid, pos, size, style,
wxDefaultValidator, name) )
return false;
FixupStyle();
return true;
} }
wxToolBarToolBase *wxToolBar::CreateTool(int toolid, wxToolBarToolBase *wxToolBar::CreateTool(int toolid,

View File

@@ -123,6 +123,15 @@ wxToolBarBase::wxToolBarBase()
m_defaultHeight = 15; m_defaultHeight = 15;
} }
void wxToolBarBase::FixupStyle()
{
if ( !HasFlag(wxTB_TOP | wxTB_LEFT | wxTB_RIGHT | wxTB_BOTTOM) )
{
// this is the default
m_windowStyle |= wxTB_TOP;
}
}
wxToolBarToolBase *wxToolBarBase::DoAddTool(int id, wxToolBarToolBase *wxToolBarBase::DoAddTool(int id,
const wxString& label, const wxString& label,
const wxBitmap& bitmap, const wxBitmap& bitmap,

View File

@@ -287,6 +287,8 @@ bool wxToolBar::Create( wxWindow *parent,
return false; return false;
} }
FixupStyle();
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
GtkSetStyle(); GtkSetStyle();

View File

@@ -285,6 +285,8 @@ bool wxToolBar::Create( wxWindow *parent,
return false; return false;
} }
FixupStyle();
GtkOrientation orient; GtkOrientation orient;
GtkToolbarStyle gtkStyle; GtkToolbarStyle gtkStyle;
GetGtkStyle(style, &orient, &gtkStyle); GetGtkStyle(style, &orient, &gtkStyle);

View File

@@ -792,6 +792,8 @@ bool wxToolBar::Create(
if ( !wxToolBarBase::Create( parent, id, pos, size, style, wxDefaultValidator, name ) ) if ( !wxToolBarBase::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
return false; return false;
FixupStyle();
OSStatus err = noErr; OSStatus err = noErr;
#if wxMAC_USE_NATIVE_TOOLBAR #if wxMAC_USE_NATIVE_TOOLBAR

View File

@@ -204,6 +204,8 @@ bool wxToolBar::Create(wxWindow *parent,
wxDefaultValidator, name ) ) wxDefaultValidator, name ) )
return false; return false;
FixupStyle();
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();

View File

@@ -234,6 +234,8 @@ bool wxToolBar::Create(wxWindow *parent,
if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
return false; return false;
FixupStyle();
// MSW-specific initialisation // MSW-specific initialisation
if ( !MSWCreateToolbar(pos, size) ) if ( !MSWCreateToolbar(pos, size) )
return false; return false;

View File

@@ -190,6 +190,8 @@ bool wxToolBar::Create(wxWindow *parent,
return false; return false;
} }
FixupStyle();
CreateInputHandler(wxINP_HANDLER_TOOLBAR); CreateInputHandler(wxINP_HANDLER_TOOLBAR);
SetInitialSize(size); SetInitialSize(size);