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
This commit is contained in:
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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(
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user