Bump version to 6.0-36
[LibreOffice.git] / UnoControls / inc / basecontrol.hxx
blob7f81e13335f2fe3bce8c9f124607d4d1af29f7e8
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 #ifndef INCLUDED_UNOCONTROLS_INC_BASECONTROL_HXX
21 #define INCLUDED_UNOCONTROLS_INC_BASECONTROL_HXX
23 #include <com/sun/star/awt/XKeyListener.hpp>
24 #include <com/sun/star/awt/XPaintListener.hpp>
25 #include <com/sun/star/awt/KeyEvent.hpp>
26 #include <com/sun/star/awt/KeyModifier.hpp>
27 #include <com/sun/star/awt/XMouseMotionListener.hpp>
28 #include <com/sun/star/awt/FocusEvent.hpp>
29 #include <com/sun/star/awt/XWindowListener.hpp>
30 #include <com/sun/star/awt/XActivateListener.hpp>
31 #include <com/sun/star/awt/MouseEvent.hpp>
32 #include <com/sun/star/awt/XTopWindowListener.hpp>
33 #include <com/sun/star/awt/PaintEvent.hpp>
34 #include <com/sun/star/awt/InputEvent.hpp>
35 #include <com/sun/star/awt/KeyGroup.hpp>
36 #include <com/sun/star/awt/Key.hpp>
37 #include <com/sun/star/awt/WindowEvent.hpp>
38 #include <com/sun/star/awt/XMouseListener.hpp>
39 #include <com/sun/star/awt/KeyFunction.hpp>
40 #include <com/sun/star/awt/FocusChangeReason.hpp>
41 #include <com/sun/star/awt/MouseButton.hpp>
42 #include <com/sun/star/awt/XFocusListener.hpp>
43 #include <com/sun/star/awt/XFileDialog.hpp>
44 #include <com/sun/star/awt/XTextComponent.hpp>
45 #include <com/sun/star/awt/XListBox.hpp>
46 #include <com/sun/star/awt/XProgressMonitor.hpp>
47 #include <com/sun/star/awt/TextAlign.hpp>
48 #include <com/sun/star/awt/XScrollBar.hpp>
49 #include <com/sun/star/awt/XVclContainerPeer.hpp>
50 #include <com/sun/star/awt/XTabControllerModel.hpp>
51 #include <com/sun/star/awt/XMessageBox.hpp>
52 #include <com/sun/star/awt/XTextEditField.hpp>
53 #include <com/sun/star/awt/Style.hpp>
54 #include <com/sun/star/awt/XTimeField.hpp>
55 #include <com/sun/star/awt/XVclWindowPeer.hpp>
56 #include <com/sun/star/awt/XControlModel.hpp>
57 #include <com/sun/star/awt/XSpinField.hpp>
58 #include <com/sun/star/awt/XUnoControlContainer.hpp>
59 #include <com/sun/star/awt/XTextLayoutConstrains.hpp>
60 #include <com/sun/star/awt/XNumericField.hpp>
61 #include <com/sun/star/awt/XButton.hpp>
62 #include <com/sun/star/awt/XTextArea.hpp>
63 #include <com/sun/star/awt/XImageButton.hpp>
64 #include <com/sun/star/awt/XFixedText.hpp>
65 #include <com/sun/star/awt/XControlContainer.hpp>
66 #include <com/sun/star/awt/XDialog.hpp>
67 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
68 #include <com/sun/star/awt/XRadioButton.hpp>
69 #include <com/sun/star/awt/XCurrencyField.hpp>
70 #include <com/sun/star/awt/XPatternField.hpp>
71 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
72 #include <com/sun/star/awt/XTabController.hpp>
73 #include <com/sun/star/awt/XVclContainer.hpp>
74 #include <com/sun/star/awt/XDateField.hpp>
75 #include <com/sun/star/awt/XComboBox.hpp>
76 #include <com/sun/star/awt/XControl.hpp>
77 #include <com/sun/star/awt/XCheckBox.hpp>
78 #include <com/sun/star/awt/XLayoutConstrains.hpp>
79 #include <com/sun/star/awt/XProgressBar.hpp>
80 #include <com/sun/star/awt/XTopWindow.hpp>
81 #include <com/sun/star/awt/XWindow.hpp>
82 #include <com/sun/star/awt/PosSize.hpp>
83 #include <com/sun/star/awt/XView.hpp>
84 #include <com/sun/star/lang/XServiceInfo.hpp>
85 #include <osl/mutex.hxx>
86 #include <tools/colordata.hxx>
87 #include <cppuhelper/weak.hxx>
88 #include <cppuhelper/component.hxx>
89 #include <rtl/ref.hxx>
91 #include "multiplexer.hxx"
93 namespace com { namespace sun { namespace star { namespace uno {
94 class XComponentContext;
95 } } } }
97 // "namespaces"
99 namespace unocontrols{
101 // structs
103 struct IMPL_MutexContainer
105 // Is necessary to initialize "BaseControl" and make this class thread-safe.
106 ::osl::Mutex m_aMutex;
109 class BaseControl : public css::lang::XServiceInfo
110 , public css::awt::XPaintListener
111 , public css::awt::XWindowListener
112 , public css::awt::XView
113 , public css::awt::XWindow
114 , public css::awt::XControl
115 , public IMPL_MutexContainer
116 , public ::cppu::OComponentHelper
119 public:
121 BaseControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
123 virtual ~BaseControl() override;
125 // XInterface
127 /**_______________________________________________________________________________________________________
128 @short give answer, if interface is supported
129 @descr The interfaces are searched by type.
131 @seealso XInterface
133 @param "rType" is the type of searched interface.
135 @return Any information about found interface
137 @onerror A RuntimeException is thrown.
140 virtual css::uno::Any SAL_CALL queryInterface(
141 const css::uno::Type& aType
142 ) override;
144 /**_______________________________________________________________________________________________________
145 @short increment refcount
146 @seealso XInterface
147 @seealso release()
148 @onerror A RuntimeException is thrown.
151 virtual void SAL_CALL acquire() throw() override;
153 /**_______________________________________________________________________________________________________
154 @short decrement refcount
155 @seealso XInterface
156 @seealso acquire()
157 @onerror A RuntimeException is thrown.
160 virtual void SAL_CALL release() throw() override;
162 // XTypeProvider
164 /**_______________________________________________________________________________________________________
165 @short get information about supported interfaces
166 @seealso XTypeProvider
167 @return Sequence of types of all supported interfaces
169 @onerror A RuntimeException is thrown.
172 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
174 /**_______________________________________________________________________________________________________
175 @short get implementation id
176 @descr This ID is necessary for UNO-caching. If there no ID, cache is disabled.
177 Another way, cache is enabled.
179 @seealso XTypeProvider
180 @return ID as Sequence of byte
182 @onerror A RuntimeException is thrown.
185 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
187 // XAggregation
189 virtual void SAL_CALL setDelegator(
190 const css::uno::Reference< css::uno::XInterface >& xDelegator
191 ) override;
193 virtual css::uno::Any SAL_CALL queryAggregation(
194 const css::uno::Type& aType
195 ) override;
197 // XServiceInfo
199 virtual sal_Bool SAL_CALL supportsService(
200 const OUString& sServiceName
201 ) override;
203 virtual OUString SAL_CALL getImplementationName() override;
205 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
207 // XComponent
209 virtual void SAL_CALL dispose() override;
211 virtual void SAL_CALL addEventListener(
212 const css::uno::Reference< css::lang::XEventListener >& xListener
213 ) override;
215 virtual void SAL_CALL removeEventListener(
216 const css::uno::Reference< css::lang::XEventListener >& xListener
217 ) override;
219 // XControl
221 virtual void SAL_CALL createPeer(
222 const css::uno::Reference< css::awt::XToolkit >& xToolkit,
223 const css::uno::Reference< css::awt::XWindowPeer >& xParent
224 ) override;
226 virtual void SAL_CALL setContext(
227 const css::uno::Reference< css::uno::XInterface >& xContext
228 ) override;
230 virtual sal_Bool SAL_CALL setModel(
231 const css::uno::Reference< css::awt::XControlModel >& xModel
232 ) override = 0;
234 virtual void SAL_CALL setDesignMode( sal_Bool bOn ) override;
236 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getContext() override;
238 virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override = 0;
240 virtual css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() override;
242 virtual css::uno::Reference< css::awt::XView > SAL_CALL getView() override;
244 virtual sal_Bool SAL_CALL isDesignMode() override;
246 virtual sal_Bool SAL_CALL isTransparent() override;
248 // XWindow
250 virtual void SAL_CALL setPosSize( sal_Int32 nX ,
251 sal_Int32 nY ,
252 sal_Int32 nWidth ,
253 sal_Int32 nHeight ,
254 sal_Int16 nFlags ) override;
256 virtual void SAL_CALL setVisible( sal_Bool bVisible ) override;
258 virtual void SAL_CALL setEnable( sal_Bool bEnable ) override;
260 virtual void SAL_CALL setFocus() override;
262 virtual css::awt::Rectangle SAL_CALL getPosSize() override;
264 virtual void SAL_CALL addWindowListener(
265 const css::uno::Reference< css::awt::XWindowListener >& xListener
266 ) override;
268 virtual void SAL_CALL addFocusListener(
269 const css::uno::Reference< css::awt::XFocusListener >& xListener
270 ) override;
272 virtual void SAL_CALL addKeyListener(
273 const css::uno::Reference< css::awt::XKeyListener >& xListener ) override;
275 virtual void SAL_CALL addMouseListener(
276 const css::uno::Reference< css::awt::XMouseListener >& xListener
277 ) override;
279 virtual void SAL_CALL addMouseMotionListener(
280 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
281 ) override;
283 virtual void SAL_CALL addPaintListener(
284 const css::uno::Reference< css::awt::XPaintListener >& xListener
285 ) override;
287 virtual void SAL_CALL removeWindowListener(
288 const css::uno::Reference< css::awt::XWindowListener >& xListener
289 ) override;
291 virtual void SAL_CALL removeFocusListener(
292 const css::uno::Reference< css::awt::XFocusListener >& xListener
293 ) override;
295 virtual void SAL_CALL removeKeyListener(
296 const css::uno::Reference< css::awt::XKeyListener >& xListener
297 ) override;
299 virtual void SAL_CALL removeMouseListener(
300 const css::uno::Reference< css::awt::XMouseListener >& xListener
301 ) override;
303 virtual void SAL_CALL removeMouseMotionListener(
304 const css::uno::Reference< css::awt::XMouseMotionListener >& xListener
305 ) override;
307 virtual void SAL_CALL removePaintListener(
308 const css::uno::Reference< css::awt::XPaintListener >& xListener
309 ) override;
311 // XView
313 virtual void SAL_CALL draw( sal_Int32 nX ,
314 sal_Int32 nY ) override;
316 virtual sal_Bool SAL_CALL setGraphics(
317 const css::uno::Reference< css::awt::XGraphics >& xDevice
318 ) override;
320 virtual void SAL_CALL setZoom( float fZoomX ,
321 float fZoomY ) override;
323 virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() override;
325 virtual css::awt::Size SAL_CALL getSize() override;
327 // css::lang::XEventListener
329 virtual void SAL_CALL disposing(
330 const css::lang::EventObject& rSource
331 ) override;
333 // XPaintListener
335 virtual void SAL_CALL windowPaint(
336 const css::awt::PaintEvent& rEvent
337 ) override;
339 // XWindowListener
341 virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) override;
342 virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) override;
343 virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) override;
344 virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override;
346 protected:
347 using OComponentHelper::disposing;
349 const css::uno::Reference< css::uno::XComponentContext >& impl_getComponentContext() const { return m_xComponentContext;}
351 const css::uno::Reference< css::awt::XWindow >& impl_getPeerWindow() const { return m_xPeerWindow;}
353 const css::uno::Reference< css::awt::XGraphics >& impl_getGraphicsPeer() const { return m_xGraphicsPeer;}
355 sal_Int32 impl_getWidth() const { return m_nWidth;}
357 sal_Int32 impl_getHeight() const { return m_nHeight;}
359 virtual css::awt::WindowDescriptor* impl_getWindowDescriptor(
360 const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
363 virtual void impl_paint( sal_Int32 nX ,
364 sal_Int32 nY ,
365 const css::uno::Reference< css::awt::XGraphics >& xGraphics );
367 virtual void impl_recalcLayout( const css::awt::WindowEvent& aEvent );
369 const css::uno::Reference< css::uno::XInterface >& impl_getDelegator() const { return m_xDelegator;}
371 private:
373 OMRCListenerMultiplexerHelper* impl_getMultiplexer();
375 css::uno::Reference< css::uno::XComponentContext > m_xComponentContext;
376 css::uno::Reference< css::uno::XInterface > m_xDelegator;
377 rtl::Reference<OMRCListenerMultiplexerHelper> m_xMultiplexer; // multiplex events
378 css::uno::Reference< css::uno::XInterface > m_xContext;
379 css::uno::Reference< css::awt::XWindowPeer > m_xPeer;
380 css::uno::Reference< css::awt::XWindow > m_xPeerWindow;
381 css::uno::Reference< css::awt::XGraphics > m_xGraphicsView; // graphics for css::awt::XView-operations
382 css::uno::Reference< css::awt::XGraphics > m_xGraphicsPeer; // graphics for painting on a peer
383 sal_Int32 m_nX; // Position ...
384 sal_Int32 m_nY;
385 sal_Int32 m_nWidth; // ... and size of window
386 sal_Int32 m_nHeight;
387 bool m_bVisible; // Some state flags
388 bool m_bInDesignMode;
389 bool m_bEnable;
391 }; // class BaseControl
393 } // namespace unocontrols
395 #endif // INCLUDED_UNOCONTROLS_INC_BASECONTROL_HXX
397 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */