Line data Source code
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 : #ifndef INCLUDED_TOOLKIT_AWT_VCLXWINDOW_HXX
21 : #define INCLUDED_TOOLKIT_AWT_VCLXWINDOW_HXX
22 :
23 : #include <toolkit/dllapi.h>
24 : #include <toolkit/awt/vclxdevice.hxx>
25 : #include <toolkit/helper/listenermultiplexer.hxx>
26 :
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/XPropertyChangeListener.hpp>
32 : #include <com/sun/star/beans/XPropertySetInfo.hpp>
33 : #include <com/sun/star/accessibility/XAccessible.hpp>
34 : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
35 : #include <com/sun/star/awt/XDockableWindow.hpp>
36 : #include <com/sun/star/awt/XStyleSettingsSupplier.hpp>
37 :
38 : #include <cppuhelper/weak.hxx>
39 : #include <cppuhelper/implbase9.hxx>
40 : #include <osl/mutex.hxx>
41 :
42 : #include <tools/gen.hxx>
43 : #include <tools/link.hxx>
44 :
45 : #include <stdarg.h>
46 : #include <list>
47 : #include <boost/function.hpp>
48 :
49 : class Window;
50 : class VclSimpleEvent;
51 : class VclWindowEvent;
52 : struct SystemParentData;
53 :
54 : namespace toolkit
55 : {
56 : class IAccessibleFactory;
57 : }
58 :
59 :
60 :
61 : // class VCLXWINDOW
62 :
63 :
64 : class UnoPropertyArrayHelper;
65 : class VCLXWindowImpl;
66 : typedef ::cppu::ImplInheritanceHelper9 < VCLXDevice
67 : , ::com::sun::star::awt::XWindow2
68 : , ::com::sun::star::awt::XVclWindowPeer
69 : , ::com::sun::star::awt::XLayoutConstrains
70 : , ::com::sun::star::awt::XView
71 : , ::com::sun::star::awt::XDockableWindow
72 : , ::com::sun::star::accessibility::XAccessible
73 : , ::com::sun::star::lang::XEventListener
74 : , ::com::sun::star::beans::XPropertySetInfo
75 : , ::com::sun::star::awt::XStyleSettingsSupplier
76 : > VCLXWindow_Base;
77 :
78 : class TOOLKIT_DLLPUBLIC VCLXWindow : public VCLXWindow_Base
79 : {
80 : private:
81 : VCLXWindowImpl* mpImpl;
82 :
83 : UnoPropertyArrayHelper *GetPropHelper();
84 :
85 : protected:
86 : Size ImplCalcWindowSize( const Size& rOutSz ) const;
87 : DECL_LINK( WindowEventListener, VclSimpleEvent* );
88 :
89 : virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
90 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
91 : CreateAccessibleContext();
92 :
93 : void SetSynthesizingVCLEvent( bool b );
94 : bool IsSynthesizingVCLEvent() const;
95 :
96 : void SetSystemParent_Impl( const com::sun::star::uno::Any& rHandle );
97 :
98 : ::toolkit::IAccessibleFactory& getAccessibleFactory();
99 :
100 : // helper ...
101 : static void PushPropertyIds( std::list< sal_uInt16 > &aIds, int nFirstId, ...);
102 : // for use in controls/
103 : static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds,
104 : bool bWithDefaults = false );
105 : virtual void GetPropertyIds( std::list< sal_uInt16 > &aIds );
106 :
107 : ::cppu::OInterfaceContainerHelper& GetContainerListeners();
108 : ::cppu::OInterfaceContainerHelper& GetTopWindowListeners();
109 :
110 : public:
111 : typedef ::boost::function0< void > Callback;
112 :
113 : protected:
114 : /** executes the given callback asynchronously
115 :
116 : At the moment the callback is called, the Solar Mutex is not locked. In particular, this implies that
117 : you cannot rely on |this| not being disposed. However, you *can* rely on |this| being still alive (i.e.
118 : having a ref count > 0).
119 :
120 : As a consequence, this can be used for doing listener notifications, using event multiplexers. Those multiplexers
121 : care for the disposed state themself, and are alive as long as |this| is alive.
122 : */
123 : void ImplExecuteAsyncWithoutSolarLock(
124 : const Callback& i_callback
125 : );
126 :
127 : public:
128 : VCLXWindow( bool bWithDefaultProps = false );
129 : virtual ~VCLXWindow();
130 :
131 : virtual void SetWindow( Window* pWindow );
132 0 : Window* GetWindow() const { return (Window*)GetOutputDevice(); }
133 :
134 : void suspendVclEventListening( );
135 : void resumeVclEventListening( );
136 :
137 : void notifyWindowRemoved( Window& _rWindow );
138 :
139 : // ::com::sun::star::lang::XUnoTunnel
140 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& GetUnoTunnelId() throw();
141 : static VCLXWindow* GetImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxIFace );
142 : sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 :
144 : // ::com::sun::star::lang::XEventListener
145 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 :
147 : // ::com::sun::star::lang::XComponent
148 : void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
149 : void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 : void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
151 :
152 : // ::com::sun::star::awt::XWindow
153 : void SAL_CALL setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 : ::com::sun::star::awt::Rectangle SAL_CALL getPosSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 : void SAL_CALL setVisible( sal_Bool Visible ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 : void SAL_CALL setEnable( sal_Bool Enable ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
157 : void SAL_CALL setFocus( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
158 : void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 : void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
160 : void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 : void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 : void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
163 : void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
164 : void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 : void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 : void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
167 : void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 : void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
169 : void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
170 :
171 : // ::com::sun::star::awt::XWindowPeer
172 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > SAL_CALL getToolkit( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 : void SAL_CALL setPointer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer >& Pointer ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 : void SAL_CALL setBackground( sal_Int32 Color ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
175 : void SAL_CALL invalidate( sal_Int16 Flags ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
176 : void SAL_CALL invalidateRect( const ::com::sun::star::awt::Rectangle& Rect, sal_Int16 Flags ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 :
178 : // ::com::sun::star::awt::XVclWindowPeer
179 : sal_Bool SAL_CALL isChild( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Peer ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 : void SAL_CALL setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 : sal_Bool SAL_CALL isDesignMode( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
182 : void SAL_CALL enableClipSiblings( sal_Bool bClip ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
183 : void SAL_CALL setForeground( sal_Int32 Color ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
184 : void SAL_CALL setControlFont( const ::com::sun::star::awt::FontDescriptor& aFont ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
185 : void SAL_CALL getStyles( sal_Int16 nType, ::com::sun::star::awt::FontDescriptor& Font, sal_Int32& ForegroundColor, sal_Int32& BackgroundColor ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
186 : void SAL_CALL setProperty( const OUString& PropertyName, const ::com::sun::star::uno::Any& Value )
187 : throw(::com::sun::star::uno::RuntimeException,
188 : std::exception) SAL_OVERRIDE;
189 : ::com::sun::star::uno::Any SAL_CALL getProperty( const OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
190 :
191 : // ::com::sun::star::awt::XLayoutConstrains
192 : ::com::sun::star::awt::Size SAL_CALL getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 : ::com::sun::star::awt::Size SAL_CALL getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
194 : ::com::sun::star::awt::Size SAL_CALL calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
195 :
196 : // ::com::sun::star::awt::XView
197 : sal_Bool SAL_CALL setGraphics( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& aDevice ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
198 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > SAL_CALL getGraphics( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
199 : ::com::sun::star::awt::Size SAL_CALL getSize( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
200 : void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
201 : void SAL_CALL setZoom( float fZoomX, float fZoomY ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
202 :
203 : // ::com::sun::star::accessibility::XAccessible
204 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
205 :
206 : // ::com::sun::star::awt::XDockableWindow
207 : void SAL_CALL addDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
208 : void SAL_CALL removeDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
209 : void SAL_CALL enableDocking( sal_Bool bEnable ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
210 : sal_Bool SAL_CALL isFloating( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
211 : void SAL_CALL setFloatingMode( sal_Bool bFloating ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
212 : void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
213 : void SAL_CALL unlock( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
214 : sal_Bool SAL_CALL isLocked( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
215 : void SAL_CALL startPopupMode( const ::com::sun::star::awt::Rectangle& WindowRect ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
216 : sal_Bool SAL_CALL isInPopupMode( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
217 :
218 : // ::com::sun::star::awt::XWindow2
219 : void SAL_CALL setOutputSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
220 : ::com::sun::star::awt::Size SAL_CALL getOutputSize( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
221 : sal_Bool SAL_CALL isVisible( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
222 : sal_Bool SAL_CALL isActive( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
223 : sal_Bool SAL_CALL isEnabled( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
224 : sal_Bool SAL_CALL hasFocus( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
225 :
226 : // ::com::sun::star::beans::XPropertySetInfo
227 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
228 : ::com::sun::star::beans::Property SAL_CALL getPropertyByName( const OUString& aName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
229 : sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
230 :
231 : // XStyleSettingsSupplier
232 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XStyleSettings > SAL_CALL getStyleSettings() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
233 : };
234 :
235 : #endif // INCLUDED_TOOLKIT_AWT_VCLXWINDOW_HXX
236 :
237 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|