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