]> git.saurik.com Git - wxWidgets.git/commitdiff
No changes, just refactor wxToolBarToolBase ctors.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 10 Dec 2009 02:59:11 +0000 (02:59 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 10 Dec 2009 02:59:11 +0000 (02:59 +0000)
Add the usual Init() function for common initialization.

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

include/wx/tbarbase.h

index ba6a73e489f68446c8942da93e35d56d8f103817..e68a1d70372de84120ab185164e5ac9e5b1eeec2 100644 (file)
@@ -60,6 +60,7 @@ public:
     // ctors & dtor
     // ------------
 
+    // generic ctor for any kind of tool
     wxToolBarToolBase(wxToolBarBase *tbar = NULL,
                       int toolid = wxID_SEPARATOR,
                       const wxString& label = wxEmptyString,
@@ -71,40 +72,34 @@ public:
                       const wxString& longHelpString = wxEmptyString)
         : m_label(label),
           m_shortHelpString(shortHelpString),
-          m_longHelpString(longHelpString),
-          m_dropdownMenu(NULL)
+          m_longHelpString(longHelpString)
     {
-        m_tbar = tbar;
-        m_id = toolid;
-        if (m_id == wxID_ANY)
-            m_id = wxWindow::NewControlId();
+        Init
+        (
+            tbar,
+            toolid == wxID_SEPARATOR ? wxTOOL_STYLE_SEPARATOR
+                                     : wxTOOL_STYLE_BUTTON,
+            toolid == wxID_ANY ? wxWindow::NewControlId()
+                               : toolid,
+            kind
+        );
+
         m_clientData = clientData;
 
         m_bmpNormal = bmpNormal;
         m_bmpDisabled = bmpDisabled;
-
-        m_kind = kind;
-
-        m_enabled = true;
-        m_toggled = false;
-
-        m_toolStyle = toolid == wxID_SEPARATOR ? wxTOOL_STYLE_SEPARATOR
-                                           : wxTOOL_STYLE_BUTTON;
     }
 
+    // ctor for controls only
     wxToolBarToolBase(wxToolBarBase *tbar,
                       wxControl *control,
                       const wxString& label)
         : m_label(label)
     {
-        m_tbar = tbar;
-        m_control = control;
-        m_id = control->GetId();
+        Init(tbar, wxTOOL_STYLE_CONTROL, control->GetId(), wxITEM_MAX);
 
-        m_kind = wxITEM_MAX;    // invalid value
-
-        m_enabled = true;
-        m_toggled = false;
+        m_control = control;
+    }
 
         m_toolStyle = wxTOOL_STYLE_CONTROL;
 
@@ -206,6 +201,25 @@ public:
     wxMenu *GetDropdownMenu() const { return m_dropdownMenu; }
 
 protected:
+    // common part of all ctors
+    void Init(wxToolBarBase *tbar,
+              wxToolBarToolStyle style,
+              int toolid,
+              wxItemKind kind)
+    {
+        m_tbar = tbar;
+        m_toolStyle = style;
+        m_id = toolid;
+        m_kind = kind;
+
+        m_clientData = NULL;
+
+        m_toggled = false;
+        m_enabled = true;
+
+        m_dropdownMenu = NULL;
+    }
+
     wxToolBarBase *m_tbar;  // the toolbar to which we belong (may be NULL)
 
     // tool parameters