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