]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/menu.cpp
fixed reverted #if condition around wxDoLogTraceWchar
[wxWidgets.git] / src / gtk1 / menu.cpp
index fa3f149dd054385613bb75c1d021055647c90e97..ea47b894ec325784450d37b418945ff0d288c126 100644 (file)
@@ -704,7 +704,7 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu,
                        wxMenu *subMenu)
           : wxMenuItemBase(parentMenu, id, text, help, kind, subMenu)
 {
-    Init(text);
+    Init();
 }
 
 wxMenuItem::wxMenuItem(wxMenu *parentMenu,
@@ -716,15 +716,15 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu,
           : wxMenuItemBase(parentMenu, id, text, help,
                            isCheckable ? wxITEM_CHECK : wxITEM_NORMAL, subMenu)
 {
-    Init(text);
+    Init();
 }
 
-void wxMenuItem::Init(const wxString& text)
+void wxMenuItem::Init()
 {
     m_labelWidget = (GtkWidget *) NULL;
     m_menuItem = (GtkWidget *) NULL;
 
-    DoSetText(text);
+    DoSetText(m_text);
 }
 
 wxMenuItem::~wxMenuItem()
@@ -834,7 +834,9 @@ void wxMenuItem::SetText( const wxString& string )
 void wxMenuItem::DoSetText( const wxString& str )
 {
     // '\t' is the deliminator indicating a hot key
-    m_text.Empty();
+    wxString text;
+    text.reserve(str.length());
+
     const wxChar *pc = str;
     while ( (*pc != wxT('\0')) && (*pc != wxT('\t')) )
     {
@@ -842,30 +844,32 @@ void wxMenuItem::DoSetText( const wxString& str )
         {
             // "&" is doubled to indicate "&" instead of accelerator
             ++pc;
-            m_text << wxT('&');
+            text << wxT('&');
         }
         else if (*pc == wxT('&'))
         {
-            m_text << wxT('_');
+            text << wxT('_');
         }
         else if ( *pc == wxT('_') )    // escape underscores
         {
-            m_text << wxT("__");
+            text << wxT("__");
         }
         else
         {
-            m_text << *pc;
+            text << *pc;
         }
         ++pc;
     }
 
     m_hotKey = wxEmptyString;
 
-    if(*pc == wxT('\t'))
+    if ( *pc == wxT('\t') )
     {
        pc++;
        m_hotKey = pc;
     }
+
+    m_text = text;
 }
 
 #if wxUSE_ACCEL
@@ -1244,10 +1248,10 @@ static wxString GetGtkHotKey( const wxMenuItem& item )
                 hotkey << wxT("Down" );
                 break;
             case WXK_PAGEUP:
-                hotkey << wxT("PgUp" );
+                hotkey << wxT("Page_Up" );
                 break;
             case WXK_PAGEDOWN:
-                hotkey << wxT("PgDn" );
+                hotkey << wxT("Page_Down" );
                 break;
             case WXK_LEFT:
                 hotkey << wxT("Left" );
@@ -1365,10 +1369,10 @@ static wxString GetGtkHotKey( const wxMenuItem& item )
                 hotkey << wxT("KP_Down" );
                 break;
             case WXK_NUMPAD_PAGEUP:
-                hotkey << wxT("KP_PgUp" );
+                hotkey << wxT("KP_Page_Up" );
                 break;
             case WXK_NUMPAD_PAGEDOWN:
-                hotkey << wxT("KP_PgDn" );
+                hotkey << wxT("KP_Page_Down" );
                 break;
             case WXK_NUMPAD_END:
                 hotkey << wxT("KP_End" );
@@ -1430,7 +1434,7 @@ static wxString GetGtkHotKey( const wxMenuItem& item )
                 if ( code < 127 )
                 {
                     wxString name = wxGTK_CONV_BACK( gdk_keyval_name((guint)code) );
-                    if ( name )
+                    if ( !name.empty() )
                     {
                         hotkey << name;
                         break;