diff --git a/docs/changes.txt b/docs/changes.txt index af74dc4cb0..5a21ed1904 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -311,6 +311,7 @@ All (GUI): - Freeze() and Thaw() now recursively freeze/thaw the children too. - Generalized wxScrolledWindow into wxScrolled template that can derive from any window class, not just wxPanel. +- Allow having menu separators with ids != wxID_SEPARATOR (Jeff Tupper) wxGTK: diff --git a/include/wx/menu.h b/include/wx/menu.h index 00fcd5995a..8cae2e1255 100644 --- a/include/wx/menu.h +++ b/include/wx/menu.h @@ -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, diff --git a/include/wx/menuitem.h b/include/wx/menuitem.h index 677aa31467..1da5f65211 100644 --- a/include/wx/menuitem.h +++ b/include/wx/menuitem.h @@ -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 diff --git a/interface/menuitem.h b/interface/menuitem.h index 4ee4df3b26..9296ab2ba3 100644 --- a/interface/menuitem.h +++ b/interface/menuitem.h @@ -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 diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index c1a25b5a8e..710742fd71 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -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 diff --git a/src/motif/menuitem.cpp b/src/motif/menuitem.cpp index 6fbfb08465..e830c00c13 100644 --- a/src/motif/menuitem.cpp +++ b/src/motif/menuitem.cpp @@ -284,7 +284,7 @@ void wxMenuItem::DestroyItem(bool full) wxMenuItemDisarmCallback, (XtPointer) this); } } - else if (GetId() == wxID_SEPARATOR) + else if (IsSeparator()) { ; // Nothing diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index 32b92ee7d2..d5ef1dc4e7 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -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);