xref: /AOO41X/main/sfx2/source/inc/virtmenu.hxx (revision 353d8f4d17010cd2d0ea815067cad67e477f2bee)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFXVIRTMENU_HXX
24 #define _SFXVIRTMENU_HXX
25 
26 
27 #include <svl/svarray.hxx>
28 #include <sfx2/mnuitem.hxx>
29 #include "mnucfga.hxx"
30 
31 class SfxBindings;
32 class Timer;
33 class SfxMenuImageControl_Impl;
34 
35 SV_DECL_PTRARR_DEL( SfxMenuCtrlArr_Impl, SfxMenuControl*, 2, 2 )
36 
37 class SAL_DLLPUBLIC_EXPORT SfxVirtualMenu
38 {
39 friend class SfxMenuControl;
40 
41 private:
42     Menu*           pSVMenu;
43     SfxVirtualMenu* pParent;
44     SfxMenuCtrlArr_Impl* pAppCtrl;
45     SfxMenuControl* pItems;
46     SfxMenuImageControl_Impl* pImageControl;
47     SfxBindings*    pBindings;
48     ResMgr*         pResMgr;
49     PopupMenu*      pWindowMenu;
50     PopupMenu*      pPickMenu;
51     PopupMenu*      pAddonsMenu;
52     Timer*          pAutoDeactivate; // Hack fuer QAP-Bug
53     sal_uInt16          nVisibleItems;
54     sal_uInt16          nId;
55     sal_uInt16          nCount;
56     sal_uInt16          nLocks;
57     sal_Bool            bResCtor : 1; // SV Menu created from resource
58     sal_Bool            bOLE : 1;     // InPlaceMenu
59     sal_Bool            bHelpInitialized : 1;
60     sal_Bool            bIsActive : 1;
61     sal_Bool            bControllersUnBound : 1;
62     sal_Bool            bWasHighContrast : 1;
63     sal_Bool            bIsAddonPopupMenu : 1;
64 
65 private:
66     void            Construct_Impl();
67     bool        Bind_Impl( Menu *pMenu );
GetAppCtrl_Impl()68     inline SfxMenuCtrlArr_Impl& GetAppCtrl_Impl()
69     {
70         return pAppCtrl? *pAppCtrl: *(pAppCtrl = new SfxMenuCtrlArr_Impl) ;
71     }
72     void            UnbindControllers();
73     void            BindControllers();
74 
75 protected:
76     SfxVirtualMenu( sal_uInt16 nOwnId, SfxVirtualMenu* pParent, Menu& rMenu, sal_Bool bWithHelp,
77                         SfxBindings &rBind, sal_Bool bOLEServer=sal_False, sal_Bool bRes=sal_False, sal_Bool bIsAddonMenu=sal_False );
78 
79     void            CreateFromSVMenu();
80     DECL_LINK( Highlight, Menu * );
81     DECL_LINK( Activate, Menu * );
82     DECL_LINK( Deactivate, Menu * );
83     DECL_LINK( SettingsChanged, void* );
84 
85     // Used for runtime popup menus
86     void            UpdateImages( Menu* pMenu );
87     void            RemoveMenuImages( Menu* pMenu );
88     void            InsertAddOnsMenuItem( Menu* pMenu );
89 
90 public:
91                     ~SfxVirtualMenu();
92                     SfxVirtualMenu( Menu *pStarViewMenu, sal_Bool bWithHelp,
93                         SfxBindings &rBind, sal_Bool bOLEServer=sal_False, sal_Bool bRes=sal_False, sal_Bool bIsAddonMenu=sal_False );
94     void            CheckItem( sal_uInt16 nItemId, sal_Bool bCheck );
95     void            EnableItem( sal_uInt16 nItemId, sal_Bool bEnable );
96     void            SetItemText( sal_uInt16 nItemId, const String& rText );
97 
98     sal_uInt16          GetItemPos( sal_uInt16 nItemId ) const;
99 
100     sal_uInt16          GetItemCount() const;
101     Menu*           GetSVMenu() const;
102     SfxMenuControl& operator[]( sal_uInt16 nPos ) const;
103 
104     sal_uInt16          GetItemId( sal_uInt16 nPos ) const;
105     SfxVirtualMenu* GetPopupMenu( sal_uInt16 nId ) const;
106     String          GetItemText( sal_uInt16 nId ) const;
107     String          GetItemHelpText( sal_uInt16 nId ) const;
108 
109     //void            InvalidateKeyCodes();
110 
GetParentMenu() const111     SfxVirtualMenu* GetParentMenu() const { return pParent; }
SetParentMenu(SfxVirtualMenu * pNewParent)112     void            SetParentMenu( SfxVirtualMenu* pNewParent )
113                     { pParent = pNewParent; }
114 
115     void            SetPopupMenu( sal_uInt16 nId, PopupMenu *pMenu );
IsFromResource() const116     sal_Bool            IsFromResource() const
117                     { return bResCtor; }
118     void            InitPopup(sal_uInt16 nPos, sal_Bool bOLE = sal_True);
119     void            InitializeHelp();
SetResMgr(ResMgr * pMgr)120     void            SetResMgr(ResMgr* pMgr)  {pResMgr = pMgr; }
GetResMgr()121     ResMgr*         GetResMgr() { return pResMgr; }
122     void            SetHelpIds( ResMgr* );
123     sal_Bool            IsHiContrastMode() const;
124     void            UpdateImages();
125 
126     DECL_LINK( Select, Menu * );
127 };
128 
129 //--------------------------------------------------------------------
130 
131 // return the number of virtual items in this menu
132 
GetItemCount() const133 inline sal_uInt16 SfxVirtualMenu::GetItemCount() const
134 {
135     return nCount;
136 }
137 //--------------------------------------------------------------------
138 
139 //
140 
operator [](sal_uInt16 nPos) const141 inline SfxMenuControl& SfxVirtualMenu::operator[]( sal_uInt16 nPos ) const
142 {
143     return *(pItems+nPos);
144 }
145 //--------------------------------------------------------------------
146 
147 // returns the item id at position nPos in the menu (or 0 if sep.)
148 
GetItemId(sal_uInt16 nPos) const149 inline sal_uInt16 SfxVirtualMenu::GetItemId( sal_uInt16 nPos ) const
150 {
151     return pItems ? pItems[nPos].GetId() : 0;
152 }
153 
154 
155 #endif
156