LibreOffice Module sfx2 (master) 1
stbitem.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#ifndef INCLUDED_SFX2_STBITEM_HXX
20#define INCLUDED_SFX2_STBITEM_HXX
21
22#include <sal/config.h>
23#include <sfx2/dllapi.h>
24#include <svl/poolitem.hxx>
26#include <vcl/vclptr.hxx>
27
28class SfxModule;
30class StatusBar;
31
33 const css::uno::Reference< css::frame::XFrame >& rFrame,
34 StatusBar* pStatusBar,
35 unsigned short nID,
36 const OUString& aCommandURL );
37typedef rtl::Reference<SfxStatusBarControl> (*SfxStatusBarControlCtor)( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb );
38
40{
42 const std::type_info& nTypeId;
43 sal_uInt16 nSlotId;
44
46 const std::type_info& nTheTypeId, sal_uInt16 nTheSlotId ):
47 pCtor(pTheCtor),
48 nTypeId(nTheTypeId),
49 nSlotId(nTheSlotId)
50 {}
51};
52
53
54class CommandEvent;
55class MouseEvent;
56class UserDrawEvent;
57
59{
60 sal_uInt16 nSlotId;
61 sal_uInt16 nId;
63
64public:
65 // new controller API
66 // XInterface
67 virtual void SAL_CALL acquire() noexcept override;
68 virtual void SAL_CALL release() noexcept override;
69
70protected:
71 // XEventListener
72 using svt::StatusbarController::disposing;
73
74 // XComponent
75 using svt::StatusbarController::dispose;
76
77 // XStatusListener
78 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
79
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;
93
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 );
103
104 static sal_uInt16 convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons );
105
106public:
107 SfxStatusBarControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar& rBar );
108 virtual ~SfxStatusBarControl() override;
109
110 sal_uInt16 GetSlotId() const { return nSlotId; }
111 sal_uInt16 GetId() const { return nId; }
112 StatusBar& GetStatusBar() const { return *pBar; }
113
114 static rtl::Reference<SfxStatusBarControl> CreateControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar *pBar, SfxModule const * );
115 static void RegisterStatusBarControl(SfxModule*, const SfxStbCtrlFactory&);
116
117};
118
119
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)
123
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 ) ); }
130
131
132#endif
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
StatusBar & GetStatusBar() const
Definition: stbitem.hxx:112
VclPtr< StatusBar > pBar
Definition: stbitem.hxx:62
sal_uInt16 nSlotId
Definition: stbitem.hxx:60
sal_uInt16 GetId() const
Definition: stbitem.hxx:111
sal_uInt16 nId
Definition: stbitem.hxx:61
virtual void SAL_CALL acquire() noexcept override
#define SFX2_DLLPUBLIC
Definition: dllapi.h:29
DdeData aData
Definition: lnkbase2.cxx:82
sal_Int16 nId
SfxItemState
rtl::Reference< svt::StatusbarController > SfxStatusBarControllerFactory(const css::uno::Reference< css::frame::XFrame > &rFrame, StatusBar *pStatusBar, unsigned short nID, const OUString &aCommandURL)
rtl::Reference< SfxStatusBarControl >(* SfxStatusBarControlCtor)(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb)
Definition: stbitem.hxx:37
const std::type_info & nTypeId
Definition: stbitem.hxx:42
SfxStbCtrlFactory(SfxStatusBarControlCtor pTheCtor, const std::type_info &nTheTypeId, sal_uInt16 nTheSlotId)
Definition: stbitem.hxx:45
sal_uInt16 nSlotId
Definition: stbitem.hxx:43
SfxStatusBarControlCtor pCtor
Definition: stbitem.hxx:41
unsigned char sal_Bool