]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/menu.cpp
minor cleanup 2 - reformatting
[wxWidgets.git] / src / gtk / menu.cpp
index 711a4f7cb9f86ca1683c80033406df082b2aeeaa..aa3a7bee524d7f2f570a79e2a14dd719427911ec 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        menu.cpp
+// Name:        src/gtk/menu.cpp
 // Purpose:
 // Author:      Robert Roebling
 // Id:          $Id$
 #include "wx/wxprec.h"
 
 #include "wx/menu.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+#endif
+
 #include "wx/log.h"
-#include "wx/intl.h"
 #include "wx/app.h"
 #include "wx/bitmap.h"
 
@@ -48,9 +52,6 @@ static const int wxGTK_TITLE_ID = -3;
 // idle system
 //-----------------------------------------------------------------------------
 
-extern void wxapp_install_idle_handler();
-extern bool g_isIdle;
-
 #if wxUSE_ACCEL
 static wxString GetGtkHotKey( const wxMenuItem& item );
 #endif
@@ -511,17 +512,7 @@ void wxMenuBar::SetLabelTop( size_t pos, const wxString& label )
     menu->SetTitle( str );
 
     if (menu->m_owner)
-    {
-        GtkLabel *glabel = GTK_LABEL( GTK_BIN(menu->m_owner)->child );
-
-        /* set new text */
-        gtk_label_set( glabel, wxGTK_CONV( str ) );
-
-        /* reparse key accel */
-        (void)gtk_label_parse_uline (GTK_LABEL(glabel), wxGTK_CONV( str ) );
-        gtk_accel_label_refetch( GTK_ACCEL_LABEL(glabel) );
-    }
-
+        gtk_label_set_text_with_mnemonic( GTK_LABEL( GTK_BIN(menu->m_owner)->child), wxGTK_CONV(str) );
 }
 
 //-----------------------------------------------------------------------------
@@ -760,7 +751,7 @@ void wxMenuItem::SetText( const wxString& str )
     oldLabel.Replace(wxT("_"), wxT(""));
     wxString label1 = wxStripMenuCodes(str);
     wxString oldhotkey = GetHotKey();    // Store the old hotkey in Ctrl-foo format
-    wxCharBuffer oldbuf = wxGTK_CONV( GetGtkHotKey(*this) );  // and as <control>foo
+    wxCharBuffer oldbuf = wxGTK_CONV_SYS( GetGtkHotKey(*this) );  // and as <control>foo
 
     DoSetText(str);
 
@@ -776,7 +767,7 @@ void wxMenuItem::SetText( const wxString& str )
         else
             label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
 
-        gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(m_text) );
+        gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV_SYS(m_text) );
     }
 
     guint accel_key;
@@ -790,7 +781,7 @@ void wxMenuItem::SetText( const wxString& str )
                                        accel_mods );
     }
 
-    wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*this) );
+    wxCharBuffer buf = wxGTK_CONV_SYS( GetGtkHotKey(*this) );
     gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods);
     if (accel_key != 0)
     {
@@ -875,7 +866,7 @@ void wxMenuItem::Check( bool check )
     {
         case wxITEM_CHECK:
         case wxITEM_RADIO:
-            gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check );
+            gtk_check_menu_item_set_active( (GtkCheckMenuItem*)m_menuItem, (gint)check );
             break;
 
         default:
@@ -924,7 +915,7 @@ void wxMenu::Init()
     {
         GtkWidget *tearoff = gtk_tearoff_menu_item_new();
 
-        gtk_menu_append(GTK_MENU(m_menu), tearoff);
+        gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), tearoff);
     }
 
     m_prevRadio = NULL;
@@ -967,7 +958,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
         text = mitem->GetText();
         const wxBitmap *bitmap = &mitem->GetBitmap();
 
-        menuItem = gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
+        menuItem = gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text ) );
 
         GtkWidget *image;
         if (bitmap->HasPixbuf())
@@ -998,7 +989,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
         {
             case wxITEM_CHECK:
             {
-                menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
+                menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text ) );
                 m_prevRadio = NULL;
                 break;
             }
@@ -1009,12 +1000,14 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
                 if ( m_prevRadio == NULL )
                 {
                     // start of a new radio group
-                    m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
+                    m_prevRadio = menuItem =
+                        gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV_SYS( text ) );
                 }
                 else // continue the radio group
                 {
                     group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
-                    m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
+                    m_prevRadio = menuItem =
+                        gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV_SYS( text ) );
                 }
                 break;
             }
@@ -1025,7 +1018,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
 
             case wxITEM_NORMAL:
             {
-                menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
+                menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text ) );
                 m_prevRadio = NULL;
                 break;
             }
@@ -1035,7 +1028,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos)
 
     guint accel_key;
     GdkModifierType accel_mods;
-    wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*mitem) );
+    wxCharBuffer buf = wxGTK_CONV_SYS( GetGtkHotKey(*mitem) );
 
     // wxPrintf( wxT("item: %s hotkey %s\n"), mitem->GetText().c_str(), GetGtkHotKey(*mitem).c_str() );
     gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods);
@@ -1209,12 +1202,10 @@ static wxString GetGtkHotKey( const wxMenuItem& item )
                 hotkey << wxT("Down" );
                 break;
             case WXK_PAGEUP:
-            case WXK_PRIOR:
-                hotkey << wxT("Prior" );
+                hotkey << wxT("PgUp" );
                 break;
             case WXK_PAGEDOWN:
-            case WXK_NEXT:
-                hotkey << wxT("Next" );
+                hotkey << wxT("PgDn" );
                 break;
             case WXK_LEFT:
                 hotkey << wxT("Left" );
@@ -1331,11 +1322,11 @@ static wxString GetGtkHotKey( const wxMenuItem& item )
             case WXK_NUMPAD_DOWN:
                 hotkey << wxT("KP_Down" );
                 break;
-            case WXK_NUMPAD_PRIOR: case WXK_NUMPAD_PAGEUP:
-                hotkey << wxT("KP_Prior" );
+            case WXK_NUMPAD_PAGEUP:
+                hotkey << wxT("KP_PgUp" );
                 break;
-            case WXK_NUMPAD_NEXT:  case WXK_NUMPAD_PAGEDOWN:
-                hotkey << wxT("KP_Next" );
+            case WXK_NUMPAD_PAGEDOWN:
+                hotkey << wxT("KP_PgDn" );
                 break;
             case WXK_NUMPAD_END:
                 hotkey << wxT("KP_End" );
@@ -1421,13 +1412,13 @@ static wxString GetGtkHotKey( const wxMenuItem& item )
 
 #if wxUSE_MENUS_NATIVE
 
-extern "C"
+extern "C" WXDLLIMPEXP_CORE
 void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting  )
 {
     *is_waiting = FALSE;
 }
 
-void SetInvokingWindow( wxMenu *menu, wxWindow* win )
+WXDLLIMPEXP_CORE void SetInvokingWindow( wxMenu *menu, wxWindow* win )
 {
     menu->SetInvokingWindow( win );
 
@@ -1444,7 +1435,7 @@ void SetInvokingWindow( wxMenu *menu, wxWindow* win )
     }
 }
 
-extern "C"
+extern "C" WXDLLIMPEXP_CORE
 void wxPopupMenuPositionCallback( GtkMenu *menu,
                                   gint *x, gint *y,
                                   gboolean * WXUNUSED(whatever),
@@ -1527,4 +1518,3 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y )
 }
 
 #endif // wxUSE_MENUS_NATIVE
-