fix build
[LibreOffice.git] / UnoControls / inc / basecontrol.hxx
blobb3451ab91734d32f1bbe2bb0c4b5acd3f49d60d4
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/XKeyListener.hpp>
24 #include <com/sun/star/awt/XPaintListener.hpp>
25 #include <com/sun/star/awt/KeyEvent.hpp>
26 #include <com/sun/star/awt/KeyModifier.hpp>
27 #include <com/sun/star/awt/XMouseMotionListener.hpp>
28 #include <com/sun/star/awt/FocusEvent.hpp>
29 #include <com/sun/star/awt/XWindowListener.hpp>
30 #include <com/sun/star/awt/XActivateListener.hpp>
31 #include <com/sun/star/awt/MouseEvent.hpp>
32 #include <com/sun/star/awt/XTopWindowListener.hpp>
33 #include <com/sun/star/awt/PaintEvent.hpp>
34 #include <com/sun/star/awt/InputEvent.hpp>
35 #include <com/sun/star/awt/KeyGroup.hpp>
36 #include <com/sun/star/awt/Key.hpp>
37 #include <com/sun/star/awt/WindowEvent.hpp>
38 #include <com/sun/star/awt/XMouseListener.hpp>
39 #include <com/sun/star/awt/KeyFunction.hpp>
40 #include <com/sun/star/awt/FocusChangeReason.hpp>
41 #include <com/sun/star/awt/MouseButton.hpp>
42 #include <com/sun/star/awt/XFocusListener.hpp>
43 #include <com/sun/star/awt/XFileDialog.hpp>
44 #include <com/sun/star/awt/XTextComponent.hpp>
45 #include <com/sun/star/awt/XListBox.hpp>
46 #include <com/sun/star/awt/XProgressMonitor.hpp>
47 #include <com/sun/star/awt/TextAlign.hpp>
48 #include <com/sun/star/awt/XScrollBar.hpp>
49 #include <com/sun/star/awt/XVclContainerPeer.hpp>
50 #include <com/sun/star/awt/XTabControllerModel.hpp>
51 #include <com/sun/star/awt/XMessageBox.hpp>
52 #include <com/sun/star/awt/XTextEditField.hpp>
53 #include <com/sun/star/awt/Style.hpp>
54 #include <com/sun/star/awt/XTimeField.hpp>
55 #include <com/sun/star/awt/XVclWindowPeer.hpp>
56 #include <com/sun/star/awt/XControlModel.hpp>
57 #include <com/sun/star/awt/XSpinField.hpp>
58 #include <com/sun/star/awt/XUnoControlContainer.hpp>
59 #include <com/sun/star/awt/XTextLayoutConstrains.hpp>
60 #include <com/sun/star/awt/XNumericField.hpp>
61 #include <com/sun/star/awt/XButton.hpp>
62 #include <com/sun/star/awt/XTextArea.hpp>
63 #include <com/sun/star/awt/XImageButton.hpp>
64 #include <com/sun/star/awt/XFixedText.hpp>
65 #include <com/sun/star/awt/XControlContainer.hpp>
66 #include <com/sun/star/awt/XDialog.hpp>
67 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
68 #include <com/sun/star/awt/XRadioButton.hpp>
69 #include <com/sun/star/awt/XCurrencyField.hpp>
70 #include <com/sun/star/awt/XPatternField.hpp>
71 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
72 #include <com/sun/star/awt/XTabController.hpp>
73 #include <com/sun/star/awt/XVclContainer.hpp>
74 #include <com/sun/star/awt/XDateField.hpp>
75 #include <com/sun/star/awt/XComboBox.hpp>
76 #include <com/sun/star/awt/XControl.hpp>
77 #include <com/sun/star/awt/XCheckBox.hpp>
78 #include <com/sun/star/awt/XLayoutConstrains.hpp>
79 #include <com/sun/star/awt/XProgressBar.hpp>
80 #include <com/sun/star/awt/XTopWindow.hpp>
81 #include <com/sun/star/awt/XWindow.hpp>
82 #include <com/sun/star/awt/PosSize.hpp>
83 #include <com/sun/star/awt/XView.hpp>
84 #include <com/sun/star/lang/XServiceInfo.hpp>
85 #include <osl/mutex.hxx>
86 #include <cppuhelper/weak.hxx>
87 #include <cppuhelper/component.hxx>
88 #include <rtl/ref.hxx>
90 #include "multiplexer.hxx"
92 namespace com { namespace sun { namespace star { namespace uno {
93 class XComponentContext;
94 } } } }
96 namespace unocontrols {
98 struct IMPL_MutexContainer
100 // Is necessary to initialize "BaseControl" and make this class thread-safe.
101 ::osl::Mutex m_aMutex;
104 class BaseControl : public css::lang::XServiceInfo
105 , public css::awt::XPaintListener
106 , public css::awt::XWindowListener
107 , public css::awt::XView
108 , public css::awt::XWindow
109 , public css::awt::XControl
110 , public IMPL_MutexContainer
111 , public ::cppu::OComponentHelper
113 public:
114 BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
116 virtual ~BaseControl() override;
118 // XInterface
121 @short give answer, if interface is supported
122 @descr The interfaces are searched by type.
124 @seealso XInterface
126 @param "rType" is the type of searched interface.
128 @return Any information about found interface
130 @onerror A RuntimeException is thrown.
133 virtual css::uno::Any SAL_CALL queryInterface(
134 const css::uno::Type& aType
135 ) override;
138 @short increment refcount
139 @seealso XInterface
140 @seealso release()
141 @onerror A RuntimeException is thrown.
144 virtual void SAL_CALL acquire() throw() override;
147 @short decrement refcount
148 @seealso XInterface
149 @seealso acquire()
150 @onerror A RuntimeException is thrown.
153 virtual void SAL_CALL release() throw() override;
155 // XTypeProvider
158 @short get information about supported interfaces
159 @seealso XTypeProvider
160 @return Sequence of types of all supported interfaces
162 @onerror A RuntimeException is thrown.
165 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
168 @short get implementation id
169 @descr This ID is necessary for UNO-caching. If there no ID, cache is disabled.
170 Another way, cache is enabled.
172 @seealso XTypeProvider
173 @return ID as Sequence of byte
175 @onerror A RuntimeException is thrown.
178 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
180 // XAggregation
182 virtual void SAL_CALL setDelegator(
183 const css::uno::Reference< css::uno::XInterface >& xDelegator
184 ) override;
186 virtual css::uno::Any SAL_CALL queryAggregation(
187 const css::uno::Type& aType
188 ) override;
190 // XServiceInfo
192 virtual sal_Bool SAL_CALL supportsService(
193 const OUString& sServiceName
194 ) override;
196 virtual OUString SAL_CALL getImplementationName() override;
198 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
200 // XComponent
202 virtual void SAL_CALL dispose() override;
204 virtual void SAL_CALL addEventListener(
205 const css::uno::Reference< css::lang::XEventListener >& xListener
206 ) override;
208 virtual void SAL_CALL removeEventListener(
209 const css::uno::Reference< css::lang::XEventListener >& xListener
210 ) override;
212 // XControl
214 virtual void SAL_CALL createPeer(
215 const css::uno::Reference< css::awt::XToolkit >& xToolkit,
216 const css::uno::Reference< css::awt::XWindowPeer >& xParent
217 ) override;
219 virtual void SAL_CALL setContext(
220 const css::uno::Reference< css::uno::XInterface >& xContext
221 ) override;
223 virtual sal_Bool SAL_CALL setModel(
224 const css::uno::Reference< css::awt::XControlModel >& xModel
225 ) override = 0;
227 virtual void SAL_CALL setDesignMode( sal_Bool bOn ) override;
229 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getContext() override;
231 virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override = 0;
233 virtual css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override;
235 virtual css::uno::Reference< css::awt::XView > SAL_CALL getView() override;
237 virtual sal_Bool SAL_CALL isDesignMode() override;
239 virtual sal_Bool SAL_CALL isTransparent() override;
241 // XWindow
243 virtual void SAL_CALL setPosSize( sal_Int32 nX ,
244 sal_Int32 nY ,
245 sal_Int32 nWidth ,
246 sal_Int32 nHeight ,
247 sal_Int16 nFlags ) override;
249 virtual void SAL_CALL setVisible( sal_Bool bVisible ) override;
251 virtual void SAL_CALL setEnable( sal_Bool bEnable ) override;
253 virtual void SAL_CALL setFocus() override;
255 virtual css::awt::Rectangle SAL_CALL getPosSize() override;
257 virtual void SAL_CALL addWindowListener(
258 const css::uno::Reference< css::awt::XWindowListener >& xListener
259 ) override;
261 virtual void SAL_CALL addFocusListener(
262 const css::uno::Reference< css::awt::XFocusListener >& xListener
263 ) override;
265 virtual void SAL_CALL addKeyListener(
266 const css::uno::Reference< css::awt::XKeyListener >& xListener ) override;
268 virtual void SAL_CALL addMouseListener(
269 const css::uno::Reference< css::awt::XMouseListener >& xListener
270 ) override;
272 virtual void SAL_CALL addMouseMotionListener(
273 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
274 ) override;
276 virtual void SAL_CALL addPaintListener(
277 const css::uno::Reference< css::awt::XPaintListener >& xListener
278 ) override;
280 virtual void SAL_CALL removeWindowListener(
281 const css::uno::Reference< css::awt::XWindowListener >& xListener
282 ) override;
284 virtual void SAL_CALL removeFocusListener(
285 const css::uno::Reference< css::awt::XFocusListener >& xListener
286 ) override;
288 virtual void SAL_CALL removeKeyListener(
289 const css::uno::Reference< css::awt::XKeyListener >& xListener
290 ) override;
292 virtual void SAL_CALL removeMouseListener(
293 const css::uno::Reference< css::awt::XMouseListener >& xListener
294 ) override;
296 virtual void SAL_CALL removeMouseMotionListener(
297 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
298 ) override;
300 virtual void SAL_CALL removePaintListener(
301 const css::uno::Reference< css::awt::XPaintListener >& xListener
302 ) override;
304 // XView
306 virtual void SAL_CALL draw( sal_Int32 nX ,
307 sal_Int32 nY ) override;
309 virtual sal_Bool SAL_CALL setGraphics(
310 const css::uno::Reference< css::awt::XGraphics >& xDevice
311 ) override;
313 virtual void SAL_CALL setZoom( float fZoomX ,
314 float fZoomY ) override;
316 virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() override;
318 virtual css::awt::Size SAL_CALL getSize() override;
320 // css::lang::XEventListener
322 virtual void SAL_CALL disposing(
323 const css::lang::EventObject& rSource
324 ) override;
326 // XPaintListener
328 virtual void SAL_CALL windowPaint(
329 const css::awt::PaintEvent& rEvent
330 ) override;
332 // XWindowListener
334 virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) override;
335 virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) override;
336 virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) override;
337 virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override;
339 protected:
340 using OComponentHelper::disposing;
342 const css::uno::Reference< css::uno::XComponentContext >& impl_getComponentContext() const { return m_xComponentContext;}
344 const css::uno::Reference< css::awt::XWindow >& impl_getPeerWindow() const { return m_xPeerWindow;}
346 const css::uno::Reference< css::awt::XGraphics >& impl_getGraphicsPeer() const { return m_xGraphicsPeer;}
348 sal_Int32 impl_getWidth() const { return m_nWidth;}
350 sal_Int32 impl_getHeight() const { return m_nHeight;}
352 virtual css::awt::WindowDescriptor* impl_getWindowDescriptor(
353 const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
356 virtual void impl_paint( sal_Int32 nX ,
357 sal_Int32 nY ,
358 const css::uno::Reference< css::awt::XGraphics >& xGraphics );
360 virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent );
362 const css::uno::Reference< css::uno::XInterface >& impl_getDelegator() const { return m_xDelegator;}
364 private:
365 OMRCListenerMultiplexerHelper* impl_getMultiplexer();
367 css::uno::Reference< css::uno::XComponentContext > m_xComponentContext;
368 css::uno::Reference< css::uno::XInterface > m_xDelegator;
369 rtl::Reference<OMRCListenerMultiplexerHelper> m_xMultiplexer; // multiplex events
370 css::uno::Reference< css::uno::XInterface > m_xContext;
371 css::uno::Reference< css::awt::XWindowPeer > m_xPeer;
372 css::uno::Reference< css::awt::XWindow > m_xPeerWindow;
373 css::uno::Reference< css::awt::XGraphics > m_xGraphicsView; // graphics for css::awt::XView-operations
374 css::uno::Reference< css::awt::XGraphics > m_xGraphicsPeer; // graphics for painting on a peer
375 sal_Int32 m_nX; // Position ...
376 sal_Int32 m_nY;
377 sal_Int32 m_nWidth; // ... and size of window
378 sal_Int32 m_nHeight;
379 bool m_bVisible; // Some state flags
380 bool m_bInDesignMode;
381 bool m_bEnable;
386 #endif // INCLUDED_UNOCONTROLS_INC_BASECONTROL_HXX
388 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */