1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef SFXVIRTMENU_HXX
20 #define SFXVIRTMENU_HXX
22 #include <boost/ptr_container/ptr_vector.hpp>
24 #include <sfx2/mnuitem.hxx>
28 class SfxMenuImageControl_Impl
;
30 typedef ::boost::ptr_vector
<SfxMenuControl
> SfxMenuCtrlArr_Impl
;
32 class SAL_DLLPUBLIC_EXPORT SfxVirtualMenu
34 friend class SfxMenuControl
;
38 SfxVirtualMenu
* pParent
;
39 SfxMenuCtrlArr_Impl
* pAppCtrl
;
40 SfxMenuControl
* pItems
;
41 SfxMenuImageControl_Impl
* pImageControl
;
42 SfxBindings
* pBindings
;
44 PopupMenu
* pWindowMenu
;
46 PopupMenu
* pAddonsMenu
;
47 Timer
* pAutoDeactivate
; // Hack for QAP-Bug
48 sal_uInt16 nVisibleItems
;
52 sal_Bool bResCtor
: 1; // SV Menu created from resource
53 sal_Bool bOLE
: 1; // InPlaceMenu
54 sal_Bool bHelpInitialized
: 1;
55 sal_Bool bIsActive
: 1;
56 sal_Bool bControllersUnBound
: 1;
57 sal_Bool bIsAddonPopupMenu
: 1;
60 void Construct_Impl();
61 bool Bind_Impl( Menu
*pMenu
);
62 inline SfxMenuCtrlArr_Impl
& GetAppCtrl_Impl()
64 return pAppCtrl
? *pAppCtrl
: *(pAppCtrl
= new SfxMenuCtrlArr_Impl
) ;
66 void UnbindControllers();
67 void BindControllers();
70 SfxVirtualMenu( sal_uInt16 nOwnId
, SfxVirtualMenu
* pParent
, Menu
& rMenu
, sal_Bool bWithHelp
,
71 SfxBindings
&rBind
, sal_Bool bOLEServer
=sal_False
, sal_Bool bRes
=sal_False
, sal_Bool bIsAddonMenu
=sal_False
);
73 void CreateFromSVMenu();
74 DECL_LINK( Highlight
, Menu
* );
75 DECL_LINK( Activate
, Menu
* );
76 DECL_LINK( Deactivate
, Menu
* );
77 DECL_LINK( SettingsChanged
, void* );
79 // Used for runtime popup menus
80 void UpdateImages( Menu
* pMenu
);
81 void RemoveMenuImages( Menu
* pMenu
);
82 void InsertAddOnsMenuItem( Menu
* pMenu
);
86 SfxVirtualMenu( Menu
*pStarViewMenu
, sal_Bool bWithHelp
,
87 SfxBindings
&rBind
, sal_Bool bOLEServer
=sal_False
, sal_Bool bRes
=sal_False
, sal_Bool bIsAddonMenu
=sal_False
);
88 void CheckItem( sal_uInt16 nItemId
, sal_Bool bCheck
);
89 void EnableItem( sal_uInt16 nItemId
, sal_Bool bEnable
);
90 void SetItemText( sal_uInt16 nItemId
, const String
& rText
);
92 sal_uInt16
GetItemCount() const;
93 Menu
* GetSVMenu() const;
94 SfxMenuControl
& operator[]( sal_uInt16 nPos
) const;
96 sal_uInt16
GetItemId( sal_uInt16 nPos
) const;
98 SfxVirtualMenu
* GetParentMenu() const { return pParent
; }
99 void SetParentMenu( SfxVirtualMenu
* pNewParent
)
100 { pParent
= pNewParent
; }
102 void SetPopupMenu( sal_uInt16 nId
, PopupMenu
*pMenu
);
103 sal_Bool
IsFromResource() const
105 void InitPopup(sal_uInt16 nPos
, sal_Bool bOLE
= sal_True
);
106 void InitializeHelp();
107 void SetResMgr(ResMgr
* pMgr
) {pResMgr
= pMgr
; }
108 ResMgr
* GetResMgr() { return pResMgr
; }
110 DECL_LINK( Select
, Menu
* );
113 //--------------------------------------------------------------------
115 // return the number of virtual items in this menu
117 inline sal_uInt16
SfxVirtualMenu::GetItemCount() const
121 //--------------------------------------------------------------------
124 inline SfxMenuControl
& SfxVirtualMenu::operator[]( sal_uInt16 nPos
) const
126 return *(pItems
+nPos
);
128 //--------------------------------------------------------------------
130 // returns the item id at position nPos in the menu (or 0 if sep.)
132 inline sal_uInt16
SfxVirtualMenu::GetItemId( sal_uInt16 nPos
) const
134 return pItems
? pItems
[nPos
].GetId() : 0;
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */