Applied patch [ 649599 ] Fixes bug 610850: Inserting a menu
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18333 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -15,6 +15,10 @@ Unix:
|
|||||||
|
|
||||||
- fixed compilation on systems with zlib installed but < 1.1.3 version
|
- fixed compilation on systems with zlib installed but < 1.1.3 version
|
||||||
|
|
||||||
|
wxGTK:
|
||||||
|
|
||||||
|
- fixed wxMenu::Remove (John Skiff and Benjamin Williams)
|
||||||
|
|
||||||
All:
|
All:
|
||||||
|
|
||||||
- Implemented GetEditControl for wxGenericTreeCtrl (Peter
|
- Implemented GetEditControl for wxGenericTreeCtrl (Peter
|
||||||
|
@@ -448,6 +448,36 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
return menuOld;
|
return menuOld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static wxMenu *CopyMenu (wxMenu *menu)
|
||||||
|
{
|
||||||
|
wxMenu *menucopy = new wxMenu ();
|
||||||
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
wxMenuItem *item = node->GetData();
|
||||||
|
int itemid = item->GetId();
|
||||||
|
wxString text = item->GetText();
|
||||||
|
text.Replace(wxT("_"), wxT("&"));
|
||||||
|
wxMenu *submenu = item->GetSubMenu();
|
||||||
|
if (!submenu)
|
||||||
|
{
|
||||||
|
wxMenuItem* itemcopy = new wxMenuItem(menucopy,
|
||||||
|
itemid, text,
|
||||||
|
menu->GetHelpString(itemid));
|
||||||
|
itemcopy->SetBitmap(item->GetBitmap());
|
||||||
|
itemcopy->SetCheckable(item->IsCheckable());
|
||||||
|
menucopy->Append(itemcopy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
menucopy->Append (itemid, text, CopyMenu(submenu),
|
||||||
|
menu->GetHelpString(itemid));
|
||||||
|
|
||||||
|
node = node->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return menucopy;
|
||||||
|
}
|
||||||
|
|
||||||
wxMenu *wxMenuBar::Remove(size_t pos)
|
wxMenu *wxMenuBar::Remove(size_t pos)
|
||||||
{
|
{
|
||||||
wxMenu *menu = wxMenuBarBase::Remove(pos);
|
wxMenu *menu = wxMenuBarBase::Remove(pos);
|
||||||
@@ -461,13 +491,17 @@ wxMenu *wxMenuBar::Remove(size_t pos)
|
|||||||
printf( "menu shell entries before %d\n", (int)g_list_length( menu_shell->children ) );
|
printf( "menu shell entries before %d\n", (int)g_list_length( menu_shell->children ) );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
wxMenu *menucopy = CopyMenu( menu );
|
||||||
|
|
||||||
// unparent calls unref() and that would delete the widget so we raise
|
// unparent calls unref() and that would delete the widget so we raise
|
||||||
// the ref count to 2 artificially before invoking unparent.
|
// the ref count to 2 artificially before invoking unparent.
|
||||||
gtk_widget_ref( menu->m_menu );
|
gtk_widget_ref( menu->m_menu );
|
||||||
gtk_widget_unparent( menu->m_menu );
|
gtk_widget_unparent( menu->m_menu );
|
||||||
|
|
||||||
gtk_widget_destroy( menu->m_owner );
|
gtk_widget_destroy( menu->m_owner );
|
||||||
|
delete menu;
|
||||||
|
|
||||||
|
menu = menucopy;
|
||||||
/*
|
/*
|
||||||
printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) );
|
printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) );
|
||||||
printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) );
|
printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) );
|
||||||
|
@@ -448,6 +448,36 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
|
|||||||
return menuOld;
|
return menuOld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static wxMenu *CopyMenu (wxMenu *menu)
|
||||||
|
{
|
||||||
|
wxMenu *menucopy = new wxMenu ();
|
||||||
|
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
wxMenuItem *item = node->GetData();
|
||||||
|
int itemid = item->GetId();
|
||||||
|
wxString text = item->GetText();
|
||||||
|
text.Replace(wxT("_"), wxT("&"));
|
||||||
|
wxMenu *submenu = item->GetSubMenu();
|
||||||
|
if (!submenu)
|
||||||
|
{
|
||||||
|
wxMenuItem* itemcopy = new wxMenuItem(menucopy,
|
||||||
|
itemid, text,
|
||||||
|
menu->GetHelpString(itemid));
|
||||||
|
itemcopy->SetBitmap(item->GetBitmap());
|
||||||
|
itemcopy->SetCheckable(item->IsCheckable());
|
||||||
|
menucopy->Append(itemcopy);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
menucopy->Append (itemid, text, CopyMenu(submenu),
|
||||||
|
menu->GetHelpString(itemid));
|
||||||
|
|
||||||
|
node = node->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return menucopy;
|
||||||
|
}
|
||||||
|
|
||||||
wxMenu *wxMenuBar::Remove(size_t pos)
|
wxMenu *wxMenuBar::Remove(size_t pos)
|
||||||
{
|
{
|
||||||
wxMenu *menu = wxMenuBarBase::Remove(pos);
|
wxMenu *menu = wxMenuBarBase::Remove(pos);
|
||||||
@@ -461,13 +491,17 @@ wxMenu *wxMenuBar::Remove(size_t pos)
|
|||||||
printf( "menu shell entries before %d\n", (int)g_list_length( menu_shell->children ) );
|
printf( "menu shell entries before %d\n", (int)g_list_length( menu_shell->children ) );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
wxMenu *menucopy = CopyMenu( menu );
|
||||||
|
|
||||||
// unparent calls unref() and that would delete the widget so we raise
|
// unparent calls unref() and that would delete the widget so we raise
|
||||||
// the ref count to 2 artificially before invoking unparent.
|
// the ref count to 2 artificially before invoking unparent.
|
||||||
gtk_widget_ref( menu->m_menu );
|
gtk_widget_ref( menu->m_menu );
|
||||||
gtk_widget_unparent( menu->m_menu );
|
gtk_widget_unparent( menu->m_menu );
|
||||||
|
|
||||||
gtk_widget_destroy( menu->m_owner );
|
gtk_widget_destroy( menu->m_owner );
|
||||||
|
delete menu;
|
||||||
|
|
||||||
|
menu = menucopy;
|
||||||
/*
|
/*
|
||||||
printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) );
|
printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) );
|
||||||
printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) );
|
printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) );
|
||||||
|
Reference in New Issue
Block a user