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 <cppuhelper/compbase.hxx>
29 #include <cppuhelper/basemutex.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 class BaseControl
: public css::lang::XServiceInfo
43 , public css::awt::XPaintListener
44 , public css::awt::XWindowListener
45 , public css::awt::XView
46 , public css::awt::XWindow
47 , public css::awt::XControl
48 , public cppu::BaseMutex
49 , public ::cppu::WeakComponentImplHelper
<>
52 BaseControl( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
54 virtual ~BaseControl() override
;
59 @short give answer, if interface is supported
60 @descr The interfaces are searched by type.
64 @param "rType" is the type of searched interface.
66 @return Any information about found interface
68 @onerror A RuntimeException is thrown.
71 virtual css::uno::Any SAL_CALL
queryInterface(
72 const css::uno::Type
& aType
76 @short increment refcount
79 @onerror A RuntimeException is thrown.
82 virtual void SAL_CALL
acquire() noexcept override
;
85 @short decrement refcount
88 @onerror A RuntimeException is thrown.
91 virtual void SAL_CALL
release() noexcept override
;
96 @short get information about supported interfaces
97 @seealso XTypeProvider
98 @return Sequence of types of all supported interfaces
100 @onerror A RuntimeException is thrown.
103 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes() override
;
106 @short get implementation id
107 @descr This ID is necessary for UNO-caching. If there no ID, cache is disabled.
108 Another way, cache is enabled.
110 @seealso XTypeProvider
111 @return ID as Sequence of byte
113 @onerror A RuntimeException is thrown.
116 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
120 virtual sal_Bool SAL_CALL
supportsService(
121 const OUString
& sServiceName
124 virtual OUString SAL_CALL
getImplementationName() override
;
126 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
130 virtual void SAL_CALL
dispose() override
;
132 virtual void SAL_CALL
addEventListener(
133 const css::uno::Reference
< css::lang::XEventListener
>& xListener
136 virtual void SAL_CALL
removeEventListener(
137 const css::uno::Reference
< css::lang::XEventListener
>& xListener
142 virtual void SAL_CALL
createPeer(
143 const css::uno::Reference
< css::awt::XToolkit
>& xToolkit
,
144 const css::uno::Reference
< css::awt::XWindowPeer
>& xParent
147 virtual void SAL_CALL
setContext(
148 const css::uno::Reference
< css::uno::XInterface
>& xContext
151 virtual sal_Bool SAL_CALL
setModel(
152 const css::uno::Reference
< css::awt::XControlModel
>& xModel
155 virtual void SAL_CALL
setDesignMode( sal_Bool bOn
) override
;
157 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getContext() override
;
159 virtual css::uno::Reference
< css::awt::XControlModel
> SAL_CALL
getModel() override
= 0;
161 virtual css::uno::Reference
< css::awt::XWindowPeer
> SAL_CALL
getPeer() override
;
163 virtual css::uno::Reference
< css::awt::XView
> SAL_CALL
getView() override
;
165 virtual sal_Bool SAL_CALL
isDesignMode() override
;
167 virtual sal_Bool SAL_CALL
isTransparent() override
;
171 virtual void SAL_CALL
setPosSize( sal_Int32 nX
,
175 sal_Int16 nFlags
) override
;
177 virtual void SAL_CALL
setVisible( sal_Bool bVisible
) override
;
179 virtual void SAL_CALL
setEnable( sal_Bool bEnable
) override
;
181 virtual void SAL_CALL
setFocus() override
;
183 virtual css::awt::Rectangle SAL_CALL
getPosSize() override
;
185 virtual void SAL_CALL
addWindowListener(
186 const css::uno::Reference
< css::awt::XWindowListener
>& xListener
189 virtual void SAL_CALL
addFocusListener(
190 const css::uno::Reference
< css::awt::XFocusListener
>& xListener
193 virtual void SAL_CALL
addKeyListener(
194 const css::uno::Reference
< css::awt::XKeyListener
>& xListener
) override
;
196 virtual void SAL_CALL
addMouseListener(
197 const css::uno::Reference
< css::awt::XMouseListener
>& xListener
200 virtual void SAL_CALL
addMouseMotionListener(
201 const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
204 virtual void SAL_CALL
addPaintListener(
205 const css::uno::Reference
< css::awt::XPaintListener
>& xListener
208 virtual void SAL_CALL
removeWindowListener(
209 const css::uno::Reference
< css::awt::XWindowListener
>& xListener
212 virtual void SAL_CALL
removeFocusListener(
213 const css::uno::Reference
< css::awt::XFocusListener
>& xListener
216 virtual void SAL_CALL
removeKeyListener(
217 const css::uno::Reference
< css::awt::XKeyListener
>& xListener
220 virtual void SAL_CALL
removeMouseListener(
221 const css::uno::Reference
< css::awt::XMouseListener
>& xListener
224 virtual void SAL_CALL
removeMouseMotionListener(
225 const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
228 virtual void SAL_CALL
removePaintListener(
229 const css::uno::Reference
< css::awt::XPaintListener
>& xListener
234 virtual void SAL_CALL
draw( sal_Int32 nX
,
235 sal_Int32 nY
) override
;
237 virtual sal_Bool SAL_CALL
setGraphics(
238 const css::uno::Reference
< css::awt::XGraphics
>& xDevice
241 virtual void SAL_CALL
setZoom( float fZoomX
,
242 float fZoomY
) override
;
244 virtual css::uno::Reference
< css::awt::XGraphics
> SAL_CALL
getGraphics() override
;
246 virtual css::awt::Size SAL_CALL
getSize() override
;
248 // css::lang::XEventListener
250 virtual void SAL_CALL
disposing(
251 const css::lang::EventObject
& rSource
256 virtual void SAL_CALL
windowPaint(
257 const css::awt::PaintEvent
& rEvent
262 virtual void SAL_CALL
windowResized( const css::awt::WindowEvent
& aEvent
) override
;
263 virtual void SAL_CALL
windowMoved( const css::awt::WindowEvent
& aEvent
) override
;
264 virtual void SAL_CALL
windowShown( const css::lang::EventObject
& aEvent
) override
;
265 virtual void SAL_CALL
windowHidden( const css::lang::EventObject
& aEvent
) override
;
268 using WeakComponentImplHelper::disposing
;
270 const css::uno::Reference
< css::uno::XComponentContext
>& impl_getComponentContext() const { return m_xComponentContext
;}
272 const css::uno::Reference
< css::awt::XWindow
>& impl_getPeerWindow() const { return m_xPeerWindow
;}
274 const css::uno::Reference
< css::awt::XGraphics
>& impl_getGraphicsPeer() const { return m_xGraphicsPeer
;}
276 sal_Int32
impl_getWidth() const { return m_nWidth
;}
278 sal_Int32
impl_getHeight() const { return m_nHeight
;}
280 virtual css::awt::WindowDescriptor
impl_getWindowDescriptor(
281 const css::uno::Reference
< css::awt::XWindowPeer
>& xParentPeer
284 virtual void impl_paint( sal_Int32 nX
,
286 const css::uno::Reference
< css::awt::XGraphics
>& xGraphics
);
288 virtual void impl_recalcLayout( const css::awt::WindowEvent
& aEvent
);
291 OMRCListenerMultiplexerHelper
* impl_getMultiplexer();
293 css::uno::Reference
< css::uno::XComponentContext
> m_xComponentContext
;
294 rtl::Reference
<OMRCListenerMultiplexerHelper
> m_xMultiplexer
; // multiplex events
295 css::uno::Reference
< css::uno::XInterface
> m_xContext
;
296 css::uno::Reference
< css::awt::XWindowPeer
> m_xPeer
;
297 css::uno::Reference
< css::awt::XWindow
> m_xPeerWindow
;
298 css::uno::Reference
< css::awt::XGraphics
> m_xGraphicsView
; // graphics for css::awt::XView-operations
299 css::uno::Reference
< css::awt::XGraphics
> m_xGraphicsPeer
; // graphics for painting on a peer
300 sal_Int32 m_nX
; // Position ...
302 sal_Int32 m_nWidth
; // ... and size of window
304 bool m_bVisible
; // Some state flags
305 bool m_bInDesignMode
;
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */