diff options
-rw-r--r-- | include/vcl/menu.hxx | 533 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 405 | ||||
-rw-r--r-- | vcl/source/window/menubarwindow.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/menufloatingwindow.cxx | 4 |
4 files changed, 460 insertions, 486 deletions
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index f4d57a4d937a..2a4abcf3052a 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -51,21 +51,14 @@ class IMenuBarWindow; struct SystemMenuData; enum class FloatWinPopupFlags; -namespace com { -namespace sun { -namespace star { -namespace accessibility { +namespace com { namespace sun { namespace star { namespace accessibility { class XAccessible; }}}} namespace vcl { struct MenuLayoutData; } - -// - Menu-Types - - - -#define MENU_APPEND ((sal_uInt16)0xFFFF) -#define MENU_ITEM_NOTFOUND ((sal_uInt16)0xFFFF) +#define MENU_APPEND (sal_uInt16(0xFFFF)) +#define MENU_ITEM_NOTFOUND (sal_uInt16(0xFFFF)) // Must match the definitions in css::awt::PopupMenuDirection.idl enum class PopupMenuFlags @@ -83,6 +76,7 @@ enum class PopupMenuFlags //the menu beside that rectangle NoHorzPlacement = 0x0020, }; + namespace o3tl { template<> struct typed_flags<PopupMenuFlags> : is_typed_flags<PopupMenuFlags, 0x003f> {}; @@ -96,14 +90,14 @@ enum class MenuFlags // overrides default hiding of disabled entries in popup menus AlwaysShowDisabledEntries = 0x0004, }; + namespace o3tl { template<> struct typed_flags<MenuFlags> : is_typed_flags<MenuFlags, 0x0007> {}; } - /// Invalid menu item id -#define ITEMPOS_INVALID 0xFFFF +#define ITEMPOS_INVALID 0xFFFF struct ImplMenuDelData { @@ -116,15 +110,11 @@ struct ImplMenuDelData bool isDeleted() const { return mpMenu == 0; } }; - -// - Menu - - - struct MenuLogo { - BitmapEx aBitmap; - Color aStartColor; - Color aEndColor; + BitmapEx aBitmap; + Color aStartColor; + Color aEndColor; }; typedef void (*MenuUserDataReleaseFunction)(sal_uLong); @@ -139,74 +129,76 @@ class VCL_DLLPUBLIC Menu : public Resource friend class SystemWindow; friend struct ImplMenuDelData; private: - ImplMenuDelData* mpFirstDel; - MenuItemList* pItemList; // Liste mit den MenuItems - MenuLogo* pLogo; - Menu* pStartedFrom; + ImplMenuDelData* mpFirstDel; + MenuItemList* pItemList; // Liste mit den MenuItems + MenuLogo* pLogo; + Menu* pStartedFrom; VclPtr<vcl::Window> pWindow; - Link<Menu *, bool> aActivateHdl; // Active-Handler - Link<Menu *, bool> aDeactivateHdl; // Deactivate-Handler - Link<Menu *, bool> aHighlightHdl; // Highlight-Handler - Link<> aSelectHdl; // Highlight-Handler + Link<Menu*, bool> aActivateHdl; // Active-Handler + Link<Menu*, bool> aDeactivateHdl; // Deactivate-Handler + Link<Menu*, bool> aHighlightHdl; // Highlight-Handler + Link<> aSelectHdl; // Highlight-Handler VclEventListeners maEventListeners; VclEventListeners maChildEventListeners; - OUString aTitleText; // PopupMenu text - sal_uInt16 nTitleHeight; + OUString aTitleText; // PopupMenu text + sal_uInt16 nTitleHeight; - ImplSVEvent * nEventId; - sal_uInt16 mnHighlightedItemPos; // for native menus: keeps track of the highlighted item - MenuFlags nMenuFlags; - sal_uInt16 nDefaultItem; // Id of default item - sal_uInt16 nSelectedId; + ImplSVEvent* nEventId; + sal_uInt16 mnHighlightedItemPos; // for native menus: keeps track of the highlighted item + MenuFlags nMenuFlags; + sal_uInt16 nDefaultItem; // Id of default item + sal_uInt16 nSelectedId; // for output: - sal_uInt16 nImgOrChkPos; - sal_uInt16 nTextPos; + sal_uInt16 nImgOrChkPos; + sal_uInt16 nTextPos; - bool bCanceled : 1, ///< Terminated during a callback - bInCallback : 1, ///< In Activate/Deactivate - bKilled : 1; ///< Killed + bool bCanceled : 1; ///< Terminated during a callback + bool bInCallback : 1; ///< In Activate/Deactivate + bool bKilled : 1; ///< Killed - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxAccessible; + css::uno::Reference<css::accessibility::XAccessible > mxAccessible; mutable vcl::MenuLayoutData* mpLayoutData; - SalMenu* mpSalMenu; + SalMenu* mpSalMenu; protected: - SAL_DLLPRIVATE Menu* ImplGetStartMenu(); - SAL_DLLPRIVATE Menu* ImplFindSelectMenu(); - SAL_DLLPRIVATE Menu* ImplFindMenu( sal_uInt16 nId ); - SAL_DLLPRIVATE Size ImplCalcSize( vcl::Window* pWin ); - SAL_DLLPRIVATE bool ImplIsVisible( sal_uInt16 nPos ) const; - SAL_DLLPRIVATE bool ImplIsSelectable( sal_uInt16 nPos ) const; - SAL_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const; - SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const; - SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const; - SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( sal_uInt16 nPos ) const; - SAL_DLLPRIVATE void ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const; - SAL_DLLPRIVATE void ImplPaintMenuTitle(vcl::RenderContext&, const Rectangle& rRect) const; - SAL_DLLPRIVATE void ImplSelect(); - SAL_DLLPRIVATE void ImplCallHighlight( sal_uInt16 nHighlightItem ); - SAL_DLLPRIVATE void ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos ); - DECL_DLLPRIVATE_LINK( ImplCallSelect, void* ); - - SAL_DLLPRIVATE void ImplFillLayoutData() const; - SAL_DLLPRIVATE SalMenu* ImplGetSalMenu() { return mpSalMenu; } - SAL_DLLPRIVATE void ImplSetSalMenu( SalMenu *pMenu ); - SAL_DLLPRIVATE OUString ImplGetHelpText( sal_uInt16 nItemId ) const; + SAL_DLLPRIVATE Menu* ImplGetStartMenu(); + SAL_DLLPRIVATE Menu* ImplFindSelectMenu(); + SAL_DLLPRIVATE Menu* ImplFindMenu( sal_uInt16 nId ); + SAL_DLLPRIVATE Size ImplCalcSize( vcl::Window* pWin ); + SAL_DLLPRIVATE bool ImplIsVisible( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE bool ImplIsSelectable( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const; + SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const; + SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE void ImplPaint(vcl::RenderContext& rRenderContext, + sal_uInt16 nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, + bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const; + SAL_DLLPRIVATE void ImplPaintMenuTitle(vcl::RenderContext&, const Rectangle& rRect) const; + SAL_DLLPRIVATE void ImplSelect(); + SAL_DLLPRIVATE void ImplCallHighlight( sal_uInt16 nHighlightItem ); + SAL_DLLPRIVATE void ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos ); + DECL_DLLPRIVATE_LINK(ImplCallSelect, void* ); + + SAL_DLLPRIVATE void ImplFillLayoutData() const; + SAL_DLLPRIVATE SalMenu* ImplGetSalMenu() { return mpSalMenu; } + SAL_DLLPRIVATE void ImplSetSalMenu( SalMenu *pMenu ); + SAL_DLLPRIVATE OUString ImplGetHelpText( sal_uInt16 nItemId ) const; // returns native check and option menu symbol height in rCheckHeight and rRadioHeight // return value is maximum width and height of checkboxes and radiobuttons - SAL_DLLPRIVATE Size ImplGetNativeCheckAndRadioSize( const vcl::Window*, long& rCheckHeight, long& rRadioHeight ) const; + SAL_DLLPRIVATE Size ImplGetNativeCheckAndRadioSize(vcl::RenderContext& rRenderContext, long& rCheckHeight, long& rRadioHeight) const; // returns native submenu arrow size and spacing from right border // return value is whether it's supported natively - SAL_DLLPRIVATE bool ImplGetNativeSubmenuArrowSize( vcl::Window* pWin, Size& rArrowSize, long& rArrowSpacing ) const; + SAL_DLLPRIVATE bool ImplGetNativeSubmenuArrowSize(vcl::RenderContext& rRenderContext, Size& rArrowSize, long& rArrowSpacing) const; - SAL_DLLPRIVATE void ImplAddDel( ImplMenuDelData &rDel ); - SAL_DLLPRIVATE void ImplRemoveDel( ImplMenuDelData &rDel ); + SAL_DLLPRIVATE void ImplAddDel( ImplMenuDelData &rDel ); + SAL_DLLPRIVATE void ImplRemoveDel( ImplMenuDelData &rDel ); SAL_DLLPRIVATE MenuItemData* NbcInsertItem(sal_uInt16 nId, MenuItemBits nBits, const OUString& rStr, Menu* pMenu, @@ -222,10 +214,10 @@ protected: virtual void MenuBarKeyInput(const KeyEvent& rEvent); public: - SAL_DLLPRIVATE void ImplKillLayoutData() const; - SAL_DLLPRIVATE Menu* ImplGetStartedFrom() const { return pStartedFrom; } + SAL_DLLPRIVATE void ImplKillLayoutData() const; + SAL_DLLPRIVATE Menu* ImplGetStartedFrom() const { return pStartedFrom; } - SAL_DLLPRIVATE vcl::Window* ImplGetWindow() const { return pWindow; } + SAL_DLLPRIVATE vcl::Window* ImplGetWindow() const { return pWindow; } void ImplSelectWithStart( Menu* pStartMenu = NULL ); protected: @@ -238,135 +230,157 @@ protected: Menu(); public: - virtual ~Menu(); - - void Activate(); - void Deactivate(); - virtual void Highlight(); - virtual void Select(); - - void InsertItem( sal_uInt16 nItemId, const OUString& rStr, - MenuItemBits nItemBits = MenuItemBits::NONE, - const OString &rIdent = OString(), - sal_uInt16 nPos = MENU_APPEND ); - void InsertItem( sal_uInt16 nItemId, const Image& rImage, - MenuItemBits nItemBits = MenuItemBits::NONE, - const OString &rIdent = OString(), - sal_uInt16 nPos = MENU_APPEND ); - void InsertItem( sal_uInt16 nItemId, - const OUString& rString, const Image& rImage, - MenuItemBits nItemBits = MenuItemBits::NONE, - const OString &rIdent = OString(), - sal_uInt16 nPos = MENU_APPEND ); - void InsertItem( const ResId& rResId, sal_uInt16 nPos = MENU_APPEND ); - void InsertSeparator( const OString &rIdent = OString(), - sal_uInt16 nPos = MENU_APPEND ); - void RemoveItem( sal_uInt16 nPos ); - void CopyItem( const Menu& rMenu, sal_uInt16 nPos, - sal_uInt16 nNewPos = MENU_APPEND ); - void Clear(); - - void CreateAutoMnemonics(); - - void SetMenuFlags( MenuFlags nFlags ) { nMenuFlags = nFlags; } - MenuFlags GetMenuFlags() const { return nMenuFlags; } - - sal_uInt16 GetItemCount() const; - sal_uInt16 GetItemId(sal_uInt16 nPos) const; - sal_uInt16 GetItemId(const OString &rIdent) const; - sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; - OString GetItemIdent(sal_uInt16 nItemId) const; - MenuItemType GetItemType( sal_uInt16 nPos ) const; - sal_uInt16 GetCurItemId() const { return nSelectedId;} - OString GetCurItemIdent() const; - - void SetDefaultItem( sal_uInt16 nItemId ) { nDefaultItem = nItemId; } - sal_uInt16 GetDefaultItem() const { return nDefaultItem; } - - void SetItemBits( sal_uInt16 nItemId, MenuItemBits nBits ); - MenuItemBits GetItemBits( sal_uInt16 nItemId ) const; - - void SetUserValue(sal_uInt16 nItemId, sal_uLong nValue, MenuUserDataReleaseFunction aFunc=0); - sal_uLong GetUserValue(sal_uInt16 nItemId) const; - - void SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu ); - PopupMenu* GetPopupMenu( sal_uInt16 nItemId ) const; - - void SetAccelKey( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode ); - vcl::KeyCode GetAccelKey( sal_uInt16 nItemId ) const; - - void CheckItem( sal_uInt16 nItemId, bool bCheck = true ); - bool IsItemChecked( sal_uInt16 nItemId ) const; - - virtual void SelectItem(sal_uInt16 nItemId) = 0; - void DeSelect() { SelectItem( 0xFFFF ); } // MENUITEMPOS_INVALID - - void EnableItem( sal_uInt16 nItemId, bool bEnable = true ); - void EnableItem(const OString &rIdent, bool bEnable = true) + virtual ~Menu(); + + void Activate(); + void Deactivate(); + virtual void Highlight(); + virtual void Select(); + + void InsertItem(sal_uInt16 nItemId, const OUString& rStr, + MenuItemBits nItemBits = MenuItemBits::NONE, + const OString &rIdent = OString(), + sal_uInt16 nPos = MENU_APPEND); + void InsertItem(sal_uInt16 nItemId, const Image& rImage, + MenuItemBits nItemBits = MenuItemBits::NONE, + const OString &rIdent = OString(), + sal_uInt16 nPos = MENU_APPEND); + void InsertItem(sal_uInt16 nItemId, + const OUString& rString, const Image& rImage, + MenuItemBits nItemBits = MenuItemBits::NONE, + const OString &rIdent = OString(), + sal_uInt16 nPos = MENU_APPEND); + void InsertItem(const ResId& rResId, sal_uInt16 nPos = MENU_APPEND ); + void InsertSeparator(const OString &rIdent = OString(), sal_uInt16 nPos = MENU_APPEND); + void RemoveItem( sal_uInt16 nPos ); + void CopyItem(const Menu& rMenu, sal_uInt16 nPos, sal_uInt16 nNewPos = MENU_APPEND ); + void Clear(); + + void CreateAutoMnemonics(); + + void SetMenuFlags( MenuFlags nFlags ) { nMenuFlags = nFlags; } + MenuFlags GetMenuFlags() const { return nMenuFlags; } + + sal_uInt16 GetItemCount() const; + sal_uInt16 GetItemId(sal_uInt16 nPos) const; + sal_uInt16 GetItemId(const OString &rIdent) const; + sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; + OString GetItemIdent(sal_uInt16 nItemId) const; + MenuItemType GetItemType( sal_uInt16 nPos ) const; + sal_uInt16 GetCurItemId() const { return nSelectedId;} + OString GetCurItemIdent() const; + + void SetDefaultItem( sal_uInt16 nItemId ) { nDefaultItem = nItemId; } + sal_uInt16 GetDefaultItem() const { return nDefaultItem; } + + void SetItemBits( sal_uInt16 nItemId, MenuItemBits nBits ); + MenuItemBits GetItemBits( sal_uInt16 nItemId ) const; + + void SetUserValue(sal_uInt16 nItemId, sal_uLong nValue, MenuUserDataReleaseFunction aFunc=0); + sal_uLong GetUserValue(sal_uInt16 nItemId) const; + + void SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu ); + PopupMenu* GetPopupMenu( sal_uInt16 nItemId ) const; + + void SetAccelKey( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode ); + vcl::KeyCode GetAccelKey( sal_uInt16 nItemId ) const; + + void CheckItem( sal_uInt16 nItemId, bool bCheck = true ); + bool IsItemChecked( sal_uInt16 nItemId ) const; + + virtual void SelectItem(sal_uInt16 nItemId) = 0; + void DeSelect() { SelectItem( 0xFFFF ); } // MENUITEMPOS_INVALID + + void EnableItem( sal_uInt16 nItemId, bool bEnable = true ); + void EnableItem(const OString &rIdent, bool bEnable = true) { EnableItem(GetItemId(rIdent), bEnable); } - bool IsItemEnabled( sal_uInt16 nItemId ) const; + bool IsItemEnabled( sal_uInt16 nItemId ) const; - void ShowItem( sal_uInt16 nItemId, bool bVisible = true ); - void HideItem( sal_uInt16 nItemId ) { ShowItem( nItemId, false ); } + void ShowItem( sal_uInt16 nItemId, bool bVisible = true ); + void HideItem( sal_uInt16 nItemId ) { ShowItem( nItemId, false ); } - bool IsItemPosVisible( sal_uInt16 nItemPos ) const; - bool IsMenuVisible() const; - virtual bool IsMenuBar() const = 0; + bool IsItemPosVisible( sal_uInt16 nItemPos ) const; + bool IsMenuVisible() const; + virtual bool IsMenuBar() const = 0; - void RemoveDisabledEntries( bool bCheckPopups = true, bool bRemoveEmptyPopups = false ); - bool HasValidEntries( bool bCheckPopups = true ); + void RemoveDisabledEntries( bool bCheckPopups = true, bool bRemoveEmptyPopups = false ); + bool HasValidEntries( bool bCheckPopups = true ); - void SetItemText( sal_uInt16 nItemId, const OUString& rStr ); - OUString GetItemText( sal_uInt16 nItemId ) const; + void SetItemText( sal_uInt16 nItemId, const OUString& rStr ); + OUString GetItemText( sal_uInt16 nItemId ) const; - void SetItemImage( sal_uInt16 nItemId, const Image& rImage ); - Image GetItemImage( sal_uInt16 nItemId ) const; - void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 ); - void SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror ); + void SetItemImage( sal_uInt16 nItemId, const Image& rImage ); + Image GetItemImage( sal_uInt16 nItemId ) const; + void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 ); + void SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror ); - void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand ); - OUString GetItemCommand( sal_uInt16 nItemId ) const; + void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand ); + OUString GetItemCommand( sal_uInt16 nItemId ) const; - void SetHelpText( sal_uInt16 nItemId, const OUString& rString ); - OUString GetHelpText( sal_uInt16 nItemId ) const; + void SetHelpText( sal_uInt16 nItemId, const OUString& rString ); + OUString GetHelpText( sal_uInt16 nItemId ) const; - void SetTipHelpText( sal_uInt16 nItemId, const OUString& rString ); - OUString GetTipHelpText( sal_uInt16 nItemId ) const; + void SetTipHelpText( sal_uInt16 nItemId, const OUString& rString ); + OUString GetTipHelpText( sal_uInt16 nItemId ) const; - void SetHelpCommand( sal_uInt16 nItemId, const OUString& rString ); - OUString GetHelpCommand( sal_uInt16 nItemId ) const; + void SetHelpCommand( sal_uInt16 nItemId, const OUString& rString ); + OUString GetHelpCommand( sal_uInt16 nItemId ) const; - void SetHelpId( sal_uInt16 nItemId, const OString& rHelpId ); - OString GetHelpId( sal_uInt16 nItemId ) const; + void SetHelpId( sal_uInt16 nItemId, const OString& rHelpId ); + OString GetHelpId( sal_uInt16 nItemId ) const; - void SetActivateHdl( const Link<Menu *, bool>& rLink ) { aActivateHdl = rLink; } + void SetActivateHdl( const Link<Menu *, bool>& rLink ) + { + aActivateHdl = rLink; + } - void SetDeactivateHdl( const Link<Menu *, bool>& rLink ) { aDeactivateHdl = rLink; } + void SetDeactivateHdl( const Link<Menu *, bool>& rLink ) + { + aDeactivateHdl = rLink; + } - void SetHighlightHdl( const Link<Menu *, bool>& rLink ) { aHighlightHdl = rLink; } + void SetHighlightHdl( const Link<Menu *, bool>& rLink ) + { + aHighlightHdl = rLink; + } - void SetSelectHdl( const Link<>& rLink ) { aSelectHdl = rLink; } - const Link<>& GetSelectHdl() const { return aSelectHdl; } + void SetSelectHdl( const Link<>& rLink ) + { + aSelectHdl = rLink; + } + const Link<>& GetSelectHdl() const + { + return aSelectHdl; + } - bool HasLogo() const { return pLogo != nullptr; } + bool HasLogo() const + { + return pLogo != nullptr; + } - sal_uInt16 GetTitleHeight() { return nTitleHeight; } + sal_uInt16 GetTitleHeight() + { + return nTitleHeight; + } - void AddEventListener( const Link<>& rEventListener ); - void RemoveEventListener( const Link<>& rEventListener ); - void AddChildEventListener( const Link<>& rEventListener ); - void RemoveChildEventListener( const Link<>& rEventListener ); + void AddEventListener( const Link<>& rEventListener ); + void RemoveEventListener( const Link<>& rEventListener ); + void AddChildEventListener( const Link<>& rEventListener ); + void RemoveChildEventListener( const Link<>& rEventListener ); - Menu& operator =( const Menu& rMenu ); + Menu& operator =( const Menu& rMenu ); // Fuer Menu-'Funktionen' - MenuItemList* GetItemList() const { return pItemList; } + MenuItemList* GetItemList() const + { + return pItemList; + } // returns the system's menu handle if native menus are supported // pData must point to a SystemMenuData structure - bool GetSystemMenuData( SystemMenuData* pData ) const; + bool GetSystemMenuData( SystemMenuData* pData ) const; // accessibility helpers @@ -380,46 +394,41 @@ public: // returns the bounding rectangle for an item at pos nItemPos Rectangle GetBoundingRectangle( sal_uInt16 nItemPos ) const; - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible(); - void SetAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxAccessible ); + css::uno::Reference<css::accessibility::XAccessible> GetAccessible(); + void SetAccessible(const css::uno::Reference<css::accessibility::XAccessible >& rxAccessible); // gets the activation key of the specified item - KeyEvent GetActivationKey( sal_uInt16 nItemId ) const; + KeyEvent GetActivationKey( sal_uInt16 nItemId ) const; - vcl::Window* GetWindow() const { return pWindow; } + vcl::Window* GetWindow() const { return pWindow; } - void SetAccessibleName( sal_uInt16 nItemId, const OUString& rStr ); - OUString GetAccessibleName( sal_uInt16 nItemId ) const; + void SetAccessibleName( sal_uInt16 nItemId, const OUString& rStr ); + OUString GetAccessibleName( sal_uInt16 nItemId ) const; // returns whether the item a position nItemPos is highlighted or not. - bool IsHighlighted( sal_uInt16 nItemPos ) const; + bool IsHighlighted( sal_uInt16 nItemPos ) const; - void HighlightItem( sal_uInt16 nItemPos ); - void DeHighlight() { HighlightItem( 0xFFFF ); } // MENUITEMPOS_INVALID + void HighlightItem( sal_uInt16 nItemPos ); + void DeHighlight() { HighlightItem( 0xFFFF ); } // MENUITEMPOS_INVALID }; -namespace vcl -{ - namespace MenuInvalidator - { - VCL_DLLPUBLIC VclEventListeners2* GetMenuInvalidateListeners(); - VCL_DLLPUBLIC void Invalidated(); - }; -} +namespace vcl { namespace MenuInvalidator { -// - MenuBar - +VCL_DLLPUBLIC VclEventListeners2* GetMenuInvalidateListeners(); +VCL_DLLPUBLIC void Invalidated(); +}} class VCL_DLLPUBLIC MenuBar : public Menu { - Link<> maCloseHdl; - Link<> maFloatHdl; - Link<> maHideHdl; - bool mbCloseBtnVisible; - bool mbFloatBtnVisible; - bool mbHideBtnVisible; - bool mbDisplayable; + Link<> maCloseHdl; + Link<> maFloatHdl; + Link<> maHideHdl; + bool mbCloseBtnVisible : 1; + bool mbFloatBtnVisible : 1; + bool mbHideBtnVisible : 1; + bool mbDisplayable : 1; friend class Application; friend class Menu; @@ -427,9 +436,10 @@ class VCL_DLLPUBLIC MenuBar : public Menu friend class MenuFloatingWindow; friend class SystemWindow; - SAL_DLLPRIVATE static vcl::Window* ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu, const css::uno::Reference<css::frame::XFrame> &rFrame); - SAL_DLLPRIVATE static void ImplDestroy( MenuBar* pMenu, bool bDelete ); - SAL_DLLPRIVATE bool ImplHandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu = true ); + SAL_DLLPRIVATE static vcl::Window* ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, + MenuBar* pMenu, const css::uno::Reference<css::frame::XFrame> &rFrame); + SAL_DLLPRIVATE static void ImplDestroy(MenuBar* pMenu, bool bDelete); + SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent& rKEvent, bool bFromMenu = true); protected: @@ -437,13 +447,13 @@ protected: IMenuBarWindow* getMenuBarWindow(); public: - MenuBar(); - MenuBar( const MenuBar& rMenu ); - virtual ~MenuBar(); + MenuBar(); + MenuBar( const MenuBar& rMenu ); + virtual ~MenuBar(); - MenuBar& operator =( const MenuBar& rMenu ); + MenuBar& operator =( const MenuBar& rMenu ); - virtual bool IsMenuBar() const SAL_OVERRIDE { return true; } + virtual bool IsMenuBar() const SAL_OVERRIDE { return true; } /// Close the 'pStartedFrom' menu window. virtual void ClosePopup(Menu* pMenu) SAL_OVERRIDE; @@ -454,65 +464,60 @@ public: /// Forward the KeyInput call to the MenuBar. virtual void MenuBarKeyInput(const KeyEvent& rEvent) SAL_OVERRIDE; - void ShowCloseButton( bool bShow = true ); - bool HasCloseButton() const { return mbCloseBtnVisible; } - bool HasFloatButton() const { return mbFloatBtnVisible; } - bool HasHideButton() const { return mbHideBtnVisible; } - 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; } - const Link<>& GetCloseButtonClickHdl() const { return maCloseHdl; } - void SetFloatButtonClickHdl( const Link<>& rLink ) { maFloatHdl = rLink; } - const Link<>& GetFloatButtonClickHdl() const { return maFloatHdl; } - void SetHideButtonClickHdl( const Link<>& rLink ) { maHideHdl = rLink; } - const Link<>& GetHideButtonClickHdl() const { return maHideHdl; } + void ShowCloseButton( bool bShow = true ); + bool HasCloseButton() const { return mbCloseBtnVisible; } + bool HasFloatButton() const { return mbFloatBtnVisible; } + bool HasHideButton() const { return mbHideBtnVisible; } + 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; } + const Link<>& GetCloseButtonClickHdl() const { return maCloseHdl; } + void SetFloatButtonClickHdl( const Link<>& rLink ) { maFloatHdl = rLink; } + const Link<>& GetFloatButtonClickHdl() const { return maFloatHdl; } + void SetHideButtonClickHdl( const Link<>& rLink ) { maHideHdl = rLink; } + const Link<>& GetHideButtonClickHdl() const { return maHideHdl; } // - by default a menubar is displayable // - if a menubar is not displayable, its MenuBarWindow will never be shown // and it will be hidden if it was visible before // - note: if a menubar is diplayable, this does not necessarily mean that it is currently visible - void SetDisplayable( bool bDisplayable ); - bool IsDisplayable() const { return mbDisplayable; } + void SetDisplayable( bool bDisplayable ); + bool IsDisplayable() const { return mbDisplayable; } struct MenuBarButtonCallbackArg { - sal_uInt16 nId; // Id of the button - bool bHighlight; // highlight on/off - MenuBar* pMenuBar; // menubar the button belongs to + sal_uInt16 nId; // Id of the button + bool bHighlight; // highlight on/off + MenuBar* pMenuBar; // menubar the button belongs to }; // add an arbitrary button to the menubar (will appear next to closer) // passed link will be call with a MenuBarButtonCallbackArg on press // passed string will be set as tooltip - sal_uInt16 AddMenuBarButton( const Image&, const Link<>&, const OUString&, sal_uInt16 nPos = 0 ); + sal_uInt16 AddMenuBarButton( const Image&, const Link<>&, const OUString&, sal_uInt16 nPos = 0 ); // set the highlight link for additional button with ID nId // highlight link will be called with a MenuBarButtonHighlightArg // the bHighlight member of that struct shall contain the new state - void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link<>& ); + void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link<>& ); // returns the rectangle occupied by the additional button named nId // coordinates are relative to the systemwindiow the menubar is attached to // if the menubar is unattached an empty rectangle is returned - Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId ); - void RemoveMenuBarButton( sal_uInt16 nId ); + Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId ); + void RemoveMenuBarButton( sal_uInt16 nId ); }; -inline MenuBar& MenuBar::operator =( const MenuBar& rMenu ) +inline MenuBar& MenuBar::operator=( const MenuBar& rMenu ) { - Menu::operator =( rMenu ); + Menu::operator=(rMenu); return *this; } - - -// - PopupMenu - - - class VCL_DLLPUBLIC PopupMenu : public Menu { friend class Menu; @@ -521,46 +526,52 @@ class VCL_DLLPUBLIC PopupMenu : public Menu friend struct MenuItemData; private: - Menu** pRefAutoSubMenu; // keeps track if a pointer to this Menu is stored in the MenuItemData + Menu** pRefAutoSubMenu; // keeps track if a pointer to this Menu is stored in the MenuItemData SAL_DLLPRIVATE MenuFloatingWindow * ImplGetFloatingWindow() const; protected: - SAL_DLLPRIVATE sal_uInt16 ImplExecute( vcl::Window* pWindow, const Rectangle& rRect, FloatWinPopupFlags nPopupFlags, Menu* pStaredFrom, bool bPreSelectFirst ); - SAL_DLLPRIVATE long ImplCalcHeight( sal_uInt16 nEntries ) const; - SAL_DLLPRIVATE sal_uInt16 ImplCalcVisEntries( long nMaxHeight, sal_uInt16 nStartEntry = 0, sal_uInt16* pLastVisible = NULL ) const; + SAL_DLLPRIVATE sal_uInt16 ImplExecute( vcl::Window* pWindow, const Rectangle& rRect, FloatWinPopupFlags nPopupFlags, Menu* pStaredFrom, bool bPreSelectFirst ); + SAL_DLLPRIVATE long ImplCalcHeight( sal_uInt16 nEntries ) const; + SAL_DLLPRIVATE sal_uInt16 ImplCalcVisEntries( long nMaxHeight, sal_uInt16 nStartEntry = 0, sal_uInt16* pLastVisible = NULL ) const; public: - PopupMenu(); - PopupMenu( const PopupMenu& rMenu ); - explicit PopupMenu( const ResId& ); - virtual ~PopupMenu(); + PopupMenu(); + PopupMenu( const PopupMenu& rMenu ); + explicit PopupMenu( const ResId& ); + virtual ~PopupMenu(); - virtual bool IsMenuBar() const SAL_OVERRIDE { return false; } + virtual bool IsMenuBar() const SAL_OVERRIDE { return false; } /// Close the 'pStartedFrom' menu window. virtual void ClosePopup(Menu* pMenu) SAL_OVERRIDE; - void SetText( const OUString& rTitle ) { aTitleText = rTitle; } - const OUString& GetText() const { return aTitleText; } + void SetText( const OUString& rTitle ) + { + aTitleText = rTitle; + } + const OUString& GetText() const + { + return aTitleText; + } - sal_uInt16 Execute( vcl::Window* pWindow, const Point& rPopupPos ); - sal_uInt16 Execute( vcl::Window* pWindow, const Rectangle& rRect, PopupMenuFlags nFlags = PopupMenuFlags::NONE ); + sal_uInt16 Execute( vcl::Window* pWindow, const Point& rPopupPos ); + sal_uInt16 Execute( vcl::Window* pWindow, const Rectangle& rRect, PopupMenuFlags nFlags = PopupMenuFlags::NONE ); // Fuer das TestTool - void EndExecute( sal_uInt16 nSelect = 0 ); - virtual void SelectItem(sal_uInt16 nId) SAL_OVERRIDE; - void SetSelectedEntry( sal_uInt16 nId ); // for use by native submenu only + void EndExecute( sal_uInt16 nSelect = 0 ); + virtual void SelectItem(sal_uInt16 nId) SAL_OVERRIDE; + void SetSelectedEntry( sal_uInt16 nId ); // for use by native submenu only - static bool IsInExecute(); - static PopupMenu* GetActivePopupMenu(); + static bool IsInExecute(); + static PopupMenu* GetActivePopupMenu(); - PopupMenu& operator =( const PopupMenu& rMenu ); + PopupMenu& operator=( const PopupMenu& rMenu ); }; -inline PopupMenu& PopupMenu::operator =( const PopupMenu& rMenu ) +inline PopupMenu& PopupMenu::operator=( const PopupMenu& rMenu ) { - Menu::operator =( rMenu ); + Menu::operator=( rMenu ); return *this; } diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 1fc1a38f0fa7..0f600bc84d02 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -1365,7 +1365,7 @@ bool Menu::ImplIsSelectable( sal_uInt16 nPos ) const return bSelectable; } -::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > Menu::GetAccessible() +css::uno::Reference<css::accessibility::XAccessible> Menu::GetAccessible() { // Since PopupMenu are sometimes shared by different instances of MenuBar, the mxAccessible member gets // overwritten and may contain a disposed object when the initial menubar gets set again. So use the @@ -1377,11 +1377,11 @@ bool Menu::ImplIsSelectable( sal_uInt16 nPos ) const sal_uInt16 nItemId = pStartedFrom->GetItemId( i ); if ( static_cast< Menu* >( pStartedFrom->GetPopupMenu( nItemId ) ) == this ) { - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xParent = pStartedFrom->GetAccessible(); + css::uno::Reference<css::accessibility::XAccessible> xParent = pStartedFrom->GetAccessible(); if ( xParent.is() ) { - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() ); - if ( xParentContext.is() ) + css::uno::Reference<css::accessibility::XAccessibleContext> xParentContext( xParent->getAccessibleContext() ); + if (xParentContext.is()) return xParentContext->getAccessibleChild( i ); } } @@ -1397,12 +1397,12 @@ bool Menu::ImplIsSelectable( sal_uInt16 nPos ) const return mxAccessible; } -void Menu::SetAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxAccessible ) +void Menu::SetAccessible(const css::uno::Reference<css::accessibility::XAccessible>& rxAccessible ) { mxAccessible = rxAccessible; } -Size Menu::ImplGetNativeCheckAndRadioSize( const vcl::Window* pWin, long& rCheckHeight, long& rRadioHeight ) const +Size Menu::ImplGetNativeCheckAndRadioSize(vcl::RenderContext& rRenderContext, long& rCheckHeight, long& rRadioHeight ) const { long nCheckWidth = 0, nRadioWidth = 0; rCheckHeight = rRadioHeight = 0; @@ -1412,35 +1412,23 @@ Size Menu::ImplGetNativeCheckAndRadioSize( const vcl::Window* pWin, long& rCheck ImplControlValue aVal; Rectangle aNativeBounds; Rectangle aNativeContent; - Point tmp( 0, 0 ); - Rectangle aCtrlRegion( Rectangle( tmp, Size( 100, 15 ) ) ); - if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK ) ) + + Rectangle aCtrlRegion(Rectangle(Point(), Size(100, 15))); + if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK)) { - if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), - ControlPart(PART_MENU_ITEM_CHECK_MARK), - aCtrlRegion, - ControlState(ControlState::ENABLED), - aVal, - OUString(), - aNativeBounds, - aNativeContent ) - ) + if (rRenderContext.GetNativeControlRegion(ControlType(CTRL_MENU_POPUP), ControlPart(PART_MENU_ITEM_CHECK_MARK), + aCtrlRegion, ControlState(ControlState::ENABLED), aVal, OUString(), + aNativeBounds, aNativeContent)) { rCheckHeight = aNativeBounds.GetHeight(); nCheckWidth = aNativeContent.GetWidth(); } } - if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK ) ) + if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK)) { - if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), - ControlPart(PART_MENU_ITEM_RADIO_MARK), - aCtrlRegion, - ControlState(ControlState::ENABLED), - aVal, - OUString(), - aNativeBounds, - aNativeContent ) - ) + if (rRenderContext.GetNativeControlRegion(ControlType(CTRL_MENU_POPUP), ControlPart(PART_MENU_ITEM_RADIO_MARK), + aCtrlRegion, ControlState(ControlState::ENABLED), aVal, OUString(), + aNativeBounds, aNativeContent)) { rRadioHeight = aNativeBounds.GetHeight(); nRadioWidth = aNativeContent.GetWidth(); @@ -1450,34 +1438,24 @@ Size Menu::ImplGetNativeCheckAndRadioSize( const vcl::Window* pWin, long& rCheck return Size(std::max(nCheckWidth, nRadioWidth), std::max(rCheckHeight, rRadioHeight)); } -bool Menu::ImplGetNativeSubmenuArrowSize( vcl::Window* pWin, Size& rArrowSize, long& rArrowSpacing ) const +bool Menu::ImplGetNativeSubmenuArrowSize(vcl::RenderContext& rRenderContext, Size& rArrowSize, long& rArrowSpacing) const { ImplControlValue aVal; Rectangle aNativeBounds; Rectangle aNativeContent; - Point tmp( 0, 0 ); - Rectangle aCtrlRegion( Rectangle( tmp, Size( 100, 15 ) ) ); - if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, - PART_MENU_SUBMENU_ARROW ) ) + Rectangle aCtrlRegion(Rectangle(Point(), Size(100, 15))); + if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_SUBMENU_ARROW)) + { + if (rRenderContext.GetNativeControlRegion(ControlType(CTRL_MENU_POPUP), ControlPart(PART_MENU_SUBMENU_ARROW), + aCtrlRegion, ControlState(ControlState::ENABLED), + aVal, OUString(), aNativeBounds, aNativeContent)) { - if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), - ControlPart(PART_MENU_SUBMENU_ARROW), - aCtrlRegion, - ControlState(ControlState::ENABLED), - aVal, - OUString(), - aNativeBounds, - aNativeContent ) - ) - { - Size aSize( Size ( aNativeContent.GetWidth(), - aNativeContent.GetHeight() ) ); - rArrowSize = aSize; - rArrowSpacing = aNativeBounds.GetWidth() - aNativeContent.GetWidth(); - - return true; - } + Size aSize(aNativeContent.GetWidth(), aNativeContent.GetHeight()); + rArrowSize = aSize; + rArrowSpacing = aNativeBounds.GetWidth() - aNativeContent.GetWidth(); + return true; } + } return false; } @@ -1521,7 +1499,7 @@ Size Menu::ImplCalcSize( vcl::Window* pWin ) long nMinMenuItemHeight = nFontHeight; long nCheckHeight = 0, nRadioHeight = 0; - Size aMaxSize = ImplGetNativeCheckAndRadioSize(pWin, nCheckHeight, nRadioHeight); + Size aMaxSize = ImplGetNativeCheckAndRadioSize(*pWin, nCheckHeight, nRadioHeight); // FIXME if( aMaxSize.Height() > nMinMenuItemHeight ) nMinMenuItemHeight = aMaxSize.Height(); @@ -1739,39 +1717,39 @@ Size Menu::ImplCalcSize( vcl::Window* pWin ) return aSz; } -static void ImplPaintCheckBackground( vcl::Window* i_pWindow, const Rectangle& i_rRect, bool i_bHighlight ) +static void ImplPaintCheckBackground(vcl::RenderContext& rRenderContext, vcl::Window& rWindow, const Rectangle& i_rRect, bool i_bHighlight) { bool bNativeOk = false; - if( i_pWindow->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) + if (rRenderContext.IsNativeControlSupported(CTRL_TOOLBAR, PART_BUTTON)) { ImplControlValue aControlValue; Rectangle aCtrlRegion( i_rRect ); ControlState nState = ControlState::PRESSED | ControlState::ENABLED; - aControlValue.setTristateVal( BUTTONVALUE_ON ); + aControlValue.setTristateVal(BUTTONVALUE_ON); - bNativeOk = i_pWindow->DrawNativeControl( CTRL_TOOLBAR, PART_BUTTON, - aCtrlRegion, nState, aControlValue, - OUString() ); + bNativeOk = rRenderContext.DrawNativeControl(CTRL_TOOLBAR, PART_BUTTON, + aCtrlRegion, nState, aControlValue, + OUString()); } - if( ! bNativeOk ) + if (!bNativeOk) { - const StyleSettings& rSettings = i_pWindow->GetSettings().GetStyleSettings(); + const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings(); Color aColor( i_bHighlight ? rSettings.GetMenuHighlightTextColor() : rSettings.GetHighlightColor() ); - i_pWindow->DrawSelectionBackground( i_rRect, 0, i_bHighlight, true, false, 2, NULL, &aColor ); + RenderTools::DrawSelectionBackground(rRenderContext, rWindow, i_rRect, 0, i_bHighlight, true, false, NULL, 2, &aColor); } } -static OUString getShortenedString( const OUString& i_rLong, vcl::Window* i_pWin, long i_nMaxWidth ) +static OUString getShortenedString( const OUString& i_rLong, vcl::RenderContext& rRenderContext, long i_nMaxWidth ) { sal_Int32 nPos = -1; - OUString aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) ); - aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS ); + OUString aNonMnem(OutputDevice::GetNonMnemonicString(i_rLong, nPos)); + aNonMnem = rRenderContext.GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS); // re-insert mnemonic - if( nPos != -1 ) + if (nPos != -1) { - if( nPos < aNonMnem.getLength() && i_rLong[nPos+1] == aNonMnem[nPos] ) + if (nPos < aNonMnem.getLength() && i_rLong[nPos+1] == aNonMnem[nPos]) { OUStringBuffer aBuf( i_rLong.getLength() ); aBuf.append( aNonMnem.copy( 0, nPos) ); @@ -1815,22 +1793,23 @@ void Menu::ImplPaintMenuTitle(vcl::RenderContext& rRenderContext, const Rectangl rRenderContext.Pop(); } -void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly, +void Menu::ImplPaint(vcl::RenderContext& rRenderContext, + sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly, bool bHighlighted, bool bLayout, bool bRollover) const { // for symbols: nFontHeight x nFontHeight - long nFontHeight = pWin->GetTextHeight(); + long nFontHeight = rRenderContext.GetTextHeight(); long nExtra = nFontHeight / 4; long nCheckHeight = 0, nRadioHeight = 0; - ImplGetNativeCheckAndRadioSize( pWin, nCheckHeight, nRadioHeight ); + ImplGetNativeCheckAndRadioSize(rRenderContext, nCheckHeight, nRadioHeight); - DecorationView aDecoView( pWin ); - const StyleSettings& rSettings = pWin->GetSettings().GetStyleSettings(); + DecorationView aDecoView(&rRenderContext); + const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings(); Point aTopLeft, aTmpPos; - if ( pLogo ) + if (pLogo) aTopLeft.X() = pLogo->aBitmap.GetSizePixel().Width(); int nOuterSpaceX = 0; @@ -1841,54 +1820,54 @@ void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuIt aTopLeft.Y() += ImplGetSVData()->maNWFData.mnMenuFormatBorderY; } - Size aOutSz = pWin->GetOutputSizePixel(); + Size aOutSz = rRenderContext.GetOutputSizePixel(); size_t nCount = pItemList->size(); - if( bLayout ) + if (bLayout) mpLayoutData->m_aVisibleItemBoundRects.clear(); // Paint title if (!pThisItemOnly && !IsMenuBar() && nTitleHeight > 0) - ImplPaintMenuTitle(*pWin/*rRenderContext*/, Rectangle(aTopLeft, aOutSz)); + ImplPaintMenuTitle(rRenderContext, Rectangle(aTopLeft, aOutSz)); - for ( size_t n = 0; n < nCount; n++ ) + for (size_t n = 0; n < nCount; n++) { MenuItemData* pData = pItemList->GetDataFromPos( n ); - if ( ImplIsVisible( n ) && ( !pThisItemOnly || ( pData == pThisItemOnly ) ) ) + if (ImplIsVisible(n) && (!pThisItemOnly || (pData == pThisItemOnly))) { - if ( pThisItemOnly ) + if (pThisItemOnly) { if (IsMenuBar()) { if (bRollover) - pWin->SetTextColor(rSettings.GetMenuBarRolloverTextColor()); + rRenderContext.SetTextColor(rSettings.GetMenuBarRolloverTextColor()); else if (bHighlighted) - pWin->SetTextColor(rSettings.GetMenuBarHighlightTextColor()); + rRenderContext.SetTextColor(rSettings.GetMenuBarHighlightTextColor()); } else { if (bHighlighted) - pWin->SetTextColor(rSettings.GetMenuHighlightTextColor()); + rRenderContext.SetTextColor(rSettings.GetMenuHighlightTextColor()); } } - Point aPos( aTopLeft ); + Point aPos(aTopLeft); aPos.Y() += nBorder; aPos.Y() += nStartY; - if ( aPos.Y() >= 0 ) + if (aPos.Y() >= 0) { - long nTextOffsetY = ((pData->aSz.Height()-nFontHeight)/2); + long nTextOffsetY = ((pData->aSz.Height() - nFontHeight) / 2); if (IsMenuBar()) nTextOffsetY += (aOutSz.Height()-pData->aSz.Height()) / 2; - sal_uInt16 nTextStyle = 0; + sal_uInt16 nTextStyle = 0; DrawSymbolFlags nSymbolStyle = DrawSymbolFlags::NONE; - sal_uInt16 nImageStyle = 0; + sal_uInt16 nImageStyle = 0; // submenus without items are not disabled when no items are // contained. The application itself should check for this! // Otherwise it could happen entries are disabled due to // asynchronous loading - if ( !pData->bEnabled ) + if (!pData->bEnabled) { nTextStyle |= TEXT_DRAW_DISABLE; nSymbolStyle |= DrawSymbolFlags::Disable; @@ -1899,42 +1878,39 @@ void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuIt if (!bLayout && !IsMenuBar() && (pData->eType == MenuItemType::SEPARATOR)) { bool bNativeOk = false; - if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, - PART_MENU_SEPARATOR ) ) + if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_SEPARATOR)) { ControlState nState = ControlState::NONE; - if ( pData->bEnabled ) + if (pData->bEnabled) nState |= ControlState::ENABLED; - if ( bHighlighted ) + if (bHighlighted) nState |= ControlState::SELECTED; - Size aSz( pData->aSz ); - aSz.Width() = aOutSz.Width() - 2*nOuterSpaceX; - Rectangle aItemRect( aPos, aSz ); - MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect ); - bNativeOk = pWin->DrawNativeControl( CTRL_MENU_POPUP, PART_MENU_SEPARATOR, - aItemRect, - nState, - aVal, - OUString() ); + Size aSz(pData->aSz); + aSz.Width() = aOutSz.Width() - 2 * nOuterSpaceX; + Rectangle aItemRect(aPos, aSz); + MenupopupValue aVal(nTextPos - GUTTERBORDER, aItemRect); + bNativeOk = rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_MENU_SEPARATOR, + aItemRect, nState, aVal, OUString()); } - if( ! bNativeOk ) + if (!bNativeOk) { - aTmpPos.Y() = aPos.Y() + ((pData->aSz.Height()-2)/2); + aTmpPos.Y() = aPos.Y() + ((pData->aSz.Height() - 2) / 2); aTmpPos.X() = aPos.X() + 2 + nOuterSpaceX; - pWin->SetLineColor( rSettings.GetShadowColor() ); - pWin->DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) ); + rRenderContext.SetLineColor(rSettings.GetShadowColor()); + rRenderContext.DrawLine(aTmpPos, Point(aOutSz.Width() - 3 - 2 * nOuterSpaceX, aTmpPos.Y())); aTmpPos.Y()++; - pWin->SetLineColor( rSettings.GetLightColor() ); - pWin->DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) ); - pWin->SetLineColor(); + rRenderContext.SetLineColor(rSettings.GetLightColor()); + rRenderContext.DrawLine(aTmpPos, Point(aOutSz.Width() - 3 - 2 * nOuterSpaceX, aTmpPos.Y())); + rRenderContext.SetLineColor(); } } - Rectangle aOuterCheckRect( Point( aPos.X()+nImgOrChkPos, aPos.Y() ), Size( pData->aSz.Height(), pData->aSz.Height() ) ); - aOuterCheckRect.Left() += 1; - aOuterCheckRect.Right() -= 1; - aOuterCheckRect.Top() += 1; - aOuterCheckRect.Bottom() -= 1; + Rectangle aOuterCheckRect(Point(aPos.X()+nImgOrChkPos, aPos.Y()), + Size(pData->aSz.Height(), pData->aSz.Height())); + aOuterCheckRect.Left() += 1; + aOuterCheckRect.Right() -= 1; + aOuterCheckRect.Top() += 1; + aOuterCheckRect.Bottom() -= 1; // CheckMark if (!bLayout && !IsMenuBar() && pData->HasCheck()) @@ -1945,12 +1921,12 @@ void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuIt // however do not do this if native checks will be painted since // the selection color too often does not fit the theme's check and/or radio - if( ! ( ( pData->eType == MenuItemType::IMAGE ) || ( pData->eType == MenuItemType::STRINGIMAGE ) ) ) + if( !((pData->eType == MenuItemType::IMAGE) || (pData->eType == MenuItemType::STRINGIMAGE))) { - if ( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, - (pData->nBits & MenuItemBits::RADIOCHECK) - ? PART_MENU_ITEM_CHECK_MARK - : PART_MENU_ITEM_RADIO_MARK ) ) + if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, + (pData->nBits & MenuItemBits::RADIOCHECK) + ? PART_MENU_ITEM_CHECK_MARK + : PART_MENU_ITEM_RADIO_MARK)) { ControlPart nPart = ((pData->nBits & MenuItemBits::RADIOCHECK) ? PART_MENU_ITEM_RADIO_MARK @@ -1958,50 +1934,47 @@ void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuIt ControlState nState = ControlState::NONE; - if ( pData->bChecked ) + if (pData->bChecked) nState |= ControlState::PRESSED; - if ( pData->bEnabled ) + if (pData->bEnabled) nState |= ControlState::ENABLED; - if ( bHighlighted ) + if (bHighlighted) nState |= ControlState::SELECTED; long nCtrlHeight = (pData->nBits & MenuItemBits::RADIOCHECK) ? nCheckHeight : nRadioHeight; - aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - nCtrlHeight)/2; - aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - nCtrlHeight)/2; - - Rectangle aCheckRect( aTmpPos, Size( nCtrlHeight, nCtrlHeight ) ); - Size aSz( pData->aSz ); - aSz.Width() = aOutSz.Width() - 2*nOuterSpaceX; - Rectangle aItemRect( aPos, aSz ); - MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect ); - pWin->DrawNativeControl( CTRL_MENU_POPUP, nPart, - aCheckRect, - nState, - aVal, - OUString() ); + aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - nCtrlHeight) / 2; + aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - nCtrlHeight) / 2; + + Rectangle aCheckRect(aTmpPos, Size(nCtrlHeight, nCtrlHeight)); + Size aSz(pData->aSz); + aSz.Width() = aOutSz.Width() - 2 * nOuterSpaceX; + Rectangle aItemRect(aPos, aSz); + MenupopupValue aVal(nTextPos - GUTTERBORDER, aItemRect); + rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, nPart, aCheckRect, + nState, aVal, OUString()); } - else if ( pData->bChecked ) // by default do nothing for unchecked items + else if (pData->bChecked) // by default do nothing for unchecked items { - ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted ); + ImplPaintCheckBackground(rRenderContext, *pWindow, aOuterCheckRect, pThisItemOnly && bHighlighted); SymbolType eSymbol; Size aSymbolSize; - if ( pData->nBits & MenuItemBits::RADIOCHECK ) + if (pData->nBits & MenuItemBits::RADIOCHECK) { eSymbol = SymbolType::RADIOCHECKMARK; - aSymbolSize = Size( nFontHeight/2, nFontHeight/2 ); + aSymbolSize = Size(nFontHeight / 2, nFontHeight / 2); } else { eSymbol = SymbolType::CHECKMARK; - aSymbolSize = Size( (nFontHeight*25)/40, nFontHeight/2 ); + aSymbolSize = Size((nFontHeight * 25) / 40, nFontHeight / 2); } - aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - aSymbolSize.Width())/2; - aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - aSymbolSize.Height())/2; - Rectangle aRect( aTmpPos, aSymbolSize ); - aDecoView.DrawSymbol( aRect, eSymbol, pWin->GetTextColor(), nSymbolStyle ); + aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - aSymbolSize.Width()) / 2; + aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - aSymbolSize.Height()) / 2; + Rectangle aRect(aTmpPos, aSymbolSize); + aDecoView.DrawSymbol(aRect, eSymbol, rRenderContext.GetTextColor(), nSymbolStyle); } } } @@ -2010,12 +1983,12 @@ void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuIt if (!bLayout && !IsMenuBar() && ((pData->eType == MenuItemType::IMAGE) || (pData->eType == MenuItemType::STRINGIMAGE))) { // Don't render an image for a check thing - if( pData->bChecked ) - ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted ); + if (pData->bChecked) + ImplPaintCheckBackground(rRenderContext, *pWindow, aOuterCheckRect, pThisItemOnly && bHighlighted); Image aImage = pData->aImage; - sal_Int32 nScaleFactor = pWindow->GetDPIScaleFactor(); + sal_Int32 nScaleFactor = rRenderContext.GetDPIScaleFactor(); if (nScaleFactor != 1) { BitmapEx aBitmap = aImage.GetBitmapEx(); @@ -2025,174 +1998,164 @@ void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuIt aTmpPos = aOuterCheckRect.TopLeft(); aTmpPos.X() += (aOuterCheckRect.GetWidth() - aImage.GetSizePixel().Width()) / 2; aTmpPos.Y() += (aOuterCheckRect.GetHeight() - aImage.GetSizePixel().Height()) / 2; - pWin->DrawImage(aTmpPos, aImage, nImageStyle); + rRenderContext.DrawImage(aTmpPos, aImage, nImageStyle); } // Text: - if ( ( pData->eType == MenuItemType::STRING ) || ( pData->eType == MenuItemType::STRINGIMAGE ) ) + if ((pData->eType == MenuItemType::STRING ) || (pData->eType == MenuItemType::STRINGIMAGE)) { aTmpPos.X() = aPos.X() + nTextPos; aTmpPos.Y() = aPos.Y(); aTmpPos.Y() += nTextOffsetY; - sal_uInt16 nStyle = nTextStyle|TEXT_DRAW_MNEMONIC; - if ( pData->bIsTemporary ) + sal_uInt16 nStyle = nTextStyle | TEXT_DRAW_MNEMONIC; + if (pData->bIsTemporary) nStyle |= TEXT_DRAW_DISABLE; MetricVector* pVector = bLayout ? &mpLayoutData->m_aUnicodeBoundRects : NULL; OUString* pDisplayText = bLayout ? &mpLayoutData->m_aDisplayText : NULL; - if( bLayout ) + if (bLayout) { - mpLayoutData->m_aLineIndices.push_back( mpLayoutData->m_aDisplayText.getLength() ); - mpLayoutData->m_aLineItemIds.push_back( pData->nId ); - mpLayoutData->m_aLineItemPositions.push_back( n ); + mpLayoutData->m_aLineIndices.push_back(mpLayoutData->m_aDisplayText.getLength()); + mpLayoutData->m_aLineItemIds.push_back(pData->nId); + mpLayoutData->m_aLineItemPositions.push_back(n); } // #i47946# with NWF painted menus the background is transparent // since DrawCtrlText can depend on the background (e.g. for // TEXT_DRAW_DISABLE), temporarily set a background which // hopefully matches the NWF background since it is read // from the system style settings - bool bSetTmpBackground = !pWin->IsBackground() && pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ); - if( bSetTmpBackground ) + bool bSetTmpBackground = !rRenderContext.IsBackground() + && rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL); + if (bSetTmpBackground) { - Color aBg = IsMenuBar()? - pWin->GetSettings().GetStyleSettings().GetMenuBarColor() : - pWin->GetSettings().GetStyleSettings().GetMenuColor(); - pWin->SetBackground( Wallpaper( aBg ) ); + Color aBg = IsMenuBar() ? rRenderContext.GetSettings().GetStyleSettings().GetMenuBarColor() + : rRenderContext.GetSettings().GetStyleSettings().GetMenuColor(); + rRenderContext.SetBackground(Wallpaper(aBg)); } // how much space is there for the text ? long nMaxItemTextWidth = aOutSz.Width() - aTmpPos.X() - nExtra - nOuterSpaceX; if (!IsMenuBar() && pData->aAccelKey.GetCode() && !ImplAccelDisabled()) { OUString aAccText = pData->aAccelKey.GetName(); - nMaxItemTextWidth -= pWin->GetTextWidth( aAccText ) + 3*nExtra; + nMaxItemTextWidth -= rRenderContext.GetTextWidth(aAccText) + 3 * nExtra; } if (!IsMenuBar() && pData->pSubMenu) { nMaxItemTextWidth -= nFontHeight - nExtra; } - OUString aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) ); - pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.getLength(), nStyle, pVector, pDisplayText ); - if( bSetTmpBackground ) - pWin->SetBackground(); + OUString aItemText(getShortenedString(pData->aText, rRenderContext, nMaxItemTextWidth)); + rRenderContext.DrawCtrlText(aTmpPos, aItemText, 0, aItemText.getLength(), nStyle, pVector, pDisplayText); + if (bSetTmpBackground) + rRenderContext.SetBackground(); } // Accel if (!bLayout && !IsMenuBar() && pData->aAccelKey.GetCode() && !ImplAccelDisabled()) { OUString aAccText = pData->aAccelKey.GetName(); - aTmpPos.X() = aOutSz.Width() - pWin->GetTextWidth( aAccText ); - aTmpPos.X() -= 4*nExtra; + aTmpPos.X() = aOutSz.Width() - rRenderContext.GetTextWidth(aAccText); + aTmpPos.X() -= 4 * nExtra; aTmpPos.X() -= nOuterSpaceX; aTmpPos.Y() = aPos.Y(); aTmpPos.Y() += nTextOffsetY; - pWin->DrawCtrlText( aTmpPos, aAccText, 0, aAccText.getLength(), nTextStyle ); + rRenderContext.DrawCtrlText(aTmpPos, aAccText, 0, aAccText.getLength(), nTextStyle); } // SubMenu? if (!bLayout && !IsMenuBar() && pData->pSubMenu) { bool bNativeOk = false; - if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, - PART_MENU_SUBMENU_ARROW ) ) + if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_SUBMENU_ARROW)) { ControlState nState = ControlState::NONE; - Size aTmpSz( 0, 0 ); + Size aTmpSz(0, 0); long aSpacing = 0; - if( !ImplGetNativeSubmenuArrowSize( pWin, - aTmpSz, aSpacing ) ) + if (!ImplGetNativeSubmenuArrowSize(rRenderContext, aTmpSz, aSpacing)) { - aTmpSz = Size( nFontHeight, nFontHeight ); + aTmpSz = Size(nFontHeight, nFontHeight); aSpacing = nOuterSpaceX; } - if ( pData->bEnabled ) + if (pData->bEnabled) nState |= ControlState::ENABLED; - if ( bHighlighted ) + if (bHighlighted) nState |= ControlState::SELECTED; aTmpPos.X() = aOutSz.Width() - aTmpSz.Width() - aSpacing - nOuterSpaceX; aTmpPos.Y() = aPos.Y() + ( pData->aSz.Height() - aTmpSz.Height() ) / 2; - aTmpPos.Y() += nExtra/2; + aTmpPos.Y() += nExtra / 2; - Rectangle aItemRect( aTmpPos, aTmpSz ); - MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect ); - bNativeOk = pWin->DrawNativeControl( CTRL_MENU_POPUP, - PART_MENU_SUBMENU_ARROW, - aItemRect, - nState, - aVal, - OUString() ); + Rectangle aItemRect(aTmpPos, aTmpSz); + MenupopupValue aVal(nTextPos - GUTTERBORDER, aItemRect); + bNativeOk = rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_MENU_SUBMENU_ARROW, + aItemRect, nState, aVal, OUString()); } - if( ! bNativeOk ) + if (!bNativeOk) { aTmpPos.X() = aOutSz.Width() - nFontHeight + nExtra - nOuterSpaceX; aTmpPos.Y() = aPos.Y(); aTmpPos.Y() += nExtra/2; - aTmpPos.Y() += ( pData->aSz.Height() / 2 ) - ( nFontHeight/4 ); - if ( pData->nBits & MenuItemBits::POPUPSELECT ) + aTmpPos.Y() += (pData->aSz.Height() / 2) - (nFontHeight / 4); + if (pData->nBits & MenuItemBits::POPUPSELECT) { - pWin->SetTextColor( rSettings.GetMenuTextColor() ); - Point aTmpPos2( aPos ); + rRenderContext.SetTextColor(rSettings.GetMenuTextColor()); + Point aTmpPos2(aPos); aTmpPos2.X() = aOutSz.Width() - nFontHeight - nFontHeight/4; - aDecoView.DrawFrame( - Rectangle( aTmpPos2, Size( nFontHeight+nFontHeight/4, pData->aSz.Height() ) ), DrawFrameStyle::Group ); + aDecoView.DrawFrame(Rectangle(aTmpPos2, Size(nFontHeight + nFontHeight / 4, + pData->aSz.Height())), + DrawFrameStyle::Group); } - aDecoView.DrawSymbol( - Rectangle( aTmpPos, Size( nFontHeight/2, nFontHeight/2 ) ), - SymbolType::SPIN_RIGHT, pWin->GetTextColor(), nSymbolStyle ); + aDecoView.DrawSymbol(Rectangle(aTmpPos, Size(nFontHeight / 2, nFontHeight / 2)), + SymbolType::SPIN_RIGHT, rRenderContext.GetTextColor(), nSymbolStyle); } } - if ( pThisItemOnly && bHighlighted ) + if (pThisItemOnly && bHighlighted) { // This restores the normal menu or menu bar text // color for when it is no longer highlighted. if (IsMenuBar()) - pWin->SetTextColor( rSettings.GetMenuBarTextColor() ); + rRenderContext.SetTextColor(rSettings.GetMenuBarTextColor()); else - pWin->SetTextColor( rSettings.GetMenuTextColor() ); + rRenderContext.SetTextColor(rSettings.GetMenuTextColor()); } } if( bLayout ) { if (!IsMenuBar()) - mpLayoutData->m_aVisibleItemBoundRects[ n ] = Rectangle( aTopLeft, Size( aOutSz.Width(), pData->aSz.Height() ) ); + mpLayoutData->m_aVisibleItemBoundRects[ n ] = Rectangle(aTopLeft, Size(aOutSz.Width(), pData->aSz.Height())); else - mpLayoutData->m_aVisibleItemBoundRects[ n ] = Rectangle( aTopLeft, pData->aSz ); + mpLayoutData->m_aVisibleItemBoundRects[ n ] = Rectangle(aTopLeft, pData->aSz); } } if (!IsMenuBar()) - { aTopLeft.Y() += pData->aSz.Height(); - } else - { aTopLeft.X() += pData->aSz.Width(); - } } - if ( !bLayout && !pThisItemOnly && pLogo ) + if (!bLayout && !pThisItemOnly && pLogo) { Size aLogoSz = pLogo->aBitmap.GetSizePixel(); - Rectangle aRect( Point( 0, 0 ), Point( aLogoSz.Width()-1, aOutSz.Height() ) ); - if ( pWin->GetColorCount() >= 256 ) + Rectangle aRect(Point(), Point(aLogoSz.Width() - 1, aOutSz.Height())); + if (rRenderContext.GetColorCount() >= 256) { - Gradient aGrad( GradientStyle_LINEAR, pLogo->aStartColor, pLogo->aEndColor ); - aGrad.SetAngle( 1800 ); - aGrad.SetBorder( 15 ); - pWin->DrawGradient( aRect, aGrad ); + Gradient aGrad(GradientStyle_LINEAR, pLogo->aStartColor, pLogo->aEndColor); + aGrad.SetAngle(1800); + aGrad.SetBorder(15); + rRenderContext.DrawGradient(aRect, aGrad); } else { - pWin->SetFillColor( pLogo->aStartColor ); - pWin->DrawRect( aRect ); + rRenderContext.SetFillColor(pLogo->aStartColor); + rRenderContext.DrawRect(aRect); } - Point aLogoPos( 0, aOutSz.Height() - aLogoSz.Height() ); - pLogo->aBitmap.Draw( pWin, aLogoPos ); + Point aLogoPos(0, aOutSz.Height() - aLogoSz.Height()); + pLogo->aBitmap.Draw(&rRenderContext, aLogoPos); } } @@ -2329,17 +2292,17 @@ void Menu::ImplKillLayoutData() const void Menu::ImplFillLayoutData() const { - if( pWindow && pWindow->IsReallyVisible() ) + if (pWindow && pWindow->IsReallyVisible()) { mpLayoutData = new MenuLayoutData(); if (IsMenuBar()) { - ImplPaint( pWindow, 0, 0, 0, false, true ); + ImplPaint(*pWindow, 0, 0, 0, false, true); // FIXME } else { MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get()); - ImplPaint( pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), 0, false, true ); + ImplPaint(*pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), 0, false, true); //FIXME } } } @@ -2391,9 +2354,9 @@ Rectangle Menu::GetBoundingRectangle( sal_uInt16 nPos ) const { Rectangle aRet; - if( ! mpLayoutData ) + if (!mpLayoutData ) ImplFillLayoutData(); - if( mpLayoutData ) + if (mpLayoutData) { std::map< sal_uInt16, Rectangle >::const_iterator it = mpLayoutData->m_aVisibleItemBoundRects.find( nPos ); if( it != mpLayoutData->m_aVisibleItemBoundRects.end() ) @@ -2404,13 +2367,13 @@ Rectangle Menu::GetBoundingRectangle( sal_uInt16 nPos ) const void Menu::SetAccessibleName( sal_uInt16 nItemId, const OUString& rStr ) { - size_t nPos; + size_t nPos; MenuItemData* pData = pItemList->GetData( nItemId, nPos ); - if ( pData && !rStr.equals( pData->aAccessibleName ) ) + if (pData && !rStr.equals(pData->aAccessibleName)) { pData->aAccessibleName = rStr; - ImplCallEventListeners( VCLEVENT_MENU_ACCESSIBLENAMECHANGED, nPos ); + ImplCallEventListeners(VCLEVENT_MENU_ACCESSIBLENAMECHANGED, nPos); } } diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx index 756c6afad06e..407e0c86ff36 100644 --- a/vcl/source/window/menubarwindow.cxx +++ b/vcl/source/window/menubarwindow.cxx @@ -665,7 +665,7 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 rRenderContext.Erase(aRect); } rRenderContext.Pop(); - pMenu->ImplPaint(this, 0, 0, pData, bHighlight, false, bRollover); + pMenu->ImplPaint(rRenderContext, 0, 0, pData, bHighlight, false, bRollover); } return; } @@ -900,7 +900,7 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&) } rRenderContext.SetFillColor(rStyleSettings.GetMenuColor()); - pMenu->ImplPaint(this, 0); + pMenu->ImplPaint(rRenderContext, 0); if (nHighlightedItem != ITEMPOS_INVALID) HighlightItem(rRenderContext, nHighlightedItem, true); diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index a3773b673320..e9cfd06210e1 100644 --- a/vcl/source/window/menufloatingwindow.cxx +++ b/vcl/source/window/menufloatingwindow.cxx @@ -791,7 +791,7 @@ void MenuFloatingWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_u rRenderContext.DrawRect(aItemRect); } - pMenu->ImplPaint(this, nScrollerHeight, nStartY, pData, bHighlight); + pMenu->ImplPaint(rRenderContext, nScrollerHeight, nStartY, pData, bHighlight); if (bRestoreLineColor) rRenderContext.SetLineColor(oldLineColor); } @@ -1103,7 +1103,7 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const Rectang ImplDrawScroller(rRenderContext, false); } rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor()); - pMenu->ImplPaint(this, nScrollerHeight, ImplGetStartY()); + pMenu->ImplPaint(rRenderContext, nScrollerHeight, ImplGetStartY()); if (nHighlightedItem != ITEMPOS_INVALID) HighlightItem(rRenderContext, nHighlightedItem, true); } |