Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / UnoControls / inc / basecontrol.hxx
blob9f60537bb7cbfc8907331b98df680c7db921a325
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 #pragma once
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<>
51 public:
52 BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
54 virtual ~BaseControl() override;
56 // XInterface
58 /**
59 @short give answer, if interface is supported
60 @descr The interfaces are searched by type.
62 @seealso XInterface
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
73 ) override;
75 /**
76 @short increment refcount
77 @seealso XInterface
78 @seealso release()
79 @onerror A RuntimeException is thrown.
82 virtual void SAL_CALL acquire() noexcept override;
84 /**
85 @short decrement refcount
86 @seealso XInterface
87 @seealso acquire()
88 @onerror A RuntimeException is thrown.
91 virtual void SAL_CALL release() noexcept override;
93 // XTypeProvider
95 /**
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;
118 // XServiceInfo
120 virtual sal_Bool SAL_CALL supportsService(
121 const OUString& sServiceName
122 ) override;
124 virtual OUString SAL_CALL getImplementationName() override;
126 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
128 // XComponent
130 virtual void SAL_CALL dispose() override;
132 virtual void SAL_CALL addEventListener(
133 const css::uno::Reference< css::lang::XEventListener >& xListener
134 ) override;
136 virtual void SAL_CALL removeEventListener(
137 const css::uno::Reference< css::lang::XEventListener >& xListener
138 ) override;
140 // XControl
142 virtual void SAL_CALL createPeer(
143 const css::uno::Reference< css::awt::XToolkit >& xToolkit,
144 const css::uno::Reference< css::awt::XWindowPeer >& xParent
145 ) override;
147 virtual void SAL_CALL setContext(
148 const css::uno::Reference< css::uno::XInterface >& xContext
149 ) override;
151 virtual sal_Bool SAL_CALL setModel(
152 const css::uno::Reference< css::awt::XControlModel >& xModel
153 ) override = 0;
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;
169 // XWindow
171 virtual void SAL_CALL setPosSize( sal_Int32 nX ,
172 sal_Int32 nY ,
173 sal_Int32 nWidth ,
174 sal_Int32 nHeight ,
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
187 ) override;
189 virtual void SAL_CALL addFocusListener(
190 const css::uno::Reference< css::awt::XFocusListener >& xListener
191 ) override;
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
198 ) override;
200 virtual void SAL_CALL addMouseMotionListener(
201 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
202 ) override;
204 virtual void SAL_CALL addPaintListener(
205 const css::uno::Reference< css::awt::XPaintListener >& xListener
206 ) override;
208 virtual void SAL_CALL removeWindowListener(
209 const css::uno::Reference< css::awt::XWindowListener >& xListener
210 ) override;
212 virtual void SAL_CALL removeFocusListener(
213 const css::uno::Reference< css::awt::XFocusListener >& xListener
214 ) override;
216 virtual void SAL_CALL removeKeyListener(
217 const css::uno::Reference< css::awt::XKeyListener >& xListener
218 ) override;
220 virtual void SAL_CALL removeMouseListener(
221 const css::uno::Reference< css::awt::XMouseListener >& xListener
222 ) override;
224 virtual void SAL_CALL removeMouseMotionListener(
225 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
226 ) override;
228 virtual void SAL_CALL removePaintListener(
229 const css::uno::Reference< css::awt::XPaintListener >& xListener
230 ) override;
232 // XView
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
239 ) override;
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
252 ) override;
254 // XPaintListener
256 virtual void SAL_CALL windowPaint(
257 const css::awt::PaintEvent& rEvent
258 ) override;
260 // XWindowListener
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;
267 protected:
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 ,
285 sal_Int32 nY ,
286 const css::uno::Reference< css::awt::XGraphics >& xGraphics );
288 virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent );
290 private:
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 ...
301 sal_Int32 m_nY;
302 sal_Int32 m_nWidth; // ... and size of window
303 sal_Int32 m_nHeight;
304 bool m_bVisible; // Some state flags
305 bool m_bInDesignMode;
306 bool m_bEnable;
312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */