merge the formfield patch from ooo-build
[ooovba.git] / toolkit / source / awt / vclxwindow.cxx
blob985dff82cc09b22f40640a7c334a111ae6fd8067
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vclxwindow.cxx,v $
10 * $Revision: 1.90 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_toolkit.hxx"
33 #include <com/sun/star/awt/WindowEvent.hpp>
34 #include <com/sun/star/awt/KeyEvent.hpp>
35 #include <com/sun/star/awt/KeyModifier.hpp>
36 #include <com/sun/star/awt/MouseEvent.hpp>
37 #include <com/sun/star/awt/MouseButton.hpp>
38 #include <com/sun/star/awt/MouseWheelBehavior.hpp>
39 #include <com/sun/star/awt/XTopWindow.hpp>
40 #include <com/sun/star/awt/Style.hpp>
41 #include <com/sun/star/accessibility/AccessibleRole.hpp>
42 #include <com/sun/star/awt/DockingEvent.hpp>
43 #include <com/sun/star/awt/EndDockingEvent.hpp>
44 #include <com/sun/star/awt/EndPopupModeEvent.hpp>
45 #include <com/sun/star/awt/XWindowListener2.hpp>
46 #include <com/sun/star/style/VerticalAlignment.hpp>
47 #include <com/sun/star/text/WritingMode2.hpp>
48 #include <toolkit/awt/vclxwindow.hxx>
49 #include <toolkit/awt/vclxpointer.hxx>
50 #include <toolkit/awt/vclxwindows.hxx>
51 #include <toolkit/helper/macros.hxx>
52 #include <toolkit/helper/vclunohelper.hxx>
53 #include <toolkit/helper/convert.hxx>
54 #include <toolkit/helper/macros.hxx>
55 #include <toolkit/helper/property.hxx>
56 #include <toolkit/helper/accessibilityclient.hxx>
57 #include <cppuhelper/typeprovider.hxx>
58 #include <rtl/memory.h>
59 #include <rtl/uuid.h>
60 #include <rtl/ustrbuf.hxx>
61 #include <vcl/svapp.hxx>
62 #include <vcl/window.hxx>
63 #include <tools/color.hxx>
64 #include <vcl/dockwin.hxx>
65 #include <vcl/pdfextoutdevdata.hxx>
66 #include <vcl/tabpage.hxx>
67 #include <comphelper/asyncnotification.hxx>
68 #include <toolkit/helper/solarrelease.hxx>
70 #include <toolkit/helper/unopropertyarrayhelper.hxx>
72 using namespace ::com::sun::star;
74 using ::com::sun::star::uno::Reference;
75 using ::com::sun::star::uno::UNO_QUERY;
76 using ::com::sun::star::lang::EventObject;
77 using ::com::sun::star::awt::XWindowListener2;
78 using ::com::sun::star::awt::XDockableWindowListener;
79 using ::com::sun::star::style::VerticalAlignment;
80 using ::com::sun::star::style::VerticalAlignment_TOP;
81 using ::com::sun::star::style::VerticalAlignment_MIDDLE;
82 using ::com::sun::star::style::VerticalAlignment_BOTTOM;
83 using ::com::sun::star::style::VerticalAlignment_MAKE_FIXED_SIZE;
85 namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
86 namespace MouseWheelBehavior = ::com::sun::star::awt::MouseWheelBehavior;
89 //====================================================================
90 //= misc helpers
91 //====================================================================
92 namespace
94 //................................................................
95 //. FlagGuard
96 //................................................................
97 class FlagGuard
99 private:
100 bool& m_rFlag;
102 public:
103 FlagGuard( bool& _rFlag )
104 :m_rFlag( _rFlag )
106 m_rFlag = true;
108 ~FlagGuard()
110 m_rFlag = false;
114 //................................................................
115 //. MouseEventType
116 //................................................................
117 enum MouseEventType
119 META_FIRST_MOUSE_EVENT = 0,
121 EVENT_MOUSE_PRESSED = 0,
122 EVENT_MOUSE_RELEASED = 1,
123 EVENT_MOUSE_ENTERED = 2,
124 EVENT_MOUSE_EXITED = 3,
126 META_LAST_MOUSE_EVENT = 3
129 //................................................................
130 //. PlainEventType
131 //................................................................
132 enum PlainEventType
134 META_FIRST_PLAIN_EVENT = 4,
136 EVENT_WINDOW_ENABLED = 4,
137 EVENT_WINDOW_DISABLED = 5,
139 META_LAST_PLAIN_EVENT = 5
142 #if OSL_DEBUG_LEVEL > 0
143 static void checkEventDefinitions()
145 OSL_ENSURE( (int)META_LAST_MOUSE_EVENT < (int)META_FIRST_PLAIN_EVENT, "checkEventDefinitions: invalid event definitions!" );
147 #define DBG_CHECK_EVENTS() checkEventDefinitions()
148 #else
149 #define DBG_CHECK_EVENTS()
150 #endif
152 //................................................................
153 //. AnyWindowEvent
154 //................................................................
155 struct AnyWindowEvent : public ::comphelper::AnyEvent
157 private:
158 awt::MouseEvent m_aMouseEvent;
159 lang::EventObject m_aPlainEvent;
161 sal_Int32 m_nEventType;
163 public:
164 AnyWindowEvent( const awt::MouseEvent& _rEvent, MouseEventType _nType )
165 :comphelper::AnyEvent()
166 ,m_aMouseEvent( _rEvent )
167 ,m_nEventType( static_cast< sal_Int32 >( _nType ) )
169 DBG_CHECK_EVENTS();
172 AnyWindowEvent( const lang::EventObject& _rEvent, PlainEventType _nType )
173 :comphelper::AnyEvent()
174 ,m_aPlainEvent( _rEvent )
175 ,m_nEventType( static_cast< sal_Int32 >( _nType ) )
177 DBG_CHECK_EVENTS();
180 bool isMouseEvent() const
182 return ( META_FIRST_MOUSE_EVENT <= m_nEventType ) && ( m_nEventType <= META_LAST_MOUSE_EVENT );
185 bool isPlainEvent() const
187 return ( META_FIRST_PLAIN_EVENT <= m_nEventType ) && ( m_nEventType <= META_LAST_PLAIN_EVENT );
190 const awt::MouseEvent& getMouseEvent() const
192 OSL_ENSURE( isMouseEvent(), "AnyWindowEvent::getMouseEvent: no mouse event!" );
193 return m_aMouseEvent;
196 MouseEventType getMouseEventType() const
198 OSL_ENSURE( isMouseEvent(), "AnyWindowEvent::getMouseEventType: no mouse event!" );
199 return static_cast< MouseEventType >( m_nEventType );
202 const lang::EventObject& getPlainEvent() const
204 OSL_ENSURE( isPlainEvent(), "AnyWindowEvent::getPlainEvent: no plain event!" );
205 return m_aPlainEvent;
208 PlainEventType getPlainEventType() const
210 OSL_ENSURE( isPlainEvent(), "AnyWindowEvent::getPlainEventType: no mouse event!" );
211 return static_cast< PlainEventType >( m_nEventType );
216 //====================================================================
217 //= VCLXWindowImpl
218 //====================================================================
219 class SAL_DLLPRIVATE VCLXWindowImpl : public ::comphelper::IEventProcessor
221 private:
222 typedef ::std::vector< ::rtl::Reference< ::comphelper::AnyEvent > >
223 EventArray;
225 private:
226 VCLXWindow& mrAntiImpl;
227 ::vos::IMutex& mrMutex;
228 ::toolkit::AccessibilityClient maAccFactory;
229 bool mbDisposed;
230 bool mbDrawingOntoParent; // no bit mask, is passed around by reference
231 sal_Bool mbEnableVisible;
232 sal_Bool mbDirectVisible;
234 ::osl::Mutex maListenerContainerMutex;
235 ::cppu::OInterfaceContainerHelper maWindow2Listeners;
236 ::cppu::OInterfaceContainerHelper maDockableWindowListeners;
237 EventListenerMultiplexer maEventListeners;
238 FocusListenerMultiplexer maFocusListeners;
239 WindowListenerMultiplexer maWindowListeners;
240 KeyListenerMultiplexer maKeyListeners;
241 MouseListenerMultiplexer maMouseListeners;
242 MouseMotionListenerMultiplexer maMouseMotionListeners;
243 PaintListenerMultiplexer maPaintListeners;
244 VclContainerListenerMultiplexer maContainerListeners;
245 TopWindowListenerMultiplexer maTopWindowListeners;
247 EventArray maEvents;
248 ULONG mnEventId;
250 public:
251 bool mbDisposing : 1;
252 bool mbDesignMode : 1;
253 bool mbSynthesizingVCLEvent : 1;
254 bool mbWithDefaultProps : 1;
256 ULONG mnListenerLockLevel;
257 sal_Int16 mnWritingMode;
258 sal_Int16 mnContextWritingMode;
260 UnoPropertyArrayHelper* mpPropHelper;
262 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer >
263 mxPointer;
264 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
265 mxAccessibleContext;
266 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >
267 mxViewGraphics;
269 public:
270 bool& getDrawingOntoParent_ref() { return mbDrawingOntoParent; }
272 public:
273 /** ctor
274 @param _pAntiImpl
275 the <type>VCLXWindow</type> instance which the object belongs to. Must
276 live longer then the object just being constructed.
278 VCLXWindowImpl( VCLXWindow& _rAntiImpl, ::vos::IMutex& _rMutex, bool _bWithDefaultProps );
280 /** synchronously mbEnableVisible
282 void setEnableVisible( sal_Bool bEnableVisible ) { mbEnableVisible = bEnableVisible; }
283 sal_Bool isEnableVisible() { return mbEnableVisible; }
284 /** synchronously mbDirectVisible;
286 void setDirectVisible( sal_Bool bDirectVisible ) { mbDirectVisible = bDirectVisible; }
287 sal_Bool isDirectVisible() { return mbDirectVisible; }
289 /** asynchronously notifies a mouse event to the VCLXWindow's XMouseListeners
291 void notifyMouseEvent( const awt::MouseEvent& _rMouseEvent, MouseEventType _nType );
293 /** asynchronously notifies an event described by an EventObject to the respective listeners
295 void notifyPlainEvent( const lang::EventObject& _rPlainEvent, PlainEventType _nType );
297 /** notifies the object that its VCLXWindow is being disposed
299 void disposing();
301 inline ::toolkit::AccessibilityClient& getAccessibleFactory()
303 return maAccFactory;
306 /** returns the container of registered XWindowListener2 listeners
308 inline ::cppu::OInterfaceContainerHelper& getWindow2Listeners() { return maWindow2Listeners; }
309 inline ::cppu::OInterfaceContainerHelper& getDockableWindowListeners(){ return maDockableWindowListeners; }
310 inline EventListenerMultiplexer& getEventListeners() { return maEventListeners; }
311 inline FocusListenerMultiplexer& getFocusListeners() { return maFocusListeners; }
312 inline WindowListenerMultiplexer& getWindowListeners() { return maWindowListeners; }
313 inline KeyListenerMultiplexer& getKeyListeners() { return maKeyListeners; }
314 inline MouseListenerMultiplexer& getMouseListeners() { return maMouseListeners; }
315 inline MouseMotionListenerMultiplexer& getMouseMotionListeners() { return maMouseMotionListeners; }
316 inline PaintListenerMultiplexer& getPaintListeners() { return maPaintListeners; }
317 inline VclContainerListenerMultiplexer& getContainerListeners() { return maContainerListeners; }
318 inline TopWindowListenerMultiplexer& getTopWindowListeners() { return maTopWindowListeners; }
320 virtual ~VCLXWindowImpl();
322 protected:
323 virtual void SAL_CALL acquire();
324 virtual void SAL_CALL release();
326 // IEventProcessor
327 virtual void processEvent( const ::comphelper::AnyEvent& _rEvent );
329 private:
330 DECL_LINK( OnProcessEvent, void* );
332 private:
333 /** notifies an arbitrary event
334 @param _rEvent
335 the event to notify
337 void impl_notifyAnyEvent(
338 const ::rtl::Reference< ::comphelper::AnyEvent >& _rEvent
341 private:
342 /** determines whether the instance is already disposed
343 @precond
344 m_aMutex must be acquired
346 inline bool impl_isDisposed()
348 return mbDisposed;
351 private:
352 VCLXWindowImpl(); // never implemented
353 VCLXWindowImpl( const VCLXWindowImpl& ); // never implemented
354 VCLXWindowImpl& operator=( const VCLXWindowImpl& ); // never implemented
357 //--------------------------------------------------------------------
358 VCLXWindowImpl::VCLXWindowImpl( VCLXWindow& _rAntiImpl, ::vos::IMutex& _rMutex, bool _bWithDefaultProps )
359 :mrAntiImpl( _rAntiImpl )
360 ,mrMutex( _rMutex )
361 ,mbDisposed( false )
362 ,mbDrawingOntoParent( false )
363 ,mbEnableVisible(sal_True)
364 ,mbDirectVisible(sal_True)
365 ,maListenerContainerMutex( )
366 ,maWindow2Listeners( maListenerContainerMutex )
367 ,maDockableWindowListeners( maListenerContainerMutex )
368 ,maEventListeners( _rAntiImpl )
369 ,maFocusListeners( _rAntiImpl )
370 ,maWindowListeners( _rAntiImpl )
371 ,maKeyListeners( _rAntiImpl )
372 ,maMouseListeners( _rAntiImpl )
373 ,maMouseMotionListeners( _rAntiImpl )
374 ,maPaintListeners( _rAntiImpl )
375 ,maContainerListeners( _rAntiImpl )
376 ,maTopWindowListeners( _rAntiImpl )
377 ,mnEventId( 0 )
378 ,mbDisposing( false )
379 ,mbDesignMode( false )
380 ,mbSynthesizingVCLEvent( false )
381 ,mbWithDefaultProps( _bWithDefaultProps )
382 ,mnListenerLockLevel( 0 )
383 ,mnWritingMode( WritingMode2::CONTEXT )
384 ,mnContextWritingMode( WritingMode2::CONTEXT )
385 ,mpPropHelper( NULL )
389 VCLXWindowImpl::~VCLXWindowImpl()
391 delete mpPropHelper;
394 //--------------------------------------------------------------------
395 void VCLXWindowImpl::disposing()
397 ::vos::OGuard aGuard( mrMutex );
398 if ( mnEventId )
399 Application::RemoveUserEvent( mnEventId );
400 mnEventId = 0;
401 mbDisposed= true;
403 ::com::sun::star::lang::EventObject aEvent;
404 aEvent.Source = mrAntiImpl;
406 maEventListeners.disposeAndClear( aEvent );
407 maFocusListeners.disposeAndClear( aEvent );
408 maWindowListeners.disposeAndClear( aEvent );
409 maKeyListeners.disposeAndClear( aEvent );
410 maMouseListeners.disposeAndClear( aEvent );
411 maMouseMotionListeners.disposeAndClear( aEvent );
412 maPaintListeners.disposeAndClear( aEvent );
413 maContainerListeners.disposeAndClear( aEvent );
414 maTopWindowListeners.disposeAndClear( aEvent );
418 //--------------------------------------------------------------------
419 void VCLXWindowImpl::impl_notifyAnyEvent( const ::rtl::Reference< ::comphelper::AnyEvent >& _rEvent )
421 maEvents.push_back( _rEvent );
422 if ( !mnEventId )
423 mnEventId = Application::PostUserEvent( LINK( this, VCLXWindowImpl, OnProcessEvent ) );
426 //--------------------------------------------------------------------
427 void VCLXWindowImpl::notifyMouseEvent( const awt::MouseEvent& _rMouseEvent, MouseEventType _nType )
429 ::vos::OClearableGuard aGuard( mrMutex );
430 if ( maMouseListeners.getLength() )
431 impl_notifyAnyEvent( new AnyWindowEvent( _rMouseEvent, _nType ) );
434 //--------------------------------------------------------------------
435 void VCLXWindowImpl::notifyPlainEvent( const lang::EventObject& _rPlainEvent, PlainEventType _nType )
437 ::vos::OClearableGuard aGuard( mrMutex );
438 if ( maWindow2Listeners.getLength() )
439 impl_notifyAnyEvent( new AnyWindowEvent( _rPlainEvent, _nType ) );
442 //--------------------------------------------------------------------
443 IMPL_LINK( VCLXWindowImpl, OnProcessEvent, void*, EMPTYARG )
445 // work on a copy of the events array
446 EventArray aEventsCopy;
448 ::vos::OGuard aGuard( mrMutex );
449 aEventsCopy = maEvents;
450 maEvents.clear();
452 if ( !mnEventId )
453 // we were disposed while waiting for the mutex to lock
454 return 1L;
456 mnEventId = 0;
460 ::toolkit::ReleaseSolarMutex aReleaseSolar;
461 for ( EventArray::const_iterator loop = aEventsCopy.begin();
462 loop != aEventsCopy.end();
463 ++loop
466 processEvent( *(*loop) );
470 return 0L;
473 //--------------------------------------------------------------------
474 void VCLXWindowImpl::processEvent( const ::comphelper::AnyEvent& _rEvent )
476 ::vos::OGuard aGuard( mrMutex );
477 if ( impl_isDisposed() )
478 // while we were waiting for our mutex, another thread disposed us
479 return;
481 const AnyWindowEvent& rEventDescriptor( static_cast< const AnyWindowEvent& >( _rEvent ) );
482 if ( rEventDescriptor.isMouseEvent() )
484 const awt::MouseEvent& rEvent( rEventDescriptor.getMouseEvent() );
485 switch ( rEventDescriptor.getMouseEventType() )
487 case EVENT_MOUSE_PRESSED:
488 maMouseListeners.mousePressed( rEvent );
489 break;
490 case EVENT_MOUSE_RELEASED:
491 maMouseListeners.mouseReleased( rEvent );
492 break;
493 case EVENT_MOUSE_ENTERED:
494 maMouseListeners.mouseEntered( rEvent );
495 break;
496 case EVENT_MOUSE_EXITED:
497 maMouseListeners.mouseExited( rEvent );
498 break;
499 default:
500 DBG_ERROR( "VCLXWindowImpl::processEvent: what kind of event *is* this (1)?" );
501 break;
504 else if ( rEventDescriptor.isPlainEvent() )
506 const lang::EventObject& rEvent( rEventDescriptor.getPlainEvent() );
507 switch ( rEventDescriptor.getPlainEventType() )
509 case EVENT_WINDOW_ENABLED:
510 maWindow2Listeners.notifyEach( &XWindowListener2::windowEnabled, rEvent );
511 break;
512 case EVENT_WINDOW_DISABLED:
513 maWindow2Listeners.notifyEach( &XWindowListener2::windowDisabled, rEvent );
514 break;
515 default:
516 DBG_ERROR( "VCLXWindowImpl::processEvent: what kind of event *is* this (2)?" );
517 break;
520 else
522 DBG_ERROR( "VCLXWindowImpl::processEvent: what kind of event *is* this (3)?" );
526 //--------------------------------------------------------------------
527 void SAL_CALL VCLXWindowImpl::acquire()
529 mrAntiImpl.acquire();
532 //--------------------------------------------------------------------
533 void SAL_CALL VCLXWindowImpl::release()
535 mrAntiImpl.release();
538 //====================================================================
539 //====================================================================
541 // Mit Out-Parameter besser als Rueckgabewert, wegen Ref-Objekt...
543 void ImplInitWindowEvent( ::com::sun::star::awt::WindowEvent& rEvent, Window* pWindow )
545 Point aPos = pWindow->GetPosPixel();
546 Size aSz = pWindow->GetSizePixel();
548 rEvent.X = aPos.X();
549 rEvent.Y = aPos.Y();
551 rEvent.Width = aSz.Width();
552 rEvent.Height = aSz.Height();
554 pWindow->GetBorder( rEvent.LeftInset, rEvent.TopInset, rEvent.RightInset, rEvent.BottomInset );
557 // ----------------------------------------------------
558 // class VCLXWindow
559 // ----------------------------------------------------
561 DBG_NAME(VCLXWindow);
563 VCLXWindow::VCLXWindow( bool _bWithDefaultProps )
564 :mpImpl( NULL )
566 DBG_CTOR( VCLXWindow, 0 );
568 mpImpl = new VCLXWindowImpl( *this, GetMutex(), _bWithDefaultProps );
571 VCLXWindow::~VCLXWindow()
573 DBG_DTOR( VCLXWindow, 0 );
575 delete mpImpl;
577 if ( GetWindow() )
579 GetWindow()->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) );
580 GetWindow()->SetWindowPeer( NULL, NULL );
581 GetWindow()->SetAccessible( NULL );
585 ::toolkit::IAccessibleFactory& VCLXWindow::getAccessibleFactory()
587 return mpImpl->getAccessibleFactory().getFactory();
590 void VCLXWindow::SetWindow( Window* pWindow )
592 if ( GetWindow() )
594 GetWindow()->RemoveEventListener( LINK( this, VCLXWindow, WindowEventListener ) );
595 // GetWindow()->DbgAssertNoEventListeners();
598 SetOutputDevice( pWindow );
600 if ( GetWindow() )
602 GetWindow()->AddEventListener( LINK( this, VCLXWindow, WindowEventListener ) );
603 sal_Bool bDirectVisible = pWindow ? pWindow->IsVisible() : false;
604 mpImpl->setDirectVisible( bDirectVisible );
609 void VCLXWindow::suspendVclEventListening( )
611 ++mpImpl->mnListenerLockLevel;
614 void VCLXWindow::resumeVclEventListening( )
616 DBG_ASSERT( mpImpl->mnListenerLockLevel, "VCLXWindow::resumeVclEventListening: not suspended!" );
617 --mpImpl->mnListenerLockLevel;
620 void VCLXWindow::notifyWindowRemoved( Window& _rWindow )
622 if ( mpImpl->getContainerListeners().getLength() )
624 awt::VclContainerEvent aEvent;
625 aEvent.Source = *this;
626 aEvent.Child = static_cast< XWindow* >( _rWindow.GetWindowPeer() );
627 mpImpl->getContainerListeners().windowRemoved( aEvent );
631 IMPL_LINK( VCLXWindow, WindowEventListener, VclSimpleEvent*, pEvent )
633 if ( mpImpl->mnListenerLockLevel )
634 return 0L;
636 DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
637 if ( pEvent && pEvent->ISA( VclWindowEvent ) )
639 DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow() && GetWindow(), "Window???" );
640 ProcessWindowEvent( *(VclWindowEvent*)pEvent );
642 return 0;
645 void VCLXWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
647 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xThis( (::cppu::OWeakObject*)this );
649 switch ( rVclWindowEvent.GetId() )
651 case VCLEVENT_WINDOW_ENABLED:
652 case VCLEVENT_WINDOW_DISABLED:
654 bool bEnabled = ( VCLEVENT_WINDOW_ENABLED == rVclWindowEvent.GetId() );
655 EventObject aEvent( *this );
656 mpImpl->notifyPlainEvent( aEvent,
657 bEnabled ? EVENT_WINDOW_ENABLED : EVENT_WINDOW_DISABLED );
659 break;
661 case VCLEVENT_WINDOW_PAINT:
663 if ( mpImpl->getPaintListeners().getLength() )
665 ::com::sun::star::awt::PaintEvent aEvent;
666 aEvent.Source = (::cppu::OWeakObject*)this;
667 aEvent.UpdateRect = AWTRectangle( *(Rectangle*)rVclWindowEvent.GetData() );
668 aEvent.Count = 0;
669 mpImpl->getPaintListeners().windowPaint( aEvent );
672 break;
673 case VCLEVENT_WINDOW_MOVE:
675 if ( mpImpl->getWindowListeners().getLength() )
677 ::com::sun::star::awt::WindowEvent aEvent;
678 aEvent.Source = (::cppu::OWeakObject*)this;
679 ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
680 mpImpl->getWindowListeners().windowMoved( aEvent );
683 break;
684 case VCLEVENT_WINDOW_RESIZE:
686 if ( mpImpl->getWindowListeners().getLength() )
688 ::com::sun::star::awt::WindowEvent aEvent;
689 aEvent.Source = (::cppu::OWeakObject*)this;
690 ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
691 mpImpl->getWindowListeners().windowResized( aEvent );
694 break;
695 case VCLEVENT_WINDOW_SHOW:
697 if ( mpImpl->getWindowListeners().getLength() )
699 ::com::sun::star::awt::WindowEvent aEvent;
700 aEvent.Source = (::cppu::OWeakObject*)this;
701 ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
702 mpImpl->getWindowListeners().windowShown( aEvent );
705 // For TopWindows this means opened...
706 if ( mpImpl->getTopWindowListeners().getLength() )
708 ::com::sun::star::lang::EventObject aEvent;
709 aEvent.Source = (::cppu::OWeakObject*)this;
710 mpImpl->getTopWindowListeners().windowOpened( aEvent );
713 break;
714 case VCLEVENT_WINDOW_HIDE:
716 if ( mpImpl->getWindowListeners().getLength() )
718 ::com::sun::star::awt::WindowEvent aEvent;
719 aEvent.Source = (::cppu::OWeakObject*)this;
720 ImplInitWindowEvent( aEvent, rVclWindowEvent.GetWindow() );
721 mpImpl->getWindowListeners().windowHidden( aEvent );
724 // For TopWindows this means closed...
725 if ( mpImpl->getTopWindowListeners().getLength() )
727 ::com::sun::star::lang::EventObject aEvent;
728 aEvent.Source = (::cppu::OWeakObject*)this;
729 mpImpl->getTopWindowListeners().windowClosed( aEvent );
732 break;
733 case VCLEVENT_WINDOW_ACTIVATE:
735 if ( mpImpl->getTopWindowListeners().getLength() )
737 ::com::sun::star::lang::EventObject aEvent;
738 aEvent.Source = (::cppu::OWeakObject*)this;
739 mpImpl->getTopWindowListeners().windowActivated( aEvent );
742 break;
743 case VCLEVENT_WINDOW_DEACTIVATE:
745 if ( mpImpl->getTopWindowListeners().getLength() )
747 ::com::sun::star::lang::EventObject aEvent;
748 aEvent.Source = (::cppu::OWeakObject*)this;
749 mpImpl->getTopWindowListeners().windowDeactivated( aEvent );
752 break;
753 case VCLEVENT_WINDOW_CLOSE:
755 if ( mpImpl->getDockableWindowListeners().getLength() )
757 ::com::sun::star::lang::EventObject aEvent;
758 aEvent.Source = (::cppu::OWeakObject*)this;
759 mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::closed, aEvent );
761 if ( mpImpl->getTopWindowListeners().getLength() )
763 ::com::sun::star::lang::EventObject aEvent;
764 aEvent.Source = (::cppu::OWeakObject*)this;
765 mpImpl->getTopWindowListeners().windowClosing( aEvent );
768 break;
769 case VCLEVENT_CONTROL_GETFOCUS:
770 case VCLEVENT_WINDOW_GETFOCUS:
772 if ( ( rVclWindowEvent.GetWindow()->IsCompoundControl()
773 && rVclWindowEvent.GetId() == VCLEVENT_CONTROL_GETFOCUS
775 || ( !rVclWindowEvent.GetWindow()->IsCompoundControl()
776 && rVclWindowEvent.GetId() == VCLEVENT_WINDOW_GETFOCUS
780 if ( mpImpl->getFocusListeners().getLength() )
782 ::com::sun::star::awt::FocusEvent aEvent;
783 aEvent.Source = (::cppu::OWeakObject*)this;
784 aEvent.FocusFlags = rVclWindowEvent.GetWindow()->GetGetFocusFlags();
785 aEvent.Temporary = sal_False;
786 mpImpl->getFocusListeners().focusGained( aEvent );
790 break;
791 case VCLEVENT_CONTROL_LOSEFOCUS:
792 case VCLEVENT_WINDOW_LOSEFOCUS:
794 if ( ( rVclWindowEvent.GetWindow()->IsCompoundControl()
795 && rVclWindowEvent.GetId() == VCLEVENT_CONTROL_LOSEFOCUS
797 || ( !rVclWindowEvent.GetWindow()->IsCompoundControl()
798 && rVclWindowEvent.GetId() == VCLEVENT_WINDOW_LOSEFOCUS
802 if ( mpImpl->getFocusListeners().getLength() )
804 ::com::sun::star::awt::FocusEvent aEvent;
805 aEvent.Source = (::cppu::OWeakObject*)this;
806 aEvent.FocusFlags = rVclWindowEvent.GetWindow()->GetGetFocusFlags();
807 aEvent.Temporary = sal_False;
809 Window* pNext = Application::GetFocusWindow();
810 if ( pNext )
812 // Bei zusammengesetzten Controls interessiert sich keiner fuer das Innenleben:
813 Window* pNextC = pNext;
814 while ( pNextC && !pNextC->IsCompoundControl() )
815 pNextC = pNextC->GetParent();
816 if ( pNextC )
817 pNext = pNextC;
819 pNext->GetComponentInterface( sal_True );
820 aEvent.NextFocus = (::cppu::OWeakObject*)pNext->GetWindowPeer();
822 mpImpl->getFocusListeners().focusLost( aEvent );
826 break;
827 case VCLEVENT_WINDOW_MINIMIZE:
829 if ( mpImpl->getTopWindowListeners().getLength() )
831 ::com::sun::star::lang::EventObject aEvent;
832 aEvent.Source = (::cppu::OWeakObject*)this;
833 mpImpl->getTopWindowListeners().windowMinimized( aEvent );
836 break;
837 case VCLEVENT_WINDOW_NORMALIZE:
839 if ( mpImpl->getTopWindowListeners().getLength() )
841 ::com::sun::star::lang::EventObject aEvent;
842 aEvent.Source = (::cppu::OWeakObject*)this;
843 mpImpl->getTopWindowListeners().windowNormalized( aEvent );
846 break;
847 case VCLEVENT_WINDOW_KEYINPUT:
849 if ( mpImpl->getKeyListeners().getLength() )
851 ::com::sun::star::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent(
852 *(KeyEvent*)rVclWindowEvent.GetData(), *this
853 ) );
854 mpImpl->getKeyListeners().keyPressed( aEvent );
857 break;
858 case VCLEVENT_WINDOW_KEYUP:
860 if ( mpImpl->getKeyListeners().getLength() )
862 ::com::sun::star::awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent(
863 *(KeyEvent*)rVclWindowEvent.GetData(), *this
864 ) );
865 mpImpl->getKeyListeners().keyReleased( aEvent );
868 break;
869 case VCLEVENT_WINDOW_COMMAND:
871 CommandEvent* pCmdEvt = (CommandEvent*)rVclWindowEvent.GetData();
872 if ( mpImpl->getMouseListeners().getLength() && ( pCmdEvt->GetCommand() == COMMAND_CONTEXTMENU ) )
874 // COMMAND_CONTEXTMENU als mousePressed mit PopupTrigger = sal_True versenden...
875 Point aWhere = static_cast< CommandEvent* >( rVclWindowEvent.GetData() )->GetMousePosPixel();
876 if ( !pCmdEvt->IsMouseEvent() )
877 { // for keyboard events, we set the coordinates to -1,-1. This is a slight HACK, but the current API
878 // handles a context menu command as special case of a mouse event, which is simply wrong.
879 // Without extending the API, we would not have another chance to notify listeners of a
880 // keyboard-triggered context menu request
881 // 102205 - 16.08.2002 - fs@openoffice.org
882 aWhere = Point( -1, -1 );
885 MouseEvent aMEvt( aWhere, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT, 0 );
886 awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( aMEvt, *this ) );
887 aEvent.PopupTrigger = sal_True;
888 mpImpl->notifyMouseEvent( aEvent, EVENT_MOUSE_PRESSED );
891 break;
892 case VCLEVENT_WINDOW_MOUSEMOVE:
894 MouseEvent* pMouseEvt = (MouseEvent*)rVclWindowEvent.GetData();
895 if ( mpImpl->getMouseListeners().getLength() && ( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() ) )
897 awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) );
898 mpImpl->notifyMouseEvent(
899 aEvent,
900 pMouseEvt->IsEnterWindow() ? EVENT_MOUSE_ENTERED : EVENT_MOUSE_EXITED
904 if ( mpImpl->getMouseMotionListeners().getLength() && !pMouseEvt->IsEnterWindow() && !pMouseEvt->IsLeaveWindow() )
906 awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt, *this ) );
907 aEvent.ClickCount = 0; // #92138#
908 if ( pMouseEvt->GetMode() & MOUSE_SIMPLEMOVE )
909 mpImpl->getMouseMotionListeners().mouseMoved( aEvent );
910 else
911 mpImpl->getMouseMotionListeners().mouseDragged( aEvent );
914 break;
915 case VCLEVENT_WINDOW_MOUSEBUTTONDOWN:
917 if ( mpImpl->getMouseListeners().getLength() )
919 awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *(MouseEvent*)rVclWindowEvent.GetData(), *this ) );
920 mpImpl->notifyMouseEvent( aEvent, EVENT_MOUSE_PRESSED );
923 break;
924 case VCLEVENT_WINDOW_MOUSEBUTTONUP:
926 if ( mpImpl->getMouseListeners().getLength() )
928 awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *(MouseEvent*)rVclWindowEvent.GetData(), *this ) );
929 mpImpl->notifyMouseEvent( aEvent, EVENT_MOUSE_RELEASED );
932 break;
933 case VCLEVENT_WINDOW_STARTDOCKING:
935 if ( mpImpl->getDockableWindowListeners().getLength() )
937 DockingData *pData = (DockingData*)rVclWindowEvent.GetData();
939 if( pData )
941 ::com::sun::star::awt::DockingEvent aEvent;
942 aEvent.Source = (::cppu::OWeakObject*)this;
943 aEvent.TrackingRectangle = AWTRectangle( pData->maTrackRect );
944 aEvent.MousePos.X = pData->maMousePos.X();
945 aEvent.MousePos.Y = pData->maMousePos.Y();
946 aEvent.bLiveMode = pData->mbLivemode;
947 aEvent.bInteractive = pData->mbInteractive;
949 mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::startDocking, aEvent );
953 break;
954 case VCLEVENT_WINDOW_DOCKING:
956 if ( mpImpl->getDockableWindowListeners().getLength() )
958 DockingData *pData = (DockingData*)rVclWindowEvent.GetData();
960 if( pData )
962 ::com::sun::star::awt::DockingEvent aEvent;
963 aEvent.Source = (::cppu::OWeakObject*)this;
964 aEvent.TrackingRectangle = AWTRectangle( pData->maTrackRect );
965 aEvent.MousePos.X = pData->maMousePos.X();
966 aEvent.MousePos.Y = pData->maMousePos.Y();
967 aEvent.bLiveMode = pData->mbLivemode;
968 aEvent.bInteractive = pData->mbInteractive;
970 Reference< XDockableWindowListener > xFirstListener;
971 ::cppu::OInterfaceIteratorHelper aIter( mpImpl->getDockableWindowListeners() );
972 while ( aIter.hasMoreElements() && !xFirstListener.is() )
974 xFirstListener.set( aIter.next(), UNO_QUERY );
977 ::com::sun::star::awt::DockingData aDockingData =
978 xFirstListener->docking( aEvent );
979 pData->maTrackRect = VCLRectangle( aDockingData.TrackingRectangle );
980 pData->mbFloating = aDockingData.bFloating;
984 break;
985 case VCLEVENT_WINDOW_ENDDOCKING:
987 if ( mpImpl->getDockableWindowListeners().getLength() )
989 EndDockingData *pData = (EndDockingData*)rVclWindowEvent.GetData();
991 if( pData )
993 ::com::sun::star::awt::EndDockingEvent aEvent;
994 aEvent.Source = (::cppu::OWeakObject*)this;
995 aEvent.WindowRectangle = AWTRectangle( pData->maWindowRect );
996 aEvent.bFloating = pData->mbFloating;
997 aEvent.bCancelled = pData->mbCancelled;
998 mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endDocking, aEvent );
1002 break;
1003 case VCLEVENT_WINDOW_PREPARETOGGLEFLOATING:
1005 if ( mpImpl->getDockableWindowListeners().getLength() )
1007 BOOL *p_bFloating = (BOOL*)rVclWindowEvent.GetData();
1009 ::com::sun::star::lang::EventObject aEvent;
1010 aEvent.Source = (::cppu::OWeakObject*)this;
1012 Reference< XDockableWindowListener > xFirstListener;
1013 ::cppu::OInterfaceIteratorHelper aIter( mpImpl->getDockableWindowListeners() );
1014 while ( aIter.hasMoreElements() && !xFirstListener.is() )
1016 xFirstListener.set( aIter.next(), UNO_QUERY );
1019 *p_bFloating = xFirstListener->prepareToggleFloatingMode( aEvent );
1022 break;
1023 case VCLEVENT_WINDOW_TOGGLEFLOATING:
1025 if ( mpImpl->getDockableWindowListeners().getLength() )
1027 ::com::sun::star::lang::EventObject aEvent;
1028 aEvent.Source = (::cppu::OWeakObject*)this;
1029 mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::toggleFloatingMode, aEvent );
1032 break;
1033 case VCLEVENT_WINDOW_ENDPOPUPMODE:
1035 if ( mpImpl->getDockableWindowListeners().getLength() )
1037 EndPopupModeData *pData = (EndPopupModeData*)rVclWindowEvent.GetData();
1039 if( pData )
1041 ::com::sun::star::awt::EndPopupModeEvent aEvent;
1042 aEvent.Source = (::cppu::OWeakObject*)this;
1043 aEvent.FloatingPosition.X = pData->maFloatingPos.X();
1044 aEvent.FloatingPosition.Y = pData->maFloatingPos.Y();
1045 aEvent.bTearoff = pData->mbTearoff;
1046 mpImpl->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endPopupMode, aEvent );
1050 break;
1055 uno::Reference< accessibility::XAccessibleContext > VCLXWindow::CreateAccessibleContext()
1057 ::vos::OGuard aGuard( GetMutex() );
1058 return getAccessibleFactory().createAccessibleContext( this );
1061 void VCLXWindow::SetSynthesizingVCLEvent( sal_Bool _b )
1063 mpImpl->mbSynthesizingVCLEvent = _b;
1066 BOOL VCLXWindow::IsSynthesizingVCLEvent() const
1068 return mpImpl->mbSynthesizingVCLEvent;
1071 Size VCLXWindow::ImplCalcWindowSize( const Size& rOutSz ) const
1073 Size aSz = rOutSz;
1075 Window* pWindow = GetWindow();
1076 if ( pWindow )
1078 sal_Int32 nLeft, nTop, nRight, nBottom;
1079 pWindow->GetBorder( nLeft, nTop, nRight, nBottom );
1080 aSz.Width() += nLeft+nRight;
1081 aSz.Height() += nTop+nBottom;
1083 return aSz;
1087 // ::com::sun::star::lang::XUnoTunnel
1088 IMPL_XUNOTUNNEL2( VCLXWindow, VCLXDevice )
1090 // ::com::sun::star::lang::Component
1091 void VCLXWindow::dispose( ) throw(::com::sun::star::uno::RuntimeException)
1093 ::vos::OGuard aGuard( GetMutex() );
1095 mpImpl->mxViewGraphics = NULL;
1097 if ( !mpImpl->mbDisposing )
1099 mpImpl->mbDisposing = true;
1101 mpImpl->disposing();
1103 if ( GetWindow() )
1105 OutputDevice* pOutDev = GetOutputDevice();
1106 SetWindow( NULL ); // Damit ggf. Handler abgemeldet werden (virtuell).
1107 SetOutputDevice( pOutDev );
1108 DestroyOutputDevice();
1111 // #i14103# dispose the accessible context after the window has been destroyed,
1112 // otherwise the old value in the child event fired in VCLXAccessibleComponent::ProcessWindowEvent()
1113 // for VCLEVENT_WINDOW_CHILDDESTROYED contains a reference to an already disposed accessible object
1116 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComponent( mpImpl->mxAccessibleContext, ::com::sun::star::uno::UNO_QUERY );
1117 if ( xComponent.is() )
1118 xComponent->dispose();
1120 catch ( const ::com::sun::star::uno::Exception& )
1122 DBG_ERROR( "VCLXWindow::dispose: could not dispose the accessible context!" );
1124 mpImpl->mxAccessibleContext.clear();
1126 mpImpl->mbDisposing = false;
1130 void VCLXWindow::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1132 ::vos::OGuard aGuard( GetMutex() );
1134 mpImpl->getEventListeners().addInterface( rxListener );
1137 void VCLXWindow::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1139 ::vos::OGuard aGuard( GetMutex() );
1141 mpImpl->getEventListeners().removeInterface( rxListener );
1145 // ::com::sun::star::awt::XWindow
1146 void VCLXWindow::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw(::com::sun::star::uno::RuntimeException)
1148 ::vos::OGuard aGuard( GetMutex() );
1150 if ( GetWindow() )
1152 if( Window::GetDockingManager()->IsDockable( GetWindow() ) )
1153 Window::GetDockingManager()->SetPosSizePixel( GetWindow() , X, Y, Width, Height, Flags );
1154 else
1155 GetWindow()->SetPosSizePixel( X, Y, Width, Height, Flags );
1159 ::com::sun::star::awt::Rectangle VCLXWindow::getPosSize( ) throw(::com::sun::star::uno::RuntimeException)
1161 ::vos::OGuard aGuard( GetMutex() );
1163 ::com::sun::star::awt::Rectangle aBounds;
1164 if ( GetWindow() )
1166 if( Window::GetDockingManager()->IsDockable( GetWindow() ) )
1167 aBounds = AWTRectangle( Window::GetDockingManager()->GetPosSizePixel( GetWindow() ) );
1168 else
1169 aBounds = AWTRectangle( Rectangle( GetWindow()->GetPosPixel(), GetWindow()->GetSizePixel() ) );
1172 return aBounds;
1175 void VCLXWindow::setVisible( sal_Bool bVisible ) throw(::com::sun::star::uno::RuntimeException)
1177 ::vos::OGuard aGuard( GetMutex() );
1179 Window* pWindow = GetWindow();
1180 if ( pWindow )
1183 if ( bVisible )
1185 // #57167# TopWindows mit unsichtbaren Parent anzeigen...
1186 ::com::sun::star::uno::Any aTest = queryInterface( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindow >*) 0 ) );
1187 if ( aTest.hasValue() )
1189 Window* pParent = pWindow->GetWindow( WINDOW_PARENTOVERLAP );
1190 if ( pParent && !pParent->IsReallyVisible() )
1191 pWindow->SetParent( pWindow->GetWindow( WINDOW_FRAME ) );
1195 mpImpl->setDirectVisible( bVisible );
1196 pWindow->Show( bVisible && mpImpl->isEnableVisible() );
1200 void VCLXWindow::setEnable( sal_Bool bEnable ) throw(::com::sun::star::uno::RuntimeException)
1202 ::vos::OGuard aGuard( GetMutex() );
1204 Window* pWindow = GetWindow();
1205 if ( pWindow )
1207 pWindow->Enable( bEnable, FALSE ); // #95824# without children!
1208 pWindow->EnableInput( bEnable );
1212 void VCLXWindow::setFocus( ) throw(::com::sun::star::uno::RuntimeException)
1214 ::vos::OGuard aGuard( GetMutex() );
1216 if ( GetWindow() )
1217 GetWindow()->GrabFocus();
1220 void VCLXWindow::addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1222 ::vos::OGuard aGuard( GetMutex() );
1224 mpImpl->getWindowListeners().addInterface( rxListener );
1226 Reference< XWindowListener2 > xListener2( rxListener, UNO_QUERY );
1227 if ( xListener2.is() )
1228 mpImpl->getWindow2Listeners().addInterface( xListener2 );
1230 // #100119# Get all resize events, even if height or width 0, or invisible
1231 if ( GetWindow() )
1232 GetWindow()->EnableAllResize( TRUE );
1235 void VCLXWindow::removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1237 ::vos::OGuard aGuard( GetMutex() );
1239 Reference< XWindowListener2 > xListener2( rxListener, UNO_QUERY );
1240 if ( xListener2.is() )
1241 mpImpl->getWindow2Listeners().removeInterface( xListener2 );
1243 mpImpl->getWindowListeners().removeInterface( rxListener );
1246 void VCLXWindow::addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1248 ::vos::OGuard aGuard( GetMutex() );
1249 mpImpl->getFocusListeners().addInterface( rxListener );
1252 void VCLXWindow::removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1254 ::vos::OGuard aGuard( GetMutex() );
1255 mpImpl->getFocusListeners().removeInterface( rxListener );
1258 void VCLXWindow::addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1260 ::vos::OGuard aGuard( GetMutex() );
1261 mpImpl->getKeyListeners().addInterface( rxListener );
1264 void VCLXWindow::removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1266 ::vos::OGuard aGuard( GetMutex() );
1267 mpImpl->getKeyListeners().removeInterface( rxListener );
1270 void VCLXWindow::addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1272 ::vos::OGuard aGuard( GetMutex() );
1273 mpImpl->getMouseListeners().addInterface( rxListener );
1276 void VCLXWindow::removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1278 ::vos::OGuard aGuard( GetMutex() );
1279 mpImpl->getMouseListeners().removeInterface( rxListener );
1282 void VCLXWindow::addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1284 ::vos::OGuard aGuard( GetMutex() );
1285 mpImpl->getMouseMotionListeners().addInterface( rxListener );
1288 void VCLXWindow::removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1290 ::vos::OGuard aGuard( GetMutex() );
1291 mpImpl->getMouseMotionListeners().removeInterface( rxListener );
1294 void VCLXWindow::addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1296 ::vos::OGuard aGuard( GetMutex() );
1297 mpImpl->getPaintListeners().addInterface( rxListener );
1300 void VCLXWindow::removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& rxListener ) throw(::com::sun::star::uno::RuntimeException)
1302 ::vos::OGuard aGuard( GetMutex() );
1303 mpImpl->getPaintListeners().removeInterface( rxListener );
1306 // ::com::sun::star::awt::XWindowPeer
1307 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > VCLXWindow::getToolkit( ) throw(::com::sun::star::uno::RuntimeException)
1309 // no guard. nothing to guard here.
1310 // 82463 - 12/21/00 - fs
1311 return Application::GetVCLToolkit();
1314 void VCLXWindow::setPointer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPointer >& rxPointer ) throw(::com::sun::star::uno::RuntimeException)
1316 ::vos::OGuard aGuard( GetMutex() );
1318 VCLXPointer* pPointer = VCLXPointer::GetImplementation( rxPointer );
1319 if ( pPointer )
1321 mpImpl->mxPointer = rxPointer;
1322 if ( GetWindow() )
1323 GetWindow()->SetPointer( pPointer->GetPointer() );
1327 void VCLXWindow::setBackground( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
1329 ::vos::OGuard aGuard( GetMutex() );
1331 if ( GetWindow() )
1333 Color aColor( (sal_uInt32)nColor );
1334 GetWindow()->SetBackground( aColor );
1335 GetWindow()->SetControlBackground( aColor );
1337 WindowType eWinType = GetWindow()->GetType();
1338 if ( ( eWinType == WINDOW_WINDOW ) ||
1339 ( eWinType == WINDOW_WORKWINDOW ) ||
1340 ( eWinType == WINDOW_FLOATINGWINDOW ) )
1342 GetWindow()->Invalidate();
1347 void VCLXWindow::invalidate( sal_Int16 nInvalidateFlags ) throw(::com::sun::star::uno::RuntimeException)
1349 ::vos::OGuard aGuard( GetMutex() );
1351 if ( GetWindow() )
1352 GetWindow()->Invalidate( (sal_uInt16) nInvalidateFlags );
1355 void VCLXWindow::invalidateRect( const ::com::sun::star::awt::Rectangle& rRect, sal_Int16 nInvalidateFlags ) throw(::com::sun::star::uno::RuntimeException)
1357 ::vos::OGuard aGuard( GetMutex() );
1359 if ( GetWindow() )
1360 GetWindow()->Invalidate( VCLRectangle(rRect), (sal_uInt16) nInvalidateFlags );
1364 // ::com::sun::star::awt::XVclWindowPeer
1365 sal_Bool VCLXWindow::isChild( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& rxPeer ) throw(::com::sun::star::uno::RuntimeException)
1367 ::vos::OGuard aGuard( GetMutex() );
1369 sal_Bool bIsChild = sal_False;
1370 Window* pWindow = GetWindow();
1371 if ( pWindow )
1373 Window* pPeerWindow = VCLUnoHelper::GetWindow( rxPeer );
1374 bIsChild = pPeerWindow && pWindow->IsChild( pPeerWindow );
1377 return bIsChild;
1380 void VCLXWindow::setDesignMode( sal_Bool bOn ) throw(::com::sun::star::uno::RuntimeException)
1382 ::vos::OGuard aGuard( GetMutex() );
1384 mpImpl->mbDesignMode = bOn;
1387 sal_Bool VCLXWindow::isDesignMode( ) throw(::com::sun::star::uno::RuntimeException)
1389 ::vos::OGuard aGuard( GetMutex() );
1390 return mpImpl->mbDesignMode;
1393 void VCLXWindow::enableClipSiblings( sal_Bool bClip ) throw(::com::sun::star::uno::RuntimeException)
1395 ::vos::OGuard aGuard( GetMutex() );
1397 if ( GetWindow() )
1398 GetWindow()->EnableClipSiblings( bClip );
1401 void VCLXWindow::setForeground( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
1403 ::vos::OGuard aGuard( GetMutex() );
1405 if ( GetWindow() )
1407 Color aColor( (sal_uInt32)nColor );
1408 GetWindow()->SetControlForeground( aColor );
1412 void VCLXWindow::setControlFont( const ::com::sun::star::awt::FontDescriptor& rFont ) throw(::com::sun::star::uno::RuntimeException)
1414 ::vos::OGuard aGuard( GetMutex() );
1416 if ( GetWindow() )
1417 GetWindow()->SetControlFont( VCLUnoHelper::CreateFont( rFont, GetWindow()->GetControlFont() ) );
1420 void VCLXWindow::getStyles( sal_Int16 nType, ::com::sun::star::awt::FontDescriptor& Font, sal_Int32& ForegroundColor, sal_Int32& BackgroundColor ) throw(::com::sun::star::uno::RuntimeException)
1422 ::vos::OGuard aGuard( GetMutex() );
1424 if ( GetWindow() )
1426 const StyleSettings& rStyleSettings = GetWindow()->GetSettings().GetStyleSettings();
1428 switch ( nType )
1430 case ::com::sun::star::awt::Style::FRAME:
1432 Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() );
1433 ForegroundColor = rStyleSettings.GetWindowTextColor().GetColor();
1434 BackgroundColor = rStyleSettings.GetWindowColor().GetColor();
1436 break;
1437 case ::com::sun::star::awt::Style::DIALOG:
1439 Font = VCLUnoHelper::CreateFontDescriptor( rStyleSettings.GetAppFont() );
1440 ForegroundColor = rStyleSettings.GetDialogTextColor().GetColor();
1441 BackgroundColor = rStyleSettings.GetDialogColor().GetColor();
1443 break;
1444 default: DBG_ERROR( "VCLWindow::getStyles() - unknown Type" );
1450 namespace toolkit
1452 static void setColorSettings( Window* _pWindow, const ::com::sun::star::uno::Any& _rValue,
1453 void (StyleSettings::*pSetter)( const Color& ), const Color& (StyleSettings::*pGetter)( ) const )
1455 sal_Int32 nColor = 0;
1456 if ( !( _rValue >>= nColor ) )
1457 nColor = (Application::GetSettings().GetStyleSettings().*pGetter)().GetColor();
1459 AllSettings aSettings = _pWindow->GetSettings();
1460 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1462 (aStyleSettings.*pSetter)( Color( nColor ) );
1464 aSettings.SetStyleSettings( aStyleSettings );
1465 _pWindow->SetSettings( aSettings, TRUE );
1469 // Terminated by BASEPROPERTY_NOTFOUND (or 0)
1470 void VCLXWindow::PushPropertyIds( std::list< sal_uInt16 > &rIds,
1471 int nFirstId, ...)
1473 va_list pVarArgs;
1474 va_start( pVarArgs, nFirstId );
1476 for ( int nId = nFirstId; nId != BASEPROPERTY_NOTFOUND;
1477 nId = va_arg( pVarArgs, int ) )
1478 rIds.push_back( (sal_uInt16) nId );
1480 va_end( pVarArgs );
1483 void VCLXWindow::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds, bool bWithDefaults )
1485 // These are common across ~all VCLXWindow derived classes
1486 if( bWithDefaults )
1487 PushPropertyIds( rIds,
1488 BASEPROPERTY_ALIGN,
1489 BASEPROPERTY_BACKGROUNDCOLOR,
1490 BASEPROPERTY_BORDER,
1491 BASEPROPERTY_BORDERCOLOR,
1492 BASEPROPERTY_DEFAULTCONTROL,
1493 BASEPROPERTY_ENABLED,
1494 BASEPROPERTY_FONTDESCRIPTOR,
1495 BASEPROPERTY_HELPTEXT,
1496 BASEPROPERTY_HELPURL,
1497 BASEPROPERTY_TEXT,
1498 BASEPROPERTY_PRINTABLE,
1499 BASEPROPERTY_ENABLEVISIBLE, // for visibility
1500 BASEPROPERTY_TABSTOP,
1503 // lovely hack from:
1504 // void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
1505 std::list< sal_uInt16 >::const_iterator iter;
1506 for( iter = rIds.begin(); iter != rIds.end(); iter++) {
1507 if( *iter == BASEPROPERTY_FONTDESCRIPTOR )
1509 // some properties are not included in the FontDescriptor, but everytime
1510 // when we have a FontDescriptor we want to have these properties too.
1511 // => Easier to register the here, istead everywhere where I register the FontDescriptor...
1513 rIds.push_back( BASEPROPERTY_TEXTCOLOR );
1514 rIds.push_back( BASEPROPERTY_TEXTLINECOLOR );
1515 rIds.push_back( BASEPROPERTY_FONTRELIEF );
1516 rIds.push_back( BASEPROPERTY_FONTEMPHASISMARK );
1517 break;
1522 void VCLXWindow::GetPropertyIds( std::list< sal_uInt16 >& _out_rIds )
1524 return ImplGetPropertyIds( _out_rIds, mpImpl->mbWithDefaultProps );
1527 ::cppu::OInterfaceContainerHelper& VCLXWindow::GetContainerListeners()
1529 return mpImpl->getContainerListeners();
1532 ::cppu::OInterfaceContainerHelper& VCLXWindow::GetTopWindowListeners()
1534 return mpImpl->getTopWindowListeners();
1537 namespace
1539 void lcl_updateWritingMode( Window& _rWindow, const sal_Int16 _nWritingMode, const sal_Int16 _nContextWritingMode )
1541 BOOL bEnableRTL = FALSE;
1542 switch ( _nWritingMode )
1544 case WritingMode2::LR_TB: bEnableRTL = FALSE; break;
1545 case WritingMode2::RL_TB: bEnableRTL = TRUE; break;
1546 case WritingMode2::CONTEXT:
1548 // consult our ContextWritingMode. If it has an explicit RTL/LTR value, then use
1549 // it. If it doesn't (but is CONTEXT itself), then just ask the parent window of our
1550 // own window for its RTL mode
1551 switch ( _nContextWritingMode )
1553 case WritingMode2::LR_TB: bEnableRTL = FALSE; break;
1554 case WritingMode2::RL_TB: bEnableRTL = TRUE; break;
1555 case WritingMode2::CONTEXT:
1557 const Window* pParent = _rWindow.GetParent();
1558 OSL_ENSURE( pParent, "lcl_updateWritingMode: cannot determine context's writing mode!" );
1559 if ( pParent )
1560 bEnableRTL = pParent->IsRTLEnabled();
1562 break;
1565 break;
1566 default:
1567 OSL_ENSURE( false, "lcl_updateWritingMode: unsupported WritingMode!" );
1568 } // switch ( nWritingMode )
1570 _rWindow.EnableRTL( bEnableRTL );
1574 void VCLXWindow::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException)
1576 ::vos::OGuard aGuard( GetMutex() );
1578 Window* pWindow = GetWindow();
1579 if ( !pWindow )
1580 return;
1582 sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
1584 WindowType eWinType = pWindow->GetType();
1585 sal_uInt16 nPropType = GetPropertyId( PropertyName );
1586 switch ( nPropType )
1588 case BASEPROPERTY_CONTEXT_WRITING_MODE:
1590 OSL_VERIFY( Value >>= mpImpl->mnContextWritingMode );
1591 if ( mpImpl->mnWritingMode == WritingMode2::CONTEXT )
1592 lcl_updateWritingMode( *pWindow, mpImpl->mnWritingMode, mpImpl->mnContextWritingMode );
1594 break;
1596 case BASEPROPERTY_WRITING_MODE:
1598 sal_Bool bProperType = ( Value >>= mpImpl->mnWritingMode );
1599 OSL_ENSURE( bProperType, "VCLXWindow::setProperty( 'WritingMode' ): illegal value type!" );
1600 if ( bProperType )
1601 lcl_updateWritingMode( *pWindow, mpImpl->mnWritingMode, mpImpl->mnContextWritingMode );
1603 break;
1605 case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR:
1607 sal_uInt16 nWheelBehavior( MouseWheelBehavior::SCROLL_FOCUS_ONLY );
1608 OSL_VERIFY( Value >>= nWheelBehavior );
1610 AllSettings aSettings = pWindow->GetSettings();
1611 MouseSettings aMouseSettings = aSettings.GetMouseSettings();
1613 USHORT nVclBehavior( MOUSE_WHEEL_FOCUS_ONLY );
1614 switch ( nWheelBehavior )
1616 case MouseWheelBehavior::SCROLL_DISABLED: nVclBehavior = MOUSE_WHEEL_DISABLE; break;
1617 case MouseWheelBehavior::SCROLL_FOCUS_ONLY: nVclBehavior = MOUSE_WHEEL_FOCUS_ONLY; break;
1618 case MouseWheelBehavior::SCROLL_ALWAYS: nVclBehavior = MOUSE_WHEEL_ALWAYS; break;
1619 default:
1620 OSL_ENSURE( false, "VCLXWindow::setProperty( 'MouseWheelBehavior' ): illegal property value!" );
1623 aMouseSettings.SetWheelBehavior( nWheelBehavior );
1624 aSettings.SetMouseSettings( aMouseSettings );
1625 pWindow->SetSettings( aSettings, TRUE );
1627 break;
1629 case BASEPROPERTY_NATIVE_WIDGET_LOOK:
1631 sal_Bool bEnable( sal_True );
1632 OSL_VERIFY( Value >>= bEnable );
1633 pWindow->EnableNativeWidget( bEnable );
1635 break;
1637 case BASEPROPERTY_PLUGINPARENT:
1639 // set parent handle
1640 SetSystemParent_Impl( Value );
1642 break;
1644 case BASEPROPERTY_ENABLED:
1646 sal_Bool b = sal_Bool();
1647 if ( Value >>= b )
1648 setEnable( b );
1650 break;
1651 case BASEPROPERTY_ENABLEVISIBLE:
1653 sal_Bool b = sal_False;
1654 if ( Value >>= b )
1656 if( b != mpImpl->isEnableVisible() )
1658 mpImpl->setEnableVisible( b );
1659 pWindow->Show( b && mpImpl->isDirectVisible() );
1663 break;
1664 case BASEPROPERTY_TEXT:
1665 case BASEPROPERTY_LABEL:
1666 case BASEPROPERTY_TITLE:
1668 ::rtl::OUString aText;
1669 if ( Value >>= aText )
1671 switch (eWinType)
1673 case WINDOW_OKBUTTON:
1674 case WINDOW_CANCELBUTTON:
1675 case WINDOW_HELPBUTTON:
1676 // Standard Button: overwrite only if not empty.
1677 if (aText.getLength())
1678 pWindow->SetText( aText );
1679 break;
1681 default:
1682 pWindow->SetText( aText );
1683 break;
1687 break;
1688 case BASEPROPERTY_ACCESSIBLENAME:
1690 ::rtl::OUString aText;
1691 if ( Value >>= aText )
1692 pWindow->SetAccessibleName( aText );
1694 break;
1695 case BASEPROPERTY_HELPURL:
1697 ::rtl::OUString aURL;
1698 if ( Value >>= aURL )
1700 String aHelpURL( aURL );
1701 String aPattern( RTL_CONSTASCII_USTRINGPARAM( "HID:" ) );
1702 if ( aHelpURL.CompareIgnoreCaseToAscii( aPattern, aPattern.Len() ) == COMPARE_EQUAL )
1704 String aID = aHelpURL.Copy( aPattern.Len() );
1705 pWindow->SetHelpId( aID.ToInt32() );
1707 else
1709 pWindow->SetSmartHelpId( SmartId( aHelpURL ) );
1713 break;
1714 case BASEPROPERTY_HELPTEXT:
1716 ::rtl::OUString aHelpText;
1717 if ( Value >>= aHelpText )
1719 pWindow->SetQuickHelpText( aHelpText );
1722 break;
1723 case BASEPROPERTY_FONTDESCRIPTOR:
1725 if ( bVoid )
1726 pWindow->SetControlFont( Font() );
1727 else
1729 ::com::sun::star::awt::FontDescriptor aFont;
1730 if ( Value >>= aFont )
1731 pWindow->SetControlFont( VCLUnoHelper::CreateFont( aFont, pWindow->GetControlFont() ) );
1734 break;
1735 case BASEPROPERTY_FONTRELIEF:
1737 sal_Int16 n = sal_Int16();
1738 if ( Value >>= n )
1740 Font aFont = pWindow->GetControlFont();
1741 aFont.SetRelief( (FontRelief)n );
1742 pWindow->SetControlFont( aFont );
1745 break;
1746 case BASEPROPERTY_FONTEMPHASISMARK:
1748 sal_Int16 n = sal_Int16();
1749 if ( Value >>= n )
1751 Font aFont = pWindow->GetControlFont();
1752 aFont.SetEmphasisMark( n );
1753 pWindow->SetControlFont( aFont );
1756 break;
1757 case BASEPROPERTY_BACKGROUNDCOLOR:
1758 if ( bVoid )
1760 switch ( eWinType )
1762 // set dialog color for default
1763 case WINDOW_DIALOG:
1764 case WINDOW_MESSBOX:
1765 case WINDOW_INFOBOX:
1766 case WINDOW_WARNINGBOX:
1767 case WINDOW_ERRORBOX:
1768 case WINDOW_QUERYBOX:
1769 case WINDOW_TABPAGE:
1771 Color aColor = pWindow->GetSettings().GetStyleSettings().GetDialogColor();
1772 pWindow->SetBackground( aColor );
1773 pWindow->SetControlBackground( aColor );
1774 break;
1777 case WINDOW_FIXEDTEXT:
1778 case WINDOW_CHECKBOX:
1779 case WINDOW_RADIOBUTTON:
1780 case WINDOW_GROUPBOX:
1781 case WINDOW_FIXEDLINE:
1783 // support transparency only for special controls
1784 pWindow->SetBackground();
1785 pWindow->SetControlBackground();
1786 pWindow->SetPaintTransparent( TRUE );
1787 break;
1790 default:
1792 // default code which enables transparency for
1793 // compound controls. It's not real transparency
1794 // as most of these controls repaint their client
1795 // area completely new.
1796 if ( pWindow->IsCompoundControl() )
1797 pWindow->SetBackground();
1798 pWindow->SetControlBackground();
1799 break;
1803 else
1805 sal_Int32 nColor = 0;
1806 if ( Value >>= nColor )
1808 Color aColor( nColor );
1809 pWindow->SetControlBackground( aColor );
1810 pWindow->SetBackground( aColor );
1811 switch ( eWinType )
1813 // reset paint transparent mode
1814 case WINDOW_FIXEDTEXT:
1815 case WINDOW_CHECKBOX:
1816 case WINDOW_RADIOBUTTON:
1817 case WINDOW_GROUPBOX:
1818 case WINDOW_FIXEDLINE:
1819 pWindow->SetPaintTransparent( FALSE );
1820 default: ;
1822 pWindow->Invalidate(); // Falls das Control nicht drauf reagiert
1825 break;
1826 case BASEPROPERTY_TEXTCOLOR:
1827 if ( bVoid )
1829 pWindow->SetControlForeground();
1831 else
1833 sal_Int32 nColor = 0;
1834 if ( Value >>= nColor )
1836 Color aColor( nColor );
1837 pWindow->SetTextColor( aColor );
1838 pWindow->SetControlForeground( aColor );
1841 break;
1842 case BASEPROPERTY_TEXTLINECOLOR:
1843 if ( bVoid )
1845 pWindow->SetTextLineColor();
1847 else
1849 sal_Int32 nColor = 0;
1850 if ( Value >>= nColor )
1852 Color aColor( nColor );
1853 pWindow->SetTextLineColor( aColor );
1856 break;
1857 case BASEPROPERTY_FILLCOLOR:
1858 if ( bVoid )
1859 pWindow->SetFillColor();
1860 else
1862 sal_Int32 nColor = 0;
1863 if ( Value >>= nColor )
1865 Color aColor( nColor );
1866 pWindow->SetFillColor( aColor );
1869 break;
1870 case BASEPROPERTY_LINECOLOR:
1871 if ( bVoid )
1872 pWindow->SetLineColor();
1873 else
1875 sal_Int32 nColor = 0;
1876 if ( Value >>= nColor )
1878 Color aColor( nColor );
1879 pWindow->SetLineColor( aColor );
1882 break;
1883 case BASEPROPERTY_BORDER:
1885 WinBits nStyle = pWindow->GetStyle();
1886 sal_uInt16 nBorder = 0;
1887 Value >>= nBorder;
1888 if ( !nBorder )
1890 pWindow->SetStyle( nStyle & ~WB_BORDER );
1892 else
1894 pWindow->SetStyle( nStyle | WB_BORDER );
1895 pWindow->SetBorderStyle( nBorder );
1898 break;
1899 case BASEPROPERTY_TABSTOP:
1901 WinBits nStyle = pWindow->GetStyle() & ~WB_TABSTOP;
1902 if ( !bVoid )
1904 sal_Bool bTab = false;
1905 Value >>= bTab;
1906 if ( bTab )
1907 nStyle |= WB_TABSTOP;
1908 else
1909 nStyle |= WB_NOTABSTOP;
1911 pWindow->SetStyle( nStyle );
1913 break;
1914 case BASEPROPERTY_VERTICALALIGN:
1916 VerticalAlignment eAlign = VerticalAlignment_MAKE_FIXED_SIZE;
1917 WinBits nStyle = pWindow->GetStyle();
1918 nStyle &= ~(WB_TOP|WB_VCENTER|WB_BOTTOM);
1919 if ( !bVoid )
1920 Value >>= eAlign;
1921 switch ( eAlign )
1923 case VerticalAlignment_TOP:
1924 nStyle |= WB_TOP;
1925 break;
1926 case VerticalAlignment_MIDDLE:
1927 nStyle |= WB_VCENTER;
1928 break;
1929 case VerticalAlignment_BOTTOM:
1930 nStyle |= WB_BOTTOM;
1931 break;
1932 default: ; // for warning free code, MAKE_FIXED_SIZE
1934 pWindow->SetStyle( nStyle );
1936 break;
1937 case BASEPROPERTY_ALIGN:
1939 sal_Int16 nAlign = PROPERTY_ALIGN_LEFT;
1940 switch ( eWinType )
1942 case WINDOW_COMBOBOX:
1943 case WINDOW_BUTTON:
1944 case WINDOW_PUSHBUTTON:
1945 case WINDOW_OKBUTTON:
1946 case WINDOW_CANCELBUTTON:
1947 case WINDOW_HELPBUTTON:
1948 nAlign = PROPERTY_ALIGN_CENTER;
1949 // no break here!
1950 case WINDOW_FIXEDTEXT:
1951 case WINDOW_EDIT:
1952 case WINDOW_MULTILINEEDIT:
1953 case WINDOW_CHECKBOX:
1954 case WINDOW_RADIOBUTTON:
1955 case WINDOW_LISTBOX:
1957 WinBits nStyle = pWindow->GetStyle();
1958 nStyle &= ~(WB_LEFT|WB_CENTER|WB_RIGHT);
1959 if ( !bVoid )
1960 Value >>= nAlign;
1961 if ( nAlign == PROPERTY_ALIGN_LEFT )
1962 nStyle |= WB_LEFT;
1963 else if ( nAlign == PROPERTY_ALIGN_CENTER )
1964 nStyle |= WB_CENTER;
1965 else
1966 nStyle |= WB_RIGHT;
1967 pWindow->SetStyle( nStyle );
1969 break;
1972 break;
1973 case BASEPROPERTY_MULTILINE:
1975 if ( ( eWinType == WINDOW_FIXEDTEXT )
1976 || ( eWinType == WINDOW_CHECKBOX )
1977 || ( eWinType == WINDOW_RADIOBUTTON )
1978 || ( eWinType == WINDOW_BUTTON )
1979 || ( eWinType == WINDOW_PUSHBUTTON )
1980 || ( eWinType == WINDOW_OKBUTTON )
1981 || ( eWinType == WINDOW_CANCELBUTTON )
1982 || ( eWinType == WINDOW_HELPBUTTON )
1985 WinBits nStyle = pWindow->GetStyle();
1986 sal_Bool bMulti = false;
1987 Value >>= bMulti;
1988 if ( bMulti )
1989 nStyle |= WB_WORDBREAK;
1990 else
1991 nStyle &= ~WB_WORDBREAK;
1992 pWindow->SetStyle( nStyle );
1995 break;
1996 case BASEPROPERTY_ORIENTATION:
1998 switch ( eWinType )
2000 case WINDOW_FIXEDLINE:
2002 sal_Int32 nOrientation = 0;
2003 if ( Value >>= nOrientation )
2005 WinBits nStyle = pWindow->GetStyle();
2006 nStyle &= ~(WB_HORZ|WB_VERT);
2007 if ( nOrientation == 0 )
2008 nStyle |= WB_HORZ;
2009 else
2010 nStyle |= WB_VERT;
2012 pWindow->SetStyle( nStyle );
2015 break;
2018 break;
2019 case BASEPROPERTY_AUTOMNEMONICS:
2021 sal_Bool bAutoMnemonics = false;
2022 Value >>= bAutoMnemonics;
2023 AllSettings aSettings = pWindow->GetSettings();
2024 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
2025 if ( aStyleSettings.GetAutoMnemonic() != bAutoMnemonics )
2027 aStyleSettings.SetAutoMnemonic( bAutoMnemonics );
2028 aSettings.SetStyleSettings( aStyleSettings );
2029 pWindow->SetSettings( aSettings );
2032 break;
2033 case BASEPROPERTY_MOUSETRANSPARENT:
2035 sal_Bool bMouseTransparent = false;
2036 Value >>= bMouseTransparent;
2037 pWindow->SetMouseTransparent( bMouseTransparent );
2039 break;
2040 case BASEPROPERTY_PAINTTRANSPARENT:
2042 sal_Bool bPaintTransparent = false;
2043 Value >>= bPaintTransparent;
2044 pWindow->SetPaintTransparent( bPaintTransparent );
2045 // pWindow->SetBackground();
2047 break;
2049 case BASEPROPERTY_REPEAT:
2051 sal_Bool bRepeat( FALSE );
2052 Value >>= bRepeat;
2054 WinBits nStyle = pWindow->GetStyle();
2055 if ( bRepeat )
2056 nStyle |= WB_REPEAT;
2057 else
2058 nStyle &= ~WB_REPEAT;
2059 pWindow->SetStyle( nStyle );
2061 break;
2063 case BASEPROPERTY_REPEAT_DELAY:
2065 sal_Int32 nRepeatDelay = 0;
2066 if ( Value >>= nRepeatDelay )
2068 AllSettings aSettings = pWindow->GetSettings();
2069 MouseSettings aMouseSettings = aSettings.GetMouseSettings();
2071 aMouseSettings.SetButtonRepeat( nRepeatDelay );
2072 aSettings.SetMouseSettings( aMouseSettings );
2074 pWindow->SetSettings( aSettings, TRUE );
2077 break;
2079 case BASEPROPERTY_SYMBOL_COLOR:
2080 ::toolkit::setColorSettings( pWindow, Value, &StyleSettings::SetButtonTextColor, &StyleSettings::GetButtonTextColor );
2081 break;
2083 case BASEPROPERTY_BORDERCOLOR:
2084 ::toolkit::setColorSettings( pWindow, Value, &StyleSettings::SetMonoColor, &StyleSettings::GetMonoColor);
2085 break;
2086 case BASEPROPERTY_DEFAULTCONTROL:
2088 rtl::OUString aName;
2089 Value >>= aName;
2090 break;
2095 ::com::sun::star::uno::Any VCLXWindow::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
2097 ::vos::OGuard aGuard( GetMutex() );
2099 ::com::sun::star::uno::Any aProp;
2100 if ( GetWindow() )
2102 WindowType eWinType = GetWindow()->GetType();
2103 sal_uInt16 nPropType = GetPropertyId( PropertyName );
2104 switch ( nPropType )
2106 case BASEPROPERTY_CONTEXT_WRITING_MODE:
2107 aProp <<= mpImpl->mnContextWritingMode;
2108 break;
2110 case BASEPROPERTY_WRITING_MODE:
2111 aProp <<= mpImpl->mnWritingMode;
2112 break;
2114 case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR:
2116 USHORT nVclBehavior = GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior();
2117 sal_Int16 nBehavior = MouseWheelBehavior::SCROLL_FOCUS_ONLY;
2118 switch ( nVclBehavior )
2120 case MOUSE_WHEEL_DISABLE: nBehavior = MouseWheelBehavior::SCROLL_DISABLED; break;
2121 case MOUSE_WHEEL_FOCUS_ONLY: nBehavior = MouseWheelBehavior::SCROLL_FOCUS_ONLY; break;
2122 case MOUSE_WHEEL_ALWAYS: nBehavior = MouseWheelBehavior::SCROLL_ALWAYS; break;
2123 default:
2124 OSL_ENSURE( false, "VCLXWindow::getProperty( 'MouseWheelBehavior' ): illegal VCL value!" );
2126 aProp <<= nBehavior;
2128 break;
2130 case BASEPROPERTY_NATIVE_WIDGET_LOOK:
2131 aProp <<= (sal_Bool) GetWindow()->IsNativeWidgetEnabled();
2132 break;
2134 case BASEPROPERTY_ENABLED:
2135 aProp <<= (sal_Bool) GetWindow()->IsEnabled();
2136 break;
2138 case BASEPROPERTY_ENABLEVISIBLE:
2139 aProp <<= (sal_Bool) mpImpl->isEnableVisible();
2140 break;
2142 case BASEPROPERTY_TEXT:
2143 case BASEPROPERTY_LABEL:
2144 case BASEPROPERTY_TITLE:
2146 ::rtl::OUString aText = GetWindow()->GetText();
2147 aProp <<= aText;
2149 break;
2150 case BASEPROPERTY_ACCESSIBLENAME:
2152 ::rtl::OUString aText = GetWindow()->GetAccessibleName();
2153 aProp <<= aText;
2155 break;
2156 case BASEPROPERTY_HELPTEXT:
2158 ::rtl::OUString aText = GetWindow()->GetQuickHelpText();
2159 aProp <<= aText;
2161 break;
2162 case BASEPROPERTY_HELPURL:
2164 SmartId aSmartId = GetWindow()->GetSmartHelpId();
2165 if( aSmartId.HasString() )
2167 String aStrHelpId = aSmartId.GetStr();
2168 aProp <<= ::rtl::OUString( aStrHelpId );
2170 else
2172 ::rtl::OUStringBuffer aURL;
2173 aURL.appendAscii( "HID:" );
2174 aURL.append( (sal_Int32) GetWindow()->GetHelpId() );
2175 aProp <<= aURL.makeStringAndClear();
2178 break;
2179 case BASEPROPERTY_FONTDESCRIPTOR:
2181 Font aFont = GetWindow()->GetControlFont();
2182 ::com::sun::star::awt::FontDescriptor aFD = VCLUnoHelper::CreateFontDescriptor( aFont );
2183 aProp <<= aFD;
2185 break;
2186 case BASEPROPERTY_BACKGROUNDCOLOR:
2187 aProp <<= (sal_Int32) GetWindow()->GetControlBackground().GetColor();
2188 break;
2189 case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR:
2190 aProp <<= (sal_Int32) GetWindow()->GetDisplayBackground().GetColor().GetColor();
2191 break;
2192 case BASEPROPERTY_FONTRELIEF:
2193 aProp <<= (sal_Int16) GetWindow()->GetControlFont().GetRelief();
2194 break;
2195 case BASEPROPERTY_FONTEMPHASISMARK:
2196 aProp <<= (sal_Int16) GetWindow()->GetControlFont().GetEmphasisMark();
2197 break;
2198 case BASEPROPERTY_TEXTCOLOR:
2199 aProp <<= (sal_Int32) GetWindow()->GetControlForeground().GetColor();
2200 break;
2201 case BASEPROPERTY_TEXTLINECOLOR:
2202 aProp <<= (sal_Int32) GetWindow()->GetTextLineColor().GetColor();
2203 break;
2204 case BASEPROPERTY_FILLCOLOR:
2205 aProp <<= (sal_Int32) GetWindow()->GetFillColor().GetColor();
2206 break;
2207 case BASEPROPERTY_LINECOLOR:
2208 aProp <<= (sal_Int32) GetWindow()->GetLineColor().GetColor();
2209 break;
2210 case BASEPROPERTY_BORDER:
2212 sal_Int16 nBorder = 0;
2213 if ( GetWindow()->GetStyle() & WB_BORDER )
2214 nBorder = GetWindow()->GetBorderStyle();
2215 aProp <<= nBorder;
2217 break;
2218 case BASEPROPERTY_TABSTOP:
2219 aProp <<= (sal_Bool) ( GetWindow()->GetStyle() & WB_TABSTOP ) ? sal_True : sal_False;
2220 break;
2221 case BASEPROPERTY_VERTICALALIGN:
2223 WinBits nStyle = GetWindow()->GetStyle();
2224 if ( nStyle & WB_TOP )
2225 aProp <<= VerticalAlignment_TOP;
2226 else if ( nStyle & WB_VCENTER )
2227 aProp <<= VerticalAlignment_MIDDLE;
2228 else if ( nStyle & WB_BOTTOM )
2229 aProp <<= VerticalAlignment_BOTTOM;
2231 break;
2232 case BASEPROPERTY_ALIGN:
2234 switch ( eWinType )
2236 case WINDOW_FIXEDTEXT:
2237 case WINDOW_EDIT:
2238 case WINDOW_MULTILINEEDIT:
2239 case WINDOW_CHECKBOX:
2240 case WINDOW_RADIOBUTTON:
2241 case WINDOW_LISTBOX:
2242 case WINDOW_COMBOBOX:
2243 case WINDOW_BUTTON:
2244 case WINDOW_PUSHBUTTON:
2245 case WINDOW_OKBUTTON:
2246 case WINDOW_CANCELBUTTON:
2247 case WINDOW_HELPBUTTON:
2249 WinBits nStyle = GetWindow()->GetStyle();
2250 if ( nStyle & WB_LEFT )
2251 aProp <<= (sal_Int16) PROPERTY_ALIGN_LEFT;
2252 else if ( nStyle & WB_CENTER )
2253 aProp <<= (sal_Int16) PROPERTY_ALIGN_CENTER;
2254 else if ( nStyle & WB_RIGHT )
2255 aProp <<= (sal_Int16) PROPERTY_ALIGN_RIGHT;
2257 break;
2260 case BASEPROPERTY_MULTILINE:
2262 if ( ( eWinType == WINDOW_FIXEDTEXT )
2263 || ( eWinType == WINDOW_CHECKBOX )
2264 || ( eWinType == WINDOW_RADIOBUTTON )
2265 || ( eWinType == WINDOW_BUTTON )
2266 || ( eWinType == WINDOW_PUSHBUTTON )
2267 || ( eWinType == WINDOW_OKBUTTON )
2268 || ( eWinType == WINDOW_CANCELBUTTON )
2269 || ( eWinType == WINDOW_HELPBUTTON )
2271 aProp <<= (sal_Bool) ( GetWindow()->GetStyle() & WB_WORDBREAK ) ? sal_True : sal_False;
2273 break;
2274 case BASEPROPERTY_AUTOMNEMONICS:
2276 sal_Bool bAutoMnemonics = GetWindow()->GetSettings().GetStyleSettings().GetAutoMnemonic();
2277 aProp <<= bAutoMnemonics;
2279 break;
2280 case BASEPROPERTY_MOUSETRANSPARENT:
2282 sal_Bool bMouseTransparent = GetWindow()->IsMouseTransparent();
2283 aProp <<= bMouseTransparent;
2285 break;
2286 case BASEPROPERTY_PAINTTRANSPARENT:
2288 sal_Bool bPaintTransparent = GetWindow()->IsPaintTransparent();
2289 aProp <<= bPaintTransparent;
2291 break;
2293 case BASEPROPERTY_REPEAT:
2294 aProp <<= (sal_Bool)( 0 != ( GetWindow()->GetStyle() & WB_REPEAT ) );
2295 break;
2297 case BASEPROPERTY_REPEAT_DELAY:
2299 sal_Int32 nButtonRepeat = GetWindow()->GetSettings().GetMouseSettings().GetButtonRepeat();
2300 aProp <<= (sal_Int32)nButtonRepeat;
2302 break;
2304 case BASEPROPERTY_SYMBOL_COLOR:
2305 aProp <<= (sal_Int32)GetWindow()->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
2306 break;
2308 case BASEPROPERTY_BORDERCOLOR:
2309 aProp <<= (sal_Int32)GetWindow()->GetSettings().GetStyleSettings().GetMonoColor().GetColor();
2310 break;
2313 return aProp;
2317 // ::com::sun::star::awt::XLayoutConstrains
2318 ::com::sun::star::awt::Size VCLXWindow::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException)
2320 ::vos::OGuard aGuard( GetMutex() );
2322 // Diese Methode sollte nur fuer Componenten gerufen werden, die zwar
2323 // ueber das ::com::sun::star::awt::Toolkit erzeugt werden koennen, aber fuer die es
2324 // kein Interface gibt.
2326 Size aSz;
2327 if ( GetWindow() )
2329 WindowType nWinType = GetWindow()->GetType();
2330 switch ( nWinType )
2332 case WINDOW_CONTROL:
2333 aSz.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*12;
2334 aSz.Height() = GetWindow()->GetTextHeight()+2*6;
2335 break;
2337 case WINDOW_PATTERNBOX:
2338 case WINDOW_NUMERICBOX:
2339 case WINDOW_METRICBOX:
2340 case WINDOW_CURRENCYBOX:
2341 case WINDOW_DATEBOX:
2342 case WINDOW_TIMEBOX:
2343 case WINDOW_LONGCURRENCYBOX:
2344 aSz.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*2;
2345 aSz.Height() = GetWindow()->GetTextHeight()+2*2;
2346 break;
2347 case WINDOW_SCROLLBARBOX:
2348 return VCLXScrollBar::implGetMinimumSize( GetWindow() );
2349 default:
2350 aSz = GetWindow()->GetOptimalSize( WINDOWSIZE_MINIMUM );
2354 return ::com::sun::star::awt::Size( aSz.Width(), aSz.Height() );
2357 ::com::sun::star::awt::Size VCLXWindow::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException)
2359 return getMinimumSize();
2362 ::com::sun::star::awt::Size VCLXWindow::calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize ) throw(::com::sun::star::uno::RuntimeException)
2364 ::vos::OGuard aGuard( GetMutex() );
2366 ::com::sun::star::awt::Size aNewSize( rNewSize );
2367 ::com::sun::star::awt::Size aMinSize = getMinimumSize();
2369 if ( aNewSize.Width < aMinSize.Width )
2370 aNewSize.Width = aMinSize.Width;
2371 if ( aNewSize.Height < aMinSize.Height )
2372 aNewSize.Height = aMinSize.Height;
2374 return aNewSize;
2378 // ::com::sun::star::awt::XView
2379 sal_Bool VCLXWindow::setGraphics( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& rxDevice ) throw(::com::sun::star::uno::RuntimeException)
2381 ::vos::OGuard aGuard( GetMutex() );
2383 if ( VCLUnoHelper::GetOutputDevice( rxDevice ) )
2384 mpImpl->mxViewGraphics = rxDevice;
2385 else
2386 mpImpl->mxViewGraphics = NULL;
2388 return mpImpl->mxViewGraphics.is();
2391 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > VCLXWindow::getGraphics( ) throw(::com::sun::star::uno::RuntimeException)
2393 ::vos::OGuard aGuard( GetMutex() );
2395 return mpImpl->mxViewGraphics;
2398 ::com::sun::star::awt::Size VCLXWindow::getSize( ) throw(::com::sun::star::uno::RuntimeException)
2400 ::vos::OGuard aGuard( GetMutex() );
2402 Size aSz;
2403 if ( GetWindow() )
2404 aSz = GetWindow()->GetSizePixel();
2405 return ::com::sun::star::awt::Size( aSz.Width(), aSz.Height() );
2408 void VCLXWindow::draw( sal_Int32 nX, sal_Int32 nY ) throw(::com::sun::star::uno::RuntimeException)
2410 ::vos::OGuard aGuard( GetMutex() );
2412 Window* pWindow = GetWindow();
2413 if ( !pWindow )
2414 return;
2416 if ( isDesignMode() || mpImpl->isEnableVisible() )
2418 TabPage* pTabPage = dynamic_cast< TabPage* >( pWindow );
2419 if ( pTabPage )
2421 Point aPos( nX, nY );
2422 Size aSize = pWindow->GetSizePixel();
2424 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( mpImpl->mxViewGraphics );
2425 aPos = pDev->PixelToLogic( aPos );
2426 aSize = pDev->PixelToLogic( aSize );
2428 pTabPage->Draw( pDev, aPos, aSize, 0 );
2429 return;
2432 OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( mpImpl->mxViewGraphics );
2433 Point aPos( nX, nY );
2435 if ( !pDev )
2436 pDev = pWindow->GetParent();
2438 if ( pWindow->GetParent() && !pWindow->IsSystemWindow() && ( pWindow->GetParent() == pDev ) )
2440 // #i40647# don't draw here if this is a recursive call
2441 // sometimes this is called recursively, because the Update call on the parent
2442 // (strangely) triggers another paint. Prevent a stack overflow here
2443 // Yes, this is only fixing symptoms for the moment ....
2444 // #i40647# / 2005-01-18 / frank.schoenheit@sun.com
2445 if ( !mpImpl->getDrawingOntoParent_ref() )
2447 FlagGuard aDrawingflagGuard( mpImpl->getDrawingOntoParent_ref() );
2449 BOOL bWasVisible = pWindow->IsVisible();
2450 Point aOldPos( pWindow->GetPosPixel() );
2452 if ( bWasVisible && aOldPos == aPos )
2454 pWindow->Update();
2455 return;
2458 pWindow->SetPosPixel( aPos );
2460 // Erstmal ein Update auf den Parent, damit nicht beim Update
2461 // auf dieses Fenster noch ein Paint vom Parent abgearbeitet wird,
2462 // wo dann ggf. dieses Fenster sofort wieder gehidet wird.
2463 if( pWindow->GetParent() )
2464 pWindow->GetParent()->Update();
2466 pWindow->Show();
2467 pWindow->Update();
2468 pWindow->SetParentUpdateMode( sal_False );
2469 pWindow->Hide();
2470 pWindow->SetParentUpdateMode( sal_True );
2472 pWindow->SetPosPixel( aOldPos );
2473 if ( bWasVisible )
2474 pWindow->Show( TRUE );
2477 else if ( pDev )
2479 Size aSz = pWindow->GetSizePixel();
2480 aSz = pDev->PixelToLogic( aSz );
2481 Point aP = pDev->PixelToLogic( aPos );
2483 vcl::PDFExtOutDevData* pPDFExport = dynamic_cast<vcl::PDFExtOutDevData*>(pDev->GetExtOutDevData());
2484 bool bDrawSimple = ( pDev->GetOutDevType() == OUTDEV_PRINTER )
2485 || ( pDev->GetOutDevViewType() == OUTDEV_VIEWTYPE_PRINTPREVIEW )
2486 || ( pPDFExport != NULL );
2487 if ( bDrawSimple )
2489 pWindow->Draw( pDev, aP, aSz, WINDOW_DRAW_NOCONTROLS );
2491 else
2493 BOOL bOldNW =pWindow->IsNativeWidgetEnabled();
2494 if( bOldNW )
2495 pWindow->EnableNativeWidget(FALSE);
2496 pWindow->PaintToDevice( pDev, aP, aSz );
2497 if( bOldNW )
2498 pWindow->EnableNativeWidget(TRUE);
2504 void VCLXWindow::setZoom( float fZoomX, float /*fZoomY*/ ) throw(::com::sun::star::uno::RuntimeException)
2506 ::vos::OGuard aGuard( GetMutex() );
2508 if ( GetWindow() )
2509 GetWindow()->SetZoom( Fraction( fZoomX ) );
2512 // ::com::sun::star::lang::XEventListener
2513 void SAL_CALL VCLXWindow::disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException)
2515 ::vos::OGuard aGuard( GetMutex() );
2517 // check if it comes from our AccessibleContext
2518 uno::Reference< uno::XInterface > aAC( mpImpl->mxAccessibleContext, uno::UNO_QUERY );
2519 uno::Reference< uno::XInterface > xSource( _rSource.Source, uno::UNO_QUERY );
2521 if ( aAC.get() == xSource.get() )
2522 { // yep, it does
2523 mpImpl->mxAccessibleContext = uno::Reference< accessibility::XAccessibleContext >();
2527 // ::com::sun::star::accessibility::XAccessible
2528 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > VCLXWindow::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException)
2530 using namespace ::com::sun::star;
2532 ::vos::OGuard aGuard( GetMutex() );
2534 // already disposed
2535 if( ! mpImpl )
2536 return uno::Reference< accessibility::XAccessibleContext >();
2538 if ( !mpImpl->mxAccessibleContext.is() && GetWindow() )
2540 mpImpl->mxAccessibleContext = CreateAccessibleContext();
2542 // add as event listener to this component
2543 // in case somebody disposes it, we do not want to have a (though weak) reference to a dead
2544 // object
2545 uno::Reference< lang::XComponent > xComp( mpImpl->mxAccessibleContext, uno::UNO_QUERY );
2546 if ( xComp.is() )
2547 xComp->addEventListener( this );
2550 return mpImpl->mxAccessibleContext;
2553 // ::com::sun::star::awt::XDockable
2554 void SAL_CALL VCLXWindow::addDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
2556 ::vos::OGuard aGuard( GetMutex() );
2558 if ( xListener.is() )
2559 mpImpl->getDockableWindowListeners().addInterface( xListener );
2563 void SAL_CALL VCLXWindow::removeDockableWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDockableWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
2565 ::vos::OGuard aGuard( GetMutex() );
2567 mpImpl->getDockableWindowListeners().removeInterface( xListener );
2570 void SAL_CALL VCLXWindow::enableDocking( sal_Bool bEnable ) throw (::com::sun::star::uno::RuntimeException)
2572 ::vos::OGuard aGuard( GetMutex() );
2574 Window* pWindow = GetWindow();
2575 if ( pWindow )
2576 pWindow->EnableDocking( bEnable );
2579 sal_Bool SAL_CALL VCLXWindow::isFloating( ) throw (::com::sun::star::uno::RuntimeException)
2581 ::vos::OGuard aGuard( GetMutex() );
2583 Window* pWindow = GetWindow();
2584 if( pWindow )
2585 return Window::GetDockingManager()->IsFloating( pWindow );
2586 else
2587 return FALSE;
2590 void SAL_CALL VCLXWindow::setFloatingMode( sal_Bool bFloating ) throw (::com::sun::star::uno::RuntimeException)
2592 ::vos::OGuard aGuard( GetMutex() );
2594 Window* pWindow = GetWindow();
2595 if( pWindow )
2596 Window::GetDockingManager()->SetFloatingMode( pWindow, bFloating );
2599 sal_Bool SAL_CALL VCLXWindow::isLocked( ) throw (::com::sun::star::uno::RuntimeException)
2601 ::vos::OGuard aGuard( GetMutex() );
2603 Window* pWindow = GetWindow();
2604 if( pWindow )
2605 return Window::GetDockingManager()->IsLocked( pWindow );
2606 else
2607 return FALSE;
2610 void SAL_CALL VCLXWindow::lock( ) throw (::com::sun::star::uno::RuntimeException)
2612 ::vos::OGuard aGuard( GetMutex() );
2614 Window* pWindow = GetWindow();
2615 if( pWindow && !Window::GetDockingManager()->IsFloating( pWindow ) )
2616 Window::GetDockingManager()->Lock( pWindow );
2619 void SAL_CALL VCLXWindow::unlock( ) throw (::com::sun::star::uno::RuntimeException)
2621 ::vos::OGuard aGuard( GetMutex() );
2623 Window* pWindow = GetWindow();
2624 if( pWindow && !Window::GetDockingManager()->IsFloating( pWindow ) )
2625 Window::GetDockingManager()->Unlock( pWindow );
2627 void SAL_CALL VCLXWindow::startPopupMode( const ::com::sun::star::awt::Rectangle& ) throw (::com::sun::star::uno::RuntimeException)
2629 // TODO: remove interface in the next incompatible build
2630 ::vos::OGuard aGuard( GetMutex() );
2634 sal_Bool SAL_CALL VCLXWindow::isInPopupMode( ) throw (::com::sun::star::uno::RuntimeException)
2636 // TODO: remove interface in the next incompatible build
2637 ::vos::OGuard aGuard( GetMutex() );
2638 return FALSE;
2642 // ::com::sun::star::awt::XWindow2
2644 void SAL_CALL VCLXWindow::setOutputSize( const ::com::sun::star::awt::Size& aSize ) throw (::com::sun::star::uno::RuntimeException)
2646 ::vos::OGuard aGuard( GetMutex() );
2647 Window *pWindow;
2648 if( (pWindow = GetWindow()) != NULL )
2650 DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow);
2651 if( pDockingWindow )
2652 pDockingWindow->SetOutputSizePixel( VCLSize( aSize ) );
2653 else
2654 pWindow->SetOutputSizePixel( VCLSize( aSize ) );
2658 ::com::sun::star::awt::Size SAL_CALL VCLXWindow::getOutputSize( ) throw (::com::sun::star::uno::RuntimeException)
2660 ::vos::OGuard aGuard( GetMutex() );
2661 Window *pWindow;
2662 if( (pWindow = GetWindow()) != NULL )
2664 DockingWindow *pDockingWindow = dynamic_cast< DockingWindow* >(pWindow);
2665 if( pDockingWindow )
2666 return AWTSize( pDockingWindow->GetOutputSizePixel() );
2667 else
2668 return AWTSize( pWindow->GetOutputSizePixel() );
2670 else
2671 return ::com::sun::star::awt::Size();
2674 sal_Bool SAL_CALL VCLXWindow::isVisible( ) throw (::com::sun::star::uno::RuntimeException)
2676 ::vos::OGuard aGuard( GetMutex() );
2677 if( GetWindow() )
2678 return GetWindow()->IsVisible();
2679 else
2680 return FALSE;
2683 sal_Bool SAL_CALL VCLXWindow::isActive( ) throw (::com::sun::star::uno::RuntimeException)
2685 ::vos::OGuard aGuard( GetMutex() );
2686 if( GetWindow() )
2687 return GetWindow()->IsActive();
2688 else
2689 return FALSE;
2693 sal_Bool SAL_CALL VCLXWindow::isEnabled( ) throw (::com::sun::star::uno::RuntimeException)
2695 ::vos::OGuard aGuard( GetMutex() );
2696 if( GetWindow() )
2697 return GetWindow()->IsEnabled();
2698 else
2699 return FALSE;
2702 sal_Bool SAL_CALL VCLXWindow::hasFocus( ) throw (::com::sun::star::uno::RuntimeException)
2704 ::vos::OGuard aGuard( GetMutex() );
2705 if( GetWindow() )
2706 return GetWindow()->HasFocus();
2707 else
2708 return FALSE;
2711 // ::com::sun::star::beans::XPropertySetInfo
2713 UnoPropertyArrayHelper *
2714 VCLXWindow::GetPropHelper()
2716 ::vos::OGuard aGuard( GetMutex() );
2717 if ( mpImpl->mpPropHelper == NULL )
2719 std::list< sal_uInt16 > aIDs;
2720 GetPropertyIds( aIDs );
2721 mpImpl->mpPropHelper = new UnoPropertyArrayHelper( aIDs );
2723 return mpImpl->mpPropHelper;
2726 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL
2727 VCLXWindow::getProperties() throw (::com::sun::star::uno::RuntimeException)
2729 return GetPropHelper()->getProperties();
2731 ::com::sun::star::beans::Property SAL_CALL
2732 VCLXWindow::getPropertyByName( const ::rtl::OUString& rName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
2734 return GetPropHelper()->getPropertyByName( rName );
2737 ::sal_Bool SAL_CALL
2738 VCLXWindow::hasPropertyByName( const ::rtl::OUString& rName ) throw (::com::sun::star::uno::RuntimeException)
2740 return GetPropHelper()->hasPropertyByName( rName );