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"
37 class SfxMenuImageControl_Impl
;
39 SV_DECL_PTRARR_DEL( SfxMenuCtrlArr_Impl
, SfxMenuControl
*, 2, 2 )
41 class SAL_DLLPUBLIC_EXPORT SfxVirtualMenu
43 friend class SfxMenuControl
;
47 SfxVirtualMenu
* pParent
;
48 SfxMenuCtrlArr_Impl
* pAppCtrl
;
49 SfxMenuControl
* pItems
;
50 SfxMenuImageControl_Impl
* pImageControl
;
51 SfxBindings
* pBindings
;
53 PopupMenu
* pWindowMenu
;
55 PopupMenu
* pAddonsMenu
;
56 Timer
* pAutoDeactivate
; // Hack fuer QAP-Bug
57 sal_uInt16 nVisibleItems
;
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;
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();
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
);
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
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;
130 DECL_LINK( Select
, Menu
* );
133 //--------------------------------------------------------------------
135 // return the number of virtual items in this menu
137 inline sal_uInt16
SfxVirtualMenu::GetItemCount() const
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;