tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / UnoControls / inc / basecontrol.hxx
blob90cdf51f7c7af6d2275e3308c522f9197ad5ae7c
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 cppu::BaseMutex,
43 public cppu::WeakComponentImplHelper<css::lang::XServiceInfo,
44 css::awt::XPaintListener,
45 css::awt::XWindowListener,
46 css::awt::XView,
47 css::awt::XWindow,
48 css::awt::XControl>
50 public:
51 BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
53 virtual ~BaseControl() override;
55 // XServiceInfo
57 virtual sal_Bool SAL_CALL supportsService(
58 const OUString& sServiceName
59 ) override;
61 virtual OUString SAL_CALL getImplementationName() override;
63 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
65 // XComponent
67 virtual void SAL_CALL dispose() override;
69 virtual void SAL_CALL addEventListener(
70 const css::uno::Reference< css::lang::XEventListener >& xListener
71 ) override;
73 virtual void SAL_CALL removeEventListener(
74 const css::uno::Reference< css::lang::XEventListener >& xListener
75 ) override;
77 // XControl
79 virtual void SAL_CALL createPeer(
80 const css::uno::Reference< css::awt::XToolkit >& xToolkit,
81 const css::uno::Reference< css::awt::XWindowPeer >& xParent
82 ) override;
84 virtual void SAL_CALL setContext(
85 const css::uno::Reference< css::uno::XInterface >& xContext
86 ) override;
88 virtual sal_Bool SAL_CALL setModel(
89 const css::uno::Reference< css::awt::XControlModel >& xModel
90 ) override = 0;
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;
106 // XWindow
108 virtual void SAL_CALL setPosSize( sal_Int32 nX ,
109 sal_Int32 nY ,
110 sal_Int32 nWidth ,
111 sal_Int32 nHeight ,
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
124 ) override;
126 virtual void SAL_CALL addFocusListener(
127 const css::uno::Reference< css::awt::XFocusListener >& xListener
128 ) override;
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
135 ) override;
137 virtual void SAL_CALL addMouseMotionListener(
138 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
139 ) override;
141 virtual void SAL_CALL addPaintListener(
142 const css::uno::Reference< css::awt::XPaintListener >& xListener
143 ) override;
145 virtual void SAL_CALL removeWindowListener(
146 const css::uno::Reference< css::awt::XWindowListener >& xListener
147 ) override;
149 virtual void SAL_CALL removeFocusListener(
150 const css::uno::Reference< css::awt::XFocusListener >& xListener
151 ) override;
153 virtual void SAL_CALL removeKeyListener(
154 const css::uno::Reference< css::awt::XKeyListener >& xListener
155 ) override;
157 virtual void SAL_CALL removeMouseListener(
158 const css::uno::Reference< css::awt::XMouseListener >& xListener
159 ) override;
161 virtual void SAL_CALL removeMouseMotionListener(
162 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
163 ) override;
165 virtual void SAL_CALL removePaintListener(
166 const css::uno::Reference< css::awt::XPaintListener >& xListener
167 ) override;
169 // XView
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
176 ) override;
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
189 ) override;
191 // XPaintListener
193 virtual void SAL_CALL windowPaint(
194 const css::awt::PaintEvent& rEvent
195 ) override;
197 // XWindowListener
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;
204 protected:
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 ,
222 sal_Int32 nY ,
223 const css::uno::Reference< css::awt::XGraphics >& xGraphics );
225 virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent );
227 private:
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 ...
238 sal_Int32 m_nY;
239 sal_Int32 m_nWidth; // ... and size of window
240 sal_Int32 m_nHeight;
241 bool m_bVisible; // Some state flags
242 bool m_bInDesignMode;
243 bool m_bEnable;
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */