bump product version to 6.4.0.3
[LibreOffice.git] / UnoControls / inc / basecontrol.hxx
blobc19e3d9cb04b24e40c3715a92f2a4833cbcdb18d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_UNOCONTROLS_INC_BASECONTROL_HXX
21 #define INCLUDED_UNOCONTROLS_INC_BASECONTROL_HXX
23 #include <com/sun/star/awt/XPaintListener.hpp>
24 #include <com/sun/star/awt/XWindowListener.hpp>
25 #include <com/sun/star/awt/XControl.hpp>
26 #include <com/sun/star/awt/XWindow.hpp>
27 #include <com/sun/star/awt/XView.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <osl/mutex.hxx>
30 #include <cppuhelper/component.hxx>
31 #include <rtl/ref.hxx>
33 namespace com::sun::star::uno { class XComponentContext; }
34 namespace com::sun::star::awt { class XFocusListener; }
35 namespace com::sun::star::awt { class XMouseListener; }
36 namespace com::sun::star::awt { class XMouseMotionListener; }
37 namespace com::sun::star::awt { struct PaintEvent; }
38 namespace com::sun::star::awt { struct WindowEvent; }
39 namespace unocontrols { class OMRCListenerMultiplexerHelper; }
41 namespace unocontrols {
43 struct IMPL_MutexContainer
45 // Is necessary to initialize "BaseControl" and make this class thread-safe.
46 ::osl::Mutex m_aMutex;
49 class BaseControl : public css::lang::XServiceInfo
50 , public css::awt::XPaintListener
51 , public css::awt::XWindowListener
52 , public css::awt::XView
53 , public css::awt::XWindow
54 , public css::awt::XControl
55 , public IMPL_MutexContainer
56 , public ::cppu::OComponentHelper
58 public:
59 BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
61 virtual ~BaseControl() override;
63 // XInterface
65 /**
66 @short give answer, if interface is supported
67 @descr The interfaces are searched by type.
69 @seealso XInterface
71 @param "rType" is the type of searched interface.
73 @return Any information about found interface
75 @onerror A RuntimeException is thrown.
78 virtual css::uno::Any SAL_CALL queryInterface(
79 const css::uno::Type& aType
80 ) override;
82 /**
83 @short increment refcount
84 @seealso XInterface
85 @seealso release()
86 @onerror A RuntimeException is thrown.
89 virtual void SAL_CALL acquire() throw() override;
91 /**
92 @short decrement refcount
93 @seealso XInterface
94 @seealso acquire()
95 @onerror A RuntimeException is thrown.
98 virtual void SAL_CALL release() throw() override;
100 // XTypeProvider
103 @short get information about supported interfaces
104 @seealso XTypeProvider
105 @return Sequence of types of all supported interfaces
107 @onerror A RuntimeException is thrown.
110 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
113 @short get implementation id
114 @descr This ID is necessary for UNO-caching. If there no ID, cache is disabled.
115 Another way, cache is enabled.
117 @seealso XTypeProvider
118 @return ID as Sequence of byte
120 @onerror A RuntimeException is thrown.
123 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
125 // XAggregation
127 virtual void SAL_CALL setDelegator(
128 const css::uno::Reference< css::uno::XInterface >& xDelegator
129 ) override;
131 virtual css::uno::Any SAL_CALL queryAggregation(
132 const css::uno::Type& aType
133 ) override;
135 // XServiceInfo
137 virtual sal_Bool SAL_CALL supportsService(
138 const OUString& sServiceName
139 ) override;
141 virtual OUString SAL_CALL getImplementationName() override;
143 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
145 // XComponent
147 virtual void SAL_CALL dispose() override;
149 virtual void SAL_CALL addEventListener(
150 const css::uno::Reference< css::lang::XEventListener >& xListener
151 ) override;
153 virtual void SAL_CALL removeEventListener(
154 const css::uno::Reference< css::lang::XEventListener >& xListener
155 ) override;
157 // XControl
159 virtual void SAL_CALL createPeer(
160 const css::uno::Reference< css::awt::XToolkit >& xToolkit,
161 const css::uno::Reference< css::awt::XWindowPeer >& xParent
162 ) override;
164 virtual void SAL_CALL setContext(
165 const css::uno::Reference< css::uno::XInterface >& xContext
166 ) override;
168 virtual sal_Bool SAL_CALL setModel(
169 const css::uno::Reference< css::awt::XControlModel >& xModel
170 ) override = 0;
172 virtual void SAL_CALL setDesignMode( sal_Bool bOn ) override;
174 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getContext() override;
176 virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override = 0;
178 virtual css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override;
180 virtual css::uno::Reference< css::awt::XView > SAL_CALL getView() override;
182 virtual sal_Bool SAL_CALL isDesignMode() override;
184 virtual sal_Bool SAL_CALL isTransparent() override;
186 // XWindow
188 virtual void SAL_CALL setPosSize( sal_Int32 nX ,
189 sal_Int32 nY ,
190 sal_Int32 nWidth ,
191 sal_Int32 nHeight ,
192 sal_Int16 nFlags ) override;
194 virtual void SAL_CALL setVisible( sal_Bool bVisible ) override;
196 virtual void SAL_CALL setEnable( sal_Bool bEnable ) override;
198 virtual void SAL_CALL setFocus() override;
200 virtual css::awt::Rectangle SAL_CALL getPosSize() override;
202 virtual void SAL_CALL addWindowListener(
203 const css::uno::Reference< css::awt::XWindowListener >& xListener
204 ) override;
206 virtual void SAL_CALL addFocusListener(
207 const css::uno::Reference< css::awt::XFocusListener >& xListener
208 ) override;
210 virtual void SAL_CALL addKeyListener(
211 const css::uno::Reference< css::awt::XKeyListener >& xListener ) override;
213 virtual void SAL_CALL addMouseListener(
214 const css::uno::Reference< css::awt::XMouseListener >& xListener
215 ) override;
217 virtual void SAL_CALL addMouseMotionListener(
218 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
219 ) override;
221 virtual void SAL_CALL addPaintListener(
222 const css::uno::Reference< css::awt::XPaintListener >& xListener
223 ) override;
225 virtual void SAL_CALL removeWindowListener(
226 const css::uno::Reference< css::awt::XWindowListener >& xListener
227 ) override;
229 virtual void SAL_CALL removeFocusListener(
230 const css::uno::Reference< css::awt::XFocusListener >& xListener
231 ) override;
233 virtual void SAL_CALL removeKeyListener(
234 const css::uno::Reference< css::awt::XKeyListener >& xListener
235 ) override;
237 virtual void SAL_CALL removeMouseListener(
238 const css::uno::Reference< css::awt::XMouseListener >& xListener
239 ) override;
241 virtual void SAL_CALL removeMouseMotionListener(
242 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
243 ) override;
245 virtual void SAL_CALL removePaintListener(
246 const css::uno::Reference< css::awt::XPaintListener >& xListener
247 ) override;
249 // XView
251 virtual void SAL_CALL draw( sal_Int32 nX ,
252 sal_Int32 nY ) override;
254 virtual sal_Bool SAL_CALL setGraphics(
255 const css::uno::Reference< css::awt::XGraphics >& xDevice
256 ) override;
258 virtual void SAL_CALL setZoom( float fZoomX ,
259 float fZoomY ) override;
261 virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() override;
263 virtual css::awt::Size SAL_CALL getSize() override;
265 // css::lang::XEventListener
267 virtual void SAL_CALL disposing(
268 const css::lang::EventObject& rSource
269 ) override;
271 // XPaintListener
273 virtual void SAL_CALL windowPaint(
274 const css::awt::PaintEvent& rEvent
275 ) override;
277 // XWindowListener
279 virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) override;
280 virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) override;
281 virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) override;
282 virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override;
284 protected:
285 using OComponentHelper::disposing;
287 const css::uno::Reference< css::uno::XComponentContext >& impl_getComponentContext() const { return m_xComponentContext;}
289 const css::uno::Reference< css::awt::XWindow >& impl_getPeerWindow() const { return m_xPeerWindow;}
291 const css::uno::Reference< css::awt::XGraphics >& impl_getGraphicsPeer() const { return m_xGraphicsPeer;}
293 sal_Int32 impl_getWidth() const { return m_nWidth;}
295 sal_Int32 impl_getHeight() const { return m_nHeight;}
297 virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
298 const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
301 virtual void impl_paint( sal_Int32 nX ,
302 sal_Int32 nY ,
303 const css::uno::Reference< css::awt::XGraphics >& xGraphics );
305 virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent );
307 const css::uno::Reference< css::uno::XInterface >& impl_getDelegator() const { return m_xDelegator;}
309 private:
310 OMRCListenerMultiplexerHelper* impl_getMultiplexer();
312 css::uno::Reference< css::uno::XComponentContext > m_xComponentContext;
313 css::uno::Reference< css::uno::XInterface > m_xDelegator;
314 rtl::Reference<OMRCListenerMultiplexerHelper> m_xMultiplexer; // multiplex events
315 css::uno::Reference< css::uno::XInterface > m_xContext;
316 css::uno::Reference< css::awt::XWindowPeer > m_xPeer;
317 css::uno::Reference< css::awt::XWindow > m_xPeerWindow;
318 css::uno::Reference< css::awt::XGraphics > m_xGraphicsView; // graphics for css::awt::XView-operations
319 css::uno::Reference< css::awt::XGraphics > m_xGraphicsPeer; // graphics for painting on a peer
320 sal_Int32 m_nX; // Position ...
321 sal_Int32 m_nY;
322 sal_Int32 m_nWidth; // ... and size of window
323 sal_Int32 m_nHeight;
324 bool m_bVisible; // Some state flags
325 bool m_bInDesignMode;
326 bool m_bEnable;
331 #endif // INCLUDED_UNOCONTROLS_INC_BASECONTROL_HXX
333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */