merged tag ooo/DEV300_m102
[LibreOffice.git] / sfx2 / source / inc / virtmenu.hxx
blobc54a627e2a7801b4b9a3033ffa08aeb0af8269f0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
27 #ifndef _SFXVIRTMENU_HXX
28 #define _SFXVIRTMENU_HXX
31 #include <svl/svarray.hxx>
32 #include <sfx2/mnuitem.hxx>
33 #include "mnucfga.hxx"
35 class SfxBindings;
36 class Timer;
37 class SfxMenuImageControl_Impl;
39 SV_DECL_PTRARR_DEL( SfxMenuCtrlArr_Impl, SfxMenuControl*, 2, 2 )
41 class SAL_DLLPUBLIC_EXPORT SfxVirtualMenu
43 friend class SfxMenuControl;
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;
69 private:
70 void Construct_Impl();
71 bool Bind_Impl( Menu *pMenu );
72 inline SfxMenuCtrlArr_Impl& GetAppCtrl_Impl()
74 return pAppCtrl? *pAppCtrl: *(pAppCtrl = new SfxMenuCtrlArr_Impl) ;
76 void UnbindControllers();
77 void BindControllers();
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 );
83 void CreateFromSVMenu();
84 DECL_LINK( Highlight, Menu * );
85 DECL_LINK( Activate, Menu * );
86 DECL_LINK( Deactivate, Menu * );
87 DECL_LINK( SettingsChanged, void* );
89 // Used for runtime popup menus
90 void UpdateImages( Menu* pMenu );
91 void RemoveMenuImages( Menu* pMenu );
92 void InsertAddOnsMenuItem( Menu* pMenu );
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 );
102 sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const;
104 sal_uInt16 GetItemCount() const;
105 Menu* GetSVMenu() const;
106 SfxMenuControl& operator[]( sal_uInt16 nPos ) const;
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;
113 //void InvalidateKeyCodes();
115 SfxVirtualMenu* GetParentMenu() const { return pParent; }
116 void SetParentMenu( SfxVirtualMenu* pNewParent )
117 { pParent = pNewParent; }
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();
130 DECL_LINK( Select, Menu * );
133 //--------------------------------------------------------------------
135 // return the number of virtual items in this menu
137 inline sal_uInt16 SfxVirtualMenu::GetItemCount() const
139 return nCount;
141 //--------------------------------------------------------------------
145 inline SfxMenuControl& SfxVirtualMenu::operator[]( sal_uInt16 nPos ) const
147 return *(pItems+nPos);
149 //--------------------------------------------------------------------
151 // returns the item id at position nPos in the menu (or 0 if sep.)
153 inline sal_uInt16 SfxVirtualMenu::GetItemId( sal_uInt16 nPos ) const
155 return pItems ? pItems[nPos].GetId() : 0;
159 #endif