summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-02-22 20:57:52 +0000
committerJan Holesovsky <kendy@collabora.com>2016-04-08 12:49:44 +0200
commit9820da23375d89c26d6feb9d8ee3969916dc0d76 (patch)
tree957c64fbe4003544948765b944bb8415747b030c
parentd94db444a6596e7169729e18874cb8ed71a4259c (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.hxx8
-rw-r--r--vcl/inc/unx/gtk/gtksalmenu.hxx4
-rw-r--r--vcl/source/window/menu.cxx15
-rw-r--r--vcl/unx/gtk/window/gtksalmenu.cxx10
4 files changed, 17 insertions, 20 deletions
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 479849f608bc..6636c8f8886d 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -411,8 +411,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;
+};
namespace vcl { namespace MenuInvalidator {
@@ -473,10 +476,7 @@ public:
void ShowButtons( bool bClose, bool bFloat, bool bHide );
virtual void SelectItem(sal_uInt16 nId) SAL_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 e74de22f3de3..cefac23923d5 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -40,7 +40,7 @@ class GtkSalMenu : public SalMenu
private:
std::vector< GtkSalMenuItem* > maItems;
- bool mbMenuBar;
+ bool mbMenuBar;
Menu* mpVCLMenu;
GtkSalMenu* mpParentSalMenu;
const GtkSalFrame* mpFrame;
@@ -51,7 +51,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 629b41981abe..e5af0093e4ae 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2663,14 +2663,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();
@@ -2680,13 +2679,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() )
@@ -2719,14 +2718,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/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index 4a189994ae76..47e97f8c9d98 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -664,11 +664,10 @@ void GtkSalMenu::DispatchCommand( gint itemId, const gchar *aCommand )
GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast<gchar*>(aCommand), FALSE );
Menu* pSubMenu = ( pSalSubMenu != NULL ) ? pSalSubMenu->GetMenu() : NULL;
- 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);
for ( sal_uInt16 nPos = 0; nPos < maItems.size(); nPos++ )
@@ -686,7 +685,7 @@ void GtkSalMenu::Activate()
{
if ( !mbMenuBar )
return;
- ActivateAllSubmenus(static_cast<MenuBar*>(mpVCLMenu));
+ ActivateAllSubmenus(mpVCLMenu);
}
void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
@@ -697,8 +696,7 @@ void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast<gchar*>(aMenuCommand), TRUE );
if ( pSalSubMenu != NULL ) {
- MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
- pMenuBar->HandleMenuDeActivateEvent( pSalSubMenu->mpVCLMenu );
+ mpVCLMenu->HandleMenuDeActivateEvent( pSalSubMenu->mpVCLMenu );
}
}