1353d8f4dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3353d8f4dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4353d8f4dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5353d8f4dSAndrew Rist * distributed with this work for additional information 6353d8f4dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7353d8f4dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8353d8f4dSAndrew Rist * "License"); you may not use this file except in compliance 9353d8f4dSAndrew Rist * with the License. You may obtain a copy of the License at 10353d8f4dSAndrew Rist * 11353d8f4dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12353d8f4dSAndrew Rist * 13353d8f4dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14353d8f4dSAndrew Rist * software distributed under the License is distributed on an 15353d8f4dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16353d8f4dSAndrew Rist * KIND, either express or implied. See the License for the 17353d8f4dSAndrew Rist * specific language governing permissions and limitations 18353d8f4dSAndrew Rist * under the License. 19353d8f4dSAndrew Rist * 20353d8f4dSAndrew Rist *************************************************************/ 21353d8f4dSAndrew Rist 22353d8f4dSAndrew Rist 23cdf0e10cSrcweir #ifndef _SFXSTBITEM_HXX 24cdf0e10cSrcweir #define _SFXSTBITEM_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "sal/config.h" 27cdf0e10cSrcweir #include "sfx2/dllapi.h" 28cdf0e10cSrcweir #include <svl/poolitem.hxx> 29cdf0e10cSrcweir #include <svtools/statusbarcontroller.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir //------------------------------------------------------------------ 32cdf0e10cSrcweir 33cdf0e10cSrcweir class SfxModule; 34cdf0e10cSrcweir class StatusBar; 35cdf0e10cSrcweir class SfxStatusBarControl; 36cdf0e10cSrcweir class SfxBindings; 37cdf0e10cSrcweir 38cdf0e10cSrcweir svt::StatusbarController* SAL_CALL SfxStatusBarControllerFactory( 39cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, 40cdf0e10cSrcweir StatusBar* pStatusBar, 41cdf0e10cSrcweir unsigned short nID, 42cdf0e10cSrcweir const ::rtl::OUString& aCommandURL ); 43cdf0e10cSrcweir typedef SfxStatusBarControl* (*SfxStatusBarControlCtor)( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); 44cdf0e10cSrcweir 45cdf0e10cSrcweir struct SfxStbCtrlFactory 46cdf0e10cSrcweir { 47cdf0e10cSrcweir SfxStatusBarControlCtor pCtor; 48cdf0e10cSrcweir TypeId nTypeId; 49cdf0e10cSrcweir sal_uInt16 nSlotId; 50cdf0e10cSrcweir SfxStbCtrlFactorySfxStbCtrlFactory51cdf0e10cSrcweir SfxStbCtrlFactory( SfxStatusBarControlCtor pTheCtor, 52cdf0e10cSrcweir TypeId nTheTypeId, sal_uInt16 nTheSlotId ): 53cdf0e10cSrcweir pCtor(pTheCtor), 54cdf0e10cSrcweir nTypeId(nTheTypeId), 55cdf0e10cSrcweir nSlotId(nTheSlotId) 56cdf0e10cSrcweir {} 57cdf0e10cSrcweir }; 58cdf0e10cSrcweir 59cdf0e10cSrcweir //------------------------------------------------------------------ 60cdf0e10cSrcweir 61cdf0e10cSrcweir class CommandEvent; 62cdf0e10cSrcweir class MouseEvent; 63cdf0e10cSrcweir class UserDrawEvent; 64cdf0e10cSrcweir 65cdf0e10cSrcweir class SFX2_DLLPUBLIC SfxStatusBarControl: public svt::StatusbarController 66cdf0e10cSrcweir { 67cdf0e10cSrcweir sal_uInt16 nSlotId; 68cdf0e10cSrcweir sal_uInt16 nId; 69cdf0e10cSrcweir StatusBar* pBar; 70cdf0e10cSrcweir 71cdf0e10cSrcweir protected: 72cdf0e10cSrcweir // new controller API 73cdf0e10cSrcweir // XInterface 74cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 75cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 76cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 77cdf0e10cSrcweir 78cdf0e10cSrcweir // XEventListener 79cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir // XComponent 82cdf0e10cSrcweir virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException); 83cdf0e10cSrcweir 84cdf0e10cSrcweir // XStatusListener 85cdf0e10cSrcweir virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) 86cdf0e10cSrcweir throw ( ::com::sun::star::uno::RuntimeException ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir // XStatusbarController 89cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL mouseButtonDown( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException); 90cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL mouseMove( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException); 91cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL mouseButtonUp( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException); 92cdf0e10cSrcweir virtual void SAL_CALL command( const ::com::sun::star::awt::Point& aPos, 93cdf0e10cSrcweir ::sal_Int32 nCommand, 94cdf0e10cSrcweir ::sal_Bool bMouseEvent, 95cdf0e10cSrcweir const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException); 96cdf0e10cSrcweir virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics, 97*0c02d14eSAriel Constenla-Haile const ::com::sun::star::awt::Rectangle& rOutputRectangle, 98*0c02d14eSAriel Constenla-Haile ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException); 99*0c02d14eSAriel Constenla-Haile virtual void SAL_CALL click( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException); 100*0c02d14eSAriel Constenla-Haile virtual void SAL_CALL doubleClick( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException); 101cdf0e10cSrcweir 102cdf0e10cSrcweir // Old sfx2 interface 103cdf0e10cSrcweir virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, 104cdf0e10cSrcweir const SfxPoolItem* pState ); 105cdf0e10cSrcweir virtual void Click(); 106cdf0e10cSrcweir virtual void DoubleClick(); 107cdf0e10cSrcweir virtual void Command( const CommandEvent& rCEvt ); 108cdf0e10cSrcweir virtual sal_Bool MouseButtonDown( const MouseEvent & ); 109cdf0e10cSrcweir virtual sal_Bool MouseMove( const MouseEvent & ); 110cdf0e10cSrcweir virtual sal_Bool MouseButtonUp( const MouseEvent & ); 111cdf0e10cSrcweir virtual void Paint( const UserDrawEvent &rUDEvt ); 112cdf0e10cSrcweir 113cdf0e10cSrcweir static sal_uInt16 convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir public: 116cdf0e10cSrcweir SfxStatusBarControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar& rBar ); 117cdf0e10cSrcweir virtual ~SfxStatusBarControl(); 118cdf0e10cSrcweir GetSlotId() const119cdf0e10cSrcweir sal_uInt16 GetSlotId() const { return nSlotId; } GetId() const120cdf0e10cSrcweir sal_uInt16 GetId() const { return nId; } GetStatusBar() const121cdf0e10cSrcweir StatusBar& GetStatusBar() const { return *pBar; } 122cdf0e10cSrcweir void CaptureMouse(); 123cdf0e10cSrcweir void ReleaseMouse(); 124cdf0e10cSrcweir 125cdf0e10cSrcweir static SfxStatusBarControl* CreateControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar *pBar, SfxModule* ); 126cdf0e10cSrcweir static void RegisterStatusBarControl(SfxModule*, SfxStbCtrlFactory*); 127cdf0e10cSrcweir 128cdf0e10cSrcweir }; 129cdf0e10cSrcweir 130cdf0e10cSrcweir //------------------------------------------------------------------ 131cdf0e10cSrcweir 132cdf0e10cSrcweir #define SFX_DECL_STATUSBAR_CONTROL() \ 133cdf0e10cSrcweir static SfxStatusBarControl* CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); \ 134cdf0e10cSrcweir static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL) 135cdf0e10cSrcweir 136cdf0e10cSrcweir #define SFX_IMPL_STATUSBAR_CONTROL(Class, nItemClass) \ 137cdf0e10cSrcweir SfxStatusBarControl* __EXPORT Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ) \ 138cdf0e10cSrcweir { return new Class( nSlotId, nId, rStb ); } \ 139cdf0e10cSrcweir void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \ 140cdf0e10cSrcweir { SfxStatusBarControl::RegisterStatusBarControl( pMod, new SfxStbCtrlFactory( \ 141cdf0e10cSrcweir Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); } 142cdf0e10cSrcweir 143cdf0e10cSrcweir 144cdf0e10cSrcweir #endif 145