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