xref: /trunk/main/sfx2/inc/sfx2/stbitem.hxx (revision 4004672e3ece5fc8daadd5740635a1c85e93e236) !
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 #ifndef _SFXSTBITEM_HXX
23 #define _SFXSTBITEM_HXX
24 
25 #include "sal/config.h"
26 #include "sfx2/dllapi.h"
27 #include <svl/poolitem.hxx>
28 #include <svtools/statusbarcontroller.hxx>
29 
30 //------------------------------------------------------------------
31 
32 class SfxModule;
33 class StatusBar;
34 class SfxStatusBarControl;
35 class SfxBindings;
36 
37 svt::StatusbarController* SAL_CALL SfxStatusBarControllerFactory(
38     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
39     StatusBar* pStatusBar,
40     unsigned short nID,
41     const ::rtl::OUString& aCommandURL );
42 typedef SfxStatusBarControl* (*SfxStatusBarControlCtor)( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb );
43 
44 struct SfxStbCtrlFactory
45 {
46     SfxStatusBarControlCtor pCtor;
47     TypeId                  nTypeId;
48     sal_uInt16                  nSlotId;
49 
SfxStbCtrlFactorySfxStbCtrlFactory50     SfxStbCtrlFactory( SfxStatusBarControlCtor pTheCtor,
51             TypeId nTheTypeId, sal_uInt16 nTheSlotId ):
52         pCtor(pTheCtor),
53         nTypeId(nTheTypeId),
54         nSlotId(nTheSlotId)
55     {}
56 };
57 
58 //------------------------------------------------------------------
59 
60 class CommandEvent;
61 class MouseEvent;
62 class UserDrawEvent;
63 
64 class SFX2_DLLPUBLIC SfxStatusBarControl: public svt::StatusbarController
65 {
66     sal_uInt16          nSlotId;
67     sal_uInt16          nId;
68     StatusBar*      pBar;
69 
70 protected:
71     // new controller API
72     // XInterface
73     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
74     virtual void               SAL_CALL acquire() throw();
75     virtual void               SAL_CALL release() throw();
76 
77     // XEventListener
78     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
79 
80     // XComponent
81     virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
82 
83     // XStatusListener
84     virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
85         throw ( ::com::sun::star::uno::RuntimeException );
86 
87     // XStatusbarController
88     virtual ::sal_Bool SAL_CALL mouseButtonDown( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
89     virtual ::sal_Bool SAL_CALL mouseMove( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
90     virtual ::sal_Bool SAL_CALL mouseButtonUp( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
91     virtual void SAL_CALL command( const ::com::sun::star::awt::Point& aPos,
92                                     ::sal_Int32 nCommand,
93                                     ::sal_Bool bMouseEvent,
94                                     const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException);
95     virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
96                                  const ::com::sun::star::awt::Rectangle& rOutputRectangle,
97                                  ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
98     virtual void SAL_CALL click( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
99     virtual void SAL_CALL doubleClick( const ::com::sun::star::awt::Point& aPos ) throw (::com::sun::star::uno::RuntimeException);
100 
101     // Old sfx2 interface
102     virtual void    StateChanged( sal_uInt16 nSID, SfxItemState eState,
103                                   const SfxPoolItem* pState );
104     virtual void    Click();
105     virtual void    DoubleClick();
106     virtual void    Command( const CommandEvent& rCEvt );
107     virtual sal_Bool    MouseButtonDown( const MouseEvent & );
108     virtual sal_Bool    MouseMove( const MouseEvent & );
109     virtual sal_Bool    MouseButtonUp( const MouseEvent & );
110     virtual void    Paint( const UserDrawEvent &rUDEvt );
111 
112     static sal_uInt16   convertAwtToVCLMouseButtons( sal_Int16 nAwtMouseButtons );
113 
114 public:
115                     SfxStatusBarControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar& rBar );
116     virtual         ~SfxStatusBarControl();
117 
GetSlotId() const118     sal_uInt16          GetSlotId() const { return nSlotId; }
GetId() const119     sal_uInt16          GetId() const { return nId; }
GetStatusBar() const120     StatusBar&      GetStatusBar() const { return *pBar; }
121     void            CaptureMouse();
122     void            ReleaseMouse();
123 
124     static SfxStatusBarControl* CreateControl( sal_uInt16 nSlotID, sal_uInt16 nId, StatusBar *pBar, SfxModule* );
125     static void RegisterStatusBarControl(SfxModule*, SfxStbCtrlFactory*);
126 
127 };
128 
129 //------------------------------------------------------------------
130 
131 #define SFX_DECL_STATUSBAR_CONTROL() \
132         static SfxStatusBarControl* CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ); \
133         static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
134 
135 #define SFX_IMPL_STATUSBAR_CONTROL(Class, nItemClass) \
136         SfxStatusBarControl* __EXPORT Class::CreateImpl( sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb ) \
137                { return new Class( nSlotId, nId, rStb ); } \
138         void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
139                { SfxStatusBarControl::RegisterStatusBarControl( pMod, new SfxStbCtrlFactory( \
140                     Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }
141 
142 #endif
143 
144 /* vim: set noet sw=4 ts=4: */
145