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