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