fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / sfx2 / mnuitem.hxx
blobe65220be2a13381675ef963f234a49f1ce4461df
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 _SFXMNUITEM_HXX
20 #define _SFXMNUITEM_HXX
22 #include "sal/config.h"
23 #include "sfx2/dllapi.h"
25 class SfxVirtualMenu;
26 class SfxBindings;
27 class SfxModule;
28 class Menu;
29 class PopupMenu;
30 class SfxUnoMenuControl;
31 class SfxUnoControllerItem;
32 struct SfxMenuCtrlFactory;
33 #include <tools/string.hxx>
34 #include <sfx2/ctrlitem.hxx>
36 class SFX2_DLLPUBLIC SfxMenuControl: public SfxControllerItem
38 String aTitle;
39 SfxVirtualMenu* pOwnMenu;
40 SfxVirtualMenu* pSubMenu;
41 sal_Bool b_ShowStrings;
43 public:
44 SfxMenuControl();
45 SfxMenuControl( sal_Bool bShowStrings );
46 SfxMenuControl( sal_uInt16, SfxBindings&);
48 static SfxMenuControl* CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings );
49 static void RegisterControl( sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL );
51 ~SfxMenuControl();
53 using SfxControllerItem::Bind;
54 void Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
55 const String& rTitle, SfxBindings& rBindings );
56 void Bind( SfxVirtualMenu* pOwnMenu, sal_uInt16 nId,
57 SfxVirtualMenu& rSubMenu,
58 const String& rTitle, SfxBindings& rBindings );
60 String GetTitle() const;
61 SfxVirtualMenu* GetPopupMenu() const;
62 virtual PopupMenu* GetPopup() const;
64 virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
65 const SfxPoolItem* pState );
67 static SfxMenuControl* CreateControl( sal_uInt16 nId, Menu &, SfxBindings & );
68 static SfxUnoMenuControl* CreateControl( const String&, sal_uInt16, Menu&, const String& sItemText, SfxBindings&, SfxVirtualMenu* );
69 static void RegisterMenuControl(SfxModule*, SfxMenuCtrlFactory*);
73 class SfxUnoMenuControl : public SfxMenuControl
75 SfxUnoControllerItem* pUnoCtrl;
76 public:
77 SfxUnoMenuControl( const String&, sal_uInt16 nId, Menu&,
78 const String&,
79 SfxBindings&, SfxVirtualMenu* );
80 ~SfxUnoMenuControl();
83 typedef SfxMenuControl* (*SfxMenuControlCtor)( sal_uInt16 nId, Menu &, SfxBindings & );
85 struct SfxMenuCtrlFactory
87 SfxMenuControlCtor pCtor;
88 TypeId nTypeId;
89 sal_uInt16 nSlotId;
91 SfxMenuCtrlFactory( SfxMenuControlCtor pTheCtor,
92 TypeId nTheTypeId, sal_uInt16 nTheSlotId ):
93 pCtor(pTheCtor),
94 nTypeId(nTheTypeId),
95 nSlotId(nTheSlotId)
99 inline String SfxMenuControl::GetTitle() const
101 return aTitle;
104 inline SfxVirtualMenu* SfxMenuControl::GetPopupMenu() const
106 return pSubMenu;
109 #define SFX_DECL_MENU_CONTROL() \
110 static SfxMenuControl* CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ); \
111 static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
113 #define SFX_IMPL_MENU_CONTROL(Class, nItemClass) \
114 SfxMenuControl* Class::CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ) \
115 { return new Class(nId, rMenu, rBindings); } \
116 void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
117 { SfxMenuControl::RegisterMenuControl( pMod, new SfxMenuCtrlFactory( \
118 Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }
119 #endif
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */