LibreOffice Module toolkit (master) 1
vclxwindow.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <toolkit/dllapi.h>
24#include <vcl/vclptr.hxx>
25
26#include <com/sun/star/awt/XWindow2.hpp>
27#include <com/sun/star/awt/XVclWindowPeer.hpp>
28#include <com/sun/star/awt/XLayoutConstrains.hpp>
29#include <com/sun/star/awt/XView.hpp>
30#include <com/sun/star/beans/XPropertySetInfo.hpp>
31#include <com/sun/star/accessibility/XAccessible.hpp>
32#include <com/sun/star/awt/XDockableWindow.hpp>
33#include <com/sun/star/awt/XStyleSettingsSupplier.hpp>
34
37
38#include <tools/gen.hxx>
39#include <tools/link.hxx>
40
41#include <memory>
42#include <vector>
43#include <functional>
44
45template <class ListenerT> class ListenerMultiplexerBase;
46namespace com::sun::star::accessibility { class XAccessibleContext; }
47namespace com::sun::star::awt { class XTopWindowListener; }
48namespace com::sun::star::awt { class XVclContainerListener; }
49namespace vcl { class Window; }
50
51class VclWindowEvent;
52
53namespace toolkit
54{
55 class IAccessibleFactory;
56}
57
58
60class VCLXWindowImpl;
61typedef cppu::ImplInheritanceHelper< VCLXDevice,
62 css::awt::XWindow2,
63 css::awt::XVclWindowPeer,
64 css::awt::XLayoutConstrains,
65 css::awt::XView,
66 css::awt::XDockableWindow,
67 css::accessibility::XAccessible,
68 css::lang::XEventListener,
69 css::beans::XPropertySetInfo,
70 css::awt::XStyleSettingsSupplier
72
74{
75private:
76 std::unique_ptr<VCLXWindowImpl> mpImpl;
77
78 UnoPropertyArrayHelper *GetPropHelper();
79
80protected:
81 Size ImplCalcWindowSize( const Size& rOutSz ) const;
82 DECL_DLLPRIVATE_LINK(WindowEventListener, VclWindowEvent&, void );
83
84 virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
85 virtual css::uno::Reference< css::accessibility::XAccessibleContext >
86 CreateAccessibleContext();
87
88 void SetSynthesizingVCLEvent( bool b );
89 bool IsSynthesizingVCLEvent() const;
90
91 void SetSystemParent_Impl( const css::uno::Any& rHandle );
92
93 ::toolkit::IAccessibleFactory& getAccessibleFactory();
94
95 // helper ...
96 static void PushPropertyIds( std::vector< sal_uInt16 > &aIds, int nFirstId, ...);
97 // for use in controls/
98 static void ImplGetPropertyIds( std::vector< sal_uInt16 > &aIds,
99 bool bWithDefaults = false );
100 virtual void GetPropertyIds( std::vector< sal_uInt16 > &aIds );
101
104
105public:
106 typedef ::std::function<void ()> Callback;
107
108protected:
118 void ImplExecuteAsyncWithoutSolarLock(
119 const Callback& i_callback
120 );
121
122public:
123 VCLXWindow( bool bWithDefaultProps = false );
124 virtual ~VCLXWindow() override;
125
126 virtual void SetWindow( const VclPtr< vcl::Window > &pWindow );
127 template< class derived_type > derived_type* GetAs() const {
128 return static_cast< derived_type * >( GetWindow() ); }
129 template< class derived_type > derived_type* GetAsDynamic() const {
130 return dynamic_cast< derived_type * >( GetWindow() ); }
132 {
133 auto p = GetOutputDevice().get();
134 return p ? p->GetOwnerWindow() : nullptr;
135 }
136
137 void suspendVclEventListening( );
138 void resumeVclEventListening( );
139
140 void notifyWindowRemoved( vcl::Window const & _rWindow );
141
142 bool IsDisposed() const;
143
144 // css::lang::XEventListener
145 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
146
147 // css::lang::XComponent
148 void SAL_CALL dispose( ) override;
149 void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override;
150 void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& rxListener ) override;
151
152 // css::awt::XWindow
153 void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) override;
154 css::awt::Rectangle SAL_CALL getPosSize( ) override;
155 void SAL_CALL setVisible( sal_Bool Visible ) override;
156 void SAL_CALL setEnable( sal_Bool Enable ) override;
157 void SAL_CALL setFocus( ) override;
158 void SAL_CALL addWindowListener( const css::uno::Reference< css::awt::XWindowListener >& rrxListener ) override;
159 void SAL_CALL removeWindowListener( const css::uno::Reference< css::awt::XWindowListener >& rrxListener ) override;
160 void SAL_CALL addFocusListener( const css::uno::Reference< css::awt::XFocusListener >& rrxListener ) override;
161 void SAL_CALL removeFocusListener( const css::uno::Reference< css::awt::XFocusListener >& rrxListener ) override;
162 void SAL_CALL addKeyListener( const css::uno::Reference< css::awt::XKeyListener >& rrxListener ) override;
163 void SAL_CALL removeKeyListener( const css::uno::Reference< css::awt::XKeyListener >& rrxListener ) override;
164 void SAL_CALL addMouseListener( const css::uno::Reference< css::awt::XMouseListener >& rrxListener ) override;
165 void SAL_CALL removeMouseListener( const css::uno::Reference< css::awt::XMouseListener >& rrxListener ) override;
166 void SAL_CALL addMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& rrxListener ) override;
167 void SAL_CALL removeMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener >& rrxListener ) override;
168 void SAL_CALL addPaintListener( const css::uno::Reference< css::awt::XPaintListener >& rrxListener ) override;
169 void SAL_CALL removePaintListener( const css::uno::Reference< css::awt::XPaintListener >& rrxListener ) override;
170
171 // css::awt::XWindowPeer
172 css::uno::Reference< css::awt::XToolkit > SAL_CALL getToolkit( ) override;
173 void SAL_CALL setPointer( const css::uno::Reference< css::awt::XPointer >& Pointer ) override;
174 void SAL_CALL setBackground( sal_Int32 Color ) override;
175 void SAL_CALL invalidate( sal_Int16 Flags ) override;
176 void SAL_CALL invalidateRect( const css::awt::Rectangle& Rect, sal_Int16 Flags ) override;
177
178 // css::awt::XVclWindowPeer
179 sal_Bool SAL_CALL isChild( const css::uno::Reference< css::awt::XWindowPeer >& Peer ) override;
180 void SAL_CALL setDesignMode( sal_Bool bOn ) override;
181 sal_Bool SAL_CALL isDesignMode( ) override;
182 void SAL_CALL enableClipSiblings( sal_Bool bClip ) override;
183 void SAL_CALL setForeground( sal_Int32 Color ) override;
184 void SAL_CALL setControlFont( const css::awt::FontDescriptor& aFont ) override;
185 void SAL_CALL getStyles( sal_Int16 nType, css::awt::FontDescriptor& Font, sal_Int32& ForegroundColor, sal_Int32& BackgroundColor ) override;
186 void SAL_CALL setProperty( const OUString& PropertyName, const css::uno::Any& Value ) override;
187 css::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) override;
188
189 // css::awt::XLayoutConstrains
190 css::awt::Size SAL_CALL getMinimumSize( ) override;
191 css::awt::Size SAL_CALL getPreferredSize( ) override;
192 css::awt::Size SAL_CALL calcAdjustedSize( const css::awt::Size& aNewSize ) override;
193
194 // css::awt::XView
195 sal_Bool SAL_CALL setGraphics( const css::uno::Reference< css::awt::XGraphics >& aDevice ) override;
196 css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics( ) override;
197 css::awt::Size SAL_CALL getSize( ) override;
198 void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) override;
199 void SAL_CALL setZoom( float fZoomX, float fZoomY ) override;
200
201 // css::accessibility::XAccessible
202 css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
203
204 // css::awt::XDockableWindow
205 void SAL_CALL addDockableWindowListener( const css::uno::Reference< css::awt::XDockableWindowListener >& xListener ) override;
206 void SAL_CALL removeDockableWindowListener( const css::uno::Reference< css::awt::XDockableWindowListener >& xListener ) override;
207 void SAL_CALL enableDocking( sal_Bool bEnable ) override;
208 sal_Bool SAL_CALL isFloating( ) override;
209 void SAL_CALL setFloatingMode( sal_Bool bFloating ) override;
210 void SAL_CALL lock( ) override;
211 void SAL_CALL unlock( ) override;
212 sal_Bool SAL_CALL isLocked( ) override;
213 void SAL_CALL startPopupMode( const css::awt::Rectangle& WindowRect ) override;
214 sal_Bool SAL_CALL isInPopupMode( ) override;
215
216 // css::awt::XWindow2
217 void SAL_CALL setOutputSize( const css::awt::Size& aSize ) override;
218 css::awt::Size SAL_CALL getOutputSize( ) override;
219 sal_Bool SAL_CALL isVisible( ) override;
220 sal_Bool SAL_CALL isActive( ) override;
221 sal_Bool SAL_CALL isEnabled( ) override;
222 sal_Bool SAL_CALL hasFocus( ) override;
223
224 // css::beans::XPropertySetInfo
225 css::uno::Sequence< css::beans::Property > SAL_CALL getProperties( ) override;
226 css::beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override;
227 sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
228
229 // XStyleSettingsSupplier
230 virtual css::uno::Reference< css::awt::XStyleSettings > SAL_CALL getStyleSettings() override;
231};
232
233/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A UNO wrapper for the VCL OutputDevice.
Definition: vclxdevice.hxx:37
std::unique_ptr< VCLXWindowImpl > mpImpl
Definition: vclxwindow.hxx:76
DECL_DLLPRIVATE_LINK(WindowEventListener, VclWindowEvent &, void)
vcl::Window * GetWindow() const
Definition: vclxwindow.hxx:131
derived_type * GetAsDynamic() const
Definition: vclxwindow.hxx:129
::std::function< void()> Callback
Definition: vclxwindow.hxx:106
derived_type * GetAs() const
Definition: vclxwindow.hxx:127
#define TOOLKIT_DLLPUBLIC
Definition: dllapi.h:29
void * p
bool isActive()
std::shared_ptr< osl::Mutex > const & lock()
bool isChild(std::u16string_view srcUnqPath, std::u16string_view dstUnqPath)
SVX_DLLPUBLIC OUString getProperty(css::uno::Reference< css::beans::XPropertyContainer > const &rxPropertyContainer, OUString const &rName)
void dispose()
unsigned char sal_Bool
cppu::ImplInheritanceHelper< VCLXDevice, css::awt::XWindow2, css::awt::XVclWindowPeer, css::awt::XLayoutConstrains, css::awt::XView, css::awt::XDockableWindow, css::accessibility::XAccessible, css::lang::XEventListener, css::beans::XPropertySetInfo, css::awt::XStyleSettingsSupplier > VCLXWindow_Base
Definition: vclxwindow.hxx:60