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 ) throw(::com::sun::star::uno::RuntimeException); 148 149 // ::com::sun::star::lang::XEventListener 150 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 151 152 // ::com::sun::star::lang::XComponent 153 void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); 154 void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException); 155 void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException); 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 ) throw(::com::sun::star::uno::RuntimeException); 159 ::com::sun::star::awt::Rectangle SAL_CALL getPosSize( ) throw(::com::sun::star::uno::RuntimeException); 160 void SAL_CALL setVisible( sal_Bool Visible ) throw(::com::sun::star::uno::RuntimeException); 161 void SAL_CALL setEnable( sal_Bool Enable ) throw(::com::sun::star::uno::RuntimeException); 162 void SAL_CALL setFocus( ) throw(::com::sun::star::uno::RuntimeException); 163 void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 164 void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 165 void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 166 void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 167 void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 168 void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 169 void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 170 void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 171 void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 172 void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 173 void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 174 void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rrxListener ) throw(::com::sun::star::uno::RuntimeException); 175 176 // ::com::sun::star::awt::XWindowPeer 177 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > SAL_CALL getToolkit( ) throw(::com::sun::star::uno::RuntimeException); 178 void SAL_CALL setPointer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer >& Pointer ) throw(::com::sun::star::uno::RuntimeException); 179 void SAL_CALL setBackground( sal_Int32 Color ) throw(::com::sun::star::uno::RuntimeException); 180 void SAL_CALL invalidate( sal_Int16 Flags ) throw(::com::sun::star::uno::RuntimeException); 181 void SAL_CALL invalidateRect( const ::com::sun::star::awt::Rectangle& Rect, sal_Int16 Flags ) throw(::com::sun::star::uno::RuntimeException); 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 ) throw(::com::sun::star::uno::RuntimeException); 185 void SAL_CALL setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException); 186 sal_Bool SAL_CALL isDesignMode( ) throw(::com::sun::star::uno::RuntimeException); 187 void SAL_CALL enableClipSiblings( sal_Bool bClip ) throw(::com::sun::star::uno::RuntimeException); 188 void SAL_CALL setForeground( sal_Int32 Color ) throw(::com::sun::star::uno::RuntimeException); 189 void SAL_CALL setControlFont( const ::com::sun::star::awt::FontDescriptor& aFont ) throw(::com::sun::star::uno::RuntimeException); 190 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); 191 void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); 192 ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException); 193 194 // ::com::sun::star::awt::XLayoutConstrains 195 ::com::sun::star::awt::Size SAL_CALL getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException); 196 ::com::sun::star::awt::Size SAL_CALL getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException); 197 ::com::sun::star::awt::Size SAL_CALL calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw(::com::sun::star::uno::RuntimeException); 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 ) throw(::com::sun::star::uno::RuntimeException); 201 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > SAL_CALL getGraphics( ) throw(::com::sun::star::uno::RuntimeException); 202 ::com::sun::star::awt::Size SAL_CALL getSize( ) throw(::com::sun::star::uno::RuntimeException); 203 void SAL_CALL draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException); 204 void SAL_CALL setZoom( float fZoomX, float fZoomY ) throw(::com::sun::star::uno::RuntimeException); 205 206 // ::com::sun::star::accessibility::XAccessible 207 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException); 208 209 // ::com::sun::star::awt::XDockableWindow 210 void SAL_CALL addDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 211 void SAL_CALL removeDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 212 void SAL_CALL enableDocking( sal_Bool bEnable ) throw (::com::sun::star::uno::RuntimeException); 213 sal_Bool SAL_CALL isFloating( ) throw (::com::sun::star::uno::RuntimeException); 214 void SAL_CALL setFloatingMode( sal_Bool bFloating ) throw (::com::sun::star::uno::RuntimeException); 215 void SAL_CALL lock( ) throw (::com::sun::star::uno::RuntimeException); 216 void SAL_CALL unlock( ) throw (::com::sun::star::uno::RuntimeException); 217 sal_Bool SAL_CALL isLocked( ) throw (::com::sun::star::uno::RuntimeException); 218 void SAL_CALL startPopupMode( const ::com::sun::star::awt::Rectangle& WindowRect ) throw (::com::sun::star::uno::RuntimeException); 219 sal_Bool SAL_CALL isInPopupMode( ) throw (::com::sun::star::uno::RuntimeException); 220 221 // ::com::sun::star::awt::XWindow2 222 void SAL_CALL setOutputSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException); 223 ::com::sun::star::awt::Size SAL_CALL getOutputSize( ) throw (::com::sun::star::uno::RuntimeException); 224 sal_Bool SAL_CALL isVisible( ) throw (::com::sun::star::uno::RuntimeException); 225 sal_Bool SAL_CALL isActive( ) throw (::com::sun::star::uno::RuntimeException); 226 sal_Bool SAL_CALL isEnabled( ) throw (::com::sun::star::uno::RuntimeException); 227 sal_Bool SAL_CALL hasFocus( ) throw (::com::sun::star::uno::RuntimeException); 228 229 // ::com::sun::star::beans::XPropertySetInfo 230 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties( ) throw (::com::sun::star::uno::RuntimeException); 231 ::com::sun::star::beans::Property SAL_CALL getPropertyByName( const ::rtl::OUString& aName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 232 ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& Name ) throw (::com::sun::star::uno::RuntimeException); 233 234 // XStyleSettingsSupplier 235 virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XStyleSettings > SAL_CALL getStyleSettings() throw (::com::sun::star::uno::RuntimeException); 236 }; 237 238 #endif // _TOOLKIT_AWT_VCLXWINDOW_HXX_ 239 240