1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
;
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
114 BaseControl( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
116 virtual ~BaseControl() override
;
121 @short give answer, if interface is supported
122 @descr The interfaces are searched by type.
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
138 @short increment refcount
141 @onerror A RuntimeException is thrown.
144 virtual void SAL_CALL
acquire() throw() override
;
147 @short decrement refcount
150 @onerror A RuntimeException is thrown.
153 virtual void SAL_CALL
release() throw() override
;
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
;
182 virtual void SAL_CALL
setDelegator(
183 const css::uno::Reference
< css::uno::XInterface
>& xDelegator
186 virtual css::uno::Any SAL_CALL
queryAggregation(
187 const css::uno::Type
& aType
192 virtual sal_Bool SAL_CALL
supportsService(
193 const OUString
& sServiceName
196 virtual OUString SAL_CALL
getImplementationName() override
;
198 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
202 virtual void SAL_CALL
dispose() override
;
204 virtual void SAL_CALL
addEventListener(
205 const css::uno::Reference
< css::lang::XEventListener
>& xListener
208 virtual void SAL_CALL
removeEventListener(
209 const css::uno::Reference
< css::lang::XEventListener
>& xListener
214 virtual void SAL_CALL
createPeer(
215 const css::uno::Reference
< css::awt::XToolkit
>& xToolkit
,
216 const css::uno::Reference
< css::awt::XWindowPeer
>& xParent
219 virtual void SAL_CALL
setContext(
220 const css::uno::Reference
< css::uno::XInterface
>& xContext
223 virtual sal_Bool SAL_CALL
setModel(
224 const css::uno::Reference
< css::awt::XControlModel
>& xModel
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
;
243 virtual void SAL_CALL
setPosSize( sal_Int32 nX
,
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
261 virtual void SAL_CALL
addFocusListener(
262 const css::uno::Reference
< css::awt::XFocusListener
>& xListener
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
272 virtual void SAL_CALL
addMouseMotionListener(
273 const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
276 virtual void SAL_CALL
addPaintListener(
277 const css::uno::Reference
< css::awt::XPaintListener
>& xListener
280 virtual void SAL_CALL
removeWindowListener(
281 const css::uno::Reference
< css::awt::XWindowListener
>& xListener
284 virtual void SAL_CALL
removeFocusListener(
285 const css::uno::Reference
< css::awt::XFocusListener
>& xListener
288 virtual void SAL_CALL
removeKeyListener(
289 const css::uno::Reference
< css::awt::XKeyListener
>& xListener
292 virtual void SAL_CALL
removeMouseListener(
293 const css::uno::Reference
< css::awt::XMouseListener
>& xListener
296 virtual void SAL_CALL
removeMouseMotionListener(
297 const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
300 virtual void SAL_CALL
removePaintListener(
301 const css::uno::Reference
< css::awt::XPaintListener
>& xListener
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
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
328 virtual void SAL_CALL
windowPaint(
329 const css::awt::PaintEvent
& rEvent
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
;
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
,
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
;}
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 ...
377 sal_Int32 m_nWidth
; // ... and size of window
379 bool m_bVisible
; // Some state flags
380 bool m_bInDesignMode
;
386 #endif // INCLUDED_UNOCONTROLS_INC_BASECONTROL_HXX
388 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */