| | 94 | static wxString wxConvertFromGTKToWXLabel(const wxString& gtkLabel) |
| | 95 | { |
| | 96 | wxString label; |
| | 97 | for ( const wxChar *pc = gtkLabel.c_str(); *pc; pc++ ) |
| | 98 | { |
| | 99 | // '_' is the escape character for GTK+. |
| | 100 | |
| | 101 | if ( *pc == wxT('_') && *(pc+1) == wxT('_')) |
| | 102 | { |
| | 103 | // An underscore was escaped. |
| | 104 | label += wxT('_'); |
| | 105 | pc++; |
| | 106 | } |
| | 107 | else if ( *pc == wxT('_') ) |
| | 108 | { |
| | 109 | // Convert GTK+ hotkey symbol to wxWidgets/Windows standard |
| | 110 | label += wxT('&'); |
| | 111 | } |
| | 112 | else if ( *pc == wxT('&') ) |
| | 113 | { |
| | 114 | // Double the ampersand to escape it as far as wxWidgets is concerned |
| | 115 | label += wxT("&&"); |
| | 116 | } |
| | 117 | else |
| | 118 | { |
| | 119 | // don't remove ampersands '&' since if we have them in the menu title |
| | 120 | // it means that they were doubled to indicate "&" instead of accelerator |
| | 121 | label += *pc; |
| | 122 | } |
| | 123 | } |
| | 124 | |
| | 125 | return label; |
| | 126 | } |
| | 127 | |
| 521 | | wxString label; |
| 522 | | wxString text( menu->GetTitle() ); |
| 523 | | for ( const wxChar *pc = text.c_str(); *pc; pc++ ) |
| 524 | | { |
| 525 | | if ( *pc == wxT('_') ) |
| 526 | | { |
| 527 | | // '_' is the escape character for GTK+ |
| 528 | | continue; |
| 529 | | } |
| 530 | | |
| 531 | | // don't remove ampersands '&' since if we have them in the menu title |
| 532 | | // it means that they were doubled to indicate "&" instead of accelerator |
| 533 | | |
| 534 | | label += *pc; |
| 535 | | } |
| 536 | | |
| 537 | | return label; |
| | 555 | return wxStripMenuCodes(wxConvertFromGTKToWXLabel(menu->GetTitle())); |
| | 556 | } |
| | 557 | |
| | 558 | // Gets the original label at the top-level of the menubar |
| | 559 | wxString wxMenuBar::GetMenuLabel(size_t pos) const |
| | 560 | { |
| | 561 | wxMenuList::compatibility_iterator node = m_menus.Item( pos ); |
| | 562 | |
| | 563 | wxCHECK_MSG( node, wxT("invalid"), wxT("menu not found") ); |
| | 564 | |
| | 565 | wxMenu* menu = node->GetData(); |
| | 566 | |
| | 567 | return wxConvertFromGTKToWXLabel(menu->GetTitle()); |