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