1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _SFXVIRTMENU_HXX 28 #define _SFXVIRTMENU_HXX 29 30 31 #include <svl/svarray.hxx> 32 #include <sfx2/mnuitem.hxx> 33 #include "mnucfga.hxx" 34 35 class SfxBindings; 36 class Timer; 37 class SfxMenuImageControl_Impl; 38 39 SV_DECL_PTRARR_DEL( SfxMenuCtrlArr_Impl, SfxMenuControl*, 2, 2 ) 40 41 class SAL_DLLPUBLIC_EXPORT SfxVirtualMenu 42 { 43 friend class SfxMenuControl; 44 45 private: 46 Menu* pSVMenu; 47 SfxVirtualMenu* pParent; 48 SfxMenuCtrlArr_Impl* pAppCtrl; 49 SfxMenuControl* pItems; 50 SfxMenuImageControl_Impl* pImageControl; 51 SfxBindings* pBindings; 52 ResMgr* pResMgr; 53 PopupMenu* pWindowMenu; 54 PopupMenu* pPickMenu; 55 PopupMenu* pAddonsMenu; 56 Timer* pAutoDeactivate; // Hack fuer QAP-Bug 57 sal_uInt16 nVisibleItems; 58 sal_uInt16 nId; 59 sal_uInt16 nCount; 60 sal_uInt16 nLocks; 61 sal_Bool bResCtor : 1; // SV Menu created from resource 62 sal_Bool bOLE : 1; // InPlaceMenu 63 sal_Bool bHelpInitialized : 1; 64 sal_Bool bIsActive : 1; 65 sal_Bool bControllersUnBound : 1; 66 sal_Bool bWasHighContrast : 1; 67 sal_Bool bIsAddonPopupMenu : 1; 68 69 private: 70 void Construct_Impl(); 71 bool Bind_Impl( Menu *pMenu ); 72 inline SfxMenuCtrlArr_Impl& GetAppCtrl_Impl() 73 { 74 return pAppCtrl? *pAppCtrl: *(pAppCtrl = new SfxMenuCtrlArr_Impl) ; 75 } 76 void UnbindControllers(); 77 void BindControllers(); 78 79 protected: 80 SfxVirtualMenu( sal_uInt16 nOwnId, SfxVirtualMenu* pParent, Menu& rMenu, sal_Bool bWithHelp, 81 SfxBindings &rBind, sal_Bool bOLEServer=sal_False, sal_Bool bRes=sal_False, sal_Bool bIsAddonMenu=sal_False ); 82 83 void CreateFromSVMenu(); 84 DECL_LINK( Highlight, Menu * ); 85 DECL_LINK( Activate, Menu * ); 86 DECL_LINK( Deactivate, Menu * ); 87 DECL_LINK( SettingsChanged, void* ); 88 89 // Used for runtime popup menus 90 void UpdateImages( Menu* pMenu ); 91 void RemoveMenuImages( Menu* pMenu ); 92 void InsertAddOnsMenuItem( Menu* pMenu ); 93 94 public: 95 ~SfxVirtualMenu(); 96 SfxVirtualMenu( Menu *pStarViewMenu, sal_Bool bWithHelp, 97 SfxBindings &rBind, sal_Bool bOLEServer=sal_False, sal_Bool bRes=sal_False, sal_Bool bIsAddonMenu=sal_False ); 98 void CheckItem( sal_uInt16 nItemId, sal_Bool bCheck ); 99 void EnableItem( sal_uInt16 nItemId, sal_Bool bEnable ); 100 void SetItemText( sal_uInt16 nItemId, const String& rText ); 101 102 sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; 103 104 sal_uInt16 GetItemCount() const; 105 Menu* GetSVMenu() const; 106 SfxMenuControl& operator[]( sal_uInt16 nPos ) const; 107 108 sal_uInt16 GetItemId( sal_uInt16 nPos ) const; 109 SfxVirtualMenu* GetPopupMenu( sal_uInt16 nId ) const; 110 String GetItemText( sal_uInt16 nId ) const; 111 String GetItemHelpText( sal_uInt16 nId ) const; 112 113 //void InvalidateKeyCodes(); 114 115 SfxVirtualMenu* GetParentMenu() const { return pParent; } 116 void SetParentMenu( SfxVirtualMenu* pNewParent ) 117 { pParent = pNewParent; } 118 119 void SetPopupMenu( sal_uInt16 nId, PopupMenu *pMenu ); 120 sal_Bool IsFromResource() const 121 { return bResCtor; } 122 void InitPopup(sal_uInt16 nPos, sal_Bool bOLE = sal_True); 123 void InitializeHelp(); 124 void SetResMgr(ResMgr* pMgr) {pResMgr = pMgr; } 125 ResMgr* GetResMgr() { return pResMgr; } 126 void SetHelpIds( ResMgr* ); 127 sal_Bool IsHiContrastMode() const; 128 void UpdateImages(); 129 130 DECL_LINK( Select, Menu * ); 131 }; 132 133 //-------------------------------------------------------------------- 134 135 // return the number of virtual items in this menu 136 137 inline sal_uInt16 SfxVirtualMenu::GetItemCount() const 138 { 139 return nCount; 140 } 141 //-------------------------------------------------------------------- 142 143 // 144 145 inline SfxMenuControl& SfxVirtualMenu::operator[]( sal_uInt16 nPos ) const 146 { 147 return *(pItems+nPos); 148 } 149 //-------------------------------------------------------------------- 150 151 // returns the item id at position nPos in the menu (or 0 if sep.) 152 153 inline sal_uInt16 SfxVirtualMenu::GetItemId( sal_uInt16 nPos ) const 154 { 155 return pItems ? pItems[nPos].GetId() : 0; 156 } 157 158 159 #endif 160