diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-02-22 20:57:52 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-02-22 20:59:15 +0000 |
commit | c13a0b1f9e76584a4ffaea0ba754c8f9a01793d8 (patch) | |
tree | c3d0aa7b7fa12ae53f0e9499b55276ac6b16da71 | |
parent | b7107eb010e775d6dca01447bbb2512990f5591c (diff) |
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
-rw-r--r-- | include/vcl/menu.hxx | 8 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtksalmenu.hxx | 4 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 15 | ||||
-rw-r--r-- | 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 34847988207f..7ad334ea40c6 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -403,8 +403,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 { @@ -452,10 +455,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<void*,void>& rLink ) { maCloseHdl = rLink; } diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx index 405c635bdb83..c323301ded2c 100644 --- a/vcl/inc/unx/gtk/gtksalmenu.hxx +++ b/vcl/inc/unx/gtk/gtksalmenu.hxx @@ -43,7 +43,7 @@ class GtkSalMenu : public SalMenu private: std::vector< GtkSalMenuItem* > maItems; - bool mbMenuBar; + bool mbMenuBar; Menu* mpVCLMenu; GtkSalMenu* mpParentSalMenu; const GtkSalFrame* mpFrame; @@ -54,7 +54,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 b36ca699679c..701779cfe9af 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2667,14 +2667,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<MenuBar*>(this); + pMenu->pStartedFrom = const_cast<Menu*>(this); pMenu->bInCallback = true; pMenu->Activate(); @@ -2684,13 +2683,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<MenuBar*>(this); + pMenu->pStartedFrom = const_cast<Menu*>(this); pMenu->bInCallback = true; pMenu->Deactivate(); if( !aDelData.isDeleted() ) @@ -2723,14 +2722,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<MenuBar*>(this)->ImplFindMenu(nCommandEventId); + pMenu = const_cast<Menu*>(this)->ImplFindMenu(nCommandEventId); if( pMenu ) { pMenu->nSelectedId = nCommandEventId; - pMenu->pStartedFrom = const_cast<MenuBar*>(this); + pMenu->pStartedFrom = const_cast<Menu*>(this); pMenu->ImplSelect(); return true; } diff --git a/vcl/unx/gtk/gtksalmenu.cxx b/vcl/unx/gtk/gtksalmenu.cxx index 7b9f7eda6cdd..7d73cac099dd 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<gchar*>(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<gchar*>(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<gchar*>(aMenuCommand), TRUE ); if ( pSalSubMenu != nullptr ) { - MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu ); - pMenuBar->HandleMenuDeActivateEvent( pSalSubMenu->mpVCLMenu ); + mpVCLMenu->HandleMenuDeActivateEvent( pSalSubMenu->mpVCLMenu ); } } |