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