From 9add93670bb4a38e4007b8422b34b29b6194eecb Mon Sep 17 00:00:00 2001
From: Robin Dunn <robin@alldunn.com>
Date: Fri, 23 Jan 2004 18:46:05 +0000
Subject: [PATCH] wxMenu::Append (and similar) now return a pointer to the
 wxMenuItem that was added.  Checked on MSW, GTK, and Mac, other port authors
 please double check changes.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/changes.txt        |   2 +
 docs/latex/wx/menu.tex  |  32 ++++-----
 include/wx/gtk/menu.h   |   6 +-
 include/wx/gtk1/menu.h  |   6 +-
 include/wx/mac/menu.h   |   6 +-
 include/wx/menu.h       | 142 ++++++++++++++++++++--------------------
 include/wx/motif/menu.h |   6 +-
 include/wx/msw/menu.h   |   6 +-
 include/wx/os2/menu.h   |   4 +-
 include/wx/univ/menu.h  |   6 +-
 src/common/menucmn.cpp  |  16 ++---
 src/gtk/menu.cpp        |  14 ++--
 src/gtk1/menu.cpp       |  14 ++--
 src/mac/carbon/menu.cpp |  15 +++--
 src/mac/menu.cpp        |  15 +++--
 src/motif/menu.cpp      |   8 +--
 src/msw/menu.cpp        |  15 +++--
 src/os2/menu.cpp        |  20 +++---
 src/univ/menu.cpp       |  12 ++--
 19 files changed, 181 insertions(+), 164 deletions(-)

diff --git a/docs/changes.txt b/docs/changes.txt
index 7b0182d2c7..99e306db43 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -114,6 +114,8 @@ All (GUI):
   when sizing smaller) (Shane Harper)
 - dbbrowse demo fixed for Unicode (Wlodzimierz Skiba)
 - added wxStatusBar support to XRC (Brian Ravnsgaard Riis)
+- wxMenu::Append and etc. return a pointer to the wxMenuItem that was
+  added or inserted, or NULL on failure.
 
 wxMSW:
 
diff --git a/docs/latex/wx/menu.tex b/docs/latex/wx/menu.tex
index 1e602717a8..763028545f 100644
--- a/docs/latex/wx/menu.tex
+++ b/docs/latex/wx/menu.tex
@@ -103,19 +103,19 @@ and recreation of internal data structures.
 
 \membersection{wxMenu::Append}\label{wxmenuappend}
 
-\func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
+\func{wxMenuItem*}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
 \param{wxItemKind}{ kind = wxITEM\_NORMAL}}
 
 Adds a string item to the end of the menu.
 
-\func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{wxMenu *}{subMenu},\rtfsp
+\func{wxMenuItem*}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{wxMenu *}{subMenu},\rtfsp
 \param{const wxString\& }{helpString = ""}}
 
 Adds a pull-right submenu to the end of the menu. Append the submenu to the parent
 menu {\it after} you have added your menu items, or accelerators may not be
 registered properly.
 
-\func{void}{Append}{\param{wxMenuItem*}{ menuItem}}
+\func{wxMenuItem*}{Append}{\param{wxMenuItem*}{ menuItem}}
 
 Adds a menu item object. This is the most generic variant of Append() method
 because it may be used for both items (including separators) and submenus and
@@ -191,7 +191,7 @@ implements the following methods:\par
 
 \membersection{wxMenu::AppendCheckItem}\label{wxmenuappendcheckitem}
 
-\func{void}{AppendCheckItem}{\param{int}{ id},\rtfsp
+\func{wxMenuItem*}{AppendCheckItem}{\param{int}{ id},\rtfsp
 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
 
 Adds a checkable item to the end of the menu.
@@ -203,7 +203,7 @@ Adds a checkable item to the end of the menu.
 
 \membersection{wxMenu::AppendRadioItem}\label{wxmenuappendradioitem}
 
-\func{void}{AppendRadioItem}{\param{int}{ id},\rtfsp
+\func{wxMenuItem*}{AppendRadioItem}{\param{int}{ id},\rtfsp
 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
 
 Adds a radio item to the end of the menu. All consequent radio items form a
@@ -220,7 +220,7 @@ automatically unchecked.
 
 \membersection{wxMenu::AppendSeparator}\label{wxmenuappendseparator}
 
-\func{void}{AppendSeparator}{\void}
+\func{wxMenuItem*}{AppendSeparator}{\void}
 
 Adds a separator to the end of the menu.
 
@@ -423,9 +423,9 @@ menubar.
 
 \membersection{wxMenu::Insert}\label{wxmenuinsert}
 
-\func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
+\func{wxMenuItem*}{Insert}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
 
-\func{void}{Insert}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
+\func{wxMenuItem*}{Insert}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
 \param{wxItemKind}{ kind = wxITEM\_NORMAL}}
 
@@ -440,7 +440,7 @@ as appending it.
 
 \membersection{wxMenu::InsertCheckItem}\label{wxmenuinsertcheckitem}
 
-\func{void}{InsertCheckItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
+\func{wxMenuItem*}{InsertCheckItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
 
 Inserts a checkable item at the given position.
@@ -452,7 +452,7 @@ Inserts a checkable item at the given position.
 
 \membersection{wxMenu::InsertRadioItem}\label{wxmenuinsertradioitem}
 
-\func{void}{InsertRadioItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
+\func{wxMenuItem*}{InsertRadioItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
 
 Inserts a radio item at the given position.
@@ -464,7 +464,7 @@ Inserts a radio item at the given position.
 
 \membersection{wxMenu::InsertSeparator}\label{wxmenuinsertseparator}
 
-\func{void}{InsertSeparator}{\param{size\_t }{pos}}
+\func{wxMenuItem*}{InsertSeparator}{\param{size\_t }{pos}}
 
 Inserts a separator at the given position.
 
@@ -511,9 +511,9 @@ true if the menu item is enabled, false otherwise.
 
 \membersection{wxMenu::Prepend}\label{wxmenuprepend}
 
-\func{bool}{Prepend}{\param{wxMenuItem *}{item}}
+\func{wxMenuItem*}{Prepend}{\param{wxMenuItem *}{item}}
 
-\func{void}{Prepend}{\param{int}{ id},\rtfsp
+\func{wxMenuItem*}{Prepend}{\param{int}{ id},\rtfsp
 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
 \param{wxItemKind}{ kind = wxITEM\_NORMAL}}
 
@@ -527,7 +527,7 @@ existing items.
 
 \membersection{wxMenu::PrependCheckItem}\label{wxmenuprependcheckitem}
 
-\func{void}{PrependCheckItem}{\param{int}{ id},\rtfsp
+\func{wxMenuItem*}{PrependCheckItem}{\param{int}{ id},\rtfsp
 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
 
 Inserts a checkable item at the position $0$.
@@ -539,7 +539,7 @@ Inserts a checkable item at the position $0$.
 
 \membersection{wxMenu::PrependRadioItem}\label{wxmenuprependradioitem}
 
-\func{void}{PrependRadioItem}{\param{int}{ id},\rtfsp
+\func{wxMenuItem*}{PrependRadioItem}{\param{int}{ id},\rtfsp
 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
 
 Inserts a radio item at the position $0$.
@@ -551,7 +551,7 @@ Inserts a radio item at the position $0$.
 
 \membersection{wxMenu::PrependSeparator}\label{wxmenuprependseparator}
 
-\func{void}{PrependSeparator}{\param{size\_t }{pos}}
+\func{wxMenuItem*}{PrependSeparator}{\param{size\_t }{pos}}
 
 Inserts a separator at the position $0$.
 
diff --git a/include/wx/gtk/menu.h b/include/wx/gtk/menu.h
index f482d01644..9af8379c5a 100644
--- a/include/wx/gtk/menu.h
+++ b/include/wx/gtk/menu.h
@@ -74,9 +74,9 @@ public:
     virtual ~wxMenu();
 
     // implement base class virtuals
-    virtual bool DoAppend(wxMenuItem *item);
-    virtual bool DoInsert(size_t pos, wxMenuItem *item);
-    virtual wxMenuItem *DoRemove(wxMenuItem *item);
+    virtual wxMenuItem* DoAppend(wxMenuItem *item);
+    virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
+    virtual wxMenuItem* DoRemove(wxMenuItem *item);
 
     // TODO: virtual void SetTitle(const wxString& title);
 
diff --git a/include/wx/gtk1/menu.h b/include/wx/gtk1/menu.h
index f482d01644..9af8379c5a 100644
--- a/include/wx/gtk1/menu.h
+++ b/include/wx/gtk1/menu.h
@@ -74,9 +74,9 @@ public:
     virtual ~wxMenu();
 
     // implement base class virtuals
-    virtual bool DoAppend(wxMenuItem *item);
-    virtual bool DoInsert(size_t pos, wxMenuItem *item);
-    virtual wxMenuItem *DoRemove(wxMenuItem *item);
+    virtual wxMenuItem* DoAppend(wxMenuItem *item);
+    virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
+    virtual wxMenuItem* DoRemove(wxMenuItem *item);
 
     // TODO: virtual void SetTitle(const wxString& title);
 
diff --git a/include/wx/mac/menu.h b/include/wx/mac/menu.h
index 9c71c05727..5f2cd2344c 100644
--- a/include/wx/mac/menu.h
+++ b/include/wx/mac/menu.h
@@ -34,9 +34,9 @@ public:
     virtual ~wxMenu();
 
     // implement base class virtuals
-    virtual bool DoAppend(wxMenuItem *item);
-    virtual bool DoInsert(size_t pos, wxMenuItem *item);
-    virtual wxMenuItem *DoRemove(wxMenuItem *item);
+    virtual wxMenuItem* DoAppend(wxMenuItem *item);
+    virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
+    virtual wxMenuItem* DoRemove(wxMenuItem *item);
     virtual void Attach(wxMenuBarBase *menubar) ;
 
     virtual void Break();
diff --git a/include/wx/menu.h b/include/wx/menu.h
index f3e34bd3f8..05cfe3948d 100644
--- a/include/wx/menu.h
+++ b/include/wx/menu.h
@@ -63,142 +63,142 @@ public:
     // -----------------
 
     // append any kind of item (normal/check/radio/separator)
-    void Append(int itemid,
-                const wxString& text,
-                const wxString& help = wxEmptyString,
-                wxItemKind kind = wxITEM_NORMAL)
+    wxMenuItem* Append(int itemid,
+                       const wxString& text,
+                       const wxString& help = wxEmptyString,
+                       wxItemKind kind = wxITEM_NORMAL)
     {
-        DoAppend(wxMenuItem::New((wxMenu *)this, itemid, text, help, kind));
+        return DoAppend(wxMenuItem::New((wxMenu *)this, itemid, text, help, kind));
     }
 
     // append a separator to the menu
-    void AppendSeparator() { Append(wxID_SEPARATOR, wxEmptyString); }
+    wxMenuItem* AppendSeparator() { return Append(wxID_SEPARATOR, wxEmptyString); }
 
     // append a check item
-    void AppendCheckItem(int itemid,
-                         const wxString& text,
-                         const wxString& help = wxEmptyString)
+    wxMenuItem* AppendCheckItem(int itemid,
+                                const wxString& text,
+                                const wxString& help = wxEmptyString)
     {
-        Append(itemid, text, help, wxITEM_CHECK);
+        return Append(itemid, text, help, wxITEM_CHECK);
     }
 
     // append a radio item
-    void AppendRadioItem(int itemid,
-                         const wxString& text,
-                         const wxString& help = wxEmptyString)
+    wxMenuItem* AppendRadioItem(int itemid,
+                                const wxString& text,
+                                const wxString& help = wxEmptyString)
     {
-        Append(itemid, text, help, wxITEM_RADIO);
+        return Append(itemid, text, help, wxITEM_RADIO);
     }
 
     // append a submenu
-    void Append(int itemid,
-                const wxString& text,
-                wxMenu *submenu,
-                const wxString& help = wxEmptyString)
+    wxMenuItem* Append(int itemid,
+                       const wxString& text,
+                       wxMenu *submenu,
+                       const wxString& help = wxEmptyString)
     {
-        DoAppend(wxMenuItem::New((wxMenu *)this, itemid, text, help,
-                                 wxITEM_NORMAL, submenu));
+        return DoAppend(wxMenuItem::New((wxMenu *)this, itemid, text, help,
+                                        wxITEM_NORMAL, submenu));
     }
 
     // the most generic form of Append() - append anything
-    void Append(wxMenuItem *item) { DoAppend(item); }
+    wxMenuItem* Append(wxMenuItem *item) { return DoAppend(item); }
 
     // insert a break in the menu (only works when appending the items, not
     // inserting them)
     virtual void Break() { }
 
     // insert an item before given position
-    bool Insert(size_t pos, wxMenuItem *item);
+    wxMenuItem* Insert(size_t pos, wxMenuItem *item);
 
     // insert an item before given position
-    void Insert(size_t pos,
-                int itemid,
-                const wxString& text,
-                const wxString& help = wxEmptyString,
-                wxItemKind kind = wxITEM_NORMAL)
+    wxMenuItem* Insert(size_t pos,
+                       int itemid,
+                       const wxString& text,
+                       const wxString& help = wxEmptyString,
+                       wxItemKind kind = wxITEM_NORMAL)
     {
-        Insert(pos, wxMenuItem::New((wxMenu *)this, itemid, text, help, kind));
+        return Insert(pos, wxMenuItem::New((wxMenu *)this, itemid, text, help, kind));
     }
 
     // insert a separator
-    void InsertSeparator(size_t pos)
+    wxMenuItem* InsertSeparator(size_t pos)
     {
-        Insert(pos, wxMenuItem::New((wxMenu *)this));
+        return Insert(pos, wxMenuItem::New((wxMenu *)this, wxID_SEPARATOR));
     }
 
     // insert a check item
-    void InsertCheckItem(size_t pos,
-                         int itemid,
-                         const wxString& text,
-                         const wxString& help = wxEmptyString)
+    wxMenuItem* InsertCheckItem(size_t pos,
+                                int itemid,
+                                const wxString& text,
+                                const wxString& help = wxEmptyString)
     {
-        Insert(pos, itemid, text, help, wxITEM_CHECK);
+        return Insert(pos, itemid, text, help, wxITEM_CHECK);
     }
 
     // insert a radio item
-    void InsertRadioItem(size_t pos,
-                         int itemid,
-                         const wxString& text,
-                         const wxString& help = wxEmptyString)
+     wxMenuItem* InsertRadioItem(size_t pos,
+                                 int itemid,
+                                 const wxString& text,
+                                 const wxString& help = wxEmptyString)
     {
-        Insert(pos, itemid, text, help, wxITEM_RADIO);
+        return Insert(pos, itemid, text, help, wxITEM_RADIO);
     }
 
     // insert a submenu
-    void Insert(size_t pos,
-                int itemid,
-                const wxString& text,
-                wxMenu *submenu,
-                const wxString& help = wxEmptyString)
+    wxMenuItem* Insert(size_t pos,
+                       int itemid,
+                       const wxString& text,
+                       wxMenu *submenu,
+                       const wxString& help = wxEmptyString)
     {
-        Insert(pos, wxMenuItem::New((wxMenu *)this, itemid, text, help,
-                                    wxITEM_NORMAL, submenu));
+        return Insert(pos, wxMenuItem::New((wxMenu *)this, itemid, text, help,
+                                           wxITEM_NORMAL, submenu));
     }
 
     // prepend an item to the menu
-    void Prepend(wxMenuItem *item)
+    wxMenuItem* Prepend(wxMenuItem *item)
     {
-        Insert(0u, item);
+        return Insert(0u, item);
     }
 
     // prepend any item to the menu
-    void Prepend(int itemid,
-                 const wxString& text,
-                 const wxString& help = wxEmptyString,
-                 wxItemKind kind = wxITEM_NORMAL)
+    wxMenuItem* Prepend(int itemid,
+                        const wxString& text,
+                        const wxString& help = wxEmptyString,
+                        wxItemKind kind = wxITEM_NORMAL)
     {
-        Insert(0u, itemid, text, help, kind);
+        return Insert(0u, itemid, text, help, kind);
     }
 
     // prepend a separator
-    void PrependSeparator()
+    wxMenuItem* PrependSeparator()
     {
-        InsertSeparator(0u);
+        return InsertSeparator(0u);
     }
 
     // prepend a check item
-    void PrependCheckItem(int itemid,
-                          const wxString& text,
-                          const wxString& help = wxEmptyString)
+    wxMenuItem* PrependCheckItem(int itemid,
+                                 const wxString& text,
+                                 const wxString& help = wxEmptyString)
     {
-        InsertCheckItem(0u, itemid, text, help);
+        return InsertCheckItem(0u, itemid, text, help);
     }
 
     // prepend a radio item
-    void PrependRadioItem(int itemid,
-                          const wxString& text,
-                          const wxString& help = wxEmptyString)
+    wxMenuItem* PrependRadioItem(int itemid,
+                                 const wxString& text,
+                                 const wxString& help = wxEmptyString)
     {
-        InsertRadioItem(0u, itemid, text, help);
+        return InsertRadioItem(0u, itemid, text, help);
     }
 
     // prepend a submenu
-    void Prepend(int itemid,
-                 const wxString& text,
-                 wxMenu *submenu,
-                 const wxString& help = wxEmptyString)
+    wxMenuItem* Prepend(int itemid,
+                        const wxString& text,
+                        wxMenu *submenu,
+                        const wxString& help = wxEmptyString)
     {
-        Insert(0u, itemid, text, submenu, help);
+        return Insert(0u, itemid, text, submenu, help);
     }
 
     // detach an item from the menu, but don't delete it so that it can be
@@ -334,8 +334,8 @@ protected:
     // virtuals to override in derived classes
     // ---------------------------------------
 
-    virtual bool DoAppend(wxMenuItem *item);
-    virtual bool DoInsert(size_t pos, wxMenuItem *item);
+    virtual wxMenuItem* DoAppend(wxMenuItem *item);
+    virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
 
     virtual wxMenuItem *DoRemove(wxMenuItem *item);
     virtual bool DoDelete(wxMenuItem *item);
diff --git a/include/wx/motif/menu.h b/include/wx/motif/menu.h
index 5bc831d69f..64ad89e2d0 100644
--- a/include/wx/motif/menu.h
+++ b/include/wx/motif/menu.h
@@ -38,9 +38,9 @@ public:
     virtual ~wxMenu();
     
     // implement base class virtuals
-    virtual bool DoAppend(wxMenuItem *item);
-    virtual bool DoInsert(size_t pos, wxMenuItem *item);
-    virtual wxMenuItem *DoRemove(wxMenuItem *item);
+    virtual wxMenuItem* DoAppend(wxMenuItem *item);
+    virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
+    virtual wxMenuItem* DoRemove(wxMenuItem *item);
     
     virtual void Break();
     
diff --git a/include/wx/msw/menu.h b/include/wx/msw/menu.h
index bc86e25417..15232791d0 100644
--- a/include/wx/msw/menu.h
+++ b/include/wx/msw/menu.h
@@ -47,9 +47,9 @@ public:
     virtual ~wxMenu();
 
     // implement base class virtuals
-    virtual bool DoAppend(wxMenuItem *item);
-    virtual bool DoInsert(size_t pos, wxMenuItem *item);
-    virtual wxMenuItem *DoRemove(wxMenuItem *item);
+    virtual wxMenuItem* DoAppend(wxMenuItem *item);
+    virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
+    virtual wxMenuItem* DoRemove(wxMenuItem *item);
 
     virtual void Break();
 
diff --git a/include/wx/os2/menu.h b/include/wx/os2/menu.h
index 3f00df4844..b088026c21 100644
--- a/include/wx/os2/menu.h
+++ b/include/wx/os2/menu.h
@@ -55,8 +55,8 @@ public:
     //
     // Implement base class virtuals
     //
-    virtual bool        DoAppend(wxMenuItem* pItem);
-    virtual bool        DoInsert( size_t      nPos
+    virtual wxMenuItem* DoAppend(wxMenuItem* pItem);
+    virtual wxMenuItem* DoInsert( size_t      nPos
                                  ,wxMenuItem* pItem
                                 );
     virtual wxMenuItem* DoRemove(wxMenuItem* pItem);
diff --git a/include/wx/univ/menu.h b/include/wx/univ/menu.h
index 774ef724bd..874f5bd896 100644
--- a/include/wx/univ/menu.h
+++ b/include/wx/univ/menu.h
@@ -79,9 +79,9 @@ public:
 
 protected:
     // implement base class virtuals
-    virtual bool DoAppend(wxMenuItem *item);
-    virtual bool DoInsert(size_t pos, wxMenuItem *item);
-    virtual wxMenuItem *DoRemove(wxMenuItem *item);
+    virtual wxMenuItem* DoAppend(wxMenuItem *item);
+    virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
+    virtual wxMenuItem* DoRemove(wxMenuItem *item);
 
     // common part of DoAppend and DoInsert
     void OnItemAdded(wxMenuItem *item);
diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp
index 094271d0f7..4cca372c62 100644
--- a/src/common/menucmn.cpp
+++ b/src/common/menucmn.cpp
@@ -310,9 +310,9 @@ void wxMenuBase::AddSubMenu(wxMenu *submenu)
     submenu->SetParent((wxMenu *)this);
 }
 
-bool wxMenuBase::DoAppend(wxMenuItem *item)
+wxMenuItem* wxMenuBase::DoAppend(wxMenuItem *item)
 {
-    wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Append()") );
+    wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Append()") );
 
     m_items.Append(item);
     item->SetMenu((wxMenu*)this);
@@ -321,12 +321,12 @@ bool wxMenuBase::DoAppend(wxMenuItem *item)
         AddSubMenu(item->GetSubMenu());
     }
 
-    return TRUE;
+    return item;
 }
 
-bool wxMenuBase::Insert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenuBase::Insert(size_t pos, wxMenuItem *item)
 {
-    wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Insert") );
+    wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Insert") );
 
     if ( pos == GetMenuItemCount() )
     {
@@ -341,9 +341,9 @@ bool wxMenuBase::Insert(size_t pos, wxMenuItem *item)
     }
 }
 
-bool wxMenuBase::DoInsert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenuBase::DoInsert(size_t pos, wxMenuItem *item)
 {
-    wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Insert()") );
+    wxCHECK_MSG( item, NULL, wxT("invalid item in wxMenu::Insert()") );
 
     wxMenuItemList::compatibility_iterator node = m_items.Item(pos);
     wxCHECK_MSG( node, FALSE, wxT("invalid index in wxMenu::Insert()") );
@@ -355,7 +355,7 @@ bool wxMenuBase::DoInsert(size_t pos, wxMenuItem *item)
         AddSubMenu(item->GetSubMenu());
     }
 
-    return TRUE;
+    return item;
 }
 
 wxMenuItem *wxMenuBase::Remove(wxMenuItem *item)
diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp
index edcbeb0d65..2c148ae7b8 100644
--- a/src/gtk/menu.cpp
+++ b/src/gtk/menu.cpp
@@ -1358,21 +1358,23 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
     return TRUE;
 }
 
-bool wxMenu::DoAppend(wxMenuItem *mitem)
+wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem)
 {
-    return GtkAppend(mitem) && wxMenuBase::DoAppend(mitem);
+    if (!GtkAppend(mitem))
+        return NULL;
+    return wxMenuBase::DoAppend(mitem);
 }
 
-bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 {
     if ( !wxMenuBase::DoInsert(pos, item) )
-        return FALSE;
+        return NULL;
 
     // GTK+ doesn't have a function to insert a menu using GtkItemFactory (as
     // of version 1.2.6), so we first append the item and then change its
     // index
     if ( !GtkAppend(item) )
-        return FALSE;
+        return NULL;
 
     if ( m_style & wxMENU_TEAROFF )
     {
@@ -1385,7 +1387,7 @@ bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
     menu_shell->children = g_list_remove(menu_shell->children, data);
     menu_shell->children = g_list_insert(menu_shell->children, data, pos);
 
-    return TRUE;
+    return item;
 }
 
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp
index edcbeb0d65..2c148ae7b8 100644
--- a/src/gtk1/menu.cpp
+++ b/src/gtk1/menu.cpp
@@ -1358,21 +1358,23 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem)
     return TRUE;
 }
 
-bool wxMenu::DoAppend(wxMenuItem *mitem)
+wxMenuItem* wxMenu::DoAppend(wxMenuItem *mitem)
 {
-    return GtkAppend(mitem) && wxMenuBase::DoAppend(mitem);
+    if (!GtkAppend(mitem))
+        return NULL;
+    return wxMenuBase::DoAppend(mitem);
 }
 
-bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 {
     if ( !wxMenuBase::DoInsert(pos, item) )
-        return FALSE;
+        return NULL;
 
     // GTK+ doesn't have a function to insert a menu using GtkItemFactory (as
     // of version 1.2.6), so we first append the item and then change its
     // index
     if ( !GtkAppend(item) )
-        return FALSE;
+        return NULL;
 
     if ( m_style & wxMENU_TEAROFF )
     {
@@ -1385,7 +1387,7 @@ bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
     menu_shell->children = g_list_remove(menu_shell->children, data);
     menu_shell->children = g_list_insert(menu_shell->children, data, pos);
 
-    return TRUE;
+    return item;
 }
 
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp
index 046f7e0166..e4e0879b02 100644
--- a/src/mac/carbon/menu.cpp
+++ b/src/mac/carbon/menu.cpp
@@ -177,9 +177,9 @@ void wxMenu::EndRadioGroup()
     m_startRadioGroup = -1;
 }
 
-bool wxMenu::DoAppend(wxMenuItem *item)
+wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
 {
-    wxCHECK_MSG( item, FALSE, _T("NULL item in wxMenu::DoAppend") );
+    wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") );
 
     bool check = FALSE;
 
@@ -222,7 +222,7 @@ bool wxMenu::DoAppend(wxMenuItem *item)
 
     if ( !wxMenuBase::DoAppend(item) || !DoInsertOrAppend(item) )
     {
-        return FALSE;
+        return NULL;
     }
 
     if ( check )
@@ -231,12 +231,15 @@ bool wxMenu::DoAppend(wxMenuItem *item)
         item->Check(TRUE);
     }
 
-    return TRUE;
+    return item;
 }
 
-bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 {
-    return wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos);
+    if (wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos))
+        return item;
+    else
+        return NULL;
 }
 
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
diff --git a/src/mac/menu.cpp b/src/mac/menu.cpp
index 046f7e0166..e4e0879b02 100644
--- a/src/mac/menu.cpp
+++ b/src/mac/menu.cpp
@@ -177,9 +177,9 @@ void wxMenu::EndRadioGroup()
     m_startRadioGroup = -1;
 }
 
-bool wxMenu::DoAppend(wxMenuItem *item)
+wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
 {
-    wxCHECK_MSG( item, FALSE, _T("NULL item in wxMenu::DoAppend") );
+    wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") );
 
     bool check = FALSE;
 
@@ -222,7 +222,7 @@ bool wxMenu::DoAppend(wxMenuItem *item)
 
     if ( !wxMenuBase::DoAppend(item) || !DoInsertOrAppend(item) )
     {
-        return FALSE;
+        return NULL;
     }
 
     if ( check )
@@ -231,12 +231,15 @@ bool wxMenu::DoAppend(wxMenuItem *item)
         item->Check(TRUE);
     }
 
-    return TRUE;
+    return item;
 }
 
-bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 {
-    return wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos);
+    if (wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos))
+        return item;
+    else
+        return NULL;
 }
 
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
diff --git a/src/motif/menu.cpp b/src/motif/menu.cpp
index 79c8ab5061..c85dea8e74 100644
--- a/src/motif/menu.cpp
+++ b/src/motif/menu.cpp
@@ -114,7 +114,7 @@ void wxMenu::Break()
 }
 
 // function appends a new item or submenu to the menu
-bool wxMenu::DoAppend(wxMenuItem *pItem)
+wxMenuItem* wxMenu::DoAppend(wxMenuItem *pItem)
 {
     if (m_menuWidget)
     {
@@ -137,14 +137,14 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
     return wxMenuBase::DoRemove(item);
 }
 
-bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 {
     if ( wxMenuBase::DoInsert(pos, item) )
-        return TRUE;
+        return item;
 
     wxFAIL_MSG(wxT("DoInsert not implemented; or error in wxMenuBase::DoInsert"));
 
-    return FALSE;
+    return NULL;
 }
 
 void wxMenu::SetTitle(const wxString& label)
diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp
index 478048e703..750b6d64f1 100644
--- a/src/msw/menu.cpp
+++ b/src/msw/menu.cpp
@@ -433,9 +433,9 @@ void wxMenu::EndRadioGroup()
     m_startRadioGroup = -1;
 }
 
-bool wxMenu::DoAppend(wxMenuItem *item)
+wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
 {
-    wxCHECK_MSG( item, FALSE, _T("NULL item in wxMenu::DoAppend") );
+    wxCHECK_MSG( item, NULL, _T("NULL item in wxMenu::DoAppend") );
 
     bool check = FALSE;
 
@@ -478,7 +478,7 @@ bool wxMenu::DoAppend(wxMenuItem *item)
 
     if ( !wxMenuBase::DoAppend(item) || !DoInsertOrAppend(item) )
     {
-        return FALSE;
+        return NULL;
     }
 
     if ( check )
@@ -487,12 +487,15 @@ bool wxMenu::DoAppend(wxMenuItem *item)
         item->Check(TRUE);
     }
 
-    return TRUE;
+    return item;
 }
 
-bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 {
-    return wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos);
+    if (wxMenuBase::DoInsert(pos, item) && DoInsertOrAppend(item, pos))
+        return item;
+    else
+        return NULL;
 }
 
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
diff --git a/src/os2/menu.cpp b/src/os2/menu.cpp
index 3dbbbb16ec..1174131571 100644
--- a/src/os2/menu.cpp
+++ b/src/os2/menu.cpp
@@ -415,11 +415,11 @@ void wxMenu::EndRadioGroup()
     m_nStartRadioGroup = -1;
 } // end of wxMenu::EndRadioGroup
 
-bool wxMenu::DoAppend(
+wxMenuItem* wxMenu::DoAppend(
   wxMenuItem*                       pItem
 )
 {
-    wxCHECK_MSG( pItem, FALSE, _T("NULL item in wxMenu::DoAppend") );
+    wxCHECK_MSG( pItem, NULL, _T("NULL item in wxMenu::DoAppend") );
 
     bool                            bCheck = FALSE;
 
@@ -471,7 +471,7 @@ bool wxMenu::DoAppend(
 
     if (!wxMenuBase::DoAppend(pItem) || !DoInsertOrAppend(pItem))
     {
-        return FALSE;
+        return NULL;
     }
     if (bCheck)
     {
@@ -480,20 +480,22 @@ bool wxMenu::DoAppend(
         //
         pItem->Check(TRUE);
     }
-    return TRUE;
+    return pItem;
 } // end of wxMenu::DoAppend
 
-bool wxMenu::DoInsert(
+wxMenuItem* wxMenu::DoInsert(
   size_t                            nPos
 , wxMenuItem*                       pItem
 )
 {
-    return ( wxMenuBase::DoInsert( nPos
-                                  ,pItem) &&
+    if ( wxMenuBase::DoInsert( nPos
+                               ,pItem) &&
              DoInsertOrAppend( pItem
                               ,nPos
-                             )
-           );
+                 ))
+         return pItem;
+    else
+        return NULL;
 } // end of wxMenu::DoInsert
 
 wxMenuItem* wxMenu::DoRemove(
diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp
index f760357497..bce164c644 100644
--- a/src/univ/menu.cpp
+++ b/src/univ/menu.cpp
@@ -1110,7 +1110,7 @@ void wxMenu::EndRadioGroup()
     m_startRadioGroup = -1;
 }
 
-bool wxMenu::DoAppend(wxMenuItem *item)
+wxMenuItem* wxMenu::DoAppend(wxMenuItem *item)
 {
     #if 0
     // not used at all
@@ -1158,21 +1158,21 @@ bool wxMenu::DoAppend(wxMenuItem *item)
     }
 
     if ( !wxMenuBase::DoAppend(item) )
-        return FALSE;
+        return NULL;
 
     OnItemAdded(item);
 
-    return TRUE;
+    return item;
 }
 
-bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
+wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
 {
     if ( !wxMenuBase::DoInsert(pos, item) )
-        return FALSE;
+        return NULL;
 
     OnItemAdded(item);
 
-    return TRUE;
+    return item;
 }
 
 wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
-- 
2.50.0

