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 <toolkit/dllapi.h>
23 #include <toolkit/awt/vclxdevice.hxx>
24 #include <vcl/vclptr.hxx>
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>
35 #include <comphelper/servicehelper.hxx>
36 #include <cppuhelper/implbase.hxx>
38 #include <tools/gen.hxx>
39 #include <tools/link.hxx>
45 template <class ListenerT
> class ListenerMultiplexerBase
;
46 namespace com::sun::star::accessibility
{ class XAccessibleContext
; }
47 namespace com::sun::star::awt
{ class XTopWindowListener
; }
48 namespace com::sun::star::awt
{ class XVclContainerListener
; }
49 namespace vcl
{ class Window
; }
55 class IAccessibleFactory
;
59 class UnoPropertyArrayHelper
;
61 typedef cppu::ImplInheritanceHelper
< VCLXDevice
,
63 css::awt::XVclWindowPeer
,
64 css::awt::XLayoutConstrains
,
66 css::awt::XDockableWindow
,
67 css::accessibility::XAccessible
,
68 css::lang::XEventListener
,
69 css::beans::XPropertySetInfo
,
70 css::awt::XStyleSettingsSupplier
73 class TOOLKIT_DLLPUBLIC VCLXWindow
: public VCLXWindow_Base
76 std::unique_ptr
<VCLXWindowImpl
> mpImpl
;
78 UnoPropertyArrayHelper
*GetPropHelper();
81 Size
ImplCalcWindowSize( const Size
& rOutSz
) const;
82 DECL_DLLPRIVATE_LINK(WindowEventListener
, VclWindowEvent
&, void );
84 virtual void ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
);
85 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
86 CreateAccessibleContext();
88 void SetSynthesizingVCLEvent( bool b
);
89 bool IsSynthesizingVCLEvent() const;
91 void SetSystemParent_Impl( const css::uno::Any
& rHandle
);
93 ::toolkit::IAccessibleFactory
& getAccessibleFactory();
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
);
102 ListenerMultiplexerBase
<css::awt::XVclContainerListener
>& GetContainerListeners();
103 ListenerMultiplexerBase
<css::awt::XTopWindowListener
>& GetTopWindowListeners();
106 typedef ::std::function
<void ()> Callback
;
109 /** executes the given callback asynchronously
111 At the moment the callback is called, the Solar Mutex is not locked. In particular, this implies that
112 you cannot rely on |this| not being disposed. However, you *can* rely on |this| being still alive (i.e.
113 having a ref count > 0).
115 As a consequence, this can be used for doing listener notifications, using event multiplexers. Those multiplexers
116 care for the disposed state themself, and are alive as long as |this| is alive.
118 void ImplExecuteAsyncWithoutSolarLock(
119 const Callback
& i_callback
123 VCLXWindow( bool bWithDefaultProps
= false );
124 virtual ~VCLXWindow() override
;
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() ); }
131 vcl::Window
* GetWindow() const
133 auto p
= GetOutputDevice().get();
134 return p
? p
->GetOwnerWindow() : nullptr;
137 void suspendVclEventListening( );
138 void resumeVclEventListening( );
140 void notifyWindowRemoved( vcl::Window
const & _rWindow
);
142 bool IsDisposed() const;
144 // css::lang::XEventListener
145 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
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
;
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
;
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
;
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
;
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
;
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
;
201 // css::accessibility::XAccessible
202 css::uno::Reference
< css::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) override
;
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
;
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
;
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
;
229 // XStyleSettingsSupplier
230 virtual css::uno::Reference
< css::awt::XStyleSettings
> SAL_CALL
getStyleSettings() override
;
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */