]> git.saurik.com Git - wxWidgets.git/commitdiff
Disallow drop downs on AUI check buttons.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 10 Nov 2012 12:40:47 +0000 (12:40 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 10 Nov 2012 12:40:47 +0000 (12:40 +0000)
This doesn't make much sense and disallowing it makes check items consistent
with radio ones as previously you could set up a dropdown for the former but
not for the latter.

Also update the documentation of the relevant methods.

Closes #14795.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72944 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/aui/auibar.h
interface/wx/aui/auibar.h
src/aui/auibar.cpp

index 3e0439957f360926549ab6a9a5b039dc519aa2ce..a156877b27d0b00473bd0452ac5153e2f654be83 100644 (file)
@@ -211,7 +211,14 @@ public:
     void SetActive(bool b) { m_active = b; }
     bool IsActive() const { return m_active; }
 
-    void SetHasDropDown(bool b) { m_dropDown = b; }
+    void SetHasDropDown(bool b)
+    {
+        wxCHECK_RET( !b || m_kind == wxITEM_NORMAL,
+                     wxS("Only normal tools can have drop downs") );
+
+        m_dropDown = b;
+    }
+
     bool HasDropDown() const { return m_dropDown; }
 
     void SetSticky(bool b) { m_sticky = b; }
index e02e3cd785a6e7ce29588f7ad70327622a13e800..513c67f58296fa6c3ffb8e569e7213a79abeede9 100644 (file)
@@ -341,11 +341,13 @@ public:
     bool IsActive() const;
 
     /**
+        Set whether this tool has a drop down button.
 
+        This is only valid for wxITEM_NORMAL tools.
     */
     void SetHasDropDown(bool b);
     /**
-
+        Returns whether the toolbar item has an associated drop down button.
     */
     bool HasDropDown() const;
 
@@ -704,7 +706,21 @@ public:
     void EnableTool(int tool_id, bool state);
     bool GetToolEnabled(int tool_id) const;
 
+    /**
+        Set whether the specified toolbar item has a drop down button.
+
+        This is only valid for wxITEM_NORMAL tools.
+
+        @see wxAuiToolBarItem::SetHasDropDown()
+    */
     void SetToolDropDown(int tool_id, bool dropdown);
+
+    /**
+        Returns whether the specified toolbar item has an associated drop down
+        button.
+
+        @see wxAuiToolBarItem::HasDropDown()
+    */
     bool GetToolDropDown(int tool_id) const;
 
     void SetToolBorderPadding(int padding);
index 564279cd9c7453134124b3ff6d648e2242168e90..d00706115b231840824d6186a23b6f17f2266d55 100644 (file)
@@ -1261,16 +1261,16 @@ void wxAuiToolBar::SetToolDropDown(int tool_id, bool dropdown)
     if (!item)
         return;
 
-    item->m_dropDown = dropdown;
+    item->SetHasDropDown(dropdown);
 }
 
 bool wxAuiToolBar::GetToolDropDown(int tool_id) const
 {
     wxAuiToolBarItem* item = FindTool(tool_id);
     if (!item)
-        return 0;
+        return false;
 
-    return item->m_dropDown;
+    return item->HasDropDown();
 }
 
 void wxAuiToolBar::SetToolSticky(int tool_id, bool sticky)
@@ -2411,41 +2411,36 @@ void wxAuiToolBar::OnPaint(wxPaintEvent& WXUNUSED(evt))
             break;
         }
 
-        if (item.m_kind == wxITEM_SEPARATOR)
-        {
-            // draw a separator
-            m_art->DrawSeparator(dc, this, item_rect);
-        }
-        else if (item.m_kind == wxITEM_LABEL)
-        {
-            // draw a text label only
-            m_art->DrawLabel(dc, this, item, item_rect);
-        }
-        else if (item.m_kind == wxITEM_NORMAL)
-        {
-            // draw a regular button or dropdown button
-            if (!item.m_dropDown)
-                m_art->DrawButton(dc, this, item, item_rect);
-            else
-                m_art->DrawDropDownButton(dc, this, item, item_rect);
-        }
-        else if (item.m_kind == wxITEM_CHECK)
+        switch ( item.m_kind )
         {
-            // draw either a regular or dropdown toggle button
-            if (!item.m_dropDown)
+            case wxITEM_NORMAL:
+                // draw a regular or dropdown button
+                if (!item.m_dropDown)
+                    m_art->DrawButton(dc, this, item, item_rect);
+                else
+                    m_art->DrawDropDownButton(dc, this, item, item_rect);
+                break;
+
+            case wxITEM_CHECK:
+            case wxITEM_RADIO:
+                // draw a toggle button
                 m_art->DrawButton(dc, this, item, item_rect);
-            else
-                m_art->DrawDropDownButton(dc, this, item, item_rect);
-        }
-        else if (item.m_kind == wxITEM_RADIO)
-        {
-            // draw a toggle button
-            m_art->DrawButton(dc, this, item, item_rect);
-        }
-        else if (item.m_kind == wxITEM_CONTROL)
-        {
-            // draw the control's label
-            m_art->DrawControlLabel(dc, this, item, item_rect);
+                break;
+
+            case wxITEM_SEPARATOR:
+                // draw a separator
+                m_art->DrawSeparator(dc, this, item_rect);
+                break;
+
+            case wxITEM_LABEL:
+                // draw a text label only
+                m_art->DrawLabel(dc, this, item, item_rect);
+                break;
+
+            case wxITEM_CONTROL:
+                // draw the control's label
+                m_art->DrawControlLabel(dc, this, item, item_rect);
+                break;
         }
 
         // fire a signal to see if the item wants to be custom-rendered