3006956
From 684f2191c0010aaa5c802a306bef209660df0968 Mon Sep 17 00:00:00 2001
3006956
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
3006956
Date: Mon, 22 Feb 2016 20:57:52 +0000
3006956
Subject: [PATCH 2/8] gtk3: some changes towards enabling native gtk3 popup
3006956
 menus
3006956
3006956
these menubar things can be menu things and can then do
3006956
away with the casting, no logic changes intended
3006956
3006956
Change-Id: Ibb1b5354d5e1483327f172d6890e134f1e4b9ee4
3006956
(cherry picked from commit c13a0b1f9e76584a4ffaea0ba754c8f9a01793d8)
3006956
---
3006956
 include/vcl/menu.hxx           |  8 ++++----
3006956
 vcl/inc/unx/gtk/gtksalmenu.hxx |  4 ++--
3006956
 vcl/source/window/menu.cxx     | 15 +++++++--------
3006956
 vcl/unx/gtk/gtksalmenu.cxx     | 13 +++++--------
3006956
 4 files changed, 18 insertions(+), 22 deletions(-)
3006956
3006956
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
3006956
index 0d6e16a..1dbd85e 100644
3006956
--- a/include/vcl/menu.hxx
3006956
+++ b/include/vcl/menu.hxx
3006956
@@ -406,8 +406,11 @@ public:
3006956
 
3006956
     void HighlightItem( sal_uInt16 nItemPos );
3006956
     void DeHighlight() { HighlightItem( 0xFFFF ); } // MENUITEMPOS_INVALID
3006956
-};
3006956
 
3006956
+    bool HandleMenuCommandEvent(Menu *pMenu, sal_uInt16 nEventId) const;
3006956
+    bool HandleMenuActivateEvent(Menu *pMenu) const;
3006956
+    bool HandleMenuDeActivateEvent(Menu *pMenu) const;
3006956
+};
3006956
 
3006956
 class VCL_DLLPUBLIC MenuBar : public Menu
3006956
 {
3006956
@@ -458,10 +461,7 @@ public:
3006956
     void ShowButtons( bool bClose, bool bFloat, bool bHide );
3006956
 
3006956
     virtual void SelectItem(sal_uInt16 nId) override;
3006956
-    bool HandleMenuActivateEvent(Menu *pMenu) const;
3006956
-    bool HandleMenuDeActivateEvent(Menu *pMenu) const;
3006956
     bool HandleMenuHighlightEvent(Menu *pMenu, sal_uInt16 nEventId) const;
3006956
-    bool HandleMenuCommandEvent(Menu *pMenu, sal_uInt16 nEventId) const;
3006956
     bool HandleMenuButtonEvent(Menu *pMenu, sal_uInt16 nEventId);
3006956
 
3006956
     void SetCloseButtonClickHdl( const Link<void*,void>& rLink ) { maCloseHdl = rLink; }
3006956
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
3006956
index 8df2c1d..1d58b7a 100644
3006956
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
3006956
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
3006956
@@ -42,7 +42,7 @@ class GtkSalMenu : public SalMenu
3006956
 private:
3006956
     std::vector< GtkSalMenuItem* >  maItems;
3006956
 
3006956
-    bool                        mbMenuBar;
3006956
+    bool                            mbMenuBar;
3006956
     Menu*                           mpVCLMenu;
3006956
     GtkSalMenu*                     mpParentSalMenu;
3006956
     const GtkSalFrame*              mpFrame;
3006956
@@ -53,7 +53,7 @@ private:
3006956
 
3006956
     GtkSalMenu*                 GetMenuForItemCommand( gchar* aCommand, gboolean bGetSubmenu );
3006956
     void                        ImplUpdate( gboolean bRecurse );
3006956
-    void                        ActivateAllSubmenus(MenuBar* pMenuBar);
3006956
+    void                        ActivateAllSubmenus(Menu* pMenuBar);
3006956
 
3006956
 public:
3006956
     GtkSalMenu( bool bMenuBar );
3006956
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
3006956
index 4aa7d41..999085e 100644
3006956
--- a/vcl/source/window/menu.cxx
3006956
+++ b/vcl/source/window/menu.cxx
3006956
@@ -2679,14 +2679,13 @@ void MenuBar::SelectItem(sal_uInt16 nId)
3006956
 }
3006956
 
3006956
 // handler for native menu selection and command events
3006956
-
3006956
-bool MenuBar::HandleMenuActivateEvent( Menu *pMenu ) const
3006956
+bool Menu::HandleMenuActivateEvent( Menu *pMenu ) const
3006956
 {
3006956
     if( pMenu )
3006956
     {
3006956
         ImplMenuDelData aDelData( this );
3006956
 
3006956
-        pMenu->pStartedFrom = const_cast<MenuBar*>(this);
3006956
+        pMenu->pStartedFrom = const_cast<Menu*>(this);
3006956
         pMenu->bInCallback = true;
3006956
         pMenu->Activate();
3006956
 
3006956
@@ -2696,13 +2695,13 @@ bool MenuBar::HandleMenuActivateEvent( Menu *pMenu ) const
3006956
     return true;
3006956
 }
3006956
 
3006956
-bool MenuBar::HandleMenuDeActivateEvent( Menu *pMenu ) const
3006956
+bool Menu::HandleMenuDeActivateEvent( Menu *pMenu ) const
3006956
 {
3006956
     if( pMenu )
3006956
     {
3006956
         ImplMenuDelData aDelData( this );
3006956
 
3006956
-        pMenu->pStartedFrom = const_cast<MenuBar*>(this);
3006956
+        pMenu->pStartedFrom = const_cast<Menu*>(this);
3006956
         pMenu->bInCallback = true;
3006956
         pMenu->Deactivate();
3006956
         if( !aDelData.isDeleted() )
3006956
@@ -2735,14 +2734,14 @@ bool MenuBar::HandleMenuHighlightEvent( Menu *pMenu, sal_uInt16 nHighlightEventI
3006956
         return false;
3006956
 }
3006956
 
3006956
-bool MenuBar::HandleMenuCommandEvent( Menu *pMenu, sal_uInt16 nCommandEventId ) const
3006956
+bool Menu::HandleMenuCommandEvent( Menu *pMenu, sal_uInt16 nCommandEventId ) const
3006956
 {
3006956
     if( !pMenu )
3006956
-        pMenu = const_cast<MenuBar*>(this)->ImplFindMenu(nCommandEventId);
3006956
+        pMenu = const_cast<Menu*>(this)->ImplFindMenu(nCommandEventId);
3006956
     if( pMenu )
3006956
     {
3006956
         pMenu->nSelectedId = nCommandEventId;
3006956
-        pMenu->pStartedFrom = const_cast<MenuBar*>(this);
3006956
+        pMenu->pStartedFrom = const_cast<Menu*>(this);
3006956
         pMenu->ImplSelect();
3006956
         return true;
3006956
     }
3006956
diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx
3006956
index fd29a25..6887ade 100644
3006956
--- a/vcl/unx/gtk/gtksalmenu.cxx
3006956
+++ b/vcl/unx/gtk/gtksalmenu.cxx
3006956
@@ -622,11 +622,10 @@ void GtkSalMenu::DispatchCommand( gint itemId, const gchar *aCommand )
3006956
     GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast<gchar*>(aCommand), FALSE );
3006956
     Menu* pSubMenu = ( pSalSubMenu != nullptr ) ? pSalSubMenu->GetMenu() : nullptr;
3006956
 
3006956
-    MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
3006956
-    pMenuBar->HandleMenuCommandEvent( pSubMenu, itemId );
3006956
+    mpVCLMenu->HandleMenuCommandEvent( pSubMenu, itemId );
3006956
 }
3006956
 
3006956
-void GtkSalMenu::ActivateAllSubmenus(MenuBar* pMenuBar)
3006956
+void GtkSalMenu::ActivateAllSubmenus(Menu* pMenuBar)
3006956
 {
3006956
     pMenuBar->HandleMenuActivateEvent(mpVCLMenu);
3006956
     pMenuBar->HandleMenuDeActivateEvent(mpVCLMenu);
3006956
@@ -647,15 +646,14 @@ void GtkSalMenu::Activate( const gchar* aMenuCommand )
3006956
         return;
3006956
 
3006956
     if ( !aMenuCommand ) {
3006956
-        ActivateAllSubmenus( static_cast< MenuBar* >( mpVCLMenu ) );
3006956
+        ActivateAllSubmenus(mpVCLMenu);
3006956
         return;
3006956
     }
3006956
 
3006956
     GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast<gchar*>(aMenuCommand), TRUE );
3006956
 
3006956
     if ( pSalSubMenu != nullptr ) {
3006956
-        MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
3006956
-        pMenuBar->HandleMenuActivateEvent( pSalSubMenu->mpVCLMenu );
3006956
+        mpVCLMenu->HandleMenuActivateEvent( pSalSubMenu->mpVCLMenu );
3006956
         pSalSubMenu->Update();
3006956
     }
3006956
 }
3006956
@@ -668,8 +666,7 @@ void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
3006956
     GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast<gchar*>(aMenuCommand), TRUE );
3006956
 
3006956
     if ( pSalSubMenu != nullptr ) {
3006956
-        MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
3006956
-        pMenuBar->HandleMenuDeActivateEvent( pSalSubMenu->mpVCLMenu );
3006956
+        mpVCLMenu->HandleMenuDeActivateEvent( pSalSubMenu->mpVCLMenu );
3006956
     }
3006956
 }
3006956
 
3006956
-- 
3006956
2.7.1
3006956