You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libreoffice/0002-gtk3-some-changes-towa...

174 lines
6.6 KiB

From 7e0dcbd97a7ec6e9d39a8b74980421a6b33132ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Mon, 22 Feb 2016 20:57:52 +0000
Subject: [PATCH] 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<void*,void>& rLink ) { maCloseHdl = rLink; }
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 93259f1..ffda51a 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, int& rDupsToSkip, 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<MenuBar*>(this);
+ pMenu->pStartedFrom = const_cast<Menu*>(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<MenuBar*>(this);
+ pMenu->pStartedFrom = const_cast<Menu*>(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<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 507d529..9b590dd 100644
--- a/vcl/unx/gtk/gtksalmenu.cxx
+++ b/vcl/unx/gtk/gtksalmenu.cxx
@@ -654,11 +654,10 @@ void GtkSalMenu::DispatchCommand( gint itemId, const gchar *aCommand )
GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast<gchar*>(aCommand), nDupsToSkip, 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);
9 years ago
@@ -679,17 +678,16 @@ void GtkSalMenu::Activate( const gchar* aMenuCommand )
return;
if ( !aMenuCommand ) {
- ActivateAllSubmenus( static_cast< MenuBar* >( mpVCLMenu ) );
+ ActivateAllSubmenus(mpVCLMenu);
return;
}
9 years ago
int nDupsToSkip;
aMenuCommand = DetermineDupIndex(aMenuCommand, nDupsToSkip);
GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast<gchar*>(aMenuCommand), nDupsToSkip, TRUE );
if ( pSalSubMenu != nullptr ) {
- MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
- pMenuBar->HandleMenuActivateEvent( pSalSubMenu->mpVCLMenu );
+ mpVCLMenu->HandleMenuActivateEvent( pSalSubMenu->mpVCLMenu );
pSalSubMenu->Update();
}
}
@@ -702,8 +700,7 @@ void GtkSalMenu::Deactivate( const gchar* aMenuCommand )
GtkSalMenu* pSalSubMenu = GetMenuForItemCommand( const_cast<gchar*>(aMenuCommand), nDupsToSkip, TRUE );
if ( pSalSubMenu != nullptr ) {
- MenuBar* pMenuBar = static_cast< MenuBar* >( mpVCLMenu );
- pMenuBar->HandleMenuDeActivateEvent( pSalSubMenu->mpVCLMenu );
+ mpVCLMenu->HandleMenuDeActivateEvent( pSalSubMenu->mpVCLMenu );
}
}
--
2.5.0