1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/status.hxx>
30 class SfxStatusBarControl
;
33 svt::StatusbarController
* SAL_CALL
SfxStatusBarControllerFactory(
34 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
,
35 StatusBar
* pStatusBar
,
37 const OUString
& aCommandURL
);
38 typedef SfxStatusBarControl
* (*SfxStatusBarControlCtor
)( sal_uInt16 nSlotId
, sal_uInt16 nId
, StatusBar
&rStb
);
40 struct SfxStbCtrlFactory
42 SfxStatusBarControlCtor pCtor
;
46 SfxStbCtrlFactory( SfxStatusBarControlCtor pTheCtor
,
47 TypeId nTheTypeId
, sal_uInt16 nTheSlotId
):
60 class SFX2_DLLPUBLIC SfxStatusBarControl
: public svt::StatusbarController
64 VclPtr
<StatusBar
> pBar
;
69 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
70 virtual void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
71 virtual void SAL_CALL
release() throw() SAL_OVERRIDE
;
74 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aEvent
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
77 virtual void SAL_CALL
dispose() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
80 virtual void SAL_CALL
statusChanged( const ::com::sun::star::frame::FeatureStateEvent
& Event
)
81 throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
83 // XStatusbarController
84 virtual sal_Bool SAL_CALL
mouseButtonDown( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
85 virtual sal_Bool SAL_CALL
mouseMove( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
86 virtual sal_Bool SAL_CALL
mouseButtonUp( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
87 virtual void SAL_CALL
command( const ::com::sun::star::awt::Point
& aPos
,
90 const ::com::sun::star::uno::Any
& aData
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 virtual void SAL_CALL
paint( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
>& xGraphics
,
92 const ::com::sun::star::awt::Rectangle
& rOutputRectangle
,
93 ::sal_Int32 nStyle
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
94 virtual void SAL_CALL
click( const ::com::sun::star::awt::Point
& aPos
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
95 virtual void SAL_CALL
doubleClick( const ::com::sun::star::awt::Point
& aPos
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 virtual void StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
99 const SfxPoolItem
* pState
);
100 virtual void Click();
101 virtual void Command( const CommandEvent
& rCEvt
);
102 virtual bool MouseButtonDown( const MouseEvent
& );
103 virtual bool MouseMove( const MouseEvent
& );
104 virtual bool MouseButtonUp( const MouseEvent
& );
105 virtual void Paint( const UserDrawEvent
&rUDEvt
);
107 static sal_uInt16
convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons
);
110 SfxStatusBarControl( sal_uInt16 nSlotID
, sal_uInt16 nId
, StatusBar
& rBar
);
111 virtual ~SfxStatusBarControl();
113 sal_uInt16
GetSlotId() const { return nSlotId
; }
114 sal_uInt16
GetId() const { return nId
; }
115 StatusBar
& GetStatusBar() const { return *pBar
; }
117 static SfxStatusBarControl
* CreateControl( sal_uInt16 nSlotID
, sal_uInt16 nId
, StatusBar
*pBar
, SfxModule
* );
118 static void RegisterStatusBarControl(SfxModule
*, SfxStbCtrlFactory
*);
124 #define SFX_DECL_STATUSBAR_CONTROL() \
125 static SfxStatusBarControl* CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); \
126 static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
128 #define SFX_IMPL_STATUSBAR_CONTROL(Class, nItemClass) \
129 SfxStatusBarControl* Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ) \
130 { return new Class( nSlotId, nId, rStb ); } \
131 void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
132 { SfxStatusBarControl::RegisterStatusBarControl( pMod, new SfxStbCtrlFactory( \
133 Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */