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 .
23 #include <com/sun/star/awt/WindowEvent.hpp>
24 #include <com/sun/star/awt/KeyEvent.hpp>
25 #include <com/sun/star/awt/KeyModifier.hpp>
26 #include <com/sun/star/awt/MouseEvent.hpp>
27 #include <com/sun/star/awt/MouseButton.hpp>
28 #include <com/sun/star/awt/MouseWheelBehavior.hpp>
29 #include <com/sun/star/awt/XTopWindow.hpp>
30 #include <com/sun/star/awt/Style.hpp>
31 #include <com/sun/star/accessibility/AccessibleRole.hpp>
32 #include <com/sun/star/awt/DockingEvent.hpp>
33 #include <com/sun/star/awt/EndDockingEvent.hpp>
34 #include <com/sun/star/awt/EndPopupModeEvent.hpp>
35 #include <com/sun/star/awt/XWindowListener2.hpp>
36 #include <com/sun/star/style/VerticalAlignment.hpp>
37 #include <com/sun/star/lang/DisposedException.hpp>
38 #include <com/sun/star/text/WritingMode2.hpp>
39 #include <toolkit/awt/vclxwindow.hxx>
40 #include <toolkit/awt/vclxpointer.hxx>
41 #include <toolkit/awt/vclxwindows.hxx>
42 #include <toolkit/helper/macros.hxx>
43 #include <toolkit/helper/vclunohelper.hxx>
44 #include <toolkit/helper/convert.hxx>
45 #include <toolkit/helper/property.hxx>
46 #include <cppuhelper/typeprovider.hxx>
48 #include <rtl/ustrbuf.hxx>
49 #include <sal/log.hxx>
50 #include <vcl/svapp.hxx>
51 #include <vcl/window.hxx>
52 #include <tools/color.hxx>
53 #include <tools/fract.hxx>
54 #include <tools/debug.hxx>
55 #include <vcl/event.hxx>
56 #include <vcl/dockwin.hxx>
57 #include <vcl/pdfextoutdevdata.hxx>
58 #include <vcl/tabpage.hxx>
59 #include <vcl/button.hxx>
60 #include <vcl/settings.hxx>
61 #include <vcl/commandevent.hxx>
62 #include <comphelper/asyncnotification.hxx>
63 #include <comphelper/flagguard.hxx>
64 #include <comphelper/interfacecontainer2.hxx>
65 #include <comphelper/profilezone.hxx>
66 #include "stylesettings.hxx"
67 #include <tools/urlobj.hxx>
69 #include <helper/accessibilityclient.hxx>
70 #include <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::uno::RuntimeException
;
77 using ::com::sun::star::lang::EventObject
;
78 using ::com::sun::star::awt::XWindowListener2
;
79 using ::com::sun::star::awt::XDockableWindowListener
;
80 using ::com::sun::star::awt::XDevice
;
81 using ::com::sun::star::awt::XStyleSettings
;
82 using ::com::sun::star::lang::DisposedException
;
83 using ::com::sun::star::style::VerticalAlignment
;
84 using ::com::sun::star::style::VerticalAlignment_TOP
;
85 using ::com::sun::star::style::VerticalAlignment_MIDDLE
;
86 using ::com::sun::star::style::VerticalAlignment_BOTTOM
;
88 namespace WritingMode2
= ::com::sun::star::text::WritingMode2
;
96 typedef ::std::vector
< VCLXWindow::Callback
> CallbackArray
;
99 VCLXWindow
& mrAntiImpl
;
100 ::toolkit::AccessibilityClient maAccFactory
;
102 bool mbDrawingOntoParent
; // no bit mask, is passed around by reference
103 bool mbEnableVisible
;
104 bool mbDirectVisible
;
106 ::osl::Mutex maListenerContainerMutex
;
107 ::comphelper::OInterfaceContainerHelper2 maWindow2Listeners
;
108 ::comphelper::OInterfaceContainerHelper2 maDockableWindowListeners
;
109 EventListenerMultiplexer maEventListeners
;
110 FocusListenerMultiplexer maFocusListeners
;
111 WindowListenerMultiplexer maWindowListeners
;
112 KeyListenerMultiplexer maKeyListeners
;
113 MouseListenerMultiplexer maMouseListeners
;
114 MouseMotionListenerMultiplexer maMouseMotionListeners
;
115 PaintListenerMultiplexer maPaintListeners
;
116 VclContainerListenerMultiplexer maContainerListeners
;
117 TopWindowListenerMultiplexer maTopWindowListeners
;
119 CallbackArray maCallbackEvents
;
120 ImplSVEvent
* mnCallbackEventId
;
123 bool mbDisposing
: 1;
124 bool mbDesignMode
: 1;
125 bool mbSynthesizingVCLEvent
: 1;
126 bool const mbWithDefaultProps
: 1;
128 sal_uLong mnListenerLockLevel
;
129 sal_Int16 mnWritingMode
;
130 sal_Int16 mnContextWritingMode
;
132 std::unique_ptr
<UnoPropertyArrayHelper
>
135 css::uno::Reference
< css::accessibility::XAccessibleContext
>
137 css::uno::Reference
< css::awt::XGraphics
>
139 css::uno::Reference
< css::awt::XStyleSettings
>
140 mxWindowStyleSettings
;
143 bool& getDrawingOntoParent_ref() { return mbDrawingOntoParent
; }
148 the <type>VCLXWindow</type> instance which the object belongs to. Must
149 live longer then the object just being constructed.
151 VCLXWindowImpl( VCLXWindow
& _rAntiImpl
, bool _bWithDefaultProps
);
153 VCLXWindowImpl( const VCLXWindowImpl
& ) = delete;
154 const VCLXWindowImpl
& operator=(const VCLXWindowImpl
&) = delete;
156 /** synchronously mbEnableVisible
158 void setEnableVisible( bool bEnableVisible
) { mbEnableVisible
= bEnableVisible
; }
159 bool isEnableVisible() { return mbEnableVisible
; }
160 /** synchronously mbDirectVisible;
162 void setDirectVisible( bool bDirectVisible
) { mbDirectVisible
= bDirectVisible
; }
163 bool isDirectVisible() { return mbDirectVisible
; }
165 /** impl-version of VCLXWindow::ImplExecuteAsyncWithoutSolarLock
167 void callBackAsync( const VCLXWindow::Callback
& i_callback
);
169 /** notifies the object that its VCLXWindow is being disposed
173 ::toolkit::AccessibilityClient
& getAccessibleFactory()
178 Reference
< XStyleSettings
> getStyleSettings();
180 /** returns the container of registered XWindowListener2 listeners
182 ::comphelper::OInterfaceContainerHelper2
& getWindow2Listeners() { return maWindow2Listeners
; }
183 ::comphelper::OInterfaceContainerHelper2
& getDockableWindowListeners(){ return maDockableWindowListeners
; }
184 EventListenerMultiplexer
& getEventListeners() { return maEventListeners
; }
185 FocusListenerMultiplexer
& getFocusListeners() { return maFocusListeners
; }
186 WindowListenerMultiplexer
& getWindowListeners() { return maWindowListeners
; }
187 KeyListenerMultiplexer
& getKeyListeners() { return maKeyListeners
; }
188 MouseListenerMultiplexer
& getMouseListeners() { return maMouseListeners
; }
189 MouseMotionListenerMultiplexer
& getMouseMotionListeners() { return maMouseMotionListeners
; }
190 PaintListenerMultiplexer
& getPaintListeners() { return maPaintListeners
; }
191 VclContainerListenerMultiplexer
& getContainerListeners() { return maContainerListeners
; }
192 TopWindowListenerMultiplexer
& getTopWindowListeners() { return maTopWindowListeners
; }
195 DECL_LINK( OnProcessCallbacks
, void*, void );
199 VCLXWindowImpl::VCLXWindowImpl( VCLXWindow
& _rAntiImpl
, bool _bWithDefaultProps
)
200 :mrAntiImpl( _rAntiImpl
)
202 ,mbDrawingOntoParent( false )
203 ,mbEnableVisible(true)
204 ,mbDirectVisible(true)
205 ,maListenerContainerMutex( )
206 ,maWindow2Listeners( maListenerContainerMutex
)
207 ,maDockableWindowListeners( maListenerContainerMutex
)
208 ,maEventListeners( _rAntiImpl
)
209 ,maFocusListeners( _rAntiImpl
)
210 ,maWindowListeners( _rAntiImpl
)
211 ,maKeyListeners( _rAntiImpl
)
212 ,maMouseListeners( _rAntiImpl
)
213 ,maMouseMotionListeners( _rAntiImpl
)
214 ,maPaintListeners( _rAntiImpl
)
215 ,maContainerListeners( _rAntiImpl
)
216 ,maTopWindowListeners( _rAntiImpl
)
217 ,mnCallbackEventId( nullptr )
218 ,mbDisposing( false )
219 ,mbDesignMode( false )
220 ,mbSynthesizingVCLEvent( false )
221 ,mbWithDefaultProps( _bWithDefaultProps
)
222 ,mnListenerLockLevel( 0 )
223 ,mnWritingMode( WritingMode2::CONTEXT
)
224 ,mnContextWritingMode( WritingMode2::CONTEXT
)
228 void VCLXWindowImpl::disposing()
230 SolarMutexGuard aGuard
;
231 if ( mnCallbackEventId
)
232 Application::RemoveUserEvent( mnCallbackEventId
);
233 mnCallbackEventId
= nullptr;
237 css::lang::EventObject aEvent
;
238 aEvent
.Source
= mrAntiImpl
;
240 maDockableWindowListeners
.disposeAndClear( aEvent
);
241 maEventListeners
.disposeAndClear( aEvent
);
242 maFocusListeners
.disposeAndClear( aEvent
);
243 maWindowListeners
.disposeAndClear( aEvent
);
244 maKeyListeners
.disposeAndClear( aEvent
);
245 maMouseListeners
.disposeAndClear( aEvent
);
246 maMouseMotionListeners
.disposeAndClear( aEvent
);
247 maPaintListeners
.disposeAndClear( aEvent
);
248 maContainerListeners
.disposeAndClear( aEvent
);
249 maTopWindowListeners
.disposeAndClear( aEvent
);
251 ::toolkit::WindowStyleSettings
* pStyleSettings
= static_cast< ::toolkit::WindowStyleSettings
* >( mxWindowStyleSettings
.get() );
252 if ( pStyleSettings
!= nullptr )
253 pStyleSettings
->dispose();
254 mxWindowStyleSettings
.clear();
258 void VCLXWindowImpl::callBackAsync( const VCLXWindow::Callback
& i_callback
)
260 DBG_TESTSOLARMUTEX();
261 maCallbackEvents
.push_back( i_callback
);
262 if ( !mnCallbackEventId
)
264 // ensure our VCLXWindow is not destroyed while the event is underway
265 mrAntiImpl
.acquire();
266 mnCallbackEventId
= Application::PostUserEvent( LINK( this, VCLXWindowImpl
, OnProcessCallbacks
) );
271 IMPL_LINK_NOARG(VCLXWindowImpl
, OnProcessCallbacks
, void*, void)
273 const Reference
< uno::XInterface
> xKeepAlive( mrAntiImpl
);
275 SAL_INFO("toolkit.controls", "OnProcessCallbacks grabbing solarmutex");
277 // work on a copy of the callback array
278 CallbackArray aCallbacksCopy
;
280 SolarMutexGuard aGuard
;
281 aCallbacksCopy
= maCallbackEvents
;
282 maCallbackEvents
.clear();
284 // we acquired our VCLXWindow once before posting the event, release this one ref now
285 mrAntiImpl
.release();
287 if ( !mnCallbackEventId
)
288 // we were disposed while waiting for the mutex to lock
291 mnCallbackEventId
= nullptr;
295 SAL_INFO("toolkit.controls", "OnProcessCallbacks relinquished solarmutex");
296 SolarMutexReleaser aReleaseSolar
;
297 for (const auto& rCallback
: aCallbacksCopy
)
304 Reference
< XStyleSettings
> VCLXWindowImpl::getStyleSettings()
306 SolarMutexGuard aGuard
;
308 throw DisposedException( OUString(), mrAntiImpl
);
309 if ( !mxWindowStyleSettings
.is() )
310 mxWindowStyleSettings
= new ::toolkit::WindowStyleSettings( maListenerContainerMutex
, mrAntiImpl
);
311 return mxWindowStyleSettings
;
315 // Uses an out-parameter instead of return value, due to the object reference
317 static void ImplInitWindowEvent( css::awt::WindowEvent
& rEvent
, vcl::Window
const * pWindow
)
319 Point aPos
= pWindow
->GetPosPixel();
320 Size aSz
= pWindow
->GetSizePixel();
325 rEvent
.Width
= aSz
.Width();
326 rEvent
.Height
= aSz
.Height();
328 pWindow
->GetBorder( rEvent
.LeftInset
, rEvent
.TopInset
, rEvent
.RightInset
, rEvent
.BottomInset
);
331 VCLXWindow::VCLXWindow( bool _bWithDefaultProps
)
333 mpImpl
.reset( new VCLXWindowImpl( *this, _bWithDefaultProps
) );
336 VCLXWindow::~VCLXWindow()
342 GetWindow()->RemoveEventListener( LINK( this, VCLXWindow
, WindowEventListener
) );
343 GetWindow()->SetWindowPeer( nullptr, nullptr );
344 GetWindow()->SetAccessible( nullptr );
349 void VCLXWindow::ImplExecuteAsyncWithoutSolarLock( const Callback
& i_callback
)
351 mpImpl
->callBackAsync( i_callback
);
355 ::toolkit::IAccessibleFactory
& VCLXWindow::getAccessibleFactory()
357 return mpImpl
->getAccessibleFactory().getFactory();
360 void VCLXWindow::SetWindow( const VclPtr
<vcl::Window
> &pWindow
)
364 GetWindow()->RemoveEventListener( LINK( this, VCLXWindow
, WindowEventListener
) );
365 // GetWindow()->DbgAssertNoEventListeners();
368 SetOutputDevice( pWindow
);
372 GetWindow()->AddEventListener( LINK( this, VCLXWindow
, WindowEventListener
) );
373 bool bDirectVisible
= pWindow
&& pWindow
->IsVisible();
374 mpImpl
->setDirectVisible( bDirectVisible
);
378 void VCLXWindow::suspendVclEventListening( )
380 ++mpImpl
->mnListenerLockLevel
;
383 void VCLXWindow::resumeVclEventListening( )
385 DBG_ASSERT( mpImpl
->mnListenerLockLevel
, "VCLXWindow::resumeVclEventListening: not suspended!" );
386 --mpImpl
->mnListenerLockLevel
;
389 void VCLXWindow::notifyWindowRemoved( vcl::Window
const & _rWindow
)
391 if ( mpImpl
->getContainerListeners().getLength() )
393 awt::VclContainerEvent aEvent
;
394 aEvent
.Source
= *this;
395 aEvent
.Child
= static_cast< XWindow
* >( _rWindow
.GetWindowPeer() );
396 mpImpl
->getContainerListeners().windowRemoved( aEvent
);
400 IMPL_LINK( VCLXWindow
, WindowEventListener
, VclWindowEvent
&, rEvent
, void )
402 if ( mpImpl
->mnListenerLockLevel
)
405 DBG_ASSERT( rEvent
.GetWindow() && GetWindow(), "Window???" );
406 ProcessWindowEvent( rEvent
);
411 struct CallWindow2Listener
413 CallWindow2Listener( ::comphelper::OInterfaceContainerHelper2
& i_rWindow2Listeners
, const bool i_bEnabled
, const EventObject
& i_rEvent
)
414 :m_rWindow2Listeners( i_rWindow2Listeners
)
415 ,m_bEnabled( i_bEnabled
)
416 ,m_aEvent( i_rEvent
)
422 m_rWindow2Listeners
.notifyEach( m_bEnabled
? &XWindowListener2::windowEnabled
: &XWindowListener2::windowDisabled
, m_aEvent
);
425 ::comphelper::OInterfaceContainerHelper2
& m_rWindow2Listeners
;
426 const bool m_bEnabled
;
427 const EventObject m_aEvent
;
431 void VCLXWindow::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
433 css::uno::Reference
< css::uno::XInterface
> xThis( static_cast<cppu::OWeakObject
*>(this) );
435 switch ( rVclWindowEvent
.GetId() )
437 case VclEventId::WindowEnabled
:
438 case VclEventId::WindowDisabled
:
440 Callback aCallback
= CallWindow2Listener(
441 mpImpl
->getWindow2Listeners(),
442 ( VclEventId::WindowEnabled
== rVclWindowEvent
.GetId() ),
445 ImplExecuteAsyncWithoutSolarLock( aCallback
);
449 case VclEventId::WindowPaint
:
451 if ( mpImpl
->getPaintListeners().getLength() )
453 css::awt::PaintEvent aEvent
;
454 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
455 aEvent
.UpdateRect
= AWTRectangle( *static_cast<tools::Rectangle
*>(rVclWindowEvent
.GetData()) );
457 mpImpl
->getPaintListeners().windowPaint( aEvent
);
461 case VclEventId::WindowMove
:
463 if ( mpImpl
->getWindowListeners().getLength() )
465 css::awt::WindowEvent aEvent
;
466 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
467 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
468 mpImpl
->getWindowListeners().windowMoved( aEvent
);
472 case VclEventId::WindowResize
:
474 if ( mpImpl
->getWindowListeners().getLength() )
476 css::awt::WindowEvent aEvent
;
477 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
478 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
479 mpImpl
->getWindowListeners().windowResized( aEvent
);
483 case VclEventId::WindowShow
:
485 if ( mpImpl
->getWindowListeners().getLength() )
487 css::awt::WindowEvent aEvent
;
488 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
489 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
490 mpImpl
->getWindowListeners().windowShown( aEvent
);
493 // For TopWindows this means opened...
494 if ( mpImpl
->getTopWindowListeners().getLength() )
496 css::lang::EventObject aEvent
;
497 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
498 mpImpl
->getTopWindowListeners().windowOpened( aEvent
);
502 case VclEventId::WindowHide
:
504 if ( mpImpl
->getWindowListeners().getLength() )
506 css::awt::WindowEvent aEvent
;
507 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
508 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
509 mpImpl
->getWindowListeners().windowHidden( aEvent
);
512 // For TopWindows this means closed...
513 if ( mpImpl
->getTopWindowListeners().getLength() )
515 css::lang::EventObject aEvent
;
516 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
517 mpImpl
->getTopWindowListeners().windowClosed( aEvent
);
521 case VclEventId::WindowActivate
:
522 case VclEventId::WindowDeactivate
:
524 if (!mpImpl
->getTopWindowListeners().getLength())
527 // Suppress events which are unlikely to be interesting to our listeners.
528 vcl::Window
* pWin
= static_cast<vcl::Window
*>(rVclWindowEvent
.GetData());
529 bool bSuppress
= false;
533 // Either the event came from the same window, from its
534 // child, or from a child of its border window (e.g.
535 // menubar or notebookbar).
536 if (pWin
->GetWindow(GetWindowType::Client
) == GetWindow())
539 if (pWin
->IsMenuFloatingWindow())
542 if (pWin
->GetType() == WindowType::FLOATINGWINDOW
&&
543 static_cast<FloatingWindow
*>(pWin
)->IsInPopupMode())
546 // Otherwise, don't suppress if the event came from a different frame.
547 if (!bSuppress
&& pWin
->GetWindow(GetWindowType::Frame
) == pWin
)
550 pWin
= pWin
->GetWindow(GetWindowType::RealParent
);
553 css::lang::EventObject aEvent
;
554 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
555 if (rVclWindowEvent
.GetId() == VclEventId::WindowActivate
)
556 mpImpl
->getTopWindowListeners().windowActivated( aEvent
);
558 mpImpl
->getTopWindowListeners().windowDeactivated( aEvent
);
561 case VclEventId::WindowClose
:
563 if ( mpImpl
->getDockableWindowListeners().getLength() )
565 css::lang::EventObject aEvent
;
566 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
567 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::closed
, aEvent
);
569 if ( mpImpl
->getTopWindowListeners().getLength() )
571 css::lang::EventObject aEvent
;
572 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
573 mpImpl
->getTopWindowListeners().windowClosing( aEvent
);
577 case VclEventId::ControlGetFocus
:
578 case VclEventId::WindowGetFocus
:
580 if ( ( rVclWindowEvent
.GetWindow()->IsCompoundControl()
581 && rVclWindowEvent
.GetId() == VclEventId::ControlGetFocus
583 || ( !rVclWindowEvent
.GetWindow()->IsCompoundControl()
584 && rVclWindowEvent
.GetId() == VclEventId::WindowGetFocus
588 if ( mpImpl
->getFocusListeners().getLength() )
590 css::awt::FocusEvent aEvent
;
591 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
592 aEvent
.FocusFlags
= static_cast<sal_Int16
>(rVclWindowEvent
.GetWindow()->GetGetFocusFlags());
593 aEvent
.Temporary
= false;
594 mpImpl
->getFocusListeners().focusGained( aEvent
);
599 case VclEventId::ControlLoseFocus
:
600 case VclEventId::WindowLoseFocus
:
602 if ( ( rVclWindowEvent
.GetWindow()->IsCompoundControl()
603 && rVclWindowEvent
.GetId() == VclEventId::ControlLoseFocus
605 || ( !rVclWindowEvent
.GetWindow()->IsCompoundControl()
606 && rVclWindowEvent
.GetId() == VclEventId::WindowLoseFocus
610 if ( mpImpl
->getFocusListeners().getLength() )
612 css::awt::FocusEvent aEvent
;
613 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
614 aEvent
.FocusFlags
= static_cast<sal_Int16
>(rVclWindowEvent
.GetWindow()->GetGetFocusFlags());
615 aEvent
.Temporary
= false;
617 vcl::Window
* pNext
= Application::GetFocusWindow();
620 // Don't care about internals if this control is compound
621 vcl::Window
* pNextC
= pNext
;
622 while ( pNextC
&& !pNextC
->IsCompoundControl() )
623 pNextC
= pNextC
->GetParent();
627 pNext
->GetComponentInterface();
628 aEvent
.NextFocus
= static_cast<cppu::OWeakObject
*>(pNext
->GetWindowPeer());
630 mpImpl
->getFocusListeners().focusLost( aEvent
);
635 case VclEventId::WindowMinimize
:
637 if ( mpImpl
->getTopWindowListeners().getLength() )
639 css::lang::EventObject aEvent
;
640 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
641 mpImpl
->getTopWindowListeners().windowMinimized( aEvent
);
645 case VclEventId::WindowNormalize
:
647 if ( mpImpl
->getTopWindowListeners().getLength() )
649 css::lang::EventObject aEvent
;
650 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
651 mpImpl
->getTopWindowListeners().windowNormalized( aEvent
);
655 case VclEventId::WindowKeyInput
:
656 case VclEventId::WindowKeyUp
:
658 VclPtr
<vcl::Window
> pWin
= GetWindow();
661 VCLXWindow
* pXWindow
= pWin
->GetWindowPeer();
662 if (!pXWindow
|| pXWindow
->mpImpl
->getKeyListeners().getLength() == 0)
664 pWin
= pWin
->GetWindow(GetWindowType::RealParent
);
668 awt::KeyEvent
aEvent(VCLUnoHelper::createKeyEvent(
669 *static_cast<KeyEvent
*>(rVclWindowEvent
.GetData()), *this));
670 if (rVclWindowEvent
.GetId() == VclEventId::WindowKeyInput
)
671 pXWindow
->mpImpl
->getKeyListeners().keyPressed(aEvent
);
673 pXWindow
->mpImpl
->getKeyListeners().keyReleased(aEvent
);
675 // Next window (parent)
676 pWin
= pWin
->GetWindow(GetWindowType::RealParent
);
680 case VclEventId::WindowCommand
:
682 CommandEvent
* pCmdEvt
= static_cast<CommandEvent
*>(rVclWindowEvent
.GetData());
683 if ( mpImpl
->getMouseListeners().getLength() && ( pCmdEvt
->GetCommand() == CommandEventId::ContextMenu
) )
685 // CommandEventId::ContextMenu: send as mousePressed with PopupTrigger = true ...
686 Point aWhere
= static_cast< CommandEvent
* >( rVclWindowEvent
.GetData() )->GetMousePosPixel();
687 if ( !pCmdEvt
->IsMouseEvent() )
688 { // for keyboard events, we set the coordinates to -1,-1. This is a slight HACK, but the current API
689 // handles a context menu command as special case of a mouse event, which is simply wrong.
690 // Without extending the API, we would not have another chance to notify listeners of a
691 // keyboard-triggered context menu request
692 aWhere
= Point( -1, -1 );
695 MouseEvent
aMEvt( aWhere
, 1, MouseEventModifiers::SIMPLECLICK
, MOUSE_LEFT
, 0 );
696 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( aMEvt
, *this ) );
697 aEvent
.PopupTrigger
= true;
699 Callback aCallback
= [ this, aEvent
]()
700 { this->mpImpl
->getMouseListeners().mousePressed( aEvent
); };
702 ImplExecuteAsyncWithoutSolarLock( aCallback
);
706 case VclEventId::WindowMouseMove
:
708 MouseEvent
* pMouseEvt
= static_cast<MouseEvent
*>(rVclWindowEvent
.GetData());
709 VclPtr
<vcl::Window
> pWin
= GetWindow();
712 VCLXWindow
* pXWindow
= pWin
->GetWindowPeer();
713 if (!pXWindow
|| pXWindow
->mpImpl
->getMouseListeners().getLength() == 0)
715 pWin
= pWin
->GetWindow(GetWindowType::RealParent
);
718 awt::MouseEvent
aEvent(VCLUnoHelper::createMouseEvent(*pMouseEvt
, *pXWindow
));
720 if (pMouseEvt
->IsEnterWindow() || pMouseEvt
->IsLeaveWindow())
722 bool const isEnter(pMouseEvt
->IsEnterWindow());
723 Callback aCallback
= [pXWindow
, isEnter
, aEvent
]() {
724 isEnter
? pXWindow
->mpImpl
->getMouseListeners().mouseEntered(aEvent
)
725 : pXWindow
->mpImpl
->getMouseListeners().mouseExited(aEvent
);
727 ImplExecuteAsyncWithoutSolarLock(aCallback
);
731 aEvent
.ClickCount
= 0;
732 MouseMotionListenerMultiplexer
& rMouseListeners
733 = pXWindow
->mpImpl
->getMouseMotionListeners();
734 if (pMouseEvt
->GetMode() & MouseEventModifiers::SIMPLEMOVE
)
735 rMouseListeners
.mouseMoved(aEvent
);
737 rMouseListeners
.mouseDragged(aEvent
);
740 // Next window (parent)
741 pWin
= pWin
->GetWindow(GetWindowType::RealParent
);
745 case VclEventId::WindowMouseButtonDown
:
746 case VclEventId::WindowMouseButtonUp
:
748 VclPtr
<vcl::Window
> pWin
= GetWindow();
751 VCLXWindow
* pXWindow
= pWin
->GetWindowPeer();
752 if (!pXWindow
|| pXWindow
->mpImpl
->getMouseListeners().getLength() == 0)
754 pWin
= pWin
->GetWindow(GetWindowType::RealParent
);
757 MouseEvent
* pMouseEvt
= static_cast<MouseEvent
*>(rVclWindowEvent
.GetData());
758 awt::MouseEvent
aEvent(VCLUnoHelper::createMouseEvent(*pMouseEvt
, *pXWindow
));
759 VclEventId eventId
= rVclWindowEvent
.GetId();
760 Callback aCallback
= [pXWindow
, aEvent
, eventId
]() {
761 eventId
== VclEventId::WindowMouseButtonDown
762 ? pXWindow
->mpImpl
->getMouseListeners().mousePressed(aEvent
)
763 : pXWindow
->mpImpl
->getMouseListeners().mouseReleased(aEvent
);
765 ImplExecuteAsyncWithoutSolarLock(aCallback
);
767 // Next window (parent)
768 pWin
= pWin
->GetWindow(GetWindowType::RealParent
);
772 case VclEventId::WindowStartDocking
:
774 if ( mpImpl
->getDockableWindowListeners().getLength() )
776 DockingData
*pData
= static_cast<DockingData
*>(rVclWindowEvent
.GetData());
780 css::awt::DockingEvent aEvent
;
781 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
782 aEvent
.TrackingRectangle
= AWTRectangle( pData
->maTrackRect
);
783 aEvent
.MousePos
.X
= pData
->maMousePos
.X();
784 aEvent
.MousePos
.Y
= pData
->maMousePos
.Y();
785 aEvent
.bLiveMode
= false;
786 aEvent
.bInteractive
= true;
788 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::startDocking
, aEvent
);
793 case VclEventId::WindowDocking
:
795 if ( mpImpl
->getDockableWindowListeners().getLength() )
797 DockingData
*pData
= static_cast<DockingData
*>(rVclWindowEvent
.GetData());
801 css::awt::DockingEvent aEvent
;
802 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
803 aEvent
.TrackingRectangle
= AWTRectangle( pData
->maTrackRect
);
804 aEvent
.MousePos
.X
= pData
->maMousePos
.X();
805 aEvent
.MousePos
.Y
= pData
->maMousePos
.Y();
806 aEvent
.bLiveMode
= false;
807 aEvent
.bInteractive
= true;
809 Reference
< XDockableWindowListener
> xFirstListener
;
810 ::comphelper::OInterfaceIteratorHelper2
aIter( mpImpl
->getDockableWindowListeners() );
811 while ( aIter
.hasMoreElements() && !xFirstListener
.is() )
813 xFirstListener
.set( aIter
.next(), UNO_QUERY
);
816 css::awt::DockingData aDockingData
=
817 xFirstListener
->docking( aEvent
);
818 pData
->maTrackRect
= VCLRectangle( aDockingData
.TrackingRectangle
);
819 pData
->mbFloating
= aDockingData
.bFloating
;
824 case VclEventId::WindowEndDocking
:
826 if ( mpImpl
->getDockableWindowListeners().getLength() )
828 EndDockingData
*pData
= static_cast<EndDockingData
*>(rVclWindowEvent
.GetData());
832 css::awt::EndDockingEvent aEvent
;
833 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
834 aEvent
.WindowRectangle
= AWTRectangle( pData
->maWindowRect
);
835 aEvent
.bFloating
= pData
->mbFloating
;
836 aEvent
.bCancelled
= pData
->mbCancelled
;
837 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endDocking
, aEvent
);
842 case VclEventId::WindowPrepareToggleFloating
:
844 if ( mpImpl
->getDockableWindowListeners().getLength() )
846 sal_Bool
*p_bFloating
= static_cast<sal_Bool
*>(rVclWindowEvent
.GetData());
848 css::lang::EventObject aEvent
;
849 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
851 Reference
< XDockableWindowListener
> xFirstListener
;
852 ::comphelper::OInterfaceIteratorHelper2
aIter( mpImpl
->getDockableWindowListeners() );
853 while ( aIter
.hasMoreElements() && !xFirstListener
.is() )
855 xFirstListener
.set( aIter
.next(), UNO_QUERY
);
858 *p_bFloating
= xFirstListener
->prepareToggleFloatingMode( aEvent
);
862 case VclEventId::WindowToggleFloating
:
864 if ( mpImpl
->getDockableWindowListeners().getLength() )
866 css::lang::EventObject aEvent
;
867 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
868 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::toggleFloatingMode
, aEvent
);
872 case VclEventId::WindowEndPopupMode
:
874 if ( mpImpl
->getDockableWindowListeners().getLength() )
876 EndPopupModeData
*pData
= static_cast<EndPopupModeData
*>(rVclWindowEvent
.GetData());
880 css::awt::EndPopupModeEvent aEvent
;
881 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
882 aEvent
.FloatingPosition
.X
= pData
->maFloatingPos
.X();
883 aEvent
.FloatingPosition
.Y
= pData
->maFloatingPos
.Y();
884 aEvent
.bTearoff
= pData
->mbTearoff
;
885 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endPopupMode
, aEvent
);
894 uno::Reference
< accessibility::XAccessibleContext
> VCLXWindow::CreateAccessibleContext()
896 SolarMutexGuard aGuard
;
897 return getAccessibleFactory().createAccessibleContext( this );
900 void VCLXWindow::SetSynthesizingVCLEvent( bool _b
)
902 mpImpl
->mbSynthesizingVCLEvent
= _b
;
905 bool VCLXWindow::IsSynthesizingVCLEvent() const
907 return mpImpl
->mbSynthesizingVCLEvent
;
910 Size
VCLXWindow::ImplCalcWindowSize( const Size
& rOutSz
) const
914 VclPtr
<vcl::Window
> pWindow
= GetWindow();
917 sal_Int32 nLeft
, nTop
, nRight
, nBottom
;
918 pWindow
->GetBorder( nLeft
, nTop
, nRight
, nBottom
);
919 aSz
.AdjustWidth(nLeft
+nRight
);
920 aSz
.AdjustHeight(nTop
+nBottom
);
926 // css::lang::XUnoTunnel
927 sal_Int64
VCLXWindow::getSomething( const css::uno::Sequence
< sal_Int8
>& rIdentifier
)
929 if( ( rIdentifier
.getLength() == 16 ) && ( 0 == memcmp( VCLXWindow::GetUnoTunnelId().getConstArray(), rIdentifier
.getConstArray(), 16 ) ) )
931 return sal::static_int_cast
< sal_Int64
>(reinterpret_cast< sal_IntPtr
>(this));
933 return VCLXDevice::getSomething( rIdentifier
);
937 class theVCLXWindowUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theVCLXWindowUnoTunnelId
> {};
939 const css::uno::Sequence
< sal_Int8
>& VCLXWindow::GetUnoTunnelId() throw()
941 return theVCLXWindowUnoTunnelId::get().getSeq();
943 VCLXWindow
* VCLXWindow::GetImplementation( const css::uno::Reference
< css::uno::XInterface
>& rxIFace
)
945 css::uno::Reference
< css::lang::XUnoTunnel
> xUT( rxIFace
, css::uno::UNO_QUERY
);
946 return xUT
.is() ? reinterpret_cast<VCLXWindow
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething( VCLXWindow::GetUnoTunnelId() ))) : nullptr;
950 // css::lang::Component
951 void VCLXWindow::dispose( )
953 SolarMutexGuard aGuard
;
955 mpImpl
->mxViewGraphics
= nullptr;
957 if ( !mpImpl
->mbDisposing
)
959 mpImpl
->mbDisposing
= true;
965 VclPtr
<OutputDevice
> pOutDev
= GetOutputDevice();
966 SetWindow( nullptr ); // so that handlers are logged off, if necessary (virtual)
967 SetOutputDevice( nullptr );
968 pOutDev
.disposeAndClear();
971 // #i14103# dispose the accessible context after the window has been destroyed,
972 // otherwise the old value in the child event fired in VCLXAccessibleComponent::ProcessWindowEvent()
973 // for VclEventId::WindowChildDestroyed contains a reference to an already disposed accessible object
976 css::uno::Reference
< css::lang::XComponent
> xComponent( mpImpl
->mxAccessibleContext
, css::uno::UNO_QUERY
);
977 if ( xComponent
.is() )
978 xComponent
->dispose();
980 catch ( const css::uno::Exception
& )
982 OSL_FAIL( "VCLXWindow::dispose: could not dispose the accessible context!" );
984 mpImpl
->mxAccessibleContext
.clear();
986 mpImpl
->mbDisposing
= false;
990 void VCLXWindow::addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
)
992 SolarMutexGuard aGuard
;
994 mpImpl
->getEventListeners().addInterface( rxListener
);
997 void VCLXWindow::removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
)
999 SolarMutexGuard aGuard
;
1001 mpImpl
->getEventListeners().removeInterface( rxListener
);
1005 // css::awt::XWindow
1006 void VCLXWindow::setPosSize( sal_Int32 X
, sal_Int32 Y
, sal_Int32 Width
, sal_Int32 Height
, sal_Int16 Flags
)
1008 SolarMutexGuard aGuard
;
1009 comphelper::ProfileZone
aZone("setPosSize");
1013 if( vcl::Window::GetDockingManager()->IsDockable( GetWindow() ) )
1014 vcl::Window::GetDockingManager()->SetPosSizePixel( GetWindow() , X
, Y
, Width
, Height
, static_cast<PosSizeFlags
>(Flags
) );
1016 GetWindow()->setPosSizePixel( X
, Y
, Width
, Height
, static_cast<PosSizeFlags
>(Flags
) );
1020 css::awt::Rectangle
VCLXWindow::getPosSize( )
1022 SolarMutexGuard aGuard
;
1024 css::awt::Rectangle aBounds
;
1027 if( vcl::Window::GetDockingManager()->IsDockable( GetWindow() ) )
1028 aBounds
= AWTRectangle( vcl::Window::GetDockingManager()->GetPosSizePixel( GetWindow() ) );
1030 aBounds
= AWTRectangle( tools::Rectangle( GetWindow()->GetPosPixel(), GetWindow()->GetSizePixel() ) );
1036 void VCLXWindow::setVisible( sal_Bool bVisible
)
1038 SolarMutexGuard aGuard
;
1040 VclPtr
<vcl::Window
> pWindow
= GetWindow();
1043 mpImpl
->setDirectVisible( bVisible
);
1044 pWindow
->Show( bVisible
&& mpImpl
->isEnableVisible() );
1048 void VCLXWindow::setEnable( sal_Bool bEnable
)
1050 SolarMutexGuard aGuard
;
1052 VclPtr
<vcl::Window
> pWindow
= GetWindow();
1055 pWindow
->Enable( bEnable
, false ); // #95824# without children!
1056 pWindow
->EnableInput( bEnable
);
1060 void VCLXWindow::setFocus( )
1062 SolarMutexGuard aGuard
;
1065 GetWindow()->GrabFocus();
1068 void VCLXWindow::addWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& rxListener
)
1070 SolarMutexGuard aGuard
;
1072 mpImpl
->getWindowListeners().addInterface( rxListener
);
1074 Reference
< XWindowListener2
> xListener2( rxListener
, UNO_QUERY
);
1075 if ( xListener2
.is() )
1076 mpImpl
->getWindow2Listeners().addInterface( xListener2
);
1078 // #100119# Get all resize events, even if height or width 0, or invisible
1080 GetWindow()->EnableAllResize();
1083 void VCLXWindow::removeWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& rxListener
)
1085 SolarMutexGuard aGuard
;
1087 Reference
< XWindowListener2
> xListener2( rxListener
, UNO_QUERY
);
1088 if ( xListener2
.is() )
1089 mpImpl
->getWindow2Listeners().removeInterface( xListener2
);
1091 mpImpl
->getWindowListeners().removeInterface( rxListener
);
1094 void VCLXWindow::addFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& rxListener
)
1096 SolarMutexGuard aGuard
;
1097 mpImpl
->getFocusListeners().addInterface( rxListener
);
1100 void VCLXWindow::removeFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& rxListener
)
1102 SolarMutexGuard aGuard
;
1103 mpImpl
->getFocusListeners().removeInterface( rxListener
);
1106 void VCLXWindow::addKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& rxListener
)
1108 SolarMutexGuard aGuard
;
1109 mpImpl
->getKeyListeners().addInterface( rxListener
);
1112 void VCLXWindow::removeKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& rxListener
)
1114 SolarMutexGuard aGuard
;
1115 mpImpl
->getKeyListeners().removeInterface( rxListener
);
1118 void VCLXWindow::addMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& rxListener
)
1120 SolarMutexGuard aGuard
;
1121 mpImpl
->getMouseListeners().addInterface( rxListener
);
1124 void VCLXWindow::removeMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& rxListener
)
1126 SolarMutexGuard aGuard
;
1127 mpImpl
->getMouseListeners().removeInterface( rxListener
);
1130 void VCLXWindow::addMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& rxListener
)
1132 SolarMutexGuard aGuard
;
1133 mpImpl
->getMouseMotionListeners().addInterface( rxListener
);
1136 void VCLXWindow::removeMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& rxListener
)
1138 SolarMutexGuard aGuard
;
1139 mpImpl
->getMouseMotionListeners().removeInterface( rxListener
);
1142 void VCLXWindow::addPaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& rxListener
)
1144 SolarMutexGuard aGuard
;
1145 mpImpl
->getPaintListeners().addInterface( rxListener
);
1148 void VCLXWindow::removePaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& rxListener
)
1150 SolarMutexGuard aGuard
;
1151 mpImpl
->getPaintListeners().removeInterface( rxListener
);
1154 // css::awt::XWindowPeer
1155 css::uno::Reference
< css::awt::XToolkit
> VCLXWindow::getToolkit( )
1157 // no guard. nothing to guard here.
1158 // 82463 - 12/21/00 - fs
1159 return Application::GetVCLToolkit();
1162 void VCLXWindow::setPointer( const css::uno::Reference
< css::awt::XPointer
>& rxPointer
)
1164 SolarMutexGuard aGuard
;
1166 VCLXPointer
* pPointer
= VCLXPointer::GetImplementation( rxPointer
);
1167 if ( pPointer
&& GetWindow() )
1168 GetWindow()->SetPointer( pPointer
->GetPointer() );
1171 void VCLXWindow::setBackground( sal_Int32 nColor
)
1173 SolarMutexGuard aGuard
;
1177 Color
aColor(nColor
);
1178 GetWindow()->SetBackground( aColor
);
1179 GetWindow()->SetControlBackground( aColor
);
1181 WindowType eWinType
= GetWindow()->GetType();
1182 if ( ( eWinType
== WindowType::WINDOW
) ||
1183 ( eWinType
== WindowType::WORKWINDOW
) ||
1184 ( eWinType
== WindowType::FLOATINGWINDOW
) )
1186 GetWindow()->Invalidate();
1191 void VCLXWindow::invalidate( sal_Int16 nInvalidateFlags
)
1193 SolarMutexGuard aGuard
;
1196 GetWindow()->Invalidate( static_cast<InvalidateFlags
>(nInvalidateFlags
) );
1199 void VCLXWindow::invalidateRect( const css::awt::Rectangle
& rRect
, sal_Int16 nInvalidateFlags
)
1201 SolarMutexGuard aGuard
;
1204 GetWindow()->Invalidate( VCLRectangle(rRect
), static_cast<InvalidateFlags
>(nInvalidateFlags
) );
1208 // css::awt::XVclWindowPeer
1209 sal_Bool
VCLXWindow::isChild( const css::uno::Reference
< css::awt::XWindowPeer
>& rxPeer
)
1211 SolarMutexGuard aGuard
;
1213 bool bIsChild
= false;
1214 VclPtr
<vcl::Window
> pWindow
= GetWindow();
1217 VclPtr
<vcl::Window
> pPeerWindow
= VCLUnoHelper::GetWindow( rxPeer
);
1218 bIsChild
= pPeerWindow
&& pWindow
->IsChild( pPeerWindow
);
1224 void VCLXWindow::setDesignMode( sal_Bool bOn
)
1226 SolarMutexGuard aGuard
;
1228 mpImpl
->mbDesignMode
= bOn
;
1231 sal_Bool
VCLXWindow::isDesignMode( )
1233 SolarMutexGuard aGuard
;
1234 return mpImpl
->mbDesignMode
;
1237 void VCLXWindow::enableClipSiblings( sal_Bool bClip
)
1239 SolarMutexGuard aGuard
;
1242 GetWindow()->EnableClipSiblings( bClip
);
1245 void VCLXWindow::setForeground( sal_Int32 nColor
)
1247 SolarMutexGuard aGuard
;
1251 GetWindow()->SetControlForeground( Color(nColor
) );
1255 void VCLXWindow::setControlFont( const css::awt::FontDescriptor
& rFont
)
1257 SolarMutexGuard aGuard
;
1260 GetWindow()->SetControlFont( VCLUnoHelper::CreateFont( rFont
, GetWindow()->GetControlFont() ) );
1263 void VCLXWindow::getStyles( sal_Int16 nType
, css::awt::FontDescriptor
& Font
, sal_Int32
& ForegroundColor
, sal_Int32
& BackgroundColor
)
1265 SolarMutexGuard aGuard
;
1269 const StyleSettings
& rStyleSettings
= GetWindow()->GetSettings().GetStyleSettings();
1273 case css::awt::Style::FRAME
:
1275 Font
= VCLUnoHelper::CreateFontDescriptor( rStyleSettings
.GetAppFont() );
1276 ForegroundColor
= sal_Int32(rStyleSettings
.GetWindowTextColor());
1277 BackgroundColor
= sal_Int32(rStyleSettings
.GetWindowColor());
1280 case css::awt::Style::DIALOG
:
1282 Font
= VCLUnoHelper::CreateFontDescriptor( rStyleSettings
.GetAppFont() );
1283 ForegroundColor
= sal_Int32(rStyleSettings
.GetDialogTextColor());
1284 BackgroundColor
= sal_Int32(rStyleSettings
.GetDialogColor());
1287 default: OSL_FAIL( "VCLWindow::getStyles() - unknown Type" );
1295 static void setColorSettings( vcl::Window
* _pWindow
, const css::uno::Any
& _rValue
,
1296 void (StyleSettings::*pSetter
)( const Color
& ), const Color
& (StyleSettings::*pGetter
)( ) const )
1298 sal_Int32 nColor
= 0;
1299 if ( !( _rValue
>>= nColor
) )
1300 nColor
= sal_Int32((Application::GetSettings().GetStyleSettings().*pGetter
)());
1302 AllSettings aSettings
= _pWindow
->GetSettings();
1303 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
1305 (aStyleSettings
.*pSetter
)( Color( nColor
) );
1307 aSettings
.SetStyleSettings( aStyleSettings
);
1308 _pWindow
->SetSettings( aSettings
, true );
1312 // Terminated by BASEPROPERTY_NOTFOUND (or 0)
1313 void VCLXWindow::PushPropertyIds( std::vector
< sal_uInt16
> &rIds
,
1317 va_start( pVarArgs
, nFirstId
);
1319 for ( int nId
= nFirstId
; nId
!= BASEPROPERTY_NOTFOUND
;
1320 nId
= va_arg( pVarArgs
, int ) )
1321 rIds
.push_back( static_cast<sal_uInt16
>(nId
) );
1326 void VCLXWindow::ImplGetPropertyIds( std::vector
< sal_uInt16
> &rIds
, bool bWithDefaults
)
1328 // These are common across ~all VCLXWindow derived classes
1330 PushPropertyIds( rIds
,
1332 BASEPROPERTY_BACKGROUNDCOLOR
,
1333 BASEPROPERTY_BORDER
,
1334 BASEPROPERTY_BORDERCOLOR
,
1335 BASEPROPERTY_DEFAULTCONTROL
,
1336 BASEPROPERTY_ENABLED
,
1337 BASEPROPERTY_FONTDESCRIPTOR
,
1338 BASEPROPERTY_HELPTEXT
,
1339 BASEPROPERTY_HELPURL
,
1341 BASEPROPERTY_PRINTABLE
,
1342 BASEPROPERTY_ENABLEVISIBLE
, // for visibility
1343 BASEPROPERTY_TABSTOP
,
1346 // lovely hack from:
1347 // void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
1348 if( std::find(rIds
.begin(), rIds
.end(), BASEPROPERTY_FONTDESCRIPTOR
) != rIds
.end() )
1350 // some properties are not included in the FontDescriptor, but every time
1351 // when we have a FontDescriptor we want to have these properties too.
1352 // => Easier to register the here, instead everywhere where I register the FontDescriptor...
1354 rIds
.push_back( BASEPROPERTY_TEXTCOLOR
);
1355 rIds
.push_back( BASEPROPERTY_TEXTLINECOLOR
);
1356 rIds
.push_back( BASEPROPERTY_FONTRELIEF
);
1357 rIds
.push_back( BASEPROPERTY_FONTEMPHASISMARK
);
1361 void VCLXWindow::GetPropertyIds( std::vector
< sal_uInt16
>& _out_rIds
)
1363 return ImplGetPropertyIds( _out_rIds
, mpImpl
->mbWithDefaultProps
);
1366 ::comphelper::OInterfaceContainerHelper2
& VCLXWindow::GetContainerListeners()
1368 return mpImpl
->getContainerListeners();
1371 ::comphelper::OInterfaceContainerHelper2
& VCLXWindow::GetTopWindowListeners()
1373 return mpImpl
->getTopWindowListeners();
1378 void lcl_updateWritingMode( vcl::Window
& _rWindow
, const sal_Int16 _nWritingMode
, const sal_Int16 _nContextWritingMode
)
1380 bool bEnableRTL
= false;
1381 switch ( _nWritingMode
)
1383 case WritingMode2::LR_TB
: bEnableRTL
= false; break;
1384 case WritingMode2::RL_TB
: bEnableRTL
= true; break;
1385 case WritingMode2::CONTEXT
:
1387 // consult our ContextWritingMode. If it has an explicit RTL/LTR value, then use
1388 // it. If it doesn't (but is CONTEXT itself), then just ask the parent window of our
1389 // own window for its RTL mode
1390 switch ( _nContextWritingMode
)
1392 case WritingMode2::LR_TB
: bEnableRTL
= false; break;
1393 case WritingMode2::RL_TB
: bEnableRTL
= true; break;
1394 case WritingMode2::CONTEXT
:
1396 const vcl::Window
* pParent
= _rWindow
.GetParent();
1397 OSL_ENSURE( pParent
, "lcl_updateWritingMode: cannot determine context's writing mode!" );
1399 bEnableRTL
= pParent
->IsRTLEnabled();
1406 OSL_FAIL( "lcl_updateWritingMode: unsupported WritingMode!" );
1407 } // switch ( nWritingMode )
1409 _rWindow
.EnableRTL( bEnableRTL
);
1413 void VCLXWindow::setProperty( const OUString
& PropertyName
, const css::uno::Any
& Value
)
1415 SolarMutexGuard aGuard
;
1417 VclPtr
<vcl::Window
> pWindow
= GetWindow();
1421 bool bVoid
= Value
.getValueType().getTypeClass() == css::uno::TypeClass_VOID
;
1423 WindowType eWinType
= pWindow
->GetType();
1424 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1425 switch ( nPropType
)
1427 case BASEPROPERTY_REFERENCE_DEVICE
:
1429 Control
* pControl
= dynamic_cast< Control
* >( pWindow
.get() );
1430 OSL_ENSURE( pControl
, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
1433 Reference
< XDevice
> xDevice( Value
, UNO_QUERY
);
1434 OutputDevice
* pDevice
= VCLUnoHelper::GetOutputDevice( xDevice
);
1435 pControl
->SetReferenceDevice( pDevice
);
1439 case BASEPROPERTY_CONTEXT_WRITING_MODE
:
1441 OSL_VERIFY( Value
>>= mpImpl
->mnContextWritingMode
);
1442 if ( mpImpl
->mnWritingMode
== WritingMode2::CONTEXT
)
1443 lcl_updateWritingMode( *pWindow
, mpImpl
->mnWritingMode
, mpImpl
->mnContextWritingMode
);
1447 case BASEPROPERTY_WRITING_MODE
:
1449 bool bProperType
= ( Value
>>= mpImpl
->mnWritingMode
);
1450 OSL_ENSURE( bProperType
, "VCLXWindow::setProperty( 'WritingMode' ): illegal value type!" );
1452 lcl_updateWritingMode( *pWindow
, mpImpl
->mnWritingMode
, mpImpl
->mnContextWritingMode
);
1456 case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
:
1458 sal_uInt16
nWheelBehavior( css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
);
1459 OSL_VERIFY( Value
>>= nWheelBehavior
);
1461 AllSettings aSettings
= pWindow
->GetSettings();
1462 MouseSettings aMouseSettings
= aSettings
.GetMouseSettings();
1464 MouseWheelBehaviour
nVclBehavior( MouseWheelBehaviour::FocusOnly
);
1465 switch ( nWheelBehavior
)
1467 case css::awt::MouseWheelBehavior::SCROLL_DISABLED
: nVclBehavior
= MouseWheelBehaviour::Disable
; break;
1468 case css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
: nVclBehavior
= MouseWheelBehaviour::FocusOnly
; break;
1469 case css::awt::MouseWheelBehavior::SCROLL_ALWAYS
: nVclBehavior
= MouseWheelBehaviour::ALWAYS
; break;
1471 OSL_FAIL( "VCLXWindow::setProperty( 'MouseWheelBehavior' ): illegal property value!" );
1474 aMouseSettings
.SetWheelBehavior( nVclBehavior
);
1475 aSettings
.SetMouseSettings( aMouseSettings
);
1476 pWindow
->SetSettings( aSettings
, true );
1480 case BASEPROPERTY_NATIVE_WIDGET_LOOK
:
1482 bool bEnable( true );
1483 OSL_VERIFY( Value
>>= bEnable
);
1484 pWindow
->EnableNativeWidget( bEnable
);
1488 case BASEPROPERTY_PLUGINPARENT
:
1490 // set parent handle
1491 SetSystemParent_Impl( Value
);
1495 case BASEPROPERTY_ENABLED
:
1502 case BASEPROPERTY_ENABLEVISIBLE
:
1507 if( b
!= mpImpl
->isEnableVisible() )
1509 mpImpl
->setEnableVisible( b
);
1510 pWindow
->Show( b
&& mpImpl
->isDirectVisible() );
1515 case BASEPROPERTY_TEXT
:
1516 case BASEPROPERTY_LABEL
:
1517 case BASEPROPERTY_TITLE
:
1520 if ( Value
>>= aText
)
1524 case WindowType::OKBUTTON
:
1525 case WindowType::CANCELBUTTON
:
1526 case WindowType::HELPBUTTON
:
1527 // Standard Button: overwrite only if not empty.
1528 if (!aText
.isEmpty())
1529 pWindow
->SetText( aText
);
1533 pWindow
->SetText( aText
);
1539 case BASEPROPERTY_ACCESSIBLENAME
:
1542 if ( Value
>>= aText
)
1543 pWindow
->SetAccessibleName( aText
);
1546 case BASEPROPERTY_HELPURL
:
1549 if ( Value
>>= aURL
)
1551 INetURLObject
aHelpURL( aURL
);
1552 if ( aHelpURL
.GetProtocol() == INetProtocol::Hid
)
1553 pWindow
->SetHelpId( OUStringToOString( aHelpURL
.GetURLPath(), RTL_TEXTENCODING_UTF8
) );
1555 pWindow
->SetHelpId( OUStringToOString( aURL
, RTL_TEXTENCODING_UTF8
) );
1559 case BASEPROPERTY_HELPTEXT
:
1562 if ( Value
>>= aHelpText
)
1564 pWindow
->SetQuickHelpText( aHelpText
);
1568 case BASEPROPERTY_FONTDESCRIPTOR
:
1571 pWindow
->SetControlFont( vcl::Font() );
1574 css::awt::FontDescriptor aFont
;
1575 if ( Value
>>= aFont
)
1576 pWindow
->SetControlFont( VCLUnoHelper::CreateFont( aFont
, pWindow
->GetControlFont() ) );
1580 case BASEPROPERTY_FONTRELIEF
:
1582 sal_Int16 n
= sal_Int16();
1585 vcl::Font aFont
= pWindow
->GetControlFont();
1586 aFont
.SetRelief( static_cast<FontRelief
>(n
) );
1587 pWindow
->SetControlFont( aFont
);
1591 case BASEPROPERTY_FONTEMPHASISMARK
:
1593 sal_Int16 n
= sal_Int16();
1596 vcl::Font aFont
= pWindow
->GetControlFont();
1597 aFont
.SetEmphasisMark( static_cast<FontEmphasisMark
>(n
) );
1598 pWindow
->SetControlFont( aFont
);
1602 case BASEPROPERTY_BACKGROUNDCOLOR
:
1607 // set dialog color for default
1608 case WindowType::DIALOG
:
1609 case WindowType::MESSBOX
:
1610 case WindowType::INFOBOX
:
1611 case WindowType::WARNINGBOX
:
1612 case WindowType::ERRORBOX
:
1613 case WindowType::QUERYBOX
:
1614 case WindowType::TABPAGE
:
1616 Color aColor
= pWindow
->GetSettings().GetStyleSettings().GetDialogColor();
1617 pWindow
->SetBackground( aColor
);
1618 pWindow
->SetControlBackground( aColor
);
1622 case WindowType::FIXEDTEXT
:
1623 case WindowType::CHECKBOX
:
1624 case WindowType::RADIOBUTTON
:
1625 case WindowType::GROUPBOX
:
1626 case WindowType::FIXEDLINE
:
1628 // support transparency only for special controls
1629 pWindow
->SetBackground();
1630 pWindow
->SetControlBackground();
1631 pWindow
->SetPaintTransparent( true );
1637 // default code which enables transparency for
1638 // compound controls. It's not real transparency
1639 // as most of these controls repaint their client
1640 // area completely new.
1641 if ( pWindow
->IsCompoundControl() )
1642 pWindow
->SetBackground();
1643 pWindow
->SetControlBackground();
1650 sal_Int32 nColor
= 0;
1651 if ( Value
>>= nColor
)
1653 Color
aColor( nColor
);
1654 pWindow
->SetControlBackground( aColor
);
1655 pWindow
->SetBackground( aColor
);
1658 // reset paint transparent mode
1659 case WindowType::FIXEDTEXT
:
1660 case WindowType::CHECKBOX
:
1661 case WindowType::RADIOBUTTON
:
1662 case WindowType::GROUPBOX
:
1663 case WindowType::FIXEDLINE
:
1664 pWindow
->SetPaintTransparent( false );
1669 pWindow
->Invalidate(); // Invalidate if control does not respond to it
1673 case BASEPROPERTY_TEXTCOLOR
:
1676 pWindow
->SetControlForeground();
1680 sal_Int32 nColor
= 0;
1681 if ( Value
>>= nColor
)
1683 Color
aColor( nColor
);
1684 pWindow
->SetTextColor( aColor
);
1685 pWindow
->SetControlForeground( aColor
);
1689 case BASEPROPERTY_TEXTLINECOLOR
:
1692 pWindow
->SetTextLineColor();
1696 sal_Int32 nColor
= 0;
1697 if ( Value
>>= nColor
)
1699 Color
aColor( nColor
);
1700 pWindow
->SetTextLineColor( aColor
);
1704 case BASEPROPERTY_FILLCOLOR
:
1706 pWindow
->SetFillColor();
1709 sal_Int32 nColor
= 0;
1710 if ( Value
>>= nColor
)
1712 Color
aColor( nColor
);
1713 pWindow
->SetFillColor( aColor
);
1717 case BASEPROPERTY_LINECOLOR
:
1719 pWindow
->SetLineColor();
1722 sal_Int32 nColor
= 0;
1723 if ( Value
>>= nColor
)
1725 Color
aColor( nColor
);
1726 pWindow
->SetLineColor( aColor
);
1730 case BASEPROPERTY_BORDER
:
1732 WinBits nStyle
= pWindow
->GetStyle();
1733 sal_uInt16 nTmp
= 0;
1735 // clear any dodgy bits passed in, can come from dodgy extensions
1736 nTmp
&= o3tl::typed_flags
<WindowBorderStyle
>::mask
;
1737 WindowBorderStyle nBorder
= static_cast<WindowBorderStyle
>(nTmp
);
1738 if ( !bool(nBorder
) )
1740 pWindow
->SetStyle( nStyle
& ~WB_BORDER
);
1744 pWindow
->SetStyle( nStyle
| WB_BORDER
);
1745 pWindow
->SetBorderStyle( nBorder
);
1749 case BASEPROPERTY_TABSTOP
:
1751 WinBits nStyle
= pWindow
->GetStyle() & ~WB_TABSTOP
;
1757 nStyle
|= WB_TABSTOP
;
1759 nStyle
|= WB_NOTABSTOP
;
1761 pWindow
->SetStyle( nStyle
);
1764 case BASEPROPERTY_VERTICALALIGN
:
1766 VerticalAlignment eAlign
= css::style::VerticalAlignment::VerticalAlignment_MAKE_FIXED_SIZE
;
1767 WinBits nStyle
= pWindow
->GetStyle();
1768 nStyle
&= ~(WB_TOP
|WB_VCENTER
|WB_BOTTOM
);
1773 case VerticalAlignment_TOP
:
1776 case VerticalAlignment_MIDDLE
:
1777 nStyle
|= WB_VCENTER
;
1779 case VerticalAlignment_BOTTOM
:
1780 nStyle
|= WB_BOTTOM
;
1782 default: ; // for warning free code, MAKE_FIXED_SIZE
1784 pWindow
->SetStyle( nStyle
);
1787 case BASEPROPERTY_ALIGN
:
1789 sal_Int16 nAlign
= PROPERTY_ALIGN_LEFT
;
1792 case WindowType::COMBOBOX
:
1793 case WindowType::PUSHBUTTON
:
1794 case WindowType::OKBUTTON
:
1795 case WindowType::CANCELBUTTON
:
1796 case WindowType::HELPBUTTON
:
1797 nAlign
= PROPERTY_ALIGN_CENTER
;
1799 case WindowType::FIXEDTEXT
:
1800 case WindowType::EDIT
:
1801 case WindowType::MULTILINEEDIT
:
1802 case WindowType::CHECKBOX
:
1803 case WindowType::RADIOBUTTON
:
1804 case WindowType::LISTBOX
:
1806 WinBits nStyle
= pWindow
->GetStyle();
1807 nStyle
&= ~(WB_LEFT
|WB_CENTER
|WB_RIGHT
);
1810 if ( nAlign
== PROPERTY_ALIGN_LEFT
)
1812 else if ( nAlign
== PROPERTY_ALIGN_CENTER
)
1813 nStyle
|= WB_CENTER
;
1816 pWindow
->SetStyle( nStyle
);
1823 case BASEPROPERTY_MULTILINE
:
1825 if ( ( eWinType
== WindowType::FIXEDTEXT
)
1826 || ( eWinType
== WindowType::CHECKBOX
)
1827 || ( eWinType
== WindowType::RADIOBUTTON
)
1828 || ( eWinType
== WindowType::PUSHBUTTON
)
1829 || ( eWinType
== WindowType::OKBUTTON
)
1830 || ( eWinType
== WindowType::CANCELBUTTON
)
1831 || ( eWinType
== WindowType::HELPBUTTON
)
1834 WinBits nStyle
= pWindow
->GetStyle();
1835 bool bMulti
= false;
1838 nStyle
|= WB_WORDBREAK
;
1840 nStyle
&= ~WB_WORDBREAK
;
1841 pWindow
->SetStyle( nStyle
);
1845 case BASEPROPERTY_ORIENTATION
:
1847 if ( eWinType
== WindowType::FIXEDLINE
)
1849 sal_Int32 nOrientation
= 0;
1850 if ( Value
>>= nOrientation
)
1852 WinBits nStyle
= pWindow
->GetStyle();
1853 nStyle
&= ~(WB_HORZ
|WB_VERT
);
1854 if ( nOrientation
== 0 )
1859 pWindow
->SetStyle( nStyle
);
1864 case BASEPROPERTY_AUTOMNEMONICS
:
1866 bool bAutoMnemonics
= false;
1867 Value
>>= bAutoMnemonics
;
1868 AllSettings aSettings
= pWindow
->GetSettings();
1869 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
1870 if ( aStyleSettings
.GetAutoMnemonic() != bAutoMnemonics
)
1872 aStyleSettings
.SetAutoMnemonic( bAutoMnemonics
);
1873 aSettings
.SetStyleSettings( aStyleSettings
);
1874 pWindow
->SetSettings( aSettings
);
1878 case BASEPROPERTY_MOUSETRANSPARENT
:
1880 bool bMouseTransparent
= false;
1881 Value
>>= bMouseTransparent
;
1882 pWindow
->SetMouseTransparent( bMouseTransparent
);
1885 case BASEPROPERTY_PAINTTRANSPARENT
:
1887 bool bPaintTransparent
= false;
1888 Value
>>= bPaintTransparent
;
1889 pWindow
->SetPaintTransparent( bPaintTransparent
);
1890 // pWindow->SetBackground();
1894 case BASEPROPERTY_REPEAT
:
1896 bool bRepeat( false );
1899 WinBits nStyle
= pWindow
->GetStyle();
1901 nStyle
|= WB_REPEAT
;
1903 nStyle
&= ~WB_REPEAT
;
1904 pWindow
->SetStyle( nStyle
);
1908 case BASEPROPERTY_REPEAT_DELAY
:
1910 sal_Int32 nRepeatDelay
= 0;
1911 if ( Value
>>= nRepeatDelay
)
1913 AllSettings aSettings
= pWindow
->GetSettings();
1914 MouseSettings aMouseSettings
= aSettings
.GetMouseSettings();
1916 aMouseSettings
.SetButtonRepeat( nRepeatDelay
);
1917 aSettings
.SetMouseSettings( aMouseSettings
);
1919 pWindow
->SetSettings( aSettings
, true );
1924 case BASEPROPERTY_SYMBOL_COLOR
:
1925 ::toolkit::setColorSettings( pWindow
, Value
, &StyleSettings::SetButtonTextColor
, &StyleSettings::GetButtonTextColor
);
1928 case BASEPROPERTY_BORDERCOLOR
:
1929 ::toolkit::setColorSettings( pWindow
, Value
, &StyleSettings::SetMonoColor
, &StyleSettings::GetMonoColor
);
1934 css::uno::Any
VCLXWindow::getProperty( const OUString
& PropertyName
)
1936 SolarMutexGuard aGuard
;
1938 css::uno::Any aProp
;
1941 WindowType eWinType
= GetWindow()->GetType();
1942 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1943 switch ( nPropType
)
1945 case BASEPROPERTY_REFERENCE_DEVICE
:
1947 VclPtr
<Control
> pControl
= GetAsDynamic
<Control
>();
1948 OSL_ENSURE( pControl
, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
1952 VCLXDevice
* pDevice
= new VCLXDevice
;
1953 pDevice
->SetOutputDevice( pControl
->GetReferenceDevice() );
1954 aProp
<<= Reference
< XDevice
>( pDevice
);
1958 case BASEPROPERTY_CONTEXT_WRITING_MODE
:
1959 aProp
<<= mpImpl
->mnContextWritingMode
;
1962 case BASEPROPERTY_WRITING_MODE
:
1963 aProp
<<= mpImpl
->mnWritingMode
;
1966 case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
:
1968 MouseWheelBehaviour nVclBehavior
= GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior();
1969 sal_uInt16 nBehavior
= css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
;
1970 switch ( nVclBehavior
)
1972 case MouseWheelBehaviour::Disable
: nBehavior
= css::awt::MouseWheelBehavior::SCROLL_DISABLED
; break;
1973 case MouseWheelBehaviour::FocusOnly
: nBehavior
= css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
; break;
1974 case MouseWheelBehaviour::ALWAYS
: nBehavior
= css::awt::MouseWheelBehavior::SCROLL_ALWAYS
; break;
1976 OSL_FAIL( "VCLXWindow::getProperty( 'MouseWheelBehavior' ): illegal VCL value!" );
1978 aProp
<<= nBehavior
;
1982 case BASEPROPERTY_NATIVE_WIDGET_LOOK
:
1983 aProp
<<= GetWindow()->IsNativeWidgetEnabled();
1986 case BASEPROPERTY_ENABLED
:
1987 aProp
<<= GetWindow()->IsEnabled();
1990 case BASEPROPERTY_ENABLEVISIBLE
:
1991 aProp
<<= mpImpl
->isEnableVisible();
1994 case BASEPROPERTY_HIGHCONTRASTMODE
:
1995 aProp
<<= GetWindow()->GetSettings().GetStyleSettings().GetHighContrastMode();
1998 case BASEPROPERTY_TEXT
:
1999 case BASEPROPERTY_LABEL
:
2000 case BASEPROPERTY_TITLE
:
2002 OUString aText
= GetWindow()->GetText();
2006 case BASEPROPERTY_ACCESSIBLENAME
:
2008 OUString aText
= GetWindow()->GetAccessibleName();
2012 case BASEPROPERTY_HELPTEXT
:
2014 OUString aText
= GetWindow()->GetQuickHelpText();
2018 case BASEPROPERTY_HELPURL
:
2020 OUString
aHelpId( OStringToOUString( GetWindow()->GetHelpId(), RTL_TEXTENCODING_UTF8
) );
2024 case BASEPROPERTY_FONTDESCRIPTOR
:
2026 vcl::Font aFont
= GetWindow()->GetControlFont();
2027 css::awt::FontDescriptor aFD
= VCLUnoHelper::CreateFontDescriptor( aFont
);
2031 case BASEPROPERTY_BACKGROUNDCOLOR
:
2032 aProp
<<= GetWindow()->GetControlBackground();
2034 case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR
:
2035 aProp
<<= GetWindow()->GetDisplayBackground().GetColor();
2037 case BASEPROPERTY_FONTRELIEF
:
2038 aProp
<<= static_cast<sal_Int16
>(GetWindow()->GetControlFont().GetRelief());
2040 case BASEPROPERTY_FONTEMPHASISMARK
:
2041 aProp
<<= static_cast<sal_Int16
>(GetWindow()->GetControlFont().GetEmphasisMark());
2043 case BASEPROPERTY_TEXTCOLOR
:
2044 aProp
<<= GetWindow()->GetControlForeground();
2046 case BASEPROPERTY_TEXTLINECOLOR
:
2047 aProp
<<= GetWindow()->GetTextLineColor();
2049 case BASEPROPERTY_FILLCOLOR
:
2050 aProp
<<= GetWindow()->GetFillColor();
2052 case BASEPROPERTY_LINECOLOR
:
2053 aProp
<<= GetWindow()->GetLineColor();
2055 case BASEPROPERTY_BORDER
:
2057 WindowBorderStyle nBorder
= WindowBorderStyle::NONE
;
2058 if ( GetWindow()->GetStyle() & WB_BORDER
)
2059 nBorder
= GetWindow()->GetBorderStyle();
2060 aProp
<<= static_cast<sal_uInt16
>(nBorder
);
2063 case BASEPROPERTY_TABSTOP
:
2064 aProp
<<= ( GetWindow()->GetStyle() & WB_TABSTOP
) != 0;
2066 case BASEPROPERTY_VERTICALALIGN
:
2068 WinBits nStyle
= GetWindow()->GetStyle();
2069 if ( nStyle
& WB_TOP
)
2070 aProp
<<= VerticalAlignment_TOP
;
2071 else if ( nStyle
& WB_VCENTER
)
2072 aProp
<<= VerticalAlignment_MIDDLE
;
2073 else if ( nStyle
& WB_BOTTOM
)
2074 aProp
<<= VerticalAlignment_BOTTOM
;
2077 case BASEPROPERTY_ALIGN
:
2081 case WindowType::FIXEDTEXT
:
2082 case WindowType::EDIT
:
2083 case WindowType::MULTILINEEDIT
:
2084 case WindowType::CHECKBOX
:
2085 case WindowType::RADIOBUTTON
:
2086 case WindowType::LISTBOX
:
2087 case WindowType::COMBOBOX
:
2088 case WindowType::PUSHBUTTON
:
2089 case WindowType::OKBUTTON
:
2090 case WindowType::CANCELBUTTON
:
2091 case WindowType::HELPBUTTON
:
2093 WinBits nStyle
= GetWindow()->GetStyle();
2094 if ( nStyle
& WB_LEFT
)
2095 aProp
<<= sal_Int16(PROPERTY_ALIGN_LEFT
);
2096 else if ( nStyle
& WB_CENTER
)
2097 aProp
<<= sal_Int16(PROPERTY_ALIGN_CENTER
);
2098 else if ( nStyle
& WB_RIGHT
)
2099 aProp
<<= sal_Int16(PROPERTY_ALIGN_RIGHT
);
2106 case BASEPROPERTY_MULTILINE
:
2108 if ( ( eWinType
== WindowType::FIXEDTEXT
)
2109 || ( eWinType
== WindowType::CHECKBOX
)
2110 || ( eWinType
== WindowType::RADIOBUTTON
)
2111 || ( eWinType
== WindowType::PUSHBUTTON
)
2112 || ( eWinType
== WindowType::OKBUTTON
)
2113 || ( eWinType
== WindowType::CANCELBUTTON
)
2114 || ( eWinType
== WindowType::HELPBUTTON
)
2116 aProp
<<= ( GetWindow()->GetStyle() & WB_WORDBREAK
) != 0;
2119 case BASEPROPERTY_AUTOMNEMONICS
:
2121 bool bAutoMnemonics
= GetWindow()->GetSettings().GetStyleSettings().GetAutoMnemonic();
2122 aProp
<<= bAutoMnemonics
;
2125 case BASEPROPERTY_MOUSETRANSPARENT
:
2127 bool bMouseTransparent
= GetWindow()->IsMouseTransparent();
2128 aProp
<<= bMouseTransparent
;
2131 case BASEPROPERTY_PAINTTRANSPARENT
:
2133 bool bPaintTransparent
= GetWindow()->IsPaintTransparent();
2134 aProp
<<= bPaintTransparent
;
2138 case BASEPROPERTY_REPEAT
:
2139 aProp
<<= ( 0 != ( GetWindow()->GetStyle() & WB_REPEAT
) );
2142 case BASEPROPERTY_REPEAT_DELAY
:
2144 sal_Int32 nButtonRepeat
= GetWindow()->GetSettings().GetMouseSettings().GetButtonRepeat();
2145 aProp
<<= nButtonRepeat
;
2149 case BASEPROPERTY_SYMBOL_COLOR
:
2150 aProp
<<= GetWindow()->GetSettings().GetStyleSettings().GetButtonTextColor();
2153 case BASEPROPERTY_BORDERCOLOR
:
2154 aProp
<<= GetWindow()->GetSettings().GetStyleSettings().GetMonoColor();
2162 // css::awt::XLayoutConstrains
2163 css::awt::Size
VCLXWindow::getMinimumSize( )
2165 SolarMutexGuard aGuard
;
2167 // Use this method only for those components which can be created through
2168 // css::awt::Toolkit , but do not have an interface
2173 WindowType nWinType
= GetWindow()->GetType();
2176 case WindowType::CONTROL
:
2177 aSz
.setWidth( GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*12 );
2178 aSz
.setHeight( GetWindow()->GetTextHeight()+2*6 );
2181 case WindowType::PATTERNBOX
:
2182 case WindowType::NUMERICBOX
:
2183 case WindowType::METRICBOX
:
2184 case WindowType::CURRENCYBOX
:
2185 case WindowType::DATEBOX
:
2186 case WindowType::TIMEBOX
:
2187 case WindowType::LONGCURRENCYBOX
:
2188 aSz
.setWidth( GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*2 );
2189 aSz
.setHeight( GetWindow()->GetTextHeight()+2*2 );
2191 case WindowType::SCROLLBARBOX
:
2192 return VCLXScrollBar::implGetMinimumSize( GetWindow() );
2194 aSz
= GetWindow()->get_preferred_size();
2198 return css::awt::Size( aSz
.Width(), aSz
.Height() );
2201 css::awt::Size
VCLXWindow::getPreferredSize( )
2203 return getMinimumSize();
2206 css::awt::Size
VCLXWindow::calcAdjustedSize( const css::awt::Size
& rNewSize
)
2208 SolarMutexGuard aGuard
;
2210 css::awt::Size
aNewSize( rNewSize
);
2211 css::awt::Size aMinSize
= getMinimumSize();
2213 if ( aNewSize
.Width
< aMinSize
.Width
)
2214 aNewSize
.Width
= aMinSize
.Width
;
2215 if ( aNewSize
.Height
< aMinSize
.Height
)
2216 aNewSize
.Height
= aMinSize
.Height
;
2223 sal_Bool
VCLXWindow::setGraphics( const css::uno::Reference
< css::awt::XGraphics
>& rxDevice
)
2225 SolarMutexGuard aGuard
;
2227 if ( VCLUnoHelper::GetOutputDevice( rxDevice
) )
2228 mpImpl
->mxViewGraphics
= rxDevice
;
2230 mpImpl
->mxViewGraphics
= nullptr;
2232 return mpImpl
->mxViewGraphics
.is();
2235 css::uno::Reference
< css::awt::XGraphics
> VCLXWindow::getGraphics( )
2237 SolarMutexGuard aGuard
;
2239 return mpImpl
->mxViewGraphics
;
2242 css::awt::Size
VCLXWindow::getSize( )
2244 SolarMutexGuard aGuard
;
2248 aSz
= GetWindow()->GetSizePixel();
2249 return css::awt::Size( aSz
.Width(), aSz
.Height() );
2252 void VCLXWindow::draw( sal_Int32 nX
, sal_Int32 nY
)
2254 SolarMutexGuard aGuard
;
2256 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2260 if ( isDesignMode() || mpImpl
->isEnableVisible() )
2262 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( mpImpl
->mxViewGraphics
);
2264 pDev
= pWindow
->GetParent();
2265 TabPage
* pTabPage
= dynamic_cast< TabPage
* >( pWindow
.get() );
2268 Point
aPos( nX
, nY
);
2269 Size aSize
= pWindow
->GetSizePixel();
2271 aPos
= pDev
->PixelToLogic( aPos
);
2272 aSize
= pDev
->PixelToLogic( aSize
);
2274 pTabPage
->Draw( pDev
, aPos
, aSize
, DrawFlags::NONE
);
2278 Point
aPos( nX
, nY
);
2280 if ( pWindow
->GetParent() && !pWindow
->IsSystemWindow() && ( pWindow
->GetParent() == pDev
) )
2282 // #i40647# don't draw here if this is a recursive call
2283 // sometimes this is called recursively, because the Update call on the parent
2284 // (strangely) triggers another paint. Prevent a stack overflow here
2285 // Yes, this is only fixing symptoms for the moment ....
2286 // #i40647# / 2005-01-18 / frank.schoenheit@sun.com
2287 if ( !mpImpl
->getDrawingOntoParent_ref() )
2289 ::comphelper::FlagGuard
aDrawingflagGuard( mpImpl
->getDrawingOntoParent_ref() );
2291 bool bWasVisible
= pWindow
->IsVisible();
2292 Point
aOldPos( pWindow
->GetPosPixel() );
2294 if ( bWasVisible
&& aOldPos
== aPos
)
2300 pWindow
->SetPosPixel( aPos
);
2302 // Update parent first to avoid painting the parent upon the update
2303 // of this window, as it may otherwise cause the parent
2304 // to hide this window again
2305 if( pWindow
->GetParent() )
2306 pWindow
->GetParent()->Update();
2310 pWindow
->SetParentUpdateMode( false );
2312 pWindow
->SetParentUpdateMode( true );
2314 pWindow
->SetPosPixel( aOldPos
);
2321 Size aSz
= pWindow
->GetSizePixel();
2322 aSz
= pDev
->PixelToLogic( aSz
);
2323 Point aP
= pDev
->PixelToLogic( aPos
);
2325 vcl::PDFExtOutDevData
* pPDFExport
= dynamic_cast<vcl::PDFExtOutDevData
*>(pDev
->GetExtOutDevData());
2326 bool bDrawSimple
= ( pDev
->GetOutDevType() == OUTDEV_PRINTER
)
2327 || ( pDev
->GetOutDevViewType() == OutDevViewType::PrintPreview
)
2328 || ( pPDFExport
!= nullptr );
2331 pWindow
->Draw( pDev
, aP
, aSz
, DrawFlags::NoControls
);
2335 bool bOldNW
=pWindow
->IsNativeWidgetEnabled();
2337 pWindow
->EnableNativeWidget(false);
2338 pWindow
->PaintToDevice( pDev
, aP
, aSz
);
2340 pWindow
->EnableNativeWidget();
2346 void VCLXWindow::setZoom( float fZoomX
, float /*fZoomY*/ )
2348 SolarMutexGuard aGuard
;
2352 // Fraction::Fraction takes a double, but we have a float only.
2353 // The implicit conversion from float to double can result in a precision loss, i.e. 1.2 is converted to
2354 // 1.200000000047something. To prevent this, we convert explicitly to double, and round it.
2355 double nZoom( fZoomX
);
2356 Fraction
aZoom(::rtl::math::round(nZoom
, 4));
2357 aZoom
.ReduceInaccurate(10); // to avoid runovers and BigInt mapping
2358 GetWindow()->SetZoom(aZoom
);
2362 // css::lang::XEventListener
2363 void SAL_CALL
VCLXWindow::disposing( const css::lang::EventObject
& _rSource
)
2365 SolarMutexGuard aGuard
;
2367 // check if it comes from our AccessibleContext
2368 uno::Reference
< uno::XInterface
> aAC( mpImpl
->mxAccessibleContext
, uno::UNO_QUERY
);
2369 uno::Reference
< uno::XInterface
> xSource( _rSource
.Source
, uno::UNO_QUERY
);
2371 if ( aAC
.get() == xSource
.get() )
2373 mpImpl
->mxAccessibleContext
.clear();
2377 // css::accessibility::XAccessible
2378 css::uno::Reference
< css::accessibility::XAccessibleContext
> VCLXWindow::getAccessibleContext( )
2380 SolarMutexGuard aGuard
;
2384 return uno::Reference
< accessibility::XAccessibleContext
>();
2386 if ( !mpImpl
->mxAccessibleContext
.is() && GetWindow() )
2388 mpImpl
->mxAccessibleContext
= CreateAccessibleContext();
2390 // add as event listener to this component
2391 // in case somebody disposes it, we do not want to have a (though weak) reference to a dead
2393 uno::Reference
< lang::XComponent
> xComp( mpImpl
->mxAccessibleContext
, uno::UNO_QUERY
);
2395 xComp
->addEventListener( this );
2398 return mpImpl
->mxAccessibleContext
;
2401 // css::awt::XDockable
2402 void SAL_CALL
VCLXWindow::addDockableWindowListener( const css::uno::Reference
< css::awt::XDockableWindowListener
>& xListener
)
2404 SolarMutexGuard aGuard
;
2406 if ( xListener
.is() )
2407 mpImpl
->getDockableWindowListeners().addInterface( xListener
);
2411 void SAL_CALL
VCLXWindow::removeDockableWindowListener( const css::uno::Reference
< css::awt::XDockableWindowListener
>& xListener
)
2413 SolarMutexGuard aGuard
;
2415 mpImpl
->getDockableWindowListeners().removeInterface( xListener
);
2418 void SAL_CALL
VCLXWindow::enableDocking( sal_Bool bEnable
)
2420 SolarMutexGuard aGuard
;
2422 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2424 pWindow
->EnableDocking( bEnable
);
2427 sal_Bool SAL_CALL
VCLXWindow::isFloating( )
2429 SolarMutexGuard aGuard
;
2431 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2433 return vcl::Window::GetDockingManager()->IsFloating( pWindow
);
2438 void SAL_CALL
VCLXWindow::setFloatingMode( sal_Bool bFloating
)
2440 SolarMutexGuard aGuard
;
2442 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2444 vcl::Window::GetDockingManager()->SetFloatingMode( pWindow
, bFloating
);
2447 sal_Bool SAL_CALL
VCLXWindow::isLocked( )
2449 SolarMutexGuard aGuard
;
2451 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2453 return vcl::Window::GetDockingManager()->IsLocked( pWindow
);
2458 void SAL_CALL
VCLXWindow::lock( )
2460 SolarMutexGuard aGuard
;
2462 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2463 if( pWindow
&& !vcl::Window::GetDockingManager()->IsFloating( pWindow
) )
2464 vcl::Window::GetDockingManager()->Lock( pWindow
);
2467 void SAL_CALL
VCLXWindow::unlock( )
2469 SolarMutexGuard aGuard
;
2471 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2472 if( pWindow
&& !vcl::Window::GetDockingManager()->IsFloating( pWindow
) )
2473 vcl::Window::GetDockingManager()->Unlock( pWindow
);
2476 void SAL_CALL
VCLXWindow::startPopupMode( const css::awt::Rectangle
& )
2478 // TODO: remove interface in the next incompatible build
2481 sal_Bool SAL_CALL
VCLXWindow::isInPopupMode( )
2483 // TODO: remove interface in the next incompatible build
2488 // css::awt::XWindow2
2490 void SAL_CALL
VCLXWindow::setOutputSize( const css::awt::Size
& aSize
)
2492 SolarMutexGuard aGuard
;
2493 VclPtr
<vcl::Window
> pWindow
;
2494 if( (pWindow
= GetWindow()) != nullptr )
2496 DockingWindow
*pDockingWindow
= dynamic_cast< DockingWindow
* >(pWindow
.get());
2497 if( pDockingWindow
)
2498 pDockingWindow
->SetOutputSizePixel( VCLSize( aSize
) );
2500 pWindow
->SetOutputSizePixel( VCLSize( aSize
) );
2504 css::awt::Size SAL_CALL
VCLXWindow::getOutputSize( )
2506 SolarMutexGuard aGuard
;
2507 VclPtr
<vcl::Window
> pWindow
;
2508 if( (pWindow
= GetWindow()) != nullptr )
2510 DockingWindow
*pDockingWindow
= dynamic_cast< DockingWindow
* >(pWindow
.get());
2511 if( pDockingWindow
)
2512 return AWTSize( pDockingWindow
->GetOutputSizePixel() );
2514 return AWTSize( pWindow
->GetOutputSizePixel() );
2517 return css::awt::Size();
2520 sal_Bool SAL_CALL
VCLXWindow::isVisible( )
2522 SolarMutexGuard aGuard
;
2524 return GetWindow()->IsVisible();
2529 sal_Bool SAL_CALL
VCLXWindow::isActive( )
2531 SolarMutexGuard aGuard
;
2533 return GetWindow()->IsActive();
2539 sal_Bool SAL_CALL
VCLXWindow::isEnabled( )
2541 SolarMutexGuard aGuard
;
2543 return GetWindow()->IsEnabled();
2548 sal_Bool SAL_CALL
VCLXWindow::hasFocus( )
2550 SolarMutexGuard aGuard
;
2552 return GetWindow()->HasFocus();
2557 // css::beans::XPropertySetInfo
2559 UnoPropertyArrayHelper
*
2560 VCLXWindow::GetPropHelper()
2562 SolarMutexGuard aGuard
;
2563 if ( mpImpl
->mpPropHelper
== nullptr )
2565 std::vector
< sal_uInt16
> aIDs
;
2566 GetPropertyIds( aIDs
);
2567 mpImpl
->mpPropHelper
.reset( new UnoPropertyArrayHelper( aIDs
) );
2569 return mpImpl
->mpPropHelper
.get();
2572 css::uno::Sequence
< css::beans::Property
> SAL_CALL
2573 VCLXWindow::getProperties()
2575 return GetPropHelper()->getProperties();
2577 css::beans::Property SAL_CALL
2578 VCLXWindow::getPropertyByName( const OUString
& rName
)
2580 return GetPropHelper()->getPropertyByName( rName
);
2584 VCLXWindow::hasPropertyByName( const OUString
& rName
)
2586 return GetPropHelper()->hasPropertyByName( rName
);
2589 Reference
< XStyleSettings
> SAL_CALL
VCLXWindow::getStyleSettings()
2591 return mpImpl
->getStyleSettings();
2594 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */