]> git.saurik.com Git - wxWidgets.git/commitdiff
use kind, not id, of a menu item to test whether it's a separator: this allows having...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Apr 2008 15:55:42 +0000 (15:55 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 6 Apr 2008 15:55:42 +0000 (15:55 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53056 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/menu.h
include/wx/menuitem.h
interface/menuitem.h
src/common/framecmn.cpp
src/motif/menuitem.cpp
src/msw/menuitem.cpp

index af74dc4cb0b87586d3e5892ff32ddb60c025ecb6..5a21ed1904398a2918b3abb23d305c59f1e18880 100644 (file)
@@ -311,6 +311,7 @@ All (GUI):
 - Freeze() and Thaw() now recursively freeze/thaw the children too.
 - Generalized wxScrolledWindow into wxScrolled<T> template that can derive
   from any window class, not just wxPanel.
+- Allow having menu separators with ids != wxID_SEPARATOR (Jeff Tupper)
 
 wxGTK:
 
index 00fcd5995a0c334c4181ef94a63ff3fadc0f2227..8cae2e12557e263a25e76c9ac3af98785ed3deab 100644 (file)
@@ -68,7 +68,7 @@ public:
     }
 
     // append a separator to the menu
-    wxMenuItem* AppendSeparator() { return Append(wxID_SEPARATOR, wxEmptyString); }
+    wxMenuItem* AppendSeparator() { return Append(wxID_SEPARATOR); }
 
     // append a check item
     wxMenuItem* AppendCheckItem(int itemid,
index 677aa3146701bd11b268c20135e3f0772bc57afd..1da5f652115f9819a9819ea0dfdb0826409dffe9 100644 (file)
@@ -56,7 +56,6 @@ public:
     // get/set id
     void SetId(int itemid) { m_id = itemid; }
     int  GetId() const { return m_id; }
-    bool IsSeparator() const { return m_id == wxID_SEPARATOR; }
 
     // the item's text (or name)
     //
@@ -81,6 +80,7 @@ public:
     // what kind of menu item we are
     wxItemKind GetKind() const { return m_kind; }
     void SetKind(wxItemKind kind) { m_kind = kind; }
+    bool IsSeparator() const { return m_kind == wxITEM_SEPARATOR; }
 
     virtual void SetCheckable(bool checkable) { m_kind = checkable ? wxITEM_CHECK : wxITEM_NORMAL; }
     bool IsCheckable() const
index 4ee4df3b269010925688c02adf62da1b22fd73ab..9296ab2ba39703f233cc8a7fe9dad8c07baf9910 100644 (file)
@@ -47,7 +47,8 @@ public:
         @param parentMenu
             Menu that the menu item belongs to.
         @param id
-            Identifier for this menu item, or wxID_SEPARATOR to indicate a separator.
+            Identifier for this menu item. May be wxID_SEPARATOR, in which case the
+            given kind is ignored and taken to be wxITEM_SEPARATOR instead.
         @param text
             Text for the menu item, as shown on the menu. An accelerator
             key can be specified using the ampersand " character. In order to embed an
index c1a25b5a8ee44efa7818e9e9224d5f78878e5e93..710742fd715ccd3d82a35593801574fcfa9025a8 100644 (file)
@@ -360,7 +360,7 @@ bool wxFrameBase::ShowMenuHelp(int menuId)
     if ( menuId != wxID_SEPARATOR && menuId != -3 /* wxID_TITLE */ )
     {
         const wxMenuItem * const item = FindItemInMenuBar(menuId);
-        if ( item )
+        if ( item && !item->IsSeparator() )
             helpString = item->GetHelp();
 
         // notice that it's ok if we don't find the item because it might
index 6fbfb08465f29a1be9985faa51acb7990fa81493..e830c00c13a42eb6efba3d70743fb75b68cc3667 100644 (file)
@@ -284,7 +284,7 @@ void wxMenuItem::DestroyItem(bool full)
                 wxMenuItemDisarmCallback, (XtPointer) this);
         }
     }
-    else if (GetId() == wxID_SEPARATOR)
+    else if (IsSeparator())
     {
         ;      // Nothing
 
index 32b92ee7d2c11b5a81c8b19411d9a75e9fdb82cc..d5ef1dc4e7f2b9e021c4c2ae5b14db45e1669516 100644 (file)
@@ -170,7 +170,7 @@ void wxMenuItem::Init()
     ResetOwnerDrawn();
 
     //  switch ownerdraw back on if using a non default margin
-    if ( GetId() != wxID_SEPARATOR )
+    if ( !IsSeparator() )
         SetMarginWidth(GetMarginWidth());
 
     // tell the owner drawing code to show the accel string as well
@@ -203,7 +203,7 @@ bool wxMenuItem::IsChecked() const
 {
     // fix that RTTI is always getting the correct state (separators cannot be checked, but the call below
     // returns true
-    if ( GetId() == wxID_SEPARATOR )
+    if ( IsSeparator() )
         return false ;
 
     int flag = ::GetMenuState(GetHMenuOf(m_parentMenu), GetMSWId(), MF_BYCOMMAND);