]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/menu.cpp
corrected off by 1 error in cMB2WC() call (thanks valgrind)
[wxWidgets.git] / src / gtk / menu.cpp
index 9f8004024621c945631536f2eff7a6d30a77172f..97d926f92fbf892fab79a108581c38085c1c77ae 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        src/gtk/menu.cpp
-// Purpose:
+// Purpose:     implementation of wxMenuBar and wxMenu classes for wxGTK
 // Author:      Robert Roebling
 // Id:          $Id$
 // Copyright:   (c) 1998 Robert Roebling
@@ -10,6 +10,8 @@
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
+#if wxUSE_MENUS
+
 #include "wx/menu.h"
 
 #ifndef WX_PRECOMP
@@ -868,18 +870,22 @@ wxString wxMenuItem::GTKProcessMenuItemLabel(const wxString& str, wxString *hotK
     wxString text;
 
     // '\t' is the deliminator indicating a hot key
-    const wxChar *pc = str;
-    while ( (*pc != wxT('\0')) && (*pc != wxT('\t')) )
+    wxString::const_iterator pc = str.begin();
+    while ( pc != str.end() && *pc != wxT('\t') )
     {
-        if ((*pc == wxT('&')) && (*(pc+1) == wxT('&')))
-        {
-            // "&" is doubled to indicate "&" instead of accelerator
-            ++pc;
-            text << wxT('&');
-        }
-        else if (*pc == wxT('&'))
+        if (*pc == wxT('&'))
         {
-            text << wxT('_');
+            wxString::const_iterator next = pc + 1;
+            if (next != str.end() && *next == wxT('&'))
+            {
+                // "&" is doubled to indicate "&" instead of accelerator
+                ++pc;
+                text << wxT('&');
+            }
+            else
+            {
+                text << wxT('_');
+            }
         }
         else if ( *pc == wxT('_') )    // escape underscores
         {
@@ -898,7 +904,7 @@ wxString wxMenuItem::GTKProcessMenuItemLabel(const wxString& str, wxString *hotK
         if(*pc == wxT('\t'))
         {
             pc++;
-            *hotKey = pc;
+            hotKey->assign(pc, str.end());
         }
     }
 
@@ -1788,3 +1794,5 @@ bool wxGetStockGtkAccelerator(const char *id, GdkModifierType *mod, guint *key)
 }
 
 #endif // __WXGTK20__
+
+#endif // wxUSE_MENUS