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 .
22 #include <com/sun/star/awt/XPaintListener.hpp>
23 #include <com/sun/star/awt/XWindowListener.hpp>
24 #include <com/sun/star/awt/XControl.hpp>
25 #include <com/sun/star/awt/XWindow.hpp>
26 #include <com/sun/star/awt/XView.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <osl/mutex.hxx>
29 #include <cppuhelper/component.hxx>
30 #include <rtl/ref.hxx>
32 namespace com::sun::star::uno
{ class XComponentContext
; }
33 namespace com::sun::star::awt
{ class XFocusListener
; }
34 namespace com::sun::star::awt
{ class XMouseListener
; }
35 namespace com::sun::star::awt
{ class XMouseMotionListener
; }
36 namespace com::sun::star::awt
{ struct PaintEvent
; }
37 namespace com::sun::star::awt
{ struct WindowEvent
; }
38 namespace unocontrols
{ class OMRCListenerMultiplexerHelper
; }
40 namespace unocontrols
{
42 struct IMPL_MutexContainer
44 // Is necessary to initialize "BaseControl" and make this class thread-safe.
45 ::osl::Mutex m_aMutex
;
48 class BaseControl
: public css::lang::XServiceInfo
49 , public css::awt::XPaintListener
50 , public css::awt::XWindowListener
51 , public css::awt::XView
52 , public css::awt::XWindow
53 , public css::awt::XControl
54 , public IMPL_MutexContainer
55 , public ::cppu::OComponentHelper
58 BaseControl( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
60 virtual ~BaseControl() override
;
65 @short give answer, if interface is supported
66 @descr The interfaces are searched by type.
70 @param "rType" is the type of searched interface.
72 @return Any information about found interface
74 @onerror A RuntimeException is thrown.
77 virtual css::uno::Any SAL_CALL
queryInterface(
78 const css::uno::Type
& aType
82 @short increment refcount
85 @onerror A RuntimeException is thrown.
88 virtual void SAL_CALL
acquire() throw() override
;
91 @short decrement refcount
94 @onerror A RuntimeException is thrown.
97 virtual void SAL_CALL
release() throw() override
;
102 @short get information about supported interfaces
103 @seealso XTypeProvider
104 @return Sequence of types of all supported interfaces
106 @onerror A RuntimeException is thrown.
109 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
112 @short get implementation id
113 @descr This ID is necessary for UNO-caching. If there no ID, cache is disabled.
114 Another way, cache is enabled.
116 @seealso XTypeProvider
117 @return ID as Sequence of byte
119 @onerror A RuntimeException is thrown.
122 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
126 virtual void SAL_CALL
setDelegator(
127 const css::uno::Reference
< css::uno::XInterface
>& xDelegator
130 virtual css::uno::Any SAL_CALL
queryAggregation(
131 const css::uno::Type
& aType
136 virtual sal_Bool SAL_CALL
supportsService(
137 const OUString
& sServiceName
140 virtual OUString SAL_CALL
getImplementationName() override
;
142 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
146 virtual void SAL_CALL
dispose() override
;
148 virtual void SAL_CALL
addEventListener(
149 const css::uno::Reference
< css::lang::XEventListener
>& xListener
152 virtual void SAL_CALL
removeEventListener(
153 const css::uno::Reference
< css::lang::XEventListener
>& xListener
158 virtual void SAL_CALL
createPeer(
159 const css::uno::Reference
< css::awt::XToolkit
>& xToolkit
,
160 const css::uno::Reference
< css::awt::XWindowPeer
>& xParent
163 virtual void SAL_CALL
setContext(
164 const css::uno::Reference
< css::uno::XInterface
>& xContext
167 virtual sal_Bool SAL_CALL
setModel(
168 const css::uno::Reference
< css::awt::XControlModel
>& xModel
171 virtual void SAL_CALL
setDesignMode( sal_Bool bOn
) override
;
173 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getContext() override
;
175 virtual css::uno::Reference
< css::awt::XControlModel
> SAL_CALL
getModel() override
= 0;
177 virtual css::uno::Reference
< css::awt::XWindowPeer
> SAL_CALL
getPeer() override
;
179 virtual css::uno::Reference
< css::awt::XView
> SAL_CALL
getView() override
;
181 virtual sal_Bool SAL_CALL
isDesignMode() override
;
183 virtual sal_Bool SAL_CALL
isTransparent() override
;
187 virtual void SAL_CALL
setPosSize( sal_Int32 nX
,
191 sal_Int16 nFlags
) override
;
193 virtual void SAL_CALL
setVisible( sal_Bool bVisible
) override
;
195 virtual void SAL_CALL
setEnable( sal_Bool bEnable
) override
;
197 virtual void SAL_CALL
setFocus() override
;
199 virtual css::awt::Rectangle SAL_CALL
getPosSize() override
;
201 virtual void SAL_CALL
addWindowListener(
202 const css::uno::Reference
< css::awt::XWindowListener
>& xListener
205 virtual void SAL_CALL
addFocusListener(
206 const css::uno::Reference
< css::awt::XFocusListener
>& xListener
209 virtual void SAL_CALL
addKeyListener(
210 const css::uno::Reference
< css::awt::XKeyListener
>& xListener
) override
;
212 virtual void SAL_CALL
addMouseListener(
213 const css::uno::Reference
< css::awt::XMouseListener
>& xListener
216 virtual void SAL_CALL
addMouseMotionListener(
217 const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
220 virtual void SAL_CALL
addPaintListener(
221 const css::uno::Reference
< css::awt::XPaintListener
>& xListener
224 virtual void SAL_CALL
removeWindowListener(
225 const css::uno::Reference
< css::awt::XWindowListener
>& xListener
228 virtual void SAL_CALL
removeFocusListener(
229 const css::uno::Reference
< css::awt::XFocusListener
>& xListener
232 virtual void SAL_CALL
removeKeyListener(
233 const css::uno::Reference
< css::awt::XKeyListener
>& xListener
236 virtual void SAL_CALL
removeMouseListener(
237 const css::uno::Reference
< css::awt::XMouseListener
>& xListener
240 virtual void SAL_CALL
removeMouseMotionListener(
241 const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
244 virtual void SAL_CALL
removePaintListener(
245 const css::uno::Reference
< css::awt::XPaintListener
>& xListener
250 virtual void SAL_CALL
draw( sal_Int32 nX
,
251 sal_Int32 nY
) override
;
253 virtual sal_Bool SAL_CALL
setGraphics(
254 const css::uno::Reference
< css::awt::XGraphics
>& xDevice
257 virtual void SAL_CALL
setZoom( float fZoomX
,
258 float fZoomY
) override
;
260 virtual css::uno::Reference
< css::awt::XGraphics
> SAL_CALL
getGraphics() override
;
262 virtual css::awt::Size SAL_CALL
getSize() override
;
264 // css::lang::XEventListener
266 virtual void SAL_CALL
disposing(
267 const css::lang::EventObject
& rSource
272 virtual void SAL_CALL
windowPaint(
273 const css::awt::PaintEvent
& rEvent
278 virtual void SAL_CALL
windowResized( const css::awt::WindowEvent
& aEvent
) override
;
279 virtual void SAL_CALL
windowMoved( const css::awt::WindowEvent
& aEvent
) override
;
280 virtual void SAL_CALL
windowShown( const css::lang::EventObject
& aEvent
) override
;
281 virtual void SAL_CALL
windowHidden( const css::lang::EventObject
& aEvent
) override
;
284 using OComponentHelper::disposing
;
286 const css::uno::Reference
< css::uno::XComponentContext
>& impl_getComponentContext() const { return m_xComponentContext
;}
288 const css::uno::Reference
< css::awt::XWindow
>& impl_getPeerWindow() const { return m_xPeerWindow
;}
290 const css::uno::Reference
< css::awt::XGraphics
>& impl_getGraphicsPeer() const { return m_xGraphicsPeer
;}
292 sal_Int32
impl_getWidth() const { return m_nWidth
;}
294 sal_Int32
impl_getHeight() const { return m_nHeight
;}
296 virtual css::awt::WindowDescriptor
impl_getWindowDescriptor(
297 const css::uno::Reference
< css::awt::XWindowPeer
>& xParentPeer
300 virtual void impl_paint( sal_Int32 nX
,
302 const css::uno::Reference
< css::awt::XGraphics
>& xGraphics
);
304 virtual void impl_recalcLayout( const css::awt::WindowEvent
& aEvent
);
306 const css::uno::Reference
< css::uno::XInterface
>& impl_getDelegator() const { return m_xDelegator
;}
309 OMRCListenerMultiplexerHelper
* impl_getMultiplexer();
311 css::uno::Reference
< css::uno::XComponentContext
> m_xComponentContext
;
312 css::uno::Reference
< css::uno::XInterface
> m_xDelegator
;
313 rtl::Reference
<OMRCListenerMultiplexerHelper
> m_xMultiplexer
; // multiplex events
314 css::uno::Reference
< css::uno::XInterface
> m_xContext
;
315 css::uno::Reference
< css::awt::XWindowPeer
> m_xPeer
;
316 css::uno::Reference
< css::awt::XWindow
> m_xPeerWindow
;
317 css::uno::Reference
< css::awt::XGraphics
> m_xGraphicsView
; // graphics for css::awt::XView-operations
318 css::uno::Reference
< css::awt::XGraphics
> m_xGraphicsPeer
; // graphics for painting on a peer
319 sal_Int32 m_nX
; // Position ...
321 sal_Int32 m_nWidth
; // ... and size of window
323 bool m_bVisible
; // Some state flags
324 bool m_bInDesignMode
;
331 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */