Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SFX2_SOURCE_INC_VIRTMENU_HXX
20 : #define INCLUDED_SFX2_SOURCE_INC_VIRTMENU_HXX
21 :
22 : #include <boost/ptr_container/ptr_vector.hpp>
23 :
24 : #include <sfx2/mnuitem.hxx>
25 :
26 : class SfxBindings;
27 : class SfxMenuImageControl_Impl;
28 :
29 : typedef ::boost::ptr_vector<SfxMenuControl> SfxMenuCtrlArr_Impl;
30 :
31 : class SAL_DLLPUBLIC_EXPORT SfxVirtualMenu
32 : {
33 : friend class SfxMenuControl;
34 :
35 : private:
36 : Menu* pSVMenu;
37 : SfxVirtualMenu* pParent;
38 : SfxMenuCtrlArr_Impl* pAppCtrl;
39 : SfxMenuControl* pItems;
40 : SfxMenuImageControl_Impl* pImageControl;
41 : SfxBindings* pBindings;
42 : ResMgr* pResMgr;
43 : PopupMenu* pWindowMenu;
44 : PopupMenu* pPickMenu;
45 : PopupMenu* pAddonsMenu;
46 : sal_uInt16 nVisibleItems;
47 : sal_uInt16 nId;
48 : sal_uInt16 nCount;
49 : sal_uInt16 nLocks;
50 : bool bResCtor : 1; // SV Menu created from resource
51 : bool bOLE : 1; // InPlaceMenu
52 : bool bHelpInitialized : 1;
53 : bool bIsActive : 1;
54 : bool bControllersUnBound : 1;
55 : bool bIsAddonPopupMenu : 1;
56 :
57 : private:
58 : void Construct_Impl();
59 : bool Bind_Impl( Menu *pMenu );
60 0 : inline SfxMenuCtrlArr_Impl& GetAppCtrl_Impl()
61 : {
62 0 : return pAppCtrl? *pAppCtrl: *(pAppCtrl = new SfxMenuCtrlArr_Impl) ;
63 : }
64 : void UnbindControllers();
65 : void BindControllers();
66 :
67 : protected:
68 : SfxVirtualMenu( sal_uInt16 nOwnId, SfxVirtualMenu* pParent, Menu& rMenu, bool bWithHelp,
69 : SfxBindings &rBind, bool bOLEServer=false, bool bRes=false, bool bIsAddonMenu=false );
70 :
71 : void CreateFromSVMenu();
72 : DECL_LINK( Highlight, void * );
73 : DECL_LINK( Activate, Menu * );
74 : DECL_LINK( Deactivate, Menu * );
75 : DECL_LINK( SettingsChanged, void* );
76 :
77 : // Used for runtime popup menus
78 : void UpdateImages( Menu* pMenu );
79 : void RemoveMenuImages( Menu* pMenu );
80 : void InsertAddOnsMenuItem( Menu* pMenu );
81 :
82 : public:
83 : ~SfxVirtualMenu();
84 : SfxVirtualMenu( Menu *pStarViewMenu, bool bWithHelp,
85 : SfxBindings &rBind, bool bOLEServer=false, bool bRes=false, bool bIsAddonMenu=false );
86 : void CheckItem( sal_uInt16 nItemId, bool bCheck );
87 : void EnableItem( sal_uInt16 nItemId, bool bEnable );
88 : void SetItemText( sal_uInt16 nItemId, const OUString& rText );
89 :
90 : sal_uInt16 GetItemCount() const;
91 : Menu* GetSVMenu() const;
92 : SfxMenuControl& operator[]( sal_uInt16 nPos ) const;
93 :
94 : sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
95 :
96 : SfxVirtualMenu* GetParentMenu() const { return pParent; }
97 : void SetParentMenu( SfxVirtualMenu* pNewParent )
98 : { pParent = pNewParent; }
99 :
100 : void SetPopupMenu( sal_uInt16 nId, PopupMenu *pMenu );
101 : bool IsFromResource() const
102 : { return bResCtor; }
103 : void InitPopup(sal_uInt16 nPos, bool bOLE = true);
104 : void InitializeHelp();
105 : void SetResMgr(ResMgr* pMgr) {pResMgr = pMgr; }
106 : ResMgr* GetResMgr() { return pResMgr; }
107 :
108 : DECL_LINK( Select, Menu * );
109 : };
110 :
111 :
112 :
113 : // return the number of virtual items in this menu
114 :
115 : inline sal_uInt16 SfxVirtualMenu::GetItemCount() const
116 : {
117 : return nCount;
118 : }
119 :
120 :
121 :
122 : inline SfxMenuControl& SfxVirtualMenu::operator[]( sal_uInt16 nPos ) const
123 : {
124 : return *(pItems+nPos);
125 : }
126 :
127 :
128 : // returns the item id at position nPos in the menu (or 0 if sep.)
129 :
130 : inline sal_uInt16 SfxVirtualMenu::GetItemId( sal_uInt16 nPos ) const
131 : {
132 : return pItems ? pItems[nPos].GetId() : 0;
133 : }
134 :
135 :
136 : #endif
137 :
138 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|