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