1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stbitem.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFXSTBITEM_HXX
31 #define _SFXSTBITEM_HXX
33 #include "sal/config.h"
34 #include "sfx2/dllapi.h"
35 #include <svtools/poolitem.hxx>
36 #include <svtools/statusbarcontroller.hxx>
38 //------------------------------------------------------------------
42 class SfxStatusBarControl
;
45 svt::StatusbarController
* SAL_CALL
SfxStatusBarControllerFactory(
46 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& rFrame
,
47 StatusBar
* pStatusBar
,
49 const ::rtl::OUString
& aCommandURL
);
50 typedef SfxStatusBarControl
* (*SfxStatusBarControlCtor
)( USHORT nSlotId
, USHORT nId
, StatusBar
&rStb
);
52 struct SfxStbCtrlFactory
54 SfxStatusBarControlCtor pCtor
;
58 SfxStbCtrlFactory( SfxStatusBarControlCtor pTheCtor
,
59 TypeId nTheTypeId
, USHORT nTheSlotId
):
66 //------------------------------------------------------------------
72 class SFX2_DLLPUBLIC SfxStatusBarControl
: public svt::StatusbarController
81 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
);
82 virtual void SAL_CALL
acquire() throw();
83 virtual void SAL_CALL
release() throw();
86 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& aEvent
) throw( ::com::sun::star::uno::RuntimeException
);
89 virtual void SAL_CALL
dispose() throw (::com::sun::star::uno::RuntimeException
);
92 virtual void SAL_CALL
statusChanged( const ::com::sun::star::frame::FeatureStateEvent
& Event
)
93 throw ( ::com::sun::star::uno::RuntimeException
);
95 // XStatusbarController
96 virtual ::sal_Bool SAL_CALL
mouseButtonDown( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
);
97 virtual ::sal_Bool SAL_CALL
mouseMove( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
);
98 virtual ::sal_Bool SAL_CALL
mouseButtonUp( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
);
99 virtual void SAL_CALL
command( const ::com::sun::star::awt::Point
& aPos
,
100 ::sal_Int32 nCommand
,
101 ::sal_Bool bMouseEvent
,
102 const ::com::sun::star::uno::Any
& aData
) throw (::com::sun::star::uno::RuntimeException
);
103 virtual void SAL_CALL
paint( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
>& xGraphics
,
104 const ::com::sun::star::awt::Rectangle
& rOutputRectangle
,
105 ::sal_Int32 nItemId
, ::sal_Int32 nStyle
) throw (::com::sun::star::uno::RuntimeException
);
106 virtual void SAL_CALL
click() throw (::com::sun::star::uno::RuntimeException
);
107 virtual void SAL_CALL
doubleClick() throw (::com::sun::star::uno::RuntimeException
);
109 // Old sfx2 interface
110 virtual void StateChanged( USHORT nSID
, SfxItemState eState
,
111 const SfxPoolItem
* pState
);
112 virtual void Click();
113 virtual void DoubleClick();
114 virtual void Command( const CommandEvent
& rCEvt
);
115 virtual BOOL
MouseButtonDown( const MouseEvent
& );
116 virtual BOOL
MouseMove( const MouseEvent
& );
117 virtual BOOL
MouseButtonUp( const MouseEvent
& );
118 virtual void Paint( const UserDrawEvent
&rUDEvt
);
120 static USHORT
convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons
);
123 SfxStatusBarControl( USHORT nSlotID
, USHORT nId
, StatusBar
& rBar
);
124 virtual ~SfxStatusBarControl();
126 USHORT
GetSlotId() const { return nSlotId
; }
127 USHORT
GetId() const { return nId
; }
128 StatusBar
& GetStatusBar() const { return *pBar
; }
132 static SfxStatusBarControl
* CreateControl( USHORT nSlotID
, USHORT nId
, StatusBar
*pBar
, SfxModule
* );
133 static void RegisterStatusBarControl(SfxModule
*, SfxStbCtrlFactory
*);
137 //------------------------------------------------------------------
139 #define SFX_DECL_STATUSBAR_CONTROL() \
140 static SfxStatusBarControl* CreateImpl( USHORT nSlotId, USHORT nId, StatusBar &rStb ); \
141 static void RegisterControl(USHORT nSlotId = 0, SfxModule *pMod=NULL)
143 #define SFX_IMPL_STATUSBAR_CONTROL(Class, nItemClass) \
144 SfxStatusBarControl* __EXPORT Class::CreateImpl( USHORT nSlotId, USHORT nId, StatusBar &rStb ) \
145 { return new Class( nSlotId, nId, rStb ); } \
146 void Class::RegisterControl(USHORT nSlotId, SfxModule *pMod) \
147 { SfxStatusBarControl::RegisterStatusBarControl( pMod, new SfxStbCtrlFactory( \
148 Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }