bump product version to 5.0.4.1
[LibreOffice.git] / sfx2 / source / inc / virtmenu.hxx
blobc71c9c0ea7ea3f890cb73cb4810248cf935d4e91
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_SOURCE_INC_VIRTMENU_HXX
20 #define INCLUDED_SFX2_SOURCE_INC_VIRTMENU_HXX
22 #include <boost/ptr_container/ptr_vector.hpp>
24 #include <sfx2/mnuitem.hxx>
26 class SfxBindings;
27 class SfxMenuImageControl_Impl;
29 typedef ::boost::ptr_vector<SfxMenuControl> SfxMenuCtrlArr_Impl;
31 class SAL_DLLPUBLIC_EXPORT SfxVirtualMenu
33 friend class SfxMenuControl;
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;
57 private:
58 void Construct_Impl();
59 bool Bind_Impl( Menu *pMenu );
60 inline SfxMenuCtrlArr_Impl& GetAppCtrl_Impl()
62 return pAppCtrl? *pAppCtrl: *(pAppCtrl = new SfxMenuCtrlArr_Impl) ;
64 void UnbindControllers();
65 void BindControllers();
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 );
71 void CreateFromSVMenu();
72 DECL_STATIC_LINK_TYPED( SfxVirtualMenu, Highlight, Menu *, bool );
73 DECL_LINK_TYPED( Activate, Menu *, bool );
74 DECL_LINK_TYPED( Deactivate, Menu *, bool );
75 DECL_LINK( SettingsChanged, void* );
77 // Used for runtime popup menus
78 void UpdateImages( Menu* pMenu );
79 void RemoveMenuImages( Menu* pMenu );
80 void InsertAddOnsMenuItem( Menu* pMenu );
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 );
90 sal_uInt16 GetItemCount() const;
91 Menu* GetSVMenu() const { return pSVMenu;}
92 SfxMenuControl& operator[]( sal_uInt16 nPos ) const;
94 sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
96 SfxVirtualMenu* GetParentMenu() const { return pParent; }
97 void SetParentMenu( SfxVirtualMenu* pNewParent )
98 { pParent = pNewParent; }
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; }
108 DECL_LINK( Select, Menu * );
113 // return the number of virtual items in this menu
115 inline sal_uInt16 SfxVirtualMenu::GetItemCount() const
117 return nCount;
122 inline SfxMenuControl& SfxVirtualMenu::operator[]( sal_uInt16 nPos ) const
124 return *(pItems+nPos);
128 // returns the item id at position nPos in the menu (or 0 if sep.)
130 inline sal_uInt16 SfxVirtualMenu::GetItemId( sal_uInt16 nPos ) const
132 return pItems ? pItems[nPos].GetId() : 0;
136 #endif
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */