1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/awt/WindowEvent.hpp>
22 #include <com/sun/star/awt/KeyEvent.hpp>
23 #include <com/sun/star/awt/KeyModifier.hpp>
24 #include <com/sun/star/awt/MouseEvent.hpp>
25 #include <com/sun/star/awt/MouseButton.hpp>
26 #include <com/sun/star/awt/MouseWheelBehavior.hpp>
27 #include <com/sun/star/awt/XTopWindow.hpp>
28 #include <com/sun/star/awt/Style.hpp>
29 #include <com/sun/star/accessibility/AccessibleRole.hpp>
30 #include <com/sun/star/awt/DockingEvent.hpp>
31 #include <com/sun/star/awt/EndDockingEvent.hpp>
32 #include <com/sun/star/awt/EndPopupModeEvent.hpp>
33 #include <com/sun/star/awt/XWindowListener2.hpp>
34 #include <com/sun/star/style/VerticalAlignment.hpp>
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <com/sun/star/text/WritingMode2.hpp>
37 #include <toolkit/awt/vclxwindow.hxx>
38 #include <toolkit/awt/vclxpointer.hxx>
39 #include <toolkit/awt/vclxwindows.hxx>
40 #include <toolkit/helper/macros.hxx>
41 #include <toolkit/helper/vclunohelper.hxx>
42 #include <toolkit/helper/convert.hxx>
43 #include <toolkit/helper/property.hxx>
44 #include <cppuhelper/typeprovider.hxx>
46 #include <rtl/ustrbuf.hxx>
47 #include <vcl/svapp.hxx>
48 #include <vcl/window.hxx>
49 #include <tools/color.hxx>
50 #include <tools/fract.hxx>
51 #include <vcl/dockwin.hxx>
52 #include <vcl/pdfextoutdevdata.hxx>
53 #include <vcl/tabpage.hxx>
54 #include <vcl/button.hxx>
55 #include <vcl/settings.hxx>
56 #include <comphelper/asyncnotification.hxx>
57 #include <comphelper/flagguard.hxx>
58 #include "stylesettings.hxx"
59 #include <tools/urlobj.hxx>
61 #include <boost/bind.hpp>
62 #include <boost/noncopyable.hpp>
64 #include "helper/accessibilityclient.hxx"
65 #include "helper/unopropertyarrayhelper.hxx"
67 using namespace ::com::sun::star
;
69 using ::com::sun::star::uno::Reference
;
70 using ::com::sun::star::uno::UNO_QUERY
;
71 using ::com::sun::star::uno::RuntimeException
;
72 using ::com::sun::star::lang::EventObject
;
73 using ::com::sun::star::awt::XWindowListener2
;
74 using ::com::sun::star::awt::XDockableWindowListener
;
75 using ::com::sun::star::awt::XDevice
;
76 using ::com::sun::star::awt::XStyleSettings
;
77 using ::com::sun::star::lang::DisposedException
;
78 using ::com::sun::star::style::VerticalAlignment
;
79 using ::com::sun::star::style::VerticalAlignment_TOP
;
80 using ::com::sun::star::style::VerticalAlignment_MIDDLE
;
81 using ::com::sun::star::style::VerticalAlignment_BOTTOM
;
82 using ::com::sun::star::style::VerticalAlignment_MAKE_FIXED_SIZE
;
84 namespace WritingMode2
= ::com::sun::star::text::WritingMode2
;
89 class VCLXWindowImpl
: private boost::noncopyable
92 typedef ::std::vector
< VCLXWindow::Callback
> CallbackArray
;
95 VCLXWindow
& mrAntiImpl
;
96 ::toolkit::AccessibilityClient maAccFactory
;
98 bool mbDrawingOntoParent
; // no bit mask, is passed around by reference
100 bool mbDirectVisible
;
102 ::osl::Mutex maListenerContainerMutex
;
103 ::cppu::OInterfaceContainerHelper maWindow2Listeners
;
104 ::cppu::OInterfaceContainerHelper maDockableWindowListeners
;
105 EventListenerMultiplexer maEventListeners
;
106 FocusListenerMultiplexer maFocusListeners
;
107 WindowListenerMultiplexer maWindowListeners
;
108 KeyListenerMultiplexer maKeyListeners
;
109 MouseListenerMultiplexer maMouseListeners
;
110 MouseMotionListenerMultiplexer maMouseMotionListeners
;
111 PaintListenerMultiplexer maPaintListeners
;
112 VclContainerListenerMultiplexer maContainerListeners
;
113 TopWindowListenerMultiplexer maTopWindowListeners
;
115 CallbackArray maCallbackEvents
;
116 ImplSVEvent
* mnCallbackEventId
;
119 bool mbDisposing
: 1;
120 bool mbDesignMode
: 1;
121 bool mbSynthesizingVCLEvent
: 1;
122 bool mbWithDefaultProps
: 1;
124 sal_uLong mnListenerLockLevel
;
125 sal_Int16 mnWritingMode
;
126 sal_Int16 mnContextWritingMode
;
128 UnoPropertyArrayHelper
* mpPropHelper
;
130 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XPointer
>
132 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
>
134 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
>
136 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XStyleSettings
>
137 mxWindowStyleSettings
;
140 bool& getDrawingOntoParent_ref() { return mbDrawingOntoParent
; }
145 the <type>VCLXWindow</type> instance which the object belongs to. Must
146 live longer then the object just being constructed.
148 VCLXWindowImpl( VCLXWindow
& _rAntiImpl
, bool _bWithDefaultProps
);
150 /** synchronously mbEnableVisible
152 void setEnableVisible( bool bEnableVisible
) { mbEnableVisible
= bEnableVisible
; }
153 bool isEnableVisible() { return mbEnableVisible
; }
154 /** synchronously mbDirectVisible;
156 void setDirectVisible( bool bDirectVisible
) { mbDirectVisible
= bDirectVisible
; }
157 bool isDirectVisible() { return mbDirectVisible
; }
159 /** impl-version of VCLXWindow::ImplExecuteAsyncWithoutSolarLock
161 void callBackAsync( const VCLXWindow::Callback
& i_callback
);
163 /** notifies the object that its VCLXWindow is being disposed
167 inline ::toolkit::AccessibilityClient
& getAccessibleFactory()
172 Reference
< XStyleSettings
> getStyleSettings();
174 /** returns the container of registered XWindowListener2 listeners
176 inline ::cppu::OInterfaceContainerHelper
& getWindow2Listeners() { return maWindow2Listeners
; }
177 inline ::cppu::OInterfaceContainerHelper
& getDockableWindowListeners(){ return maDockableWindowListeners
; }
178 inline EventListenerMultiplexer
& getEventListeners() { return maEventListeners
; }
179 inline FocusListenerMultiplexer
& getFocusListeners() { return maFocusListeners
; }
180 inline WindowListenerMultiplexer
& getWindowListeners() { return maWindowListeners
; }
181 inline KeyListenerMultiplexer
& getKeyListeners() { return maKeyListeners
; }
182 inline MouseListenerMultiplexer
& getMouseListeners() { return maMouseListeners
; }
183 inline MouseMotionListenerMultiplexer
& getMouseMotionListeners() { return maMouseMotionListeners
; }
184 inline PaintListenerMultiplexer
& getPaintListeners() { return maPaintListeners
; }
185 inline VclContainerListenerMultiplexer
& getContainerListeners() { return maContainerListeners
; }
186 inline TopWindowListenerMultiplexer
& getTopWindowListeners() { return maTopWindowListeners
; }
191 DECL_LINK( OnProcessCallbacks
, void* );
195 VCLXWindowImpl::VCLXWindowImpl( VCLXWindow
& _rAntiImpl
, bool _bWithDefaultProps
)
196 :mrAntiImpl( _rAntiImpl
)
198 ,mbDrawingOntoParent( false )
199 ,mbEnableVisible(true)
200 ,mbDirectVisible(true)
201 ,maListenerContainerMutex( )
202 ,maWindow2Listeners( maListenerContainerMutex
)
203 ,maDockableWindowListeners( maListenerContainerMutex
)
204 ,maEventListeners( _rAntiImpl
)
205 ,maFocusListeners( _rAntiImpl
)
206 ,maWindowListeners( _rAntiImpl
)
207 ,maKeyListeners( _rAntiImpl
)
208 ,maMouseListeners( _rAntiImpl
)
209 ,maMouseMotionListeners( _rAntiImpl
)
210 ,maPaintListeners( _rAntiImpl
)
211 ,maContainerListeners( _rAntiImpl
)
212 ,maTopWindowListeners( _rAntiImpl
)
213 ,mnCallbackEventId( 0 )
214 ,mbDisposing( false )
215 ,mbDesignMode( false )
216 ,mbSynthesizingVCLEvent( false )
217 ,mbWithDefaultProps( _bWithDefaultProps
)
218 ,mnListenerLockLevel( 0 )
219 ,mnWritingMode( WritingMode2::CONTEXT
)
220 ,mnContextWritingMode( WritingMode2::CONTEXT
)
221 ,mpPropHelper( NULL
)
225 VCLXWindowImpl::~VCLXWindowImpl()
231 void VCLXWindowImpl::disposing()
233 SolarMutexGuard aGuard
;
234 if ( mnCallbackEventId
)
235 Application::RemoveUserEvent( mnCallbackEventId
);
236 mnCallbackEventId
= 0;
240 ::com::sun::star::lang::EventObject aEvent
;
241 aEvent
.Source
= mrAntiImpl
;
243 maDockableWindowListeners
.disposeAndClear( aEvent
);
244 maEventListeners
.disposeAndClear( aEvent
);
245 maFocusListeners
.disposeAndClear( aEvent
);
246 maWindowListeners
.disposeAndClear( aEvent
);
247 maKeyListeners
.disposeAndClear( aEvent
);
248 maMouseListeners
.disposeAndClear( aEvent
);
249 maMouseMotionListeners
.disposeAndClear( aEvent
);
250 maPaintListeners
.disposeAndClear( aEvent
);
251 maContainerListeners
.disposeAndClear( aEvent
);
252 maTopWindowListeners
.disposeAndClear( aEvent
);
254 ::toolkit::WindowStyleSettings
* pStyleSettings
= static_cast< ::toolkit::WindowStyleSettings
* >( mxWindowStyleSettings
.get() );
255 if ( pStyleSettings
!= NULL
)
256 pStyleSettings
->dispose();
257 mxWindowStyleSettings
.clear();
261 void VCLXWindowImpl::callBackAsync( const VCLXWindow::Callback
& i_callback
)
263 DBG_TESTSOLARMUTEX();
264 maCallbackEvents
.push_back( i_callback
);
265 if ( !mnCallbackEventId
)
267 // ensure our VCLXWindow is not destroyed while the event is underway
268 mrAntiImpl
.acquire();
269 mnCallbackEventId
= Application::PostUserEvent( LINK( this, VCLXWindowImpl
, OnProcessCallbacks
) );
274 IMPL_LINK_NOARG(VCLXWindowImpl
, OnProcessCallbacks
)
276 const Reference
< uno::XInterface
> xKeepAlive( mrAntiImpl
);
278 // work on a copy of the callback array
279 CallbackArray aCallbacksCopy
;
281 SolarMutexGuard aGuard
;
282 aCallbacksCopy
= maCallbackEvents
;
283 maCallbackEvents
.clear();
285 // we acquired our VCLXWindow once before posting the event, release this one ref now
286 mrAntiImpl
.release();
288 if ( !mnCallbackEventId
)
289 // we were disposed while waiting for the mutex to lock
292 mnCallbackEventId
= 0;
296 SolarMutexReleaser aReleaseSolar
;
297 for ( CallbackArray::const_iterator loop
= aCallbacksCopy
.begin();
298 loop
!= aCallbacksCopy
.end();
309 Reference
< XStyleSettings
> VCLXWindowImpl::getStyleSettings()
311 SolarMutexGuard aGuard
;
313 throw DisposedException( OUString(), mrAntiImpl
);
314 if ( !mxWindowStyleSettings
.is() )
315 mxWindowStyleSettings
= new ::toolkit::WindowStyleSettings( maListenerContainerMutex
, mrAntiImpl
);
316 return mxWindowStyleSettings
;
322 // Uses an out-parameter instead of return value, due to the object reference
324 void ImplInitWindowEvent( ::com::sun::star::awt::WindowEvent
& rEvent
, vcl::Window
* pWindow
)
326 Point aPos
= pWindow
->GetPosPixel();
327 Size aSz
= pWindow
->GetSizePixel();
332 rEvent
.Width
= aSz
.Width();
333 rEvent
.Height
= aSz
.Height();
335 pWindow
->GetBorder( rEvent
.LeftInset
, rEvent
.TopInset
, rEvent
.RightInset
, rEvent
.BottomInset
);
338 VCLXWindow::VCLXWindow( bool _bWithDefaultProps
)
341 mpImpl
= new VCLXWindowImpl( *this, _bWithDefaultProps
);
344 VCLXWindow::~VCLXWindow()
350 GetWindow()->RemoveEventListener( LINK( this, VCLXWindow
, WindowEventListener
) );
351 GetWindow()->SetWindowPeer( NULL
, NULL
);
352 GetWindow()->SetAccessible( NULL
);
357 void VCLXWindow::ImplExecuteAsyncWithoutSolarLock( const Callback
& i_callback
)
359 mpImpl
->callBackAsync( i_callback
);
363 ::toolkit::IAccessibleFactory
& VCLXWindow::getAccessibleFactory()
365 return mpImpl
->getAccessibleFactory().getFactory();
368 void VCLXWindow::SetWindow( const VclPtr
<vcl::Window
> &pWindow
)
372 GetWindow()->RemoveEventListener( LINK( this, VCLXWindow
, WindowEventListener
) );
373 // GetWindow()->DbgAssertNoEventListeners();
376 SetOutputDevice( pWindow
);
380 GetWindow()->AddEventListener( LINK( this, VCLXWindow
, WindowEventListener
) );
381 bool bDirectVisible
= pWindow
&& pWindow
->IsVisible();
382 mpImpl
->setDirectVisible( bDirectVisible
);
386 void VCLXWindow::suspendVclEventListening( )
388 ++mpImpl
->mnListenerLockLevel
;
391 void VCLXWindow::resumeVclEventListening( )
393 DBG_ASSERT( mpImpl
->mnListenerLockLevel
, "VCLXWindow::resumeVclEventListening: not suspended!" );
394 --mpImpl
->mnListenerLockLevel
;
397 void VCLXWindow::notifyWindowRemoved( vcl::Window
& _rWindow
)
399 if ( mpImpl
->getContainerListeners().getLength() )
401 awt::VclContainerEvent aEvent
;
402 aEvent
.Source
= *this;
403 aEvent
.Child
= static_cast< XWindow
* >( _rWindow
.GetWindowPeer() );
404 mpImpl
->getContainerListeners().windowRemoved( aEvent
);
408 IMPL_LINK( VCLXWindow
, WindowEventListener
, VclSimpleEvent
*, pEvent
)
410 if ( mpImpl
->mnListenerLockLevel
)
413 DBG_ASSERT( pEvent
&& pEvent
->ISA( VclWindowEvent
), "Unknown WindowEvent!" );
414 if ( pEvent
&& pEvent
->ISA( VclWindowEvent
) )
416 DBG_ASSERT( static_cast<VclWindowEvent
*>(pEvent
)->GetWindow() && GetWindow(), "Window???" );
417 ProcessWindowEvent( *static_cast<VclWindowEvent
*>(pEvent
) );
424 struct CallWindow2Listener
426 CallWindow2Listener( ::cppu::OInterfaceContainerHelper
& i_rWindow2Listeners
, const bool i_bEnabled
, const EventObject
& i_rEvent
)
427 :m_rWindow2Listeners( i_rWindow2Listeners
)
428 ,m_bEnabled( i_bEnabled
)
429 ,m_aEvent( i_rEvent
)
435 m_rWindow2Listeners
.notifyEach( m_bEnabled
? &XWindowListener2::windowEnabled
: &XWindowListener2::windowDisabled
, m_aEvent
);
438 ::cppu::OInterfaceContainerHelper
& m_rWindow2Listeners
;
439 const bool m_bEnabled
;
440 const EventObject m_aEvent
;
444 void VCLXWindow::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
446 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> xThis( (::cppu::OWeakObject
*)this );
448 switch ( rVclWindowEvent
.GetId() )
450 case VCLEVENT_WINDOW_ENABLED
:
451 case VCLEVENT_WINDOW_DISABLED
:
453 Callback aCallback
= CallWindow2Listener(
454 mpImpl
->getWindow2Listeners(),
455 ( VCLEVENT_WINDOW_ENABLED
== rVclWindowEvent
.GetId() ),
458 ImplExecuteAsyncWithoutSolarLock( aCallback
);
462 case VCLEVENT_WINDOW_PAINT
:
464 if ( mpImpl
->getPaintListeners().getLength() )
466 ::com::sun::star::awt::PaintEvent aEvent
;
467 aEvent
.Source
= (::cppu::OWeakObject
*)this;
468 aEvent
.UpdateRect
= AWTRectangle( *static_cast<Rectangle
*>(rVclWindowEvent
.GetData()) );
470 mpImpl
->getPaintListeners().windowPaint( aEvent
);
474 case VCLEVENT_WINDOW_MOVE
:
476 if ( mpImpl
->getWindowListeners().getLength() )
478 ::com::sun::star::awt::WindowEvent aEvent
;
479 aEvent
.Source
= (::cppu::OWeakObject
*)this;
480 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
481 mpImpl
->getWindowListeners().windowMoved( aEvent
);
485 case VCLEVENT_WINDOW_RESIZE
:
487 if ( mpImpl
->getWindowListeners().getLength() )
489 ::com::sun::star::awt::WindowEvent aEvent
;
490 aEvent
.Source
= (::cppu::OWeakObject
*)this;
491 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
492 mpImpl
->getWindowListeners().windowResized( aEvent
);
496 case VCLEVENT_WINDOW_SHOW
:
498 if ( mpImpl
->getWindowListeners().getLength() )
500 ::com::sun::star::awt::WindowEvent aEvent
;
501 aEvent
.Source
= (::cppu::OWeakObject
*)this;
502 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
503 mpImpl
->getWindowListeners().windowShown( aEvent
);
506 // For TopWindows this means opened...
507 if ( mpImpl
->getTopWindowListeners().getLength() )
509 ::com::sun::star::lang::EventObject aEvent
;
510 aEvent
.Source
= (::cppu::OWeakObject
*)this;
511 mpImpl
->getTopWindowListeners().windowOpened( aEvent
);
515 case VCLEVENT_WINDOW_HIDE
:
517 if ( mpImpl
->getWindowListeners().getLength() )
519 ::com::sun::star::awt::WindowEvent aEvent
;
520 aEvent
.Source
= (::cppu::OWeakObject
*)this;
521 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
522 mpImpl
->getWindowListeners().windowHidden( aEvent
);
525 // For TopWindows this means closed...
526 if ( mpImpl
->getTopWindowListeners().getLength() )
528 ::com::sun::star::lang::EventObject aEvent
;
529 aEvent
.Source
= (::cppu::OWeakObject
*)this;
530 mpImpl
->getTopWindowListeners().windowClosed( aEvent
);
534 case VCLEVENT_WINDOW_ACTIVATE
:
536 if ( mpImpl
->getTopWindowListeners().getLength() )
538 ::com::sun::star::lang::EventObject aEvent
;
539 aEvent
.Source
= (::cppu::OWeakObject
*)this;
540 mpImpl
->getTopWindowListeners().windowActivated( aEvent
);
544 case VCLEVENT_WINDOW_DEACTIVATE
:
546 if ( mpImpl
->getTopWindowListeners().getLength() )
548 ::com::sun::star::lang::EventObject aEvent
;
549 aEvent
.Source
= (::cppu::OWeakObject
*)this;
550 mpImpl
->getTopWindowListeners().windowDeactivated( aEvent
);
554 case VCLEVENT_WINDOW_CLOSE
:
556 if ( mpImpl
->getDockableWindowListeners().getLength() )
558 ::com::sun::star::lang::EventObject aEvent
;
559 aEvent
.Source
= (::cppu::OWeakObject
*)this;
560 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::closed
, aEvent
);
562 if ( mpImpl
->getTopWindowListeners().getLength() )
564 ::com::sun::star::lang::EventObject aEvent
;
565 aEvent
.Source
= (::cppu::OWeakObject
*)this;
566 mpImpl
->getTopWindowListeners().windowClosing( aEvent
);
570 case VCLEVENT_CONTROL_GETFOCUS
:
571 case VCLEVENT_WINDOW_GETFOCUS
:
573 if ( ( rVclWindowEvent
.GetWindow()->IsCompoundControl()
574 && rVclWindowEvent
.GetId() == VCLEVENT_CONTROL_GETFOCUS
576 || ( !rVclWindowEvent
.GetWindow()->IsCompoundControl()
577 && rVclWindowEvent
.GetId() == VCLEVENT_WINDOW_GETFOCUS
581 if ( mpImpl
->getFocusListeners().getLength() )
583 ::com::sun::star::awt::FocusEvent aEvent
;
584 aEvent
.Source
= (::cppu::OWeakObject
*)this;
585 aEvent
.FocusFlags
= rVclWindowEvent
.GetWindow()->GetGetFocusFlags();
586 aEvent
.Temporary
= sal_False
;
587 mpImpl
->getFocusListeners().focusGained( aEvent
);
592 case VCLEVENT_CONTROL_LOSEFOCUS
:
593 case VCLEVENT_WINDOW_LOSEFOCUS
:
595 if ( ( rVclWindowEvent
.GetWindow()->IsCompoundControl()
596 && rVclWindowEvent
.GetId() == VCLEVENT_CONTROL_LOSEFOCUS
598 || ( !rVclWindowEvent
.GetWindow()->IsCompoundControl()
599 && rVclWindowEvent
.GetId() == VCLEVENT_WINDOW_LOSEFOCUS
603 if ( mpImpl
->getFocusListeners().getLength() )
605 ::com::sun::star::awt::FocusEvent aEvent
;
606 aEvent
.Source
= (::cppu::OWeakObject
*)this;
607 aEvent
.FocusFlags
= rVclWindowEvent
.GetWindow()->GetGetFocusFlags();
608 aEvent
.Temporary
= sal_False
;
610 vcl::Window
* pNext
= Application::GetFocusWindow();
613 // Don't care about internals if this control is compound
614 vcl::Window
* pNextC
= pNext
;
615 while ( pNextC
&& !pNextC
->IsCompoundControl() )
616 pNextC
= pNextC
->GetParent();
620 pNext
->GetComponentInterface( true );
621 aEvent
.NextFocus
= (::cppu::OWeakObject
*)pNext
->GetWindowPeer();
623 mpImpl
->getFocusListeners().focusLost( aEvent
);
628 case VCLEVENT_WINDOW_MINIMIZE
:
630 if ( mpImpl
->getTopWindowListeners().getLength() )
632 ::com::sun::star::lang::EventObject aEvent
;
633 aEvent
.Source
= (::cppu::OWeakObject
*)this;
634 mpImpl
->getTopWindowListeners().windowMinimized( aEvent
);
638 case VCLEVENT_WINDOW_NORMALIZE
:
640 if ( mpImpl
->getTopWindowListeners().getLength() )
642 ::com::sun::star::lang::EventObject aEvent
;
643 aEvent
.Source
= (::cppu::OWeakObject
*)this;
644 mpImpl
->getTopWindowListeners().windowNormalized( aEvent
);
648 case VCLEVENT_WINDOW_KEYINPUT
:
650 if ( mpImpl
->getKeyListeners().getLength() )
652 ::com::sun::star::awt::KeyEvent
aEvent( VCLUnoHelper::createKeyEvent(
653 *static_cast<KeyEvent
*>(rVclWindowEvent
.GetData()), *this
655 mpImpl
->getKeyListeners().keyPressed( aEvent
);
659 case VCLEVENT_WINDOW_KEYUP
:
661 if ( mpImpl
->getKeyListeners().getLength() )
663 ::com::sun::star::awt::KeyEvent
aEvent( VCLUnoHelper::createKeyEvent(
664 *static_cast<KeyEvent
*>(rVclWindowEvent
.GetData()), *this
666 mpImpl
->getKeyListeners().keyReleased( aEvent
);
670 case VCLEVENT_WINDOW_COMMAND
:
672 CommandEvent
* pCmdEvt
= static_cast<CommandEvent
*>(rVclWindowEvent
.GetData());
673 if ( mpImpl
->getMouseListeners().getLength() && ( pCmdEvt
->GetCommand() == CommandEventId::ContextMenu
) )
675 // CommandEventId::ContextMenu als mousePressed mit PopupTrigger = sal_True versenden...
676 Point aWhere
= static_cast< CommandEvent
* >( rVclWindowEvent
.GetData() )->GetMousePosPixel();
677 if ( !pCmdEvt
->IsMouseEvent() )
678 { // for keyboard events, we set the coordinates to -1,-1. This is a slight HACK, but the current API
679 // handles a context menu command as special case of a mouse event, which is simply wrong.
680 // Without extending the API, we would not have another chance to notify listeners of a
681 // keyboard-triggered context menu request
682 aWhere
= Point( -1, -1 );
685 MouseEvent
aMEvt( aWhere
, 1, MouseEventModifiers::SIMPLECLICK
, MOUSE_LEFT
, 0 );
686 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( aMEvt
, *this ) );
687 aEvent
.PopupTrigger
= sal_True
;
689 Callback aCallback
= ::boost::bind(
690 &MouseListenerMultiplexer::mousePressed
,
691 &mpImpl
->getMouseListeners(),
694 ImplExecuteAsyncWithoutSolarLock( aCallback
);
698 case VCLEVENT_WINDOW_MOUSEMOVE
:
700 MouseEvent
* pMouseEvt
= static_cast<MouseEvent
*>(rVclWindowEvent
.GetData());
701 if ( mpImpl
->getMouseListeners().getLength() && ( pMouseEvt
->IsEnterWindow() || pMouseEvt
->IsLeaveWindow() ) )
703 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt
, *this ) );
705 Callback aCallback
= ::boost::bind(
706 pMouseEvt
->IsEnterWindow() ? &MouseListenerMultiplexer::mouseEntered
: &MouseListenerMultiplexer::mouseExited
,
707 &mpImpl
->getMouseListeners(),
710 ImplExecuteAsyncWithoutSolarLock( aCallback
);
713 if ( mpImpl
->getMouseMotionListeners().getLength() && !pMouseEvt
->IsEnterWindow() && !pMouseEvt
->IsLeaveWindow() )
715 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt
, *this ) );
716 aEvent
.ClickCount
= 0; // #92138#
717 if ( pMouseEvt
->GetMode() & MouseEventModifiers::SIMPLEMOVE
)
718 mpImpl
->getMouseMotionListeners().mouseMoved( aEvent
);
720 mpImpl
->getMouseMotionListeners().mouseDragged( aEvent
);
724 case VCLEVENT_WINDOW_MOUSEBUTTONDOWN
:
726 if ( mpImpl
->getMouseListeners().getLength() )
728 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( *static_cast<MouseEvent
*>(rVclWindowEvent
.GetData()), *this ) );
729 Callback aCallback
= ::boost::bind(
730 &MouseListenerMultiplexer::mousePressed
,
731 &mpImpl
->getMouseListeners(),
734 ImplExecuteAsyncWithoutSolarLock( aCallback
);
738 case VCLEVENT_WINDOW_MOUSEBUTTONUP
:
740 if ( mpImpl
->getMouseListeners().getLength() )
742 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( *static_cast<MouseEvent
*>(rVclWindowEvent
.GetData()), *this ) );
743 Callback aCallback
= ::boost::bind(
744 &MouseListenerMultiplexer::mouseReleased
,
745 &mpImpl
->getMouseListeners(),
748 ImplExecuteAsyncWithoutSolarLock( aCallback
);
752 case VCLEVENT_WINDOW_STARTDOCKING
:
754 if ( mpImpl
->getDockableWindowListeners().getLength() )
756 DockingData
*pData
= static_cast<DockingData
*>(rVclWindowEvent
.GetData());
760 ::com::sun::star::awt::DockingEvent aEvent
;
761 aEvent
.Source
= (::cppu::OWeakObject
*)this;
762 aEvent
.TrackingRectangle
= AWTRectangle( pData
->maTrackRect
);
763 aEvent
.MousePos
.X
= pData
->maMousePos
.X();
764 aEvent
.MousePos
.Y
= pData
->maMousePos
.Y();
765 aEvent
.bLiveMode
= pData
->mbLivemode
;
766 aEvent
.bInteractive
= pData
->mbInteractive
;
768 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::startDocking
, aEvent
);
773 case VCLEVENT_WINDOW_DOCKING
:
775 if ( mpImpl
->getDockableWindowListeners().getLength() )
777 DockingData
*pData
= static_cast<DockingData
*>(rVclWindowEvent
.GetData());
781 ::com::sun::star::awt::DockingEvent aEvent
;
782 aEvent
.Source
= (::cppu::OWeakObject
*)this;
783 aEvent
.TrackingRectangle
= AWTRectangle( pData
->maTrackRect
);
784 aEvent
.MousePos
.X
= pData
->maMousePos
.X();
785 aEvent
.MousePos
.Y
= pData
->maMousePos
.Y();
786 aEvent
.bLiveMode
= pData
->mbLivemode
;
787 aEvent
.bInteractive
= pData
->mbInteractive
;
789 Reference
< XDockableWindowListener
> xFirstListener
;
790 ::cppu::OInterfaceIteratorHelper
aIter( mpImpl
->getDockableWindowListeners() );
791 while ( aIter
.hasMoreElements() && !xFirstListener
.is() )
793 xFirstListener
.set( aIter
.next(), UNO_QUERY
);
796 ::com::sun::star::awt::DockingData aDockingData
=
797 xFirstListener
->docking( aEvent
);
798 pData
->maTrackRect
= VCLRectangle( aDockingData
.TrackingRectangle
);
799 pData
->mbFloating
= aDockingData
.bFloating
;
804 case VCLEVENT_WINDOW_ENDDOCKING
:
806 if ( mpImpl
->getDockableWindowListeners().getLength() )
808 EndDockingData
*pData
= static_cast<EndDockingData
*>(rVclWindowEvent
.GetData());
812 ::com::sun::star::awt::EndDockingEvent aEvent
;
813 aEvent
.Source
= (::cppu::OWeakObject
*)this;
814 aEvent
.WindowRectangle
= AWTRectangle( pData
->maWindowRect
);
815 aEvent
.bFloating
= pData
->mbFloating
;
816 aEvent
.bCancelled
= pData
->mbCancelled
;
817 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endDocking
, aEvent
);
822 case VCLEVENT_WINDOW_PREPARETOGGLEFLOATING
:
824 if ( mpImpl
->getDockableWindowListeners().getLength() )
826 sal_Bool
*p_bFloating
= static_cast<sal_Bool
*>(rVclWindowEvent
.GetData());
828 ::com::sun::star::lang::EventObject aEvent
;
829 aEvent
.Source
= (::cppu::OWeakObject
*)this;
831 Reference
< XDockableWindowListener
> xFirstListener
;
832 ::cppu::OInterfaceIteratorHelper
aIter( mpImpl
->getDockableWindowListeners() );
833 while ( aIter
.hasMoreElements() && !xFirstListener
.is() )
835 xFirstListener
.set( aIter
.next(), UNO_QUERY
);
838 *p_bFloating
= xFirstListener
->prepareToggleFloatingMode( aEvent
);
842 case VCLEVENT_WINDOW_TOGGLEFLOATING
:
844 if ( mpImpl
->getDockableWindowListeners().getLength() )
846 ::com::sun::star::lang::EventObject aEvent
;
847 aEvent
.Source
= (::cppu::OWeakObject
*)this;
848 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::toggleFloatingMode
, aEvent
);
852 case VCLEVENT_WINDOW_ENDPOPUPMODE
:
854 if ( mpImpl
->getDockableWindowListeners().getLength() )
856 EndPopupModeData
*pData
= static_cast<EndPopupModeData
*>(rVclWindowEvent
.GetData());
860 ::com::sun::star::awt::EndPopupModeEvent aEvent
;
861 aEvent
.Source
= (::cppu::OWeakObject
*)this;
862 aEvent
.FloatingPosition
.X
= pData
->maFloatingPos
.X();
863 aEvent
.FloatingPosition
.Y
= pData
->maFloatingPos
.Y();
864 aEvent
.bTearoff
= pData
->mbTearoff
;
865 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endPopupMode
, aEvent
);
874 uno::Reference
< accessibility::XAccessibleContext
> VCLXWindow::CreateAccessibleContext()
876 SolarMutexGuard aGuard
;
877 return getAccessibleFactory().createAccessibleContext( this );
880 void VCLXWindow::SetSynthesizingVCLEvent( bool _b
)
882 mpImpl
->mbSynthesizingVCLEvent
= _b
;
885 bool VCLXWindow::IsSynthesizingVCLEvent() const
887 return mpImpl
->mbSynthesizingVCLEvent
;
890 Size
VCLXWindow::ImplCalcWindowSize( const Size
& rOutSz
) const
894 vcl::Window
* pWindow
= GetWindow();
897 sal_Int32 nLeft
, nTop
, nRight
, nBottom
;
898 pWindow
->GetBorder( nLeft
, nTop
, nRight
, nBottom
);
899 aSz
.Width() += nLeft
+nRight
;
900 aSz
.Height() += nTop
+nBottom
;
906 // ::com::sun::star::lang::XUnoTunnel
907 IMPL_XUNOTUNNEL2( VCLXWindow
, VCLXDevice
)
909 // ::com::sun::star::lang::Component
910 void VCLXWindow::dispose( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
912 SolarMutexGuard aGuard
;
914 mpImpl
->mxViewGraphics
= NULL
;
916 if ( !mpImpl
->mbDisposing
)
918 mpImpl
->mbDisposing
= true;
924 VclPtr
<OutputDevice
> pOutDev
= GetOutputDevice();
925 SetWindow( NULL
); // so that handlers are logged off, if necessary (virtual)
926 SetOutputDevice( pOutDev
);
927 pOutDev
.disposeAndClear();
928 SetOutputDevice( NULL
);
931 // #i14103# dispose the accessible context after the window has been destroyed,
932 // otherwise the old value in the child event fired in VCLXAccessibleComponent::ProcessWindowEvent()
933 // for VCLEVENT_WINDOW_CHILDDESTROYED contains a reference to an already disposed accessible object
936 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> xComponent( mpImpl
->mxAccessibleContext
, ::com::sun::star::uno::UNO_QUERY
);
937 if ( xComponent
.is() )
938 xComponent
->dispose();
940 catch ( const ::com::sun::star::uno::Exception
& )
942 OSL_FAIL( "VCLXWindow::dispose: could not dispose the accessible context!" );
944 mpImpl
->mxAccessibleContext
.clear();
946 mpImpl
->mbDisposing
= false;
950 void VCLXWindow::addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
952 SolarMutexGuard aGuard
;
954 mpImpl
->getEventListeners().addInterface( rxListener
);
957 void VCLXWindow::removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
959 SolarMutexGuard aGuard
;
961 mpImpl
->getEventListeners().removeInterface( rxListener
);
965 // ::com::sun::star::awt::XWindow
966 void VCLXWindow::setPosSize( sal_Int32 X
, sal_Int32 Y
, sal_Int32 Width
, sal_Int32 Height
, sal_Int16 Flags
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
968 SolarMutexGuard aGuard
;
972 if( vcl::Window::GetDockingManager()->IsDockable( GetWindow() ) )
973 vcl::Window::GetDockingManager()->SetPosSizePixel( GetWindow() , X
, Y
, Width
, Height
, static_cast<PosSizeFlags
>(Flags
) );
975 GetWindow()->setPosSizePixel( X
, Y
, Width
, Height
, static_cast<PosSizeFlags
>(Flags
) );
979 ::com::sun::star::awt::Rectangle
VCLXWindow::getPosSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
981 SolarMutexGuard aGuard
;
983 ::com::sun::star::awt::Rectangle aBounds
;
986 if( vcl::Window::GetDockingManager()->IsDockable( GetWindow() ) )
987 aBounds
= AWTRectangle( vcl::Window::GetDockingManager()->GetPosSizePixel( GetWindow() ) );
989 aBounds
= AWTRectangle( Rectangle( GetWindow()->GetPosPixel(), GetWindow()->GetSizePixel() ) );
995 void VCLXWindow::setVisible( sal_Bool bVisible
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
997 SolarMutexGuard aGuard
;
999 vcl::Window
* pWindow
= GetWindow();
1002 mpImpl
->setDirectVisible( bVisible
);
1003 pWindow
->Show( bVisible
&& mpImpl
->isEnableVisible() );
1007 void VCLXWindow::setEnable( sal_Bool bEnable
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1009 SolarMutexGuard aGuard
;
1011 vcl::Window
* pWindow
= GetWindow();
1014 pWindow
->Enable( bEnable
, false ); // #95824# without children!
1015 pWindow
->EnableInput( bEnable
);
1019 void VCLXWindow::setFocus( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1021 SolarMutexGuard aGuard
;
1024 GetWindow()->GrabFocus();
1027 void VCLXWindow::addWindowListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1029 SolarMutexGuard aGuard
;
1031 mpImpl
->getWindowListeners().addInterface( rxListener
);
1033 Reference
< XWindowListener2
> xListener2( rxListener
, UNO_QUERY
);
1034 if ( xListener2
.is() )
1035 mpImpl
->getWindow2Listeners().addInterface( xListener2
);
1037 // #100119# Get all resize events, even if height or width 0, or invisible
1039 GetWindow()->EnableAllResize( true );
1042 void VCLXWindow::removeWindowListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1044 SolarMutexGuard aGuard
;
1046 Reference
< XWindowListener2
> xListener2( rxListener
, UNO_QUERY
);
1047 if ( xListener2
.is() )
1048 mpImpl
->getWindow2Listeners().removeInterface( xListener2
);
1050 mpImpl
->getWindowListeners().removeInterface( rxListener
);
1053 void VCLXWindow::addFocusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1055 SolarMutexGuard aGuard
;
1056 mpImpl
->getFocusListeners().addInterface( rxListener
);
1059 void VCLXWindow::removeFocusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFocusListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1061 SolarMutexGuard aGuard
;
1062 mpImpl
->getFocusListeners().removeInterface( rxListener
);
1065 void VCLXWindow::addKeyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XKeyListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1067 SolarMutexGuard aGuard
;
1068 mpImpl
->getKeyListeners().addInterface( rxListener
);
1071 void VCLXWindow::removeKeyListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XKeyListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1073 SolarMutexGuard aGuard
;
1074 mpImpl
->getKeyListeners().removeInterface( rxListener
);
1077 void VCLXWindow::addMouseListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMouseListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1079 SolarMutexGuard aGuard
;
1080 mpImpl
->getMouseListeners().addInterface( rxListener
);
1083 void VCLXWindow::removeMouseListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMouseListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1085 SolarMutexGuard aGuard
;
1086 mpImpl
->getMouseListeners().removeInterface( rxListener
);
1089 void VCLXWindow::addMouseMotionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMouseMotionListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1091 SolarMutexGuard aGuard
;
1092 mpImpl
->getMouseMotionListeners().addInterface( rxListener
);
1095 void VCLXWindow::removeMouseMotionListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XMouseMotionListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1097 SolarMutexGuard aGuard
;
1098 mpImpl
->getMouseMotionListeners().removeInterface( rxListener
);
1101 void VCLXWindow::addPaintListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XPaintListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1103 SolarMutexGuard aGuard
;
1104 mpImpl
->getPaintListeners().addInterface( rxListener
);
1107 void VCLXWindow::removePaintListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XPaintListener
>& rxListener
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1109 SolarMutexGuard aGuard
;
1110 mpImpl
->getPaintListeners().removeInterface( rxListener
);
1113 // ::com::sun::star::awt::XWindowPeer
1114 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XToolkit
> VCLXWindow::getToolkit( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1116 // no guard. nothing to guard here.
1117 // 82463 - 12/21/00 - fs
1118 return Application::GetVCLToolkit();
1121 void VCLXWindow::setPointer( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XPointer
>& rxPointer
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1123 SolarMutexGuard aGuard
;
1125 VCLXPointer
* pPointer
= VCLXPointer::GetImplementation( rxPointer
);
1128 mpImpl
->mxPointer
= rxPointer
;
1130 GetWindow()->SetPointer( pPointer
->GetPointer() );
1134 void VCLXWindow::setBackground( sal_Int32 nColor
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1136 SolarMutexGuard aGuard
;
1140 Color
aColor( (sal_uInt32
)nColor
);
1141 GetWindow()->SetBackground( aColor
);
1142 GetWindow()->SetControlBackground( aColor
);
1144 WindowType eWinType
= GetWindow()->GetType();
1145 if ( ( eWinType
== WINDOW_WINDOW
) ||
1146 ( eWinType
== WINDOW_WORKWINDOW
) ||
1147 ( eWinType
== WINDOW_FLOATINGWINDOW
) )
1149 GetWindow()->Invalidate();
1154 void VCLXWindow::invalidate( sal_Int16 nInvalidateFlags
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1156 SolarMutexGuard aGuard
;
1159 GetWindow()->Invalidate( (sal_uInt16
) nInvalidateFlags
);
1162 void VCLXWindow::invalidateRect( const ::com::sun::star::awt::Rectangle
& rRect
, sal_Int16 nInvalidateFlags
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1164 SolarMutexGuard aGuard
;
1167 GetWindow()->Invalidate( VCLRectangle(rRect
), (sal_uInt16
) nInvalidateFlags
);
1171 // ::com::sun::star::awt::XVclWindowPeer
1172 sal_Bool
VCLXWindow::isChild( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindowPeer
>& rxPeer
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1174 SolarMutexGuard aGuard
;
1176 bool bIsChild
= false;
1177 vcl::Window
* pWindow
= GetWindow();
1180 vcl::Window
* pPeerWindow
= VCLUnoHelper::GetWindow( rxPeer
);
1181 bIsChild
= pPeerWindow
&& pWindow
->IsChild( pPeerWindow
);
1187 void VCLXWindow::setDesignMode( sal_Bool bOn
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1189 SolarMutexGuard aGuard
;
1191 mpImpl
->mbDesignMode
= bOn
;
1194 sal_Bool
VCLXWindow::isDesignMode( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1196 SolarMutexGuard aGuard
;
1197 return mpImpl
->mbDesignMode
;
1200 void VCLXWindow::enableClipSiblings( sal_Bool bClip
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1202 SolarMutexGuard aGuard
;
1205 GetWindow()->EnableClipSiblings( bClip
);
1208 void VCLXWindow::setForeground( sal_Int32 nColor
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1210 SolarMutexGuard aGuard
;
1214 Color
aColor( (sal_uInt32
)nColor
);
1215 GetWindow()->SetControlForeground( aColor
);
1219 void VCLXWindow::setControlFont( const ::com::sun::star::awt::FontDescriptor
& rFont
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1221 SolarMutexGuard aGuard
;
1224 GetWindow()->SetControlFont( VCLUnoHelper::CreateFont( rFont
, GetWindow()->GetControlFont() ) );
1227 void VCLXWindow::getStyles( sal_Int16 nType
, ::com::sun::star::awt::FontDescriptor
& Font
, sal_Int32
& ForegroundColor
, sal_Int32
& BackgroundColor
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1229 SolarMutexGuard aGuard
;
1233 const StyleSettings
& rStyleSettings
= GetWindow()->GetSettings().GetStyleSettings();
1237 case ::com::sun::star::awt::Style::FRAME
:
1239 Font
= VCLUnoHelper::CreateFontDescriptor( rStyleSettings
.GetAppFont() );
1240 ForegroundColor
= rStyleSettings
.GetWindowTextColor().GetColor();
1241 BackgroundColor
= rStyleSettings
.GetWindowColor().GetColor();
1244 case ::com::sun::star::awt::Style::DIALOG
:
1246 Font
= VCLUnoHelper::CreateFontDescriptor( rStyleSettings
.GetAppFont() );
1247 ForegroundColor
= rStyleSettings
.GetDialogTextColor().GetColor();
1248 BackgroundColor
= rStyleSettings
.GetDialogColor().GetColor();
1251 default: OSL_FAIL( "VCLWindow::getStyles() - unknown Type" );
1259 static void setColorSettings( vcl::Window
* _pWindow
, const ::com::sun::star::uno::Any
& _rValue
,
1260 void (StyleSettings::*pSetter
)( const Color
& ), const Color
& (StyleSettings::*pGetter
)( ) const )
1262 sal_Int32 nColor
= 0;
1263 if ( !( _rValue
>>= nColor
) )
1264 nColor
= (Application::GetSettings().GetStyleSettings().*pGetter
)().GetColor();
1266 AllSettings aSettings
= _pWindow
->GetSettings();
1267 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
1269 (aStyleSettings
.*pSetter
)( Color( nColor
) );
1271 aSettings
.SetStyleSettings( aStyleSettings
);
1272 _pWindow
->SetSettings( aSettings
, true );
1276 // Terminated by BASEPROPERTY_NOTFOUND (or 0)
1277 void VCLXWindow::PushPropertyIds( std::list
< sal_uInt16
> &rIds
,
1281 va_start( pVarArgs
, nFirstId
);
1283 for ( int nId
= nFirstId
; nId
!= BASEPROPERTY_NOTFOUND
;
1284 nId
= va_arg( pVarArgs
, int ) )
1285 rIds
.push_back( (sal_uInt16
) nId
);
1290 void VCLXWindow::ImplGetPropertyIds( std::list
< sal_uInt16
> &rIds
, bool bWithDefaults
)
1292 // These are common across ~all VCLXWindow derived classes
1294 PushPropertyIds( rIds
,
1296 BASEPROPERTY_BACKGROUNDCOLOR
,
1297 BASEPROPERTY_BORDER
,
1298 BASEPROPERTY_BORDERCOLOR
,
1299 BASEPROPERTY_DEFAULTCONTROL
,
1300 BASEPROPERTY_ENABLED
,
1301 BASEPROPERTY_FONTDESCRIPTOR
,
1302 BASEPROPERTY_HELPTEXT
,
1303 BASEPROPERTY_HELPURL
,
1305 BASEPROPERTY_PRINTABLE
,
1306 BASEPROPERTY_ENABLEVISIBLE
, // for visibility
1307 BASEPROPERTY_TABSTOP
,
1310 // lovely hack from:
1311 // void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
1312 std::list
< sal_uInt16
>::const_iterator iter
;
1313 for( iter
= rIds
.begin(); iter
!= rIds
.end(); ++iter
) {
1314 if( *iter
== BASEPROPERTY_FONTDESCRIPTOR
)
1316 // some properties are not included in the FontDescriptor, but every time
1317 // when we have a FontDescriptor we want to have these properties too.
1318 // => Easier to register the here, istead everywhere where I register the FontDescriptor...
1320 rIds
.push_back( BASEPROPERTY_TEXTCOLOR
);
1321 rIds
.push_back( BASEPROPERTY_TEXTLINECOLOR
);
1322 rIds
.push_back( BASEPROPERTY_FONTRELIEF
);
1323 rIds
.push_back( BASEPROPERTY_FONTEMPHASISMARK
);
1329 void VCLXWindow::GetPropertyIds( std::list
< sal_uInt16
>& _out_rIds
)
1331 return ImplGetPropertyIds( _out_rIds
, mpImpl
->mbWithDefaultProps
);
1334 ::cppu::OInterfaceContainerHelper
& VCLXWindow::GetContainerListeners()
1336 return mpImpl
->getContainerListeners();
1339 ::cppu::OInterfaceContainerHelper
& VCLXWindow::GetTopWindowListeners()
1341 return mpImpl
->getTopWindowListeners();
1346 void lcl_updateWritingMode( vcl::Window
& _rWindow
, const sal_Int16 _nWritingMode
, const sal_Int16 _nContextWritingMode
)
1348 bool bEnableRTL
= false;
1349 switch ( _nWritingMode
)
1351 case WritingMode2::LR_TB
: bEnableRTL
= false; break;
1352 case WritingMode2::RL_TB
: bEnableRTL
= true; break;
1353 case WritingMode2::CONTEXT
:
1355 // consult our ContextWritingMode. If it has an explicit RTL/LTR value, then use
1356 // it. If it doesn't (but is CONTEXT itself), then just ask the parent window of our
1357 // own window for its RTL mode
1358 switch ( _nContextWritingMode
)
1360 case WritingMode2::LR_TB
: bEnableRTL
= false; break;
1361 case WritingMode2::RL_TB
: bEnableRTL
= true; break;
1362 case WritingMode2::CONTEXT
:
1364 const vcl::Window
* pParent
= _rWindow
.GetParent();
1365 OSL_ENSURE( pParent
, "lcl_updateWritingMode: cannot determine context's writing mode!" );
1367 bEnableRTL
= pParent
->IsRTLEnabled();
1374 OSL_FAIL( "lcl_updateWritingMode: unsupported WritingMode!" );
1375 } // switch ( nWritingMode )
1377 _rWindow
.EnableRTL( bEnableRTL
);
1381 void VCLXWindow::setProperty( const OUString
& PropertyName
, const ::com::sun::star::uno::Any
& Value
)
1382 throw(::com::sun::star::uno::RuntimeException
,
1385 SolarMutexGuard aGuard
;
1387 vcl::Window
* pWindow
= GetWindow();
1391 bool bVoid
= Value
.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID
;
1393 WindowType eWinType
= pWindow
->GetType();
1394 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1395 switch ( nPropType
)
1397 case BASEPROPERTY_REFERENCE_DEVICE
:
1399 Control
* pControl
= dynamic_cast< Control
* >( pWindow
);
1400 OSL_ENSURE( pControl
, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
1403 Reference
< XDevice
> xDevice( Value
, UNO_QUERY
);
1404 OutputDevice
* pDevice
= VCLUnoHelper::GetOutputDevice( xDevice
);
1405 pControl
->SetReferenceDevice( pDevice
);
1409 case BASEPROPERTY_CONTEXT_WRITING_MODE
:
1411 OSL_VERIFY( Value
>>= mpImpl
->mnContextWritingMode
);
1412 if ( mpImpl
->mnWritingMode
== WritingMode2::CONTEXT
)
1413 lcl_updateWritingMode( *pWindow
, mpImpl
->mnWritingMode
, mpImpl
->mnContextWritingMode
);
1417 case BASEPROPERTY_WRITING_MODE
:
1419 bool bProperType
= ( Value
>>= mpImpl
->mnWritingMode
);
1420 OSL_ENSURE( bProperType
, "VCLXWindow::setProperty( 'WritingMode' ): illegal value type!" );
1422 lcl_updateWritingMode( *pWindow
, mpImpl
->mnWritingMode
, mpImpl
->mnContextWritingMode
);
1426 case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
:
1428 sal_uInt16
nWheelBehavior( css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
);
1429 OSL_VERIFY( Value
>>= nWheelBehavior
);
1431 AllSettings aSettings
= pWindow
->GetSettings();
1432 MouseSettings aMouseSettings
= aSettings
.GetMouseSettings();
1434 MouseWheelBehaviour
nVclBehavior( MouseWheelBehaviour::FocusOnly
);
1435 switch ( nWheelBehavior
)
1437 case css::awt::MouseWheelBehavior::SCROLL_DISABLED
: nVclBehavior
= MouseWheelBehaviour::Disable
; break;
1438 case css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
: nVclBehavior
= MouseWheelBehaviour::FocusOnly
; break;
1439 case css::awt::MouseWheelBehavior::SCROLL_ALWAYS
: nVclBehavior
= MouseWheelBehaviour::ALWAYS
; break;
1441 OSL_FAIL( "VCLXWindow::setProperty( 'MouseWheelBehavior' ): illegal property value!" );
1444 aMouseSettings
.SetWheelBehavior( nVclBehavior
);
1445 aSettings
.SetMouseSettings( aMouseSettings
);
1446 pWindow
->SetSettings( aSettings
, true );
1450 case BASEPROPERTY_NATIVE_WIDGET_LOOK
:
1452 bool bEnable( true );
1453 OSL_VERIFY( Value
>>= bEnable
);
1454 pWindow
->EnableNativeWidget( bEnable
);
1458 case BASEPROPERTY_PLUGINPARENT
:
1460 // set parent handle
1461 SetSystemParent_Impl( Value
);
1465 case BASEPROPERTY_ENABLED
:
1472 case BASEPROPERTY_ENABLEVISIBLE
:
1477 if( b
!= mpImpl
->isEnableVisible() )
1479 mpImpl
->setEnableVisible( b
);
1480 pWindow
->Show( b
&& mpImpl
->isDirectVisible() );
1485 case BASEPROPERTY_TEXT
:
1486 case BASEPROPERTY_LABEL
:
1487 case BASEPROPERTY_TITLE
:
1490 if ( Value
>>= aText
)
1494 case WINDOW_OKBUTTON
:
1495 case WINDOW_CANCELBUTTON
:
1496 case WINDOW_HELPBUTTON
:
1497 // Standard Button: overwrite only if not empty.
1498 if (!aText
.isEmpty())
1499 pWindow
->SetText( aText
);
1503 pWindow
->SetText( aText
);
1509 case BASEPROPERTY_ACCESSIBLENAME
:
1512 if ( Value
>>= aText
)
1513 pWindow
->SetAccessibleName( aText
);
1516 case BASEPROPERTY_HELPURL
:
1519 if ( Value
>>= aURL
)
1521 INetURLObject
aHelpURL( aURL
);
1522 if ( aHelpURL
.GetProtocol() == INetProtocol::Hid
)
1523 pWindow
->SetHelpId( OUStringToOString( aHelpURL
.GetURLPath(), RTL_TEXTENCODING_UTF8
) );
1525 pWindow
->SetHelpId( OUStringToOString( aURL
, RTL_TEXTENCODING_UTF8
) );
1529 case BASEPROPERTY_HELPTEXT
:
1532 if ( Value
>>= aHelpText
)
1534 pWindow
->SetQuickHelpText( aHelpText
);
1538 case BASEPROPERTY_FONTDESCRIPTOR
:
1541 pWindow
->SetControlFont( vcl::Font() );
1544 ::com::sun::star::awt::FontDescriptor aFont
;
1545 if ( Value
>>= aFont
)
1546 pWindow
->SetControlFont( VCLUnoHelper::CreateFont( aFont
, pWindow
->GetControlFont() ) );
1550 case BASEPROPERTY_FONTRELIEF
:
1552 sal_Int16 n
= sal_Int16();
1555 vcl::Font aFont
= pWindow
->GetControlFont();
1556 aFont
.SetRelief( (FontRelief
)n
);
1557 pWindow
->SetControlFont( aFont
);
1561 case BASEPROPERTY_FONTEMPHASISMARK
:
1563 sal_Int16 n
= sal_Int16();
1566 vcl::Font aFont
= pWindow
->GetControlFont();
1567 aFont
.SetEmphasisMark( n
);
1568 pWindow
->SetControlFont( aFont
);
1572 case BASEPROPERTY_BACKGROUNDCOLOR
:
1577 // set dialog color for default
1579 case WINDOW_MESSBOX
:
1580 case WINDOW_INFOBOX
:
1581 case WINDOW_WARNINGBOX
:
1582 case WINDOW_ERRORBOX
:
1583 case WINDOW_QUERYBOX
:
1584 case WINDOW_TABPAGE
:
1586 Color aColor
= pWindow
->GetSettings().GetStyleSettings().GetDialogColor();
1587 pWindow
->SetBackground( aColor
);
1588 pWindow
->SetControlBackground( aColor
);
1592 case WINDOW_FIXEDTEXT
:
1593 case WINDOW_CHECKBOX
:
1594 case WINDOW_RADIOBUTTON
:
1595 case WINDOW_GROUPBOX
:
1596 case WINDOW_FIXEDLINE
:
1598 // support transparency only for special controls
1599 pWindow
->SetBackground();
1600 pWindow
->SetControlBackground();
1601 pWindow
->SetPaintTransparent( true );
1607 // default code which enables transparency for
1608 // compound controls. It's not real transparency
1609 // as most of these controls repaint their client
1610 // area completely new.
1611 if ( pWindow
->IsCompoundControl() )
1612 pWindow
->SetBackground();
1613 pWindow
->SetControlBackground();
1620 sal_Int32 nColor
= 0;
1621 if ( Value
>>= nColor
)
1623 Color
aColor( nColor
);
1624 pWindow
->SetControlBackground( aColor
);
1625 pWindow
->SetBackground( aColor
);
1628 // reset paint transparent mode
1629 case WINDOW_FIXEDTEXT
:
1630 case WINDOW_CHECKBOX
:
1631 case WINDOW_RADIOBUTTON
:
1632 case WINDOW_GROUPBOX
:
1633 case WINDOW_FIXEDLINE
:
1634 pWindow
->SetPaintTransparent( false );
1637 pWindow
->Invalidate(); // Invalidate if control does not respond to it
1641 case BASEPROPERTY_TEXTCOLOR
:
1644 pWindow
->SetControlForeground();
1648 sal_Int32 nColor
= 0;
1649 if ( Value
>>= nColor
)
1651 Color
aColor( nColor
);
1652 pWindow
->SetTextColor( aColor
);
1653 pWindow
->SetControlForeground( aColor
);
1657 case BASEPROPERTY_TEXTLINECOLOR
:
1660 pWindow
->SetTextLineColor();
1664 sal_Int32 nColor
= 0;
1665 if ( Value
>>= nColor
)
1667 Color
aColor( nColor
);
1668 pWindow
->SetTextLineColor( aColor
);
1672 case BASEPROPERTY_FILLCOLOR
:
1674 pWindow
->SetFillColor();
1677 sal_Int32 nColor
= 0;
1678 if ( Value
>>= nColor
)
1680 Color
aColor( nColor
);
1681 pWindow
->SetFillColor( aColor
);
1685 case BASEPROPERTY_LINECOLOR
:
1687 pWindow
->SetLineColor();
1690 sal_Int32 nColor
= 0;
1691 if ( Value
>>= nColor
)
1693 Color
aColor( nColor
);
1694 pWindow
->SetLineColor( aColor
);
1698 case BASEPROPERTY_BORDER
:
1700 WinBits nStyle
= pWindow
->GetStyle();
1701 sal_uInt16 nTmp
= 0;
1703 WindowBorderStyle nBorder
= static_cast<WindowBorderStyle
>(nTmp
);
1704 if ( !bool(nBorder
) )
1706 pWindow
->SetStyle( nStyle
& ~WB_BORDER
);
1710 pWindow
->SetStyle( nStyle
| WB_BORDER
);
1711 pWindow
->SetBorderStyle( nBorder
);
1715 case BASEPROPERTY_TABSTOP
:
1717 WinBits nStyle
= pWindow
->GetStyle() & ~WB_TABSTOP
;
1723 nStyle
|= WB_TABSTOP
;
1725 nStyle
|= WB_NOTABSTOP
;
1727 pWindow
->SetStyle( nStyle
);
1730 case BASEPROPERTY_VERTICALALIGN
:
1732 VerticalAlignment eAlign
= VerticalAlignment_MAKE_FIXED_SIZE
;
1733 WinBits nStyle
= pWindow
->GetStyle();
1734 nStyle
&= ~(WB_TOP
|WB_VCENTER
|WB_BOTTOM
);
1739 case VerticalAlignment_TOP
:
1742 case VerticalAlignment_MIDDLE
:
1743 nStyle
|= WB_VCENTER
;
1745 case VerticalAlignment_BOTTOM
:
1746 nStyle
|= WB_BOTTOM
;
1748 default: ; // for warning free code, MAKE_FIXED_SIZE
1750 pWindow
->SetStyle( nStyle
);
1753 case BASEPROPERTY_ALIGN
:
1755 sal_Int16 nAlign
= PROPERTY_ALIGN_LEFT
;
1758 case WINDOW_COMBOBOX
:
1760 case WINDOW_PUSHBUTTON
:
1761 case WINDOW_OKBUTTON
:
1762 case WINDOW_CANCELBUTTON
:
1763 case WINDOW_HELPBUTTON
:
1764 nAlign
= PROPERTY_ALIGN_CENTER
;
1766 case WINDOW_FIXEDTEXT
:
1768 case WINDOW_MULTILINEEDIT
:
1769 case WINDOW_CHECKBOX
:
1770 case WINDOW_RADIOBUTTON
:
1771 case WINDOW_LISTBOX
:
1773 WinBits nStyle
= pWindow
->GetStyle();
1774 nStyle
&= ~(WB_LEFT
|WB_CENTER
|WB_RIGHT
);
1777 if ( nAlign
== PROPERTY_ALIGN_LEFT
)
1779 else if ( nAlign
== PROPERTY_ALIGN_CENTER
)
1780 nStyle
|= WB_CENTER
;
1783 pWindow
->SetStyle( nStyle
);
1789 case BASEPROPERTY_MULTILINE
:
1791 if ( ( eWinType
== WINDOW_FIXEDTEXT
)
1792 || ( eWinType
== WINDOW_CHECKBOX
)
1793 || ( eWinType
== WINDOW_RADIOBUTTON
)
1794 || ( eWinType
== WINDOW_BUTTON
)
1795 || ( eWinType
== WINDOW_PUSHBUTTON
)
1796 || ( eWinType
== WINDOW_OKBUTTON
)
1797 || ( eWinType
== WINDOW_CANCELBUTTON
)
1798 || ( eWinType
== WINDOW_HELPBUTTON
)
1801 WinBits nStyle
= pWindow
->GetStyle();
1802 bool bMulti
= false;
1805 nStyle
|= WB_WORDBREAK
;
1807 nStyle
&= ~WB_WORDBREAK
;
1808 pWindow
->SetStyle( nStyle
);
1812 case BASEPROPERTY_ORIENTATION
:
1816 case WINDOW_FIXEDLINE
:
1818 sal_Int32 nOrientation
= 0;
1819 if ( Value
>>= nOrientation
)
1821 WinBits nStyle
= pWindow
->GetStyle();
1822 nStyle
&= ~(WB_HORZ
|WB_VERT
);
1823 if ( nOrientation
== 0 )
1828 pWindow
->SetStyle( nStyle
);
1835 case BASEPROPERTY_AUTOMNEMONICS
:
1837 bool bAutoMnemonics
= false;
1838 Value
>>= bAutoMnemonics
;
1839 AllSettings aSettings
= pWindow
->GetSettings();
1840 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
1841 if ( aStyleSettings
.GetAutoMnemonic() != bAutoMnemonics
)
1843 aStyleSettings
.SetAutoMnemonic( bAutoMnemonics
);
1844 aSettings
.SetStyleSettings( aStyleSettings
);
1845 pWindow
->SetSettings( aSettings
);
1849 case BASEPROPERTY_MOUSETRANSPARENT
:
1851 bool bMouseTransparent
= false;
1852 Value
>>= bMouseTransparent
;
1853 pWindow
->SetMouseTransparent( bMouseTransparent
);
1856 case BASEPROPERTY_PAINTTRANSPARENT
:
1858 bool bPaintTransparent
= false;
1859 Value
>>= bPaintTransparent
;
1860 pWindow
->SetPaintTransparent( bPaintTransparent
);
1861 // pWindow->SetBackground();
1865 case BASEPROPERTY_REPEAT
:
1867 bool bRepeat( false );
1870 WinBits nStyle
= pWindow
->GetStyle();
1872 nStyle
|= WB_REPEAT
;
1874 nStyle
&= ~WB_REPEAT
;
1875 pWindow
->SetStyle( nStyle
);
1879 case BASEPROPERTY_REPEAT_DELAY
:
1881 sal_Int32 nRepeatDelay
= 0;
1882 if ( Value
>>= nRepeatDelay
)
1884 AllSettings aSettings
= pWindow
->GetSettings();
1885 MouseSettings aMouseSettings
= aSettings
.GetMouseSettings();
1887 aMouseSettings
.SetButtonRepeat( nRepeatDelay
);
1888 aSettings
.SetMouseSettings( aMouseSettings
);
1890 pWindow
->SetSettings( aSettings
, true );
1895 case BASEPROPERTY_SYMBOL_COLOR
:
1896 ::toolkit::setColorSettings( pWindow
, Value
, &StyleSettings::SetButtonTextColor
, &StyleSettings::GetButtonTextColor
);
1899 case BASEPROPERTY_BORDERCOLOR
:
1900 ::toolkit::setColorSettings( pWindow
, Value
, &StyleSettings::SetMonoColor
, &StyleSettings::GetMonoColor
);
1902 case BASEPROPERTY_DEFAULTCONTROL
:
1911 ::com::sun::star::uno::Any
VCLXWindow::getProperty( const OUString
& PropertyName
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1913 SolarMutexGuard aGuard
;
1915 ::com::sun::star::uno::Any aProp
;
1918 WindowType eWinType
= GetWindow()->GetType();
1919 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1920 switch ( nPropType
)
1922 case BASEPROPERTY_REFERENCE_DEVICE
:
1924 VclPtr
<Control
> pControl
= GetAsDynamic
<Control
>();
1925 OSL_ENSURE( pControl
, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
1929 VCLXDevice
* pDevice
= new VCLXDevice
;
1930 pDevice
->SetOutputDevice( pControl
->GetReferenceDevice() );
1931 aProp
<<= Reference
< XDevice
>( pDevice
);
1935 case BASEPROPERTY_CONTEXT_WRITING_MODE
:
1936 aProp
<<= mpImpl
->mnContextWritingMode
;
1939 case BASEPROPERTY_WRITING_MODE
:
1940 aProp
<<= mpImpl
->mnWritingMode
;
1943 case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
:
1945 MouseWheelBehaviour nVclBehavior
= GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior();
1946 sal_uInt16 nBehavior
= css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
;
1947 switch ( nVclBehavior
)
1949 case MouseWheelBehaviour::Disable
: nBehavior
= css::awt::MouseWheelBehavior::SCROLL_DISABLED
; break;
1950 case MouseWheelBehaviour::FocusOnly
: nBehavior
= css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
; break;
1951 case MouseWheelBehaviour::ALWAYS
: nBehavior
= css::awt::MouseWheelBehavior::SCROLL_ALWAYS
; break;
1953 OSL_FAIL( "VCLXWindow::getProperty( 'MouseWheelBehavior' ): illegal VCL value!" );
1955 aProp
<<= nBehavior
;
1959 case BASEPROPERTY_NATIVE_WIDGET_LOOK
:
1960 aProp
<<= GetWindow()->IsNativeWidgetEnabled();
1963 case BASEPROPERTY_ENABLED
:
1964 aProp
<<= GetWindow()->IsEnabled();
1967 case BASEPROPERTY_ENABLEVISIBLE
:
1968 aProp
<<= mpImpl
->isEnableVisible();
1971 case BASEPROPERTY_HIGHCONTRASTMODE
:
1972 aProp
<<= GetWindow()->GetSettings().GetStyleSettings().GetHighContrastMode();
1975 case BASEPROPERTY_TEXT
:
1976 case BASEPROPERTY_LABEL
:
1977 case BASEPROPERTY_TITLE
:
1979 OUString aText
= GetWindow()->GetText();
1983 case BASEPROPERTY_ACCESSIBLENAME
:
1985 OUString aText
= GetWindow()->GetAccessibleName();
1989 case BASEPROPERTY_HELPTEXT
:
1991 OUString aText
= GetWindow()->GetQuickHelpText();
1995 case BASEPROPERTY_HELPURL
:
1997 OUString
aHelpId( OStringToOUString( GetWindow()->GetHelpId(), RTL_TEXTENCODING_UTF8
) );
1998 aProp
<<= OUString( aHelpId
);
2001 case BASEPROPERTY_FONTDESCRIPTOR
:
2003 vcl::Font aFont
= GetWindow()->GetControlFont();
2004 ::com::sun::star::awt::FontDescriptor aFD
= VCLUnoHelper::CreateFontDescriptor( aFont
);
2008 case BASEPROPERTY_BACKGROUNDCOLOR
:
2009 aProp
<<= (sal_Int32
) GetWindow()->GetControlBackground().GetColor();
2011 case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR
:
2012 aProp
<<= (sal_Int32
) GetWindow()->GetDisplayBackground().GetColor().GetColor();
2014 case BASEPROPERTY_FONTRELIEF
:
2015 aProp
<<= (sal_Int16
) GetWindow()->GetControlFont().GetRelief();
2017 case BASEPROPERTY_FONTEMPHASISMARK
:
2018 aProp
<<= (sal_Int16
) GetWindow()->GetControlFont().GetEmphasisMark();
2020 case BASEPROPERTY_TEXTCOLOR
:
2021 aProp
<<= (sal_Int32
) GetWindow()->GetControlForeground().GetColor();
2023 case BASEPROPERTY_TEXTLINECOLOR
:
2024 aProp
<<= (sal_Int32
) GetWindow()->GetTextLineColor().GetColor();
2026 case BASEPROPERTY_FILLCOLOR
:
2027 aProp
<<= (sal_Int32
) GetWindow()->GetFillColor().GetColor();
2029 case BASEPROPERTY_LINECOLOR
:
2030 aProp
<<= (sal_Int32
) GetWindow()->GetLineColor().GetColor();
2032 case BASEPROPERTY_BORDER
:
2034 WindowBorderStyle nBorder
= WindowBorderStyle::NONE
;
2035 if ( GetWindow()->GetStyle() & WB_BORDER
)
2036 nBorder
= GetWindow()->GetBorderStyle();
2037 aProp
<<= static_cast<sal_uInt16
>(nBorder
);
2040 case BASEPROPERTY_TABSTOP
:
2041 aProp
<<= ( GetWindow()->GetStyle() & WB_TABSTOP
) != 0;
2043 case BASEPROPERTY_VERTICALALIGN
:
2045 WinBits nStyle
= GetWindow()->GetStyle();
2046 if ( nStyle
& WB_TOP
)
2047 aProp
<<= VerticalAlignment_TOP
;
2048 else if ( nStyle
& WB_VCENTER
)
2049 aProp
<<= VerticalAlignment_MIDDLE
;
2050 else if ( nStyle
& WB_BOTTOM
)
2051 aProp
<<= VerticalAlignment_BOTTOM
;
2054 case BASEPROPERTY_ALIGN
:
2058 case WINDOW_FIXEDTEXT
:
2060 case WINDOW_MULTILINEEDIT
:
2061 case WINDOW_CHECKBOX
:
2062 case WINDOW_RADIOBUTTON
:
2063 case WINDOW_LISTBOX
:
2064 case WINDOW_COMBOBOX
:
2066 case WINDOW_PUSHBUTTON
:
2067 case WINDOW_OKBUTTON
:
2068 case WINDOW_CANCELBUTTON
:
2069 case WINDOW_HELPBUTTON
:
2071 WinBits nStyle
= GetWindow()->GetStyle();
2072 if ( nStyle
& WB_LEFT
)
2073 aProp
<<= (sal_Int16
) PROPERTY_ALIGN_LEFT
;
2074 else if ( nStyle
& WB_CENTER
)
2075 aProp
<<= (sal_Int16
) PROPERTY_ALIGN_CENTER
;
2076 else if ( nStyle
& WB_RIGHT
)
2077 aProp
<<= (sal_Int16
) PROPERTY_ALIGN_RIGHT
;
2083 case BASEPROPERTY_MULTILINE
:
2085 if ( ( eWinType
== WINDOW_FIXEDTEXT
)
2086 || ( eWinType
== WINDOW_CHECKBOX
)
2087 || ( eWinType
== WINDOW_RADIOBUTTON
)
2088 || ( eWinType
== WINDOW_BUTTON
)
2089 || ( eWinType
== WINDOW_PUSHBUTTON
)
2090 || ( eWinType
== WINDOW_OKBUTTON
)
2091 || ( eWinType
== WINDOW_CANCELBUTTON
)
2092 || ( eWinType
== WINDOW_HELPBUTTON
)
2094 aProp
<<= ( GetWindow()->GetStyle() & WB_WORDBREAK
) != 0;
2097 case BASEPROPERTY_AUTOMNEMONICS
:
2099 bool bAutoMnemonics
= GetWindow()->GetSettings().GetStyleSettings().GetAutoMnemonic();
2100 aProp
<<= bAutoMnemonics
;
2103 case BASEPROPERTY_MOUSETRANSPARENT
:
2105 bool bMouseTransparent
= GetWindow()->IsMouseTransparent();
2106 aProp
<<= bMouseTransparent
;
2109 case BASEPROPERTY_PAINTTRANSPARENT
:
2111 bool bPaintTransparent
= GetWindow()->IsPaintTransparent();
2112 aProp
<<= bPaintTransparent
;
2116 case BASEPROPERTY_REPEAT
:
2117 aProp
<<= ( 0 != ( GetWindow()->GetStyle() & WB_REPEAT
) );
2120 case BASEPROPERTY_REPEAT_DELAY
:
2122 sal_Int32 nButtonRepeat
= GetWindow()->GetSettings().GetMouseSettings().GetButtonRepeat();
2123 aProp
<<= (sal_Int32
)nButtonRepeat
;
2127 case BASEPROPERTY_SYMBOL_COLOR
:
2128 aProp
<<= (sal_Int32
)GetWindow()->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
2131 case BASEPROPERTY_BORDERCOLOR
:
2132 aProp
<<= (sal_Int32
)GetWindow()->GetSettings().GetStyleSettings().GetMonoColor().GetColor();
2140 // ::com::sun::star::awt::XLayoutConstrains
2141 ::com::sun::star::awt::Size
VCLXWindow::getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2143 SolarMutexGuard aGuard
;
2145 // Use this method only for those components which can be created through
2146 // ::com::sun::star::awt::Toolkit , but do not have an interface
2151 WindowType nWinType
= GetWindow()->GetType();
2154 case WINDOW_CONTROL
:
2155 aSz
.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*12;
2156 aSz
.Height() = GetWindow()->GetTextHeight()+2*6;
2159 case WINDOW_PATTERNBOX
:
2160 case WINDOW_NUMERICBOX
:
2161 case WINDOW_METRICBOX
:
2162 case WINDOW_CURRENCYBOX
:
2163 case WINDOW_DATEBOX
:
2164 case WINDOW_TIMEBOX
:
2165 case WINDOW_LONGCURRENCYBOX
:
2166 aSz
.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*2;
2167 aSz
.Height() = GetWindow()->GetTextHeight()+2*2;
2169 case WINDOW_SCROLLBARBOX
:
2170 return VCLXScrollBar::implGetMinimumSize( GetWindow() );
2172 aSz
= GetWindow()->get_preferred_size();
2176 return ::com::sun::star::awt::Size( aSz
.Width(), aSz
.Height() );
2179 ::com::sun::star::awt::Size
VCLXWindow::getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2181 return getMinimumSize();
2184 ::com::sun::star::awt::Size
VCLXWindow::calcAdjustedSize( const ::com::sun::star::awt::Size
& rNewSize
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2186 SolarMutexGuard aGuard
;
2188 ::com::sun::star::awt::Size
aNewSize( rNewSize
);
2189 ::com::sun::star::awt::Size aMinSize
= getMinimumSize();
2191 if ( aNewSize
.Width
< aMinSize
.Width
)
2192 aNewSize
.Width
= aMinSize
.Width
;
2193 if ( aNewSize
.Height
< aMinSize
.Height
)
2194 aNewSize
.Height
= aMinSize
.Height
;
2200 // ::com::sun::star::awt::XView
2201 sal_Bool
VCLXWindow::setGraphics( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
>& rxDevice
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2203 SolarMutexGuard aGuard
;
2205 if ( VCLUnoHelper::GetOutputDevice( rxDevice
) )
2206 mpImpl
->mxViewGraphics
= rxDevice
;
2208 mpImpl
->mxViewGraphics
= NULL
;
2210 return mpImpl
->mxViewGraphics
.is();
2213 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
> VCLXWindow::getGraphics( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2215 SolarMutexGuard aGuard
;
2217 return mpImpl
->mxViewGraphics
;
2220 ::com::sun::star::awt::Size
VCLXWindow::getSize( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2222 SolarMutexGuard aGuard
;
2226 aSz
= GetWindow()->GetSizePixel();
2227 return ::com::sun::star::awt::Size( aSz
.Width(), aSz
.Height() );
2230 void VCLXWindow::draw( sal_Int32 nX
, sal_Int32 nY
) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2232 SolarMutexGuard aGuard
;
2234 vcl::Window
* pWindow
= GetWindow();
2238 if ( isDesignMode() || mpImpl
->isEnableVisible() )
2240 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( mpImpl
->mxViewGraphics
);
2242 pDev
= pWindow
->GetParent();
2243 TabPage
* pTabPage
= dynamic_cast< TabPage
* >( pWindow
);
2246 Point
aPos( nX
, nY
);
2247 Size aSize
= pWindow
->GetSizePixel();
2249 aPos
= pDev
->PixelToLogic( aPos
);
2250 aSize
= pDev
->PixelToLogic( aSize
);
2252 pTabPage
->Draw( pDev
, aPos
, aSize
, 0 );
2256 Point
aPos( nX
, nY
);
2258 if ( pWindow
->GetParent() && !pWindow
->IsSystemWindow() && ( pWindow
->GetParent() == pDev
) )
2260 // #i40647# don't draw here if this is a recursive call
2261 // sometimes this is called recursively, because the Update call on the parent
2262 // (strangely) triggers another paint. Prevent a stack overflow here
2263 // Yes, this is only fixing symptoms for the moment ....
2264 // #i40647# / 2005-01-18 / frank.schoenheit@sun.com
2265 if ( !mpImpl
->getDrawingOntoParent_ref() )
2267 ::comphelper::FlagGuard
aDrawingflagGuard( mpImpl
->getDrawingOntoParent_ref() );
2269 bool bWasVisible
= pWindow
->IsVisible();
2270 Point
aOldPos( pWindow
->GetPosPixel() );
2272 if ( bWasVisible
&& aOldPos
== aPos
)
2278 pWindow
->SetPosPixel( aPos
);
2280 // Update parent first to avoid painting the parent upon the update
2281 // of this window, as it may otherwise cause the parent
2282 // to hide this window again
2283 if( pWindow
->GetParent() )
2284 pWindow
->GetParent()->Update();
2288 pWindow
->SetParentUpdateMode( false );
2290 pWindow
->SetParentUpdateMode( true );
2292 pWindow
->SetPosPixel( aOldPos
);
2294 pWindow
->Show( true );
2299 Size aSz
= pWindow
->GetSizePixel();
2300 aSz
= pDev
->PixelToLogic( aSz
);
2301 Point aP
= pDev
->PixelToLogic( aPos
);
2303 vcl::PDFExtOutDevData
* pPDFExport
= dynamic_cast<vcl::PDFExtOutDevData
*>(pDev
->GetExtOutDevData());
2304 bool bDrawSimple
= ( pDev
->GetOutDevType() == OUTDEV_PRINTER
)
2305 || ( pDev
->GetOutDevViewType() == OUTDEV_VIEWTYPE_PRINTPREVIEW
)
2306 || ( pPDFExport
!= NULL
);
2309 pWindow
->Draw( pDev
, aP
, aSz
, WINDOW_DRAW_NOCONTROLS
);
2313 bool bOldNW
=pWindow
->IsNativeWidgetEnabled();
2315 pWindow
->EnableNativeWidget(false);
2316 pWindow
->PaintToDevice( pDev
, aP
, aSz
);
2318 pWindow
->EnableNativeWidget(true);
2324 void VCLXWindow::setZoom( float fZoomX
, float /*fZoomY*/ ) throw(::com::sun::star::uno::RuntimeException
, std::exception
)
2326 SolarMutexGuard aGuard
;
2330 // Fraction::Fraction takes a double, but we have a float only.
2331 // The implicit conversion from float to double can result in a precision loss, i.e. 1.2 is converted to
2332 // 1.200000000047something. To prevent this, we convert explicitly to double, and round it.
2333 double nZoom( fZoomX
);
2334 Fraction
aZoom(::rtl::math::round(nZoom
, 4));
2335 aZoom
.ReduceInaccurate(10); // to avoid runovers and BigInt mapping
2336 GetWindow()->SetZoom(aZoom
);
2340 // ::com::sun::star::lang::XEventListener
2341 void SAL_CALL
VCLXWindow::disposing( const ::com::sun::star::lang::EventObject
& _rSource
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2343 SolarMutexGuard aGuard
;
2345 // check if it comes from our AccessibleContext
2346 uno::Reference
< uno::XInterface
> aAC( mpImpl
->mxAccessibleContext
, uno::UNO_QUERY
);
2347 uno::Reference
< uno::XInterface
> xSource( _rSource
.Source
, uno::UNO_QUERY
);
2349 if ( aAC
.get() == xSource
.get() )
2351 mpImpl
->mxAccessibleContext
= uno::Reference
< accessibility::XAccessibleContext
>();
2355 // ::com::sun::star::accessibility::XAccessible
2356 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> VCLXWindow::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2358 using namespace ::com::sun::star
;
2360 SolarMutexGuard aGuard
;
2364 return uno::Reference
< accessibility::XAccessibleContext
>();
2366 if ( !mpImpl
->mxAccessibleContext
.is() && GetWindow() )
2368 mpImpl
->mxAccessibleContext
= CreateAccessibleContext();
2370 // add as event listener to this component
2371 // in case somebody disposes it, we do not want to have a (though weak) reference to a dead
2373 uno::Reference
< lang::XComponent
> xComp( mpImpl
->mxAccessibleContext
, uno::UNO_QUERY
);
2375 xComp
->addEventListener( this );
2378 return mpImpl
->mxAccessibleContext
;
2381 // ::com::sun::star::awt::XDockable
2382 void SAL_CALL
VCLXWindow::addDockableWindowListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XDockableWindowListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2384 SolarMutexGuard aGuard
;
2386 if ( xListener
.is() )
2387 mpImpl
->getDockableWindowListeners().addInterface( xListener
);
2391 void SAL_CALL
VCLXWindow::removeDockableWindowListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XDockableWindowListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2393 SolarMutexGuard aGuard
;
2395 mpImpl
->getDockableWindowListeners().removeInterface( xListener
);
2398 void SAL_CALL
VCLXWindow::enableDocking( sal_Bool bEnable
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2400 SolarMutexGuard aGuard
;
2402 vcl::Window
* pWindow
= GetWindow();
2404 pWindow
->EnableDocking( bEnable
);
2407 sal_Bool SAL_CALL
VCLXWindow::isFloating( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2409 SolarMutexGuard aGuard
;
2411 vcl::Window
* pWindow
= GetWindow();
2413 return vcl::Window::GetDockingManager()->IsFloating( pWindow
);
2418 void SAL_CALL
VCLXWindow::setFloatingMode( sal_Bool bFloating
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2420 SolarMutexGuard aGuard
;
2422 vcl::Window
* pWindow
= GetWindow();
2424 vcl::Window::GetDockingManager()->SetFloatingMode( pWindow
, bFloating
);
2427 sal_Bool SAL_CALL
VCLXWindow::isLocked( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2429 SolarMutexGuard aGuard
;
2431 vcl::Window
* pWindow
= GetWindow();
2433 return vcl::Window::GetDockingManager()->IsLocked( pWindow
);
2438 void SAL_CALL
VCLXWindow::lock( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2440 SolarMutexGuard aGuard
;
2442 vcl::Window
* pWindow
= GetWindow();
2443 if( pWindow
&& !vcl::Window::GetDockingManager()->IsFloating( pWindow
) )
2444 vcl::Window::GetDockingManager()->Lock( pWindow
);
2447 void SAL_CALL
VCLXWindow::unlock( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2449 SolarMutexGuard aGuard
;
2451 vcl::Window
* pWindow
= GetWindow();
2452 if( pWindow
&& !vcl::Window::GetDockingManager()->IsFloating( pWindow
) )
2453 vcl::Window::GetDockingManager()->Unlock( pWindow
);
2455 void SAL_CALL
VCLXWindow::startPopupMode( const ::com::sun::star::awt::Rectangle
& ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2457 // TODO: remove interface in the next incompatible build
2458 SolarMutexGuard aGuard
;
2462 sal_Bool SAL_CALL
VCLXWindow::isInPopupMode( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2464 // TODO: remove interface in the next incompatible build
2465 SolarMutexGuard aGuard
;
2470 // ::com::sun::star::awt::XWindow2
2472 void SAL_CALL
VCLXWindow::setOutputSize( const ::com::sun::star::awt::Size
& aSize
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2474 SolarMutexGuard aGuard
;
2475 vcl::Window
*pWindow
;
2476 if( (pWindow
= GetWindow()) != NULL
)
2478 DockingWindow
*pDockingWindow
= dynamic_cast< DockingWindow
* >(pWindow
);
2479 if( pDockingWindow
)
2480 pDockingWindow
->SetOutputSizePixel( VCLSize( aSize
) );
2482 pWindow
->SetOutputSizePixel( VCLSize( aSize
) );
2486 ::com::sun::star::awt::Size SAL_CALL
VCLXWindow::getOutputSize( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2488 SolarMutexGuard aGuard
;
2489 vcl::Window
*pWindow
;
2490 if( (pWindow
= GetWindow()) != NULL
)
2492 DockingWindow
*pDockingWindow
= dynamic_cast< DockingWindow
* >(pWindow
);
2493 if( pDockingWindow
)
2494 return AWTSize( pDockingWindow
->GetOutputSizePixel() );
2496 return AWTSize( pWindow
->GetOutputSizePixel() );
2499 return ::com::sun::star::awt::Size();
2502 sal_Bool SAL_CALL
VCLXWindow::isVisible( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2504 SolarMutexGuard aGuard
;
2506 return GetWindow()->IsVisible();
2511 sal_Bool SAL_CALL
VCLXWindow::isActive( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2513 SolarMutexGuard aGuard
;
2515 return GetWindow()->IsActive();
2521 sal_Bool SAL_CALL
VCLXWindow::isEnabled( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2523 SolarMutexGuard aGuard
;
2525 return GetWindow()->IsEnabled();
2530 sal_Bool SAL_CALL
VCLXWindow::hasFocus( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2532 SolarMutexGuard aGuard
;
2534 return GetWindow()->HasFocus();
2539 // ::com::sun::star::beans::XPropertySetInfo
2541 UnoPropertyArrayHelper
*
2542 VCLXWindow::GetPropHelper()
2544 SolarMutexGuard aGuard
;
2545 if ( mpImpl
->mpPropHelper
== NULL
)
2547 std::list
< sal_uInt16
> aIDs
;
2548 GetPropertyIds( aIDs
);
2549 mpImpl
->mpPropHelper
= new UnoPropertyArrayHelper( aIDs
);
2551 return mpImpl
->mpPropHelper
;
2554 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::Property
> SAL_CALL
2555 VCLXWindow::getProperties() throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2557 return GetPropHelper()->getProperties();
2559 ::com::sun::star::beans::Property SAL_CALL
2560 VCLXWindow::getPropertyByName( const OUString
& rName
) throw (::com::sun::star::beans::UnknownPropertyException
, ::com::sun::star::uno::RuntimeException
, std::exception
)
2562 return GetPropHelper()->getPropertyByName( rName
);
2566 VCLXWindow::hasPropertyByName( const OUString
& rName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
2568 return GetPropHelper()->hasPropertyByName( rName
);
2571 Reference
< XStyleSettings
> SAL_CALL
VCLXWindow::getStyleSettings() throw (RuntimeException
, std::exception
)
2573 return mpImpl
->getStyleSettings();
2576 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */