Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / sfx2 / stbitem.hxx
blob67c88c68710d98bc61ccef13da61e85f020c0611
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_STBITEM_HXX
20 #define INCLUDED_SFX2_STBITEM_HXX
22 #include <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <svl/poolitem.hxx>
25 #include <svtools/statusbarcontroller.hxx>
26 #include <vcl/vclptr.hxx>
28 class SfxModule;
29 class SfxStatusBarControl;
30 class StatusBar;
32 rtl::Reference<svt::StatusbarController> SfxStatusBarControllerFactory(
33 const css::uno::Reference< css::frame::XFrame >& rFrame,
34 StatusBar* pStatusBar,
35 unsigned short nID,
36 const OUString& aCommandURL );
37 typedef rtl::Reference<SfxStatusBarControl> (*SfxStatusBarControlCtor)( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb );
39 struct SfxStbCtrlFactory
41 SfxStatusBarControlCtor pCtor;
42 const std::type_info& nTypeId;
43 sal_uInt16 nSlotId;
45 SfxStbCtrlFactory( SfxStatusBarControlCtor pTheCtor,
46 const std::type_info& nTheTypeId, sal_uInt16 nTheSlotId ):
47 pCtor(pTheCtor),
48 nTypeId(nTheTypeId),
49 nSlotId(nTheSlotId)
54 class CommandEvent;
55 class MouseEvent;
56 class UserDrawEvent;
58 class SFX2_DLLPUBLIC SfxStatusBarControl: public svt::StatusbarController
60 sal_uInt16 nSlotId;
61 sal_uInt16 nId;
62 VclPtr<StatusBar> pBar;
64 public:
65 // new controller API
66 // XInterface
67 virtual void SAL_CALL acquire() noexcept override;
68 virtual void SAL_CALL release() noexcept override;
70 protected:
71 // XEventListener
72 using svt::StatusbarController::disposing;
74 // XComponent
75 using svt::StatusbarController::dispose;
77 // XStatusListener
78 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
80 // XStatusbarController
81 virtual sal_Bool SAL_CALL mouseButtonDown( const css::awt::MouseEvent& aMouseEvent ) override;
82 virtual sal_Bool SAL_CALL mouseMove( const css::awt::MouseEvent& aMouseEvent ) override;
83 virtual sal_Bool SAL_CALL mouseButtonUp( const css::awt::MouseEvent& aMouseEvent ) override;
84 virtual void SAL_CALL command( const css::awt::Point& aPos,
85 ::sal_Int32 nCommand,
86 sal_Bool bMouseEvent,
87 const css::uno::Any& aData ) override;
88 virtual void SAL_CALL paint( const css::uno::Reference< css::awt::XGraphics >& xGraphics,
89 const css::awt::Rectangle& rOutputRectangle,
90 ::sal_Int32 nStyle ) override;
91 virtual void SAL_CALL click( const css::awt::Point& aPos ) override;
92 virtual void SAL_CALL doubleClick( const css::awt::Point& aPos ) override;
94 // Old sfx2 interface
95 virtual void StateChangedAtStatusBarControl( sal_uInt16 nSID, SfxItemState eState,
96 const SfxPoolItem* pState );
97 virtual void Click();
98 virtual void Command( const CommandEvent& rCEvt );
99 virtual bool MouseButtonDown( const MouseEvent & );
100 virtual bool MouseMove( const MouseEvent & );
101 virtual bool MouseButtonUp( const MouseEvent & );
102 virtual void Paint( const UserDrawEvent &rUDEvt );
104 static sal_uInt16 convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons );
106 public:
107 SfxStatusBarControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar& rBar );
108 virtual ~SfxStatusBarControl() override;
110 sal_uInt16 GetSlotId() const { return nSlotId; }
111 sal_uInt16 GetId() const { return nId; }
112 StatusBar& GetStatusBar() const { return *pBar; }
114 static rtl::Reference<SfxStatusBarControl> CreateControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar *pBar, SfxModule const * );
115 static void RegisterStatusBarControl(SfxModule*, const SfxStbCtrlFactory&);
120 #define SFX_DECL_STATUSBAR_CONTROL() \
121 static rtl::Reference<SfxStatusBarControl> CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); \
122 static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=nullptr)
124 #define SFX_IMPL_STATUSBAR_CONTROL(Class, nItemClass) \
125 rtl::Reference<SfxStatusBarControl> Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ) \
126 { return new Class( nSlotId, nId, rStb ); } \
127 void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
128 { SfxStatusBarControl::RegisterStatusBarControl( pMod, SfxStbCtrlFactory( \
129 Class::CreateImpl, typeid(nItemClass), nSlotId ) ); }
132 #endif
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */