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 <cppuhelper/implbase.hxx>
37 #include <tools/gen.hxx>
38 #include <tools/link.hxx>
44 template <class ListenerT
> class ListenerMultiplexerBase
;
45 namespace com::sun::star::accessibility
{ class XAccessibleContext
; }
46 namespace com::sun::star::awt
{ class XTopWindowListener
; }
47 namespace com::sun::star::awt
{ class XVclContainerListener
; }
48 namespace vcl
{ class Window
; }
54 class IAccessibleFactory
;
58 class UnoPropertyArrayHelper
;
60 typedef cppu::ImplInheritanceHelper
< VCLXDevice
,
62 css::awt::XVclWindowPeer
,
63 css::awt::XLayoutConstrains
,
65 css::awt::XDockableWindow
,
66 css::accessibility::XAccessible
,
67 css::lang::XEventListener
,
68 css::beans::XPropertySetInfo
,
69 css::awt::XStyleSettingsSupplier
72 class TOOLKIT_DLLPUBLIC VCLXWindow
: public VCLXWindow_Base
75 std::unique_ptr
<VCLXWindowImpl
> mpImpl
;
77 UnoPropertyArrayHelper
*GetPropHelper();
80 Size
ImplCalcWindowSize( const Size
& rOutSz
) const;
81 DECL_DLLPRIVATE_LINK(WindowEventListener
, VclWindowEvent
&, void );
83 virtual void ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
);
84 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
85 CreateAccessibleContext();
87 void SetSynthesizingVCLEvent( bool b
);
88 bool IsSynthesizingVCLEvent() const;
90 void SetSystemParent_Impl( const css::uno::Any
& rHandle
);
92 ::toolkit::IAccessibleFactory
& getAccessibleFactory();
95 static void PushPropertyIds( std::vector
< sal_uInt16
> &aIds
, int nFirstId
, ...);
96 // for use in controls/
97 static void ImplGetPropertyIds( std::vector
< sal_uInt16
> &aIds
,
98 bool bWithDefaults
= false );
99 virtual void GetPropertyIds( std::vector
< sal_uInt16
> &aIds
);
101 ListenerMultiplexerBase
<css::awt::XVclContainerListener
>& GetContainerListeners();
102 ListenerMultiplexerBase
<css::awt::XTopWindowListener
>& GetTopWindowListeners();
105 typedef ::std::function
<void ()> Callback
;
108 /** executes the given callback asynchronously
110 At the moment the callback is called, the Solar Mutex is not locked. In particular, this implies that
111 you cannot rely on |this| not being disposed. However, you *can* rely on |this| being still alive (i.e.
112 having a ref count > 0).
114 As a consequence, this can be used for doing listener notifications, using event multiplexers. Those multiplexers
115 care for the disposed state themself, and are alive as long as |this| is alive.
117 void ImplExecuteAsyncWithoutSolarLock(
118 const Callback
& i_callback
122 VCLXWindow( bool bWithDefaultProps
= false );
123 virtual ~VCLXWindow() override
;
125 virtual void SetWindow( const VclPtr
< vcl::Window
> &pWindow
);
126 template< class derived_type
> derived_type
* GetAs() const {
127 return static_cast< derived_type
* >( GetWindow() ); }
128 template< class derived_type
> derived_type
* GetAsDynamic() const {
129 return dynamic_cast< derived_type
* >( GetWindow() ); }
130 vcl::Window
* GetWindow() const
132 auto p
= GetOutputDevice().get();
133 return p
? p
->GetOwnerWindow() : nullptr;
136 void suspendVclEventListening( );
137 void resumeVclEventListening( );
139 void notifyWindowRemoved( vcl::Window
const & _rWindow
);
141 bool IsDisposed() const;
143 // css::lang::XEventListener
144 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
146 // css::lang::XComponent
147 void SAL_CALL
dispose( ) override
;
148 void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
) override
;
149 void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
) override
;
152 void SAL_CALL
setPosSize( sal_Int32 X
, sal_Int32 Y
, sal_Int32 Width
, sal_Int32 Height
, sal_Int16 Flags
) override
;
153 css::awt::Rectangle SAL_CALL
getPosSize( ) override
;
154 void SAL_CALL
setVisible( sal_Bool Visible
) override
;
155 void SAL_CALL
setEnable( sal_Bool Enable
) override
;
156 void SAL_CALL
setFocus( ) override
;
157 void SAL_CALL
addWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& rrxListener
) override
;
158 void SAL_CALL
removeWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& rrxListener
) override
;
159 void SAL_CALL
addFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& rrxListener
) override
;
160 void SAL_CALL
removeFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& rrxListener
) override
;
161 void SAL_CALL
addKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& rrxListener
) override
;
162 void SAL_CALL
removeKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& rrxListener
) override
;
163 void SAL_CALL
addMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& rrxListener
) override
;
164 void SAL_CALL
removeMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& rrxListener
) override
;
165 void SAL_CALL
addMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& rrxListener
) override
;
166 void SAL_CALL
removeMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& rrxListener
) override
;
167 void SAL_CALL
addPaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& rrxListener
) override
;
168 void SAL_CALL
removePaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& rrxListener
) override
;
170 // css::awt::XWindowPeer
171 css::uno::Reference
< css::awt::XToolkit
> SAL_CALL
getToolkit( ) override
;
172 void SAL_CALL
setPointer( const css::uno::Reference
< css::awt::XPointer
>& Pointer
) override
;
173 void SAL_CALL
setBackground( sal_Int32 Color
) override
;
174 void SAL_CALL
invalidate( sal_Int16 Flags
) override
;
175 void SAL_CALL
invalidateRect( const css::awt::Rectangle
& Rect
, sal_Int16 Flags
) override
;
177 // css::awt::XVclWindowPeer
178 sal_Bool SAL_CALL
isChild( const css::uno::Reference
< css::awt::XWindowPeer
>& Peer
) override
;
179 void SAL_CALL
setDesignMode( sal_Bool bOn
) override
;
180 sal_Bool SAL_CALL
isDesignMode( ) override
;
181 void SAL_CALL
enableClipSiblings( sal_Bool bClip
) override
;
182 void SAL_CALL
setForeground( sal_Int32 Color
) override
;
183 void SAL_CALL
setControlFont( const css::awt::FontDescriptor
& aFont
) override
;
184 void SAL_CALL
getStyles( sal_Int16 nType
, css::awt::FontDescriptor
& Font
, sal_Int32
& ForegroundColor
, sal_Int32
& BackgroundColor
) override
;
185 void SAL_CALL
setProperty( const OUString
& PropertyName
, const css::uno::Any
& Value
) override
;
186 css::uno::Any SAL_CALL
getProperty( const OUString
& PropertyName
) override
;
188 // css::awt::XLayoutConstrains
189 css::awt::Size SAL_CALL
getMinimumSize( ) override
;
190 css::awt::Size SAL_CALL
getPreferredSize( ) override
;
191 css::awt::Size SAL_CALL
calcAdjustedSize( const css::awt::Size
& aNewSize
) override
;
194 sal_Bool SAL_CALL
setGraphics( const css::uno::Reference
< css::awt::XGraphics
>& aDevice
) override
;
195 css::uno::Reference
< css::awt::XGraphics
> SAL_CALL
getGraphics( ) override
;
196 css::awt::Size SAL_CALL
getSize( ) override
;
197 void SAL_CALL
draw( sal_Int32 nX
, sal_Int32 nY
) override
;
198 void SAL_CALL
setZoom( float fZoomX
, float fZoomY
) override
;
200 // css::accessibility::XAccessible
201 css::uno::Reference
< css::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) override
;
203 // css::awt::XDockableWindow
204 void SAL_CALL
addDockableWindowListener( const css::uno::Reference
< css::awt::XDockableWindowListener
>& xListener
) override
;
205 void SAL_CALL
removeDockableWindowListener( const css::uno::Reference
< css::awt::XDockableWindowListener
>& xListener
) override
;
206 void SAL_CALL
enableDocking( sal_Bool bEnable
) override
;
207 sal_Bool SAL_CALL
isFloating( ) override
;
208 void SAL_CALL
setFloatingMode( sal_Bool bFloating
) override
;
209 void SAL_CALL
lock( ) override
;
210 void SAL_CALL
unlock( ) override
;
211 sal_Bool SAL_CALL
isLocked( ) override
;
212 void SAL_CALL
startPopupMode( const css::awt::Rectangle
& WindowRect
) override
;
213 sal_Bool SAL_CALL
isInPopupMode( ) override
;
215 // css::awt::XWindow2
216 void SAL_CALL
setOutputSize( const css::awt::Size
& aSize
) override
;
217 css::awt::Size SAL_CALL
getOutputSize( ) override
;
218 sal_Bool SAL_CALL
isVisible( ) override
;
219 sal_Bool SAL_CALL
isActive( ) override
;
220 sal_Bool SAL_CALL
isEnabled( ) override
;
221 sal_Bool SAL_CALL
hasFocus( ) override
;
223 // css::beans::XPropertySetInfo
224 css::uno::Sequence
< css::beans::Property
> SAL_CALL
getProperties( ) override
;
225 css::beans::Property SAL_CALL
getPropertyByName( const OUString
& aName
) override
;
226 sal_Bool SAL_CALL
hasPropertyByName( const OUString
& Name
) override
;
228 // XStyleSettingsSupplier
229 virtual css::uno::Reference
< css::awt::XStyleSettings
> SAL_CALL
getStyleSettings() override
;
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */