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 cppu::BaseMutex
,
43 public cppu::WeakComponentImplHelper
<css::lang::XServiceInfo
,
44 css::awt::XPaintListener
,
45 css::awt::XWindowListener
,
51 BaseControl( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
53 virtual ~BaseControl() override
;
57 virtual sal_Bool SAL_CALL
supportsService(
58 const OUString
& sServiceName
61 virtual OUString SAL_CALL
getImplementationName() override
;
63 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
67 virtual void SAL_CALL
dispose() override
;
69 virtual void SAL_CALL
addEventListener(
70 const css::uno::Reference
< css::lang::XEventListener
>& xListener
73 virtual void SAL_CALL
removeEventListener(
74 const css::uno::Reference
< css::lang::XEventListener
>& xListener
79 virtual void SAL_CALL
createPeer(
80 const css::uno::Reference
< css::awt::XToolkit
>& xToolkit
,
81 const css::uno::Reference
< css::awt::XWindowPeer
>& xParent
84 virtual void SAL_CALL
setContext(
85 const css::uno::Reference
< css::uno::XInterface
>& xContext
88 virtual sal_Bool SAL_CALL
setModel(
89 const css::uno::Reference
< css::awt::XControlModel
>& xModel
92 virtual void SAL_CALL
setDesignMode( sal_Bool bOn
) override
;
94 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getContext() override
;
96 virtual css::uno::Reference
< css::awt::XControlModel
> SAL_CALL
getModel() override
= 0;
98 virtual css::uno::Reference
< css::awt::XWindowPeer
> SAL_CALL
getPeer() override
;
100 virtual css::uno::Reference
< css::awt::XView
> SAL_CALL
getView() override
;
102 virtual sal_Bool SAL_CALL
isDesignMode() override
;
104 virtual sal_Bool SAL_CALL
isTransparent() override
;
108 virtual void SAL_CALL
setPosSize( sal_Int32 nX
,
112 sal_Int16 nFlags
) override
;
114 virtual void SAL_CALL
setVisible( sal_Bool bVisible
) override
;
116 virtual void SAL_CALL
setEnable( sal_Bool bEnable
) override
;
118 virtual void SAL_CALL
setFocus() override
;
120 virtual css::awt::Rectangle SAL_CALL
getPosSize() override
;
122 virtual void SAL_CALL
addWindowListener(
123 const css::uno::Reference
< css::awt::XWindowListener
>& xListener
126 virtual void SAL_CALL
addFocusListener(
127 const css::uno::Reference
< css::awt::XFocusListener
>& xListener
130 virtual void SAL_CALL
addKeyListener(
131 const css::uno::Reference
< css::awt::XKeyListener
>& xListener
) override
;
133 virtual void SAL_CALL
addMouseListener(
134 const css::uno::Reference
< css::awt::XMouseListener
>& xListener
137 virtual void SAL_CALL
addMouseMotionListener(
138 const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
141 virtual void SAL_CALL
addPaintListener(
142 const css::uno::Reference
< css::awt::XPaintListener
>& xListener
145 virtual void SAL_CALL
removeWindowListener(
146 const css::uno::Reference
< css::awt::XWindowListener
>& xListener
149 virtual void SAL_CALL
removeFocusListener(
150 const css::uno::Reference
< css::awt::XFocusListener
>& xListener
153 virtual void SAL_CALL
removeKeyListener(
154 const css::uno::Reference
< css::awt::XKeyListener
>& xListener
157 virtual void SAL_CALL
removeMouseListener(
158 const css::uno::Reference
< css::awt::XMouseListener
>& xListener
161 virtual void SAL_CALL
removeMouseMotionListener(
162 const css::uno::Reference
< css::awt::XMouseMotionListener
>& xListener
165 virtual void SAL_CALL
removePaintListener(
166 const css::uno::Reference
< css::awt::XPaintListener
>& xListener
171 virtual void SAL_CALL
draw( sal_Int32 nX
,
172 sal_Int32 nY
) override
;
174 virtual sal_Bool SAL_CALL
setGraphics(
175 const css::uno::Reference
< css::awt::XGraphics
>& xDevice
178 virtual void SAL_CALL
setZoom( float fZoomX
,
179 float fZoomY
) override
;
181 virtual css::uno::Reference
< css::awt::XGraphics
> SAL_CALL
getGraphics() override
;
183 virtual css::awt::Size SAL_CALL
getSize() override
;
185 // css::lang::XEventListener
187 virtual void SAL_CALL
disposing(
188 const css::lang::EventObject
& rSource
193 virtual void SAL_CALL
windowPaint(
194 const css::awt::PaintEvent
& rEvent
199 virtual void SAL_CALL
windowResized( const css::awt::WindowEvent
& aEvent
) override
;
200 virtual void SAL_CALL
windowMoved( const css::awt::WindowEvent
& aEvent
) override
;
201 virtual void SAL_CALL
windowShown( const css::lang::EventObject
& aEvent
) override
;
202 virtual void SAL_CALL
windowHidden( const css::lang::EventObject
& aEvent
) override
;
205 using WeakComponentImplHelperBase::disposing
;
207 const css::uno::Reference
< css::uno::XComponentContext
>& impl_getComponentContext() const { return m_xComponentContext
;}
209 const css::uno::Reference
< css::awt::XWindow
>& impl_getPeerWindow() const { return m_xPeerWindow
;}
211 const css::uno::Reference
< css::awt::XGraphics
>& impl_getGraphicsPeer() const { return m_xGraphicsPeer
;}
213 sal_Int32
impl_getWidth() const { return m_nWidth
;}
215 sal_Int32
impl_getHeight() const { return m_nHeight
;}
217 virtual css::awt::WindowDescriptor
impl_getWindowDescriptor(
218 const css::uno::Reference
< css::awt::XWindowPeer
>& xParentPeer
221 virtual void impl_paint( sal_Int32 nX
,
223 const css::uno::Reference
< css::awt::XGraphics
>& xGraphics
);
225 virtual void impl_recalcLayout( const css::awt::WindowEvent
& aEvent
);
228 OMRCListenerMultiplexerHelper
* impl_getMultiplexer();
230 css::uno::Reference
< css::uno::XComponentContext
> m_xComponentContext
;
231 rtl::Reference
<OMRCListenerMultiplexerHelper
> m_xMultiplexer
; // multiplex events
232 css::uno::Reference
< css::uno::XInterface
> m_xContext
;
233 css::uno::Reference
< css::awt::XWindowPeer
> m_xPeer
;
234 css::uno::Reference
< css::awt::XWindow
> m_xPeerWindow
;
235 css::uno::Reference
< css::awt::XGraphics
> m_xGraphicsView
; // graphics for css::awt::XView-operations
236 css::uno::Reference
< css::awt::XGraphics
> m_xGraphicsPeer
; // graphics for painting on a peer
237 sal_Int32 m_nX
; // Position ...
239 sal_Int32 m_nWidth
; // ... and size of window
241 bool m_bVisible
; // Some state flags
242 bool m_bInDesignMode
;
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */