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 SFXVIRTMENU_HXX
20 : #define SFXVIRTMENU_HXX
21 :
22 : #include <boost/ptr_container/ptr_vector.hpp>
23 :
24 : #include <sfx2/mnuitem.hxx>
25 :
26 : class SfxBindings;
27 : class Timer;
28 : class SfxMenuImageControl_Impl;
29 :
30 : typedef ::boost::ptr_vector<SfxMenuControl> SfxMenuCtrlArr_Impl;
31 :
32 : class SAL_DLLPUBLIC_EXPORT SfxVirtualMenu
33 : {
34 : friend class SfxMenuControl;
35 :
36 : private:
37 : Menu* pSVMenu;
38 : SfxVirtualMenu* pParent;
39 : SfxMenuCtrlArr_Impl* pAppCtrl;
40 : SfxMenuControl* pItems;
41 : SfxMenuImageControl_Impl* pImageControl;
42 : SfxBindings* pBindings;
43 : ResMgr* pResMgr;
44 : PopupMenu* pWindowMenu;
45 : PopupMenu* pPickMenu;
46 : PopupMenu* pAddonsMenu;
47 : Timer* pAutoDeactivate; // Hack for QAP-Bug
48 : sal_uInt16 nVisibleItems;
49 : sal_uInt16 nId;
50 : sal_uInt16 nCount;
51 : sal_uInt16 nLocks;
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;
58 :
59 : private:
60 : void Construct_Impl();
61 : bool Bind_Impl( Menu *pMenu );
62 0 : inline SfxMenuCtrlArr_Impl& GetAppCtrl_Impl()
63 : {
64 0 : return pAppCtrl? *pAppCtrl: *(pAppCtrl = new SfxMenuCtrlArr_Impl) ;
65 : }
66 : void UnbindControllers();
67 : void BindControllers();
68 :
69 : protected:
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 );
72 :
73 : void CreateFromSVMenu();
74 : DECL_LINK( Highlight, Menu * );
75 : DECL_LINK( Activate, Menu * );
76 : DECL_LINK( Deactivate, Menu * );
77 : DECL_LINK( SettingsChanged, void* );
78 :
79 : // Used for runtime popup menus
80 : void UpdateImages( Menu* pMenu );
81 : void RemoveMenuImages( Menu* pMenu );
82 : void InsertAddOnsMenuItem( Menu* pMenu );
83 :
84 : public:
85 : ~SfxVirtualMenu();
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 );
91 :
92 : sal_uInt16 GetItemCount() const;
93 : Menu* GetSVMenu() const;
94 : SfxMenuControl& operator[]( sal_uInt16 nPos ) const;
95 :
96 : sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
97 :
98 : SfxVirtualMenu* GetParentMenu() const { return pParent; }
99 : void SetParentMenu( SfxVirtualMenu* pNewParent )
100 : { pParent = pNewParent; }
101 :
102 : void SetPopupMenu( sal_uInt16 nId, PopupMenu *pMenu );
103 : sal_Bool IsFromResource() const
104 : { return bResCtor; }
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; }
109 :
110 : DECL_LINK( Select, Menu * );
111 : };
112 :
113 : //--------------------------------------------------------------------
114 :
115 : // return the number of virtual items in this menu
116 :
117 : inline sal_uInt16 SfxVirtualMenu::GetItemCount() const
118 : {
119 : return nCount;
120 : }
121 : //--------------------------------------------------------------------
122 :
123 :
124 : inline SfxMenuControl& SfxVirtualMenu::operator[]( sal_uInt16 nPos ) const
125 : {
126 : return *(pItems+nPos);
127 : }
128 : //--------------------------------------------------------------------
129 :
130 : // returns the item id at position nPos in the menu (or 0 if sep.)
131 :
132 : inline sal_uInt16 SfxVirtualMenu::GetItemId( sal_uInt16 nPos ) const
133 : {
134 : return pItems ? pItems[nPos].GetId() : 0;
135 : }
136 :
137 :
138 : #endif
139 :
140 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|