]> git.saurik.com Git - wxWidgets.git/commitdiff
ensure that wxToolBar has one of wxTB_TOP/LEFT/RIGHT/BOTTOM styles set, otherwise...
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 31 Oct 2006 13:09:08 +0000 (13:09 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 31 Oct 2006 13:09:08 +0000 (13:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/tbarbase.h
src/cocoa/toolbar.mm
src/common/tbarbase.cpp
src/gtk/tbargtk.cpp
src/gtk1/tbargtk.cpp
src/mac/carbon/toolbar.cpp
src/motif/toolbar.cpp
src/msw/tbar95.cpp
src/univ/toolbar.cpp

index 1a3dee8604d09d2b1b3e7dbb2682e5ac904be535..3aa70ce99dc4b62ee6c8fb6dc4f1328275aa496b 100644 (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
     void UnToggleRadioGroup(wxToolBarToolBase *tool);
 
     // un-toggle all buttons in the same radio group
     void UnToggleRadioGroup(wxToolBarToolBase *tool);
 
index b831696cfe323cd41a3ce6ac6c560d800ef1cccc..f6211e3c7901186c8e18870a4400ba596ce4d504 100644 (file)
@@ -186,7 +186,13 @@ bool wxToolBar::Create( wxWindow *parent,
                         const wxString& name )
 {
     // Call wxControl::Create so we get a wxNonControlNSControl
                         const wxString& name )
 {
     // 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,
index 7814a7b4ae2604fd193f79e69c5fe6fa986a56b6..f8957002e0f8cbc83e5a18752a307975ee96cf1d 100644 (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,
                                             const wxString& label,
                                             const wxBitmap& bitmap,
 wxToolBarToolBase *wxToolBarBase::DoAddTool(int id,
                                             const wxString& label,
                                             const wxBitmap& bitmap,
index 42bca3ab03d21a8ba336f351ccd262c4bbf316f5..dd18e1d3a9b00be34867ec7417615680c010efe7 100644 (file)
@@ -287,6 +287,8 @@ bool wxToolBar::Create( wxWindow *parent,
         return false;
     }
 
         return false;
     }
 
+    FixupStyle();
+
     m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
     GtkSetStyle();
 
     m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
     GtkSetStyle();
 
index 06885d53411b659e3b232c3e870ec661505cd326..fab29b7cfeb2793f8dd51b86b69d476538d5d410 100644 (file)
@@ -285,6 +285,8 @@ bool wxToolBar::Create( wxWindow *parent,
         return false;
     }
 
         return false;
     }
 
+    FixupStyle();
+
     GtkOrientation orient;
     GtkToolbarStyle gtkStyle;
     GetGtkStyle(style, &orient, &gtkStyle);
     GtkOrientation orient;
     GtkToolbarStyle gtkStyle;
     GetGtkStyle(style, &orient, &gtkStyle);
index 997a557d1be91b5f64e7103b02cde8365dbfbbdd..7614e623124c412aec03d1abf1f5b3a91f02613a 100644 (file)
@@ -792,6 +792,8 @@ bool wxToolBar::Create(
     if ( !wxToolBarBase::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
         return false;
 
     if ( !wxToolBarBase::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
         return false;
 
+    FixupStyle();
+
     OSStatus err = noErr;
 
 #if wxMAC_USE_NATIVE_TOOLBAR
     OSStatus err = noErr;
 
 #if wxMAC_USE_NATIVE_TOOLBAR
index 753bb8ff20eae117935fd848af2a889f77ca17fa..42851b1b386c4d5f84087b5ae68b04c45cdd43c9 100644 (file)
@@ -204,6 +204,8 @@ bool wxToolBar::Create(wxWindow *parent,
                                    wxDefaultValidator, name ) )
         return false;
 
                                    wxDefaultValidator, name ) )
         return false;
 
+    FixupStyle();
+
     m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
 
     Widget parentWidget = (Widget) parent->GetClientWidget();
     m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
 
     Widget parentWidget = (Widget) parent->GetClientWidget();
index 16a2ec95c957691b8f97f6884ded3c566cdb038c..8cab9f682ee7859fe7924d5798218d39a6bb85df 100644 (file)
@@ -234,6 +234,8 @@ bool wxToolBar::Create(wxWindow *parent,
     if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
         return false;
 
     if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
         return false;
 
+    FixupStyle();
+
     // MSW-specific initialisation
     if ( !MSWCreateToolbar(pos, size) )
         return false;
     // MSW-specific initialisation
     if ( !MSWCreateToolbar(pos, size) )
         return false;
index fafb168d02de42e17de369ecd73b597305f24139..264bddd0439c444eb2d6c364e87edb7e0f7b7559 100644 (file)
@@ -190,6 +190,8 @@ bool wxToolBar::Create(wxWindow *parent,
         return false;
     }
 
         return false;
     }
 
+    FixupStyle();
+
     CreateInputHandler(wxINP_HANDLER_TOOLBAR);
 
     SetInitialSize(size);
     CreateInputHandler(wxINP_HANDLER_TOOLBAR);
 
     SetInitialSize(size);