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 .
20 #ifndef INCLUDED_TOOLKIT_AWT_VCLXWINDOW_HXX
21 #define INCLUDED_TOOLKIT_AWT_VCLXWINDOW_HXX
23 #include <toolkit/dllapi.h>
24 #include <toolkit/awt/vclxdevice.hxx>
25 #include <vcl/window.hxx>
27 #include <com/sun/star/awt/XWindow2.hpp>
28 #include <com/sun/star/awt/XVclWindowPeer.hpp>
29 #include <com/sun/star/awt/XLayoutConstrains.hpp>
30 #include <com/sun/star/awt/XView.hpp>
31 #include <com/sun/star/beans/XPropertySetInfo.hpp>
32 #include <com/sun/star/accessibility/XAccessible.hpp>
33 #include <com/sun/star/awt/XDockableWindow.hpp>
34 #include <com/sun/star/awt/XStyleSettingsSupplier.hpp>
36 #include <comphelper/servicehelper.hxx>
37 #include <cppuhelper/implbase.hxx>
39 #include <tools/gen.hxx>
40 #include <tools/link.hxx>
46 namespace comphelper
{ class OInterfaceContainerHelper2
; }
47 namespace com
{ namespace sun
{ namespace star
{ namespace accessibility
{ class XAccessibleContext
; } } } }
53 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_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 ::comphelper::OInterfaceContainerHelper2
& GetContainerListeners();
102 ::comphelper::OInterfaceContainerHelper2
& 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
> VclPtr
< derived_type
> GetAs() const {
127 return VclPtr
< derived_type
>( static_cast< derived_type
* >( GetOutputDevice().get() ) ); }
128 template< class derived_type
> VclPtr
< derived_type
> GetAsDynamic() const {
129 return VclPtr
< derived_type
>( dynamic_cast< derived_type
* >( GetOutputDevice().get() ) ); }
130 VclPtr
<vcl::Window
> GetWindow() const { return GetAs
<vcl::Window
>(); }
132 void suspendVclEventListening( );
133 void resumeVclEventListening( );
135 void notifyWindowRemoved( vcl::Window
const & _rWindow
);
137 // css::lang::XUnoTunnel
138 UNO3_GETIMPLEMENTATION_DECL(VCLXWindow
)
140 // css::lang::XEventListener
141 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
143 // css::lang::XComponent
144 void SAL_CALL
dispose( ) override
;
145 void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
) override
;
146 void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
) override
;
149 void SAL_CALL
setPosSize( sal_Int32 X
, sal_Int32 Y
, sal_Int32 Width
, sal_Int32 Height
, sal_Int16 Flags
) override
;
150 css::awt::Rectangle SAL_CALL
getPosSize( ) override
;
151 void SAL_CALL
setVisible( sal_Bool Visible
) override
;
152 void SAL_CALL
setEnable( sal_Bool Enable
) override
;
153 void SAL_CALL
setFocus( ) override
;
154 void SAL_CALL
addWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& rrxListener
) override
;
155 void SAL_CALL
removeWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& rrxListener
) override
;
156 void SAL_CALL
addFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& rrxListener
) override
;
157 void SAL_CALL
removeFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& rrxListener
) override
;
158 void SAL_CALL
addKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& rrxListener
) override
;
159 void SAL_CALL
removeKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& rrxListener
) override
;
160 void SAL_CALL
addMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& rrxListener
) override
;
161 void SAL_CALL
removeMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& rrxListener
) override
;
162 void SAL_CALL
addMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& rrxListener
) override
;
163 void SAL_CALL
removeMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& rrxListener
) override
;
164 void SAL_CALL
addPaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& rrxListener
) override
;
165 void SAL_CALL
removePaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& rrxListener
) override
;
167 // css::awt::XWindowPeer
168 css::uno::Reference
< css::awt::XToolkit
> SAL_CALL
getToolkit( ) override
;
169 void SAL_CALL
setPointer( const css::uno::Reference
< css::awt::XPointer
>& Pointer
) override
;
170 void SAL_CALL
setBackground( sal_Int32 Color
) override
;
171 void SAL_CALL
invalidate( sal_Int16 Flags
) override
;
172 void SAL_CALL
invalidateRect( const css::awt::Rectangle
& Rect
, sal_Int16 Flags
) override
;
174 // css::awt::XVclWindowPeer
175 sal_Bool SAL_CALL
isChild( const css::uno::Reference
< css::awt::XWindowPeer
>& Peer
) override
;
176 void SAL_CALL
setDesignMode( sal_Bool bOn
) override
;
177 sal_Bool SAL_CALL
isDesignMode( ) override
;
178 void SAL_CALL
enableClipSiblings( sal_Bool bClip
) override
;
179 void SAL_CALL
setForeground( sal_Int32 Color
) override
;
180 void SAL_CALL
setControlFont( const css::awt::FontDescriptor
& aFont
) override
;
181 void SAL_CALL
getStyles( sal_Int16 nType
, css::awt::FontDescriptor
& Font
, sal_Int32
& ForegroundColor
, sal_Int32
& BackgroundColor
) override
;
182 void SAL_CALL
setProperty( const OUString
& PropertyName
, const css::uno::Any
& Value
) override
;
183 css::uno::Any SAL_CALL
getProperty( const OUString
& PropertyName
) override
;
185 // css::awt::XLayoutConstrains
186 css::awt::Size SAL_CALL
getMinimumSize( ) override
;
187 css::awt::Size SAL_CALL
getPreferredSize( ) override
;
188 css::awt::Size SAL_CALL
calcAdjustedSize( const css::awt::Size
& aNewSize
) override
;
191 sal_Bool SAL_CALL
setGraphics( const css::uno::Reference
< css::awt::XGraphics
>& aDevice
) override
;
192 css::uno::Reference
< css::awt::XGraphics
> SAL_CALL
getGraphics( ) override
;
193 css::awt::Size SAL_CALL
getSize( ) override
;
194 void SAL_CALL
draw( sal_Int32 nX
, sal_Int32 nY
) override
;
195 void SAL_CALL
setZoom( float fZoomX
, float fZoomY
) override
;
197 // css::accessibility::XAccessible
198 css::uno::Reference
< css::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) override
;
200 // css::awt::XDockableWindow
201 void SAL_CALL
addDockableWindowListener( const css::uno::Reference
< css::awt::XDockableWindowListener
>& xListener
) override
;
202 void SAL_CALL
removeDockableWindowListener( const css::uno::Reference
< css::awt::XDockableWindowListener
>& xListener
) override
;
203 void SAL_CALL
enableDocking( sal_Bool bEnable
) override
;
204 sal_Bool SAL_CALL
isFloating( ) override
;
205 void SAL_CALL
setFloatingMode( sal_Bool bFloating
) override
;
206 void SAL_CALL
lock( ) override
;
207 void SAL_CALL
unlock( ) override
;
208 sal_Bool SAL_CALL
isLocked( ) override
;
209 void SAL_CALL
startPopupMode( const css::awt::Rectangle
& WindowRect
) override
;
210 sal_Bool SAL_CALL
isInPopupMode( ) override
;
212 // css::awt::XWindow2
213 void SAL_CALL
setOutputSize( const css::awt::Size
& aSize
) override
;
214 css::awt::Size SAL_CALL
getOutputSize( ) override
;
215 sal_Bool SAL_CALL
isVisible( ) override
;
216 sal_Bool SAL_CALL
isActive( ) override
;
217 sal_Bool SAL_CALL
isEnabled( ) override
;
218 sal_Bool SAL_CALL
hasFocus( ) override
;
220 // css::beans::XPropertySetInfo
221 css::uno::Sequence
< css::beans::Property
> SAL_CALL
getProperties( ) override
;
222 css::beans::Property SAL_CALL
getPropertyByName( const OUString
& aName
) override
;
223 sal_Bool SAL_CALL
hasPropertyByName( const OUString
& Name
) override
;
225 // XStyleSettingsSupplier
226 virtual css::uno::Reference
< css::awt::XStyleSettings
> SAL_CALL
getStyleSettings() override
;
229 #endif // INCLUDED_TOOLKIT_AWT_VCLXWINDOW_HXX
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */