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 .
22 #include <com/sun/star/awt/WindowEvent.hpp>
23 #include <com/sun/star/awt/KeyEvent.hpp>
24 #include <com/sun/star/awt/KeyModifier.hpp>
25 #include <com/sun/star/awt/MouseEvent.hpp>
26 #include <com/sun/star/awt/MouseButton.hpp>
27 #include <com/sun/star/awt/MouseWheelBehavior.hpp>
28 #include <com/sun/star/awt/XTopWindow.hpp>
29 #include <com/sun/star/awt/Style.hpp>
30 #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 #include <com/sun/star/awt/DockingEvent.hpp>
32 #include <com/sun/star/awt/EndDockingEvent.hpp>
33 #include <com/sun/star/awt/EndPopupModeEvent.hpp>
34 #include <com/sun/star/awt/XWindowListener2.hpp>
35 #include <com/sun/star/style/VerticalAlignment.hpp>
36 #include <com/sun/star/lang/DisposedException.hpp>
37 #include <com/sun/star/text/WritingMode2.hpp>
38 #include <toolkit/awt/vclxwindow.hxx>
39 #include <toolkit/awt/vclxpointer.hxx>
40 #include <toolkit/awt/vclxwindows.hxx>
41 #include <toolkit/helper/macros.hxx>
42 #include <toolkit/helper/vclunohelper.hxx>
43 #include <toolkit/helper/convert.hxx>
44 #include <toolkit/helper/property.hxx>
45 #include <cppuhelper/typeprovider.hxx>
47 #include <rtl/ustrbuf.hxx>
48 #include <vcl/svapp.hxx>
49 #include <vcl/window.hxx>
50 #include <tools/color.hxx>
51 #include <tools/fract.hxx>
52 #include <vcl/dockwin.hxx>
53 #include <vcl/pdfextoutdevdata.hxx>
54 #include <vcl/tabpage.hxx>
55 #include <vcl/button.hxx>
56 #include <vcl/settings.hxx>
57 #include <comphelper/asyncnotification.hxx>
58 #include <comphelper/flagguard.hxx>
59 #include "stylesettings.hxx"
60 #include <tools/urlobj.hxx>
62 #include "helper/accessibilityclient.hxx"
63 #include "helper/unopropertyarrayhelper.hxx"
65 using namespace ::com::sun::star
;
67 using ::com::sun::star::uno::Reference
;
68 using ::com::sun::star::uno::UNO_QUERY
;
69 using ::com::sun::star::uno::RuntimeException
;
70 using ::com::sun::star::lang::EventObject
;
71 using ::com::sun::star::awt::XWindowListener2
;
72 using ::com::sun::star::awt::XDockableWindowListener
;
73 using ::com::sun::star::awt::XDevice
;
74 using ::com::sun::star::awt::XStyleSettings
;
75 using ::com::sun::star::lang::DisposedException
;
76 using ::com::sun::star::style::VerticalAlignment
;
77 using ::com::sun::star::style::VerticalAlignment_TOP
;
78 using ::com::sun::star::style::VerticalAlignment_MIDDLE
;
79 using ::com::sun::star::style::VerticalAlignment_BOTTOM
;
81 namespace WritingMode2
= ::com::sun::star::text::WritingMode2
;
89 typedef ::std::vector
< VCLXWindow::Callback
> CallbackArray
;
92 VCLXWindow
& mrAntiImpl
;
93 ::toolkit::AccessibilityClient maAccFactory
;
95 bool mbDrawingOntoParent
; // no bit mask, is passed around by reference
99 ::osl::Mutex maListenerContainerMutex
;
100 ::comphelper::OInterfaceContainerHelper2 maWindow2Listeners
;
101 ::comphelper::OInterfaceContainerHelper2 maDockableWindowListeners
;
102 EventListenerMultiplexer maEventListeners
;
103 FocusListenerMultiplexer maFocusListeners
;
104 WindowListenerMultiplexer maWindowListeners
;
105 KeyListenerMultiplexer maKeyListeners
;
106 MouseListenerMultiplexer maMouseListeners
;
107 MouseMotionListenerMultiplexer maMouseMotionListeners
;
108 PaintListenerMultiplexer maPaintListeners
;
109 VclContainerListenerMultiplexer maContainerListeners
;
110 TopWindowListenerMultiplexer maTopWindowListeners
;
112 CallbackArray maCallbackEvents
;
113 ImplSVEvent
* mnCallbackEventId
;
116 bool mbDisposing
: 1;
117 bool mbDesignMode
: 1;
118 bool mbSynthesizingVCLEvent
: 1;
119 bool mbWithDefaultProps
: 1;
121 sal_uLong mnListenerLockLevel
;
122 sal_Int16 mnWritingMode
;
123 sal_Int16 mnContextWritingMode
;
125 std::unique_ptr
<UnoPropertyArrayHelper
>
128 css::uno::Reference
< css::awt::XPointer
>
130 css::uno::Reference
< css::accessibility::XAccessibleContext
>
132 css::uno::Reference
< css::awt::XGraphics
>
134 css::uno::Reference
< css::awt::XStyleSettings
>
135 mxWindowStyleSettings
;
138 bool& getDrawingOntoParent_ref() { return mbDrawingOntoParent
; }
143 the <type>VCLXWindow</type> instance which the object belongs to. Must
144 live longer then the object just being constructed.
146 VCLXWindowImpl( VCLXWindow
& _rAntiImpl
, bool _bWithDefaultProps
);
148 VCLXWindowImpl( const VCLXWindowImpl
& ) = delete;
149 const VCLXWindowImpl
& operator=(const VCLXWindowImpl
&) = delete;
151 /** synchronously mbEnableVisible
153 void setEnableVisible( bool bEnableVisible
) { mbEnableVisible
= bEnableVisible
; }
154 bool isEnableVisible() { return mbEnableVisible
; }
155 /** synchronously mbDirectVisible;
157 void setDirectVisible( bool bDirectVisible
) { mbDirectVisible
= bDirectVisible
; }
158 bool isDirectVisible() { return mbDirectVisible
; }
160 /** impl-version of VCLXWindow::ImplExecuteAsyncWithoutSolarLock
162 void callBackAsync( const VCLXWindow::Callback
& i_callback
);
164 /** notifies the object that its VCLXWindow is being disposed
168 ::toolkit::AccessibilityClient
& getAccessibleFactory()
173 Reference
< XStyleSettings
> getStyleSettings();
175 /** returns the container of registered XWindowListener2 listeners
177 ::comphelper::OInterfaceContainerHelper2
& getWindow2Listeners() { return maWindow2Listeners
; }
178 ::comphelper::OInterfaceContainerHelper2
& getDockableWindowListeners(){ return maDockableWindowListeners
; }
179 EventListenerMultiplexer
& getEventListeners() { return maEventListeners
; }
180 FocusListenerMultiplexer
& getFocusListeners() { return maFocusListeners
; }
181 WindowListenerMultiplexer
& getWindowListeners() { return maWindowListeners
; }
182 KeyListenerMultiplexer
& getKeyListeners() { return maKeyListeners
; }
183 MouseListenerMultiplexer
& getMouseListeners() { return maMouseListeners
; }
184 MouseMotionListenerMultiplexer
& getMouseMotionListeners() { return maMouseMotionListeners
; }
185 PaintListenerMultiplexer
& getPaintListeners() { return maPaintListeners
; }
186 VclContainerListenerMultiplexer
& getContainerListeners() { return maContainerListeners
; }
187 TopWindowListenerMultiplexer
& getTopWindowListeners() { return maTopWindowListeners
; }
190 DECL_LINK( OnProcessCallbacks
, void*, void );
194 VCLXWindowImpl::VCLXWindowImpl( VCLXWindow
& _rAntiImpl
, bool _bWithDefaultProps
)
195 :mrAntiImpl( _rAntiImpl
)
197 ,mbDrawingOntoParent( false )
198 ,mbEnableVisible(true)
199 ,mbDirectVisible(true)
200 ,maListenerContainerMutex( )
201 ,maWindow2Listeners( maListenerContainerMutex
)
202 ,maDockableWindowListeners( maListenerContainerMutex
)
203 ,maEventListeners( _rAntiImpl
)
204 ,maFocusListeners( _rAntiImpl
)
205 ,maWindowListeners( _rAntiImpl
)
206 ,maKeyListeners( _rAntiImpl
)
207 ,maMouseListeners( _rAntiImpl
)
208 ,maMouseMotionListeners( _rAntiImpl
)
209 ,maPaintListeners( _rAntiImpl
)
210 ,maContainerListeners( _rAntiImpl
)
211 ,maTopWindowListeners( _rAntiImpl
)
212 ,mnCallbackEventId( nullptr )
213 ,mbDisposing( false )
214 ,mbDesignMode( false )
215 ,mbSynthesizingVCLEvent( false )
216 ,mbWithDefaultProps( _bWithDefaultProps
)
217 ,mnListenerLockLevel( 0 )
218 ,mnWritingMode( WritingMode2::CONTEXT
)
219 ,mnContextWritingMode( WritingMode2::CONTEXT
)
220 ,mpPropHelper( nullptr )
224 void VCLXWindowImpl::disposing()
226 SolarMutexGuard aGuard
;
227 if ( mnCallbackEventId
)
228 Application::RemoveUserEvent( mnCallbackEventId
);
229 mnCallbackEventId
= nullptr;
233 css::lang::EventObject aEvent
;
234 aEvent
.Source
= mrAntiImpl
;
236 maDockableWindowListeners
.disposeAndClear( aEvent
);
237 maEventListeners
.disposeAndClear( aEvent
);
238 maFocusListeners
.disposeAndClear( aEvent
);
239 maWindowListeners
.disposeAndClear( aEvent
);
240 maKeyListeners
.disposeAndClear( aEvent
);
241 maMouseListeners
.disposeAndClear( aEvent
);
242 maMouseMotionListeners
.disposeAndClear( aEvent
);
243 maPaintListeners
.disposeAndClear( aEvent
);
244 maContainerListeners
.disposeAndClear( aEvent
);
245 maTopWindowListeners
.disposeAndClear( aEvent
);
247 ::toolkit::WindowStyleSettings
* pStyleSettings
= static_cast< ::toolkit::WindowStyleSettings
* >( mxWindowStyleSettings
.get() );
248 if ( pStyleSettings
!= nullptr )
249 pStyleSettings
->dispose();
250 mxWindowStyleSettings
.clear();
254 void VCLXWindowImpl::callBackAsync( const VCLXWindow::Callback
& i_callback
)
256 DBG_TESTSOLARMUTEX();
257 maCallbackEvents
.push_back( i_callback
);
258 if ( !mnCallbackEventId
)
260 // ensure our VCLXWindow is not destroyed while the event is underway
261 mrAntiImpl
.acquire();
262 mnCallbackEventId
= Application::PostUserEvent( LINK( this, VCLXWindowImpl
, OnProcessCallbacks
) );
267 IMPL_LINK_NOARG(VCLXWindowImpl
, OnProcessCallbacks
, void*, void)
269 const Reference
< uno::XInterface
> xKeepAlive( mrAntiImpl
);
271 // work on a copy of the callback array
272 CallbackArray aCallbacksCopy
;
274 SolarMutexGuard aGuard
;
275 aCallbacksCopy
= maCallbackEvents
;
276 maCallbackEvents
.clear();
278 // we acquired our VCLXWindow once before posting the event, release this one ref now
279 mrAntiImpl
.release();
281 if ( !mnCallbackEventId
)
282 // we were disposed while waiting for the mutex to lock
285 mnCallbackEventId
= nullptr;
289 SolarMutexReleaser aReleaseSolar
;
290 for ( CallbackArray::const_iterator loop
= aCallbacksCopy
.begin();
291 loop
!= aCallbacksCopy
.end();
300 Reference
< XStyleSettings
> VCLXWindowImpl::getStyleSettings()
302 SolarMutexGuard aGuard
;
304 throw DisposedException( OUString(), mrAntiImpl
);
305 if ( !mxWindowStyleSettings
.is() )
306 mxWindowStyleSettings
= new ::toolkit::WindowStyleSettings( maListenerContainerMutex
, mrAntiImpl
);
307 return mxWindowStyleSettings
;
311 // Uses an out-parameter instead of return value, due to the object reference
313 void ImplInitWindowEvent( css::awt::WindowEvent
& rEvent
, vcl::Window
* pWindow
)
315 Point aPos
= pWindow
->GetPosPixel();
316 Size aSz
= pWindow
->GetSizePixel();
321 rEvent
.Width
= aSz
.Width();
322 rEvent
.Height
= aSz
.Height();
324 pWindow
->GetBorder( rEvent
.LeftInset
, rEvent
.TopInset
, rEvent
.RightInset
, rEvent
.BottomInset
);
327 VCLXWindow::VCLXWindow( bool _bWithDefaultProps
)
330 mpImpl
= new VCLXWindowImpl( *this, _bWithDefaultProps
);
333 VCLXWindow::~VCLXWindow()
339 GetWindow()->RemoveEventListener( LINK( this, VCLXWindow
, WindowEventListener
) );
340 GetWindow()->SetWindowPeer( nullptr, nullptr );
341 GetWindow()->SetAccessible( nullptr );
346 void VCLXWindow::ImplExecuteAsyncWithoutSolarLock( const Callback
& i_callback
)
348 mpImpl
->callBackAsync( i_callback
);
352 ::toolkit::IAccessibleFactory
& VCLXWindow::getAccessibleFactory()
354 return mpImpl
->getAccessibleFactory().getFactory();
357 void VCLXWindow::SetWindow( const VclPtr
<vcl::Window
> &pWindow
)
361 GetWindow()->RemoveEventListener( LINK( this, VCLXWindow
, WindowEventListener
) );
362 // GetWindow()->DbgAssertNoEventListeners();
365 SetOutputDevice( pWindow
);
369 GetWindow()->AddEventListener( LINK( this, VCLXWindow
, WindowEventListener
) );
370 bool bDirectVisible
= pWindow
&& pWindow
->IsVisible();
371 mpImpl
->setDirectVisible( bDirectVisible
);
375 void VCLXWindow::suspendVclEventListening( )
377 ++mpImpl
->mnListenerLockLevel
;
380 void VCLXWindow::resumeVclEventListening( )
382 DBG_ASSERT( mpImpl
->mnListenerLockLevel
, "VCLXWindow::resumeVclEventListening: not suspended!" );
383 --mpImpl
->mnListenerLockLevel
;
386 void VCLXWindow::notifyWindowRemoved( vcl::Window
& _rWindow
)
388 if ( mpImpl
->getContainerListeners().getLength() )
390 awt::VclContainerEvent aEvent
;
391 aEvent
.Source
= *this;
392 aEvent
.Child
= static_cast< XWindow
* >( _rWindow
.GetWindowPeer() );
393 mpImpl
->getContainerListeners().windowRemoved( aEvent
);
397 IMPL_LINK( VCLXWindow
, WindowEventListener
, VclWindowEvent
&, rEvent
, void )
399 if ( mpImpl
->mnListenerLockLevel
)
402 DBG_ASSERT( rEvent
.GetWindow() && GetWindow(), "Window???" );
403 ProcessWindowEvent( rEvent
);
408 struct CallWindow2Listener
410 CallWindow2Listener( ::comphelper::OInterfaceContainerHelper2
& i_rWindow2Listeners
, const bool i_bEnabled
, const EventObject
& i_rEvent
)
411 :m_rWindow2Listeners( i_rWindow2Listeners
)
412 ,m_bEnabled( i_bEnabled
)
413 ,m_aEvent( i_rEvent
)
419 m_rWindow2Listeners
.notifyEach( m_bEnabled
? &XWindowListener2::windowEnabled
: &XWindowListener2::windowDisabled
, m_aEvent
);
422 ::comphelper::OInterfaceContainerHelper2
& m_rWindow2Listeners
;
423 const bool m_bEnabled
;
424 const EventObject m_aEvent
;
428 void VCLXWindow::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
430 css::uno::Reference
< css::uno::XInterface
> xThis( static_cast<cppu::OWeakObject
*>(this) );
432 switch ( rVclWindowEvent
.GetId() )
434 case VclEventId::WindowEnabled
:
435 case VclEventId::WindowDisabled
:
437 Callback aCallback
= CallWindow2Listener(
438 mpImpl
->getWindow2Listeners(),
439 ( VclEventId::WindowEnabled
== rVclWindowEvent
.GetId() ),
442 ImplExecuteAsyncWithoutSolarLock( aCallback
);
446 case VclEventId::WindowPaint
:
448 if ( mpImpl
->getPaintListeners().getLength() )
450 css::awt::PaintEvent aEvent
;
451 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
452 aEvent
.UpdateRect
= AWTRectangle( *static_cast<tools::Rectangle
*>(rVclWindowEvent
.GetData()) );
454 mpImpl
->getPaintListeners().windowPaint( aEvent
);
458 case VclEventId::WindowMove
:
460 if ( mpImpl
->getWindowListeners().getLength() )
462 css::awt::WindowEvent aEvent
;
463 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
464 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
465 mpImpl
->getWindowListeners().windowMoved( aEvent
);
469 case VclEventId::WindowResize
:
471 if ( mpImpl
->getWindowListeners().getLength() )
473 css::awt::WindowEvent aEvent
;
474 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
475 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
476 mpImpl
->getWindowListeners().windowResized( aEvent
);
480 case VclEventId::WindowShow
:
482 if ( mpImpl
->getWindowListeners().getLength() )
484 css::awt::WindowEvent aEvent
;
485 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
486 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
487 mpImpl
->getWindowListeners().windowShown( aEvent
);
490 // For TopWindows this means opened...
491 if ( mpImpl
->getTopWindowListeners().getLength() )
493 css::lang::EventObject aEvent
;
494 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
495 mpImpl
->getTopWindowListeners().windowOpened( aEvent
);
499 case VclEventId::WindowHide
:
501 if ( mpImpl
->getWindowListeners().getLength() )
503 css::awt::WindowEvent aEvent
;
504 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
505 ImplInitWindowEvent( aEvent
, rVclWindowEvent
.GetWindow() );
506 mpImpl
->getWindowListeners().windowHidden( aEvent
);
509 // For TopWindows this means closed...
510 if ( mpImpl
->getTopWindowListeners().getLength() )
512 css::lang::EventObject aEvent
;
513 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
514 mpImpl
->getTopWindowListeners().windowClosed( aEvent
);
518 case VclEventId::WindowActivate
:
520 if ( mpImpl
->getTopWindowListeners().getLength() )
522 css::lang::EventObject aEvent
;
523 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
524 mpImpl
->getTopWindowListeners().windowActivated( aEvent
);
528 case VclEventId::WindowDeactivate
:
530 if ( mpImpl
->getTopWindowListeners().getLength() )
532 css::lang::EventObject aEvent
;
533 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
534 mpImpl
->getTopWindowListeners().windowDeactivated( aEvent
);
538 case VclEventId::WindowClose
:
540 if ( mpImpl
->getDockableWindowListeners().getLength() )
542 css::lang::EventObject aEvent
;
543 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
544 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::closed
, aEvent
);
546 if ( mpImpl
->getTopWindowListeners().getLength() )
548 css::lang::EventObject aEvent
;
549 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
550 mpImpl
->getTopWindowListeners().windowClosing( aEvent
);
554 case VclEventId::ControlGetFocus
:
555 case VclEventId::WindowGetFocus
:
557 if ( ( rVclWindowEvent
.GetWindow()->IsCompoundControl()
558 && rVclWindowEvent
.GetId() == VclEventId::ControlGetFocus
560 || ( !rVclWindowEvent
.GetWindow()->IsCompoundControl()
561 && rVclWindowEvent
.GetId() == VclEventId::WindowGetFocus
565 if ( mpImpl
->getFocusListeners().getLength() )
567 css::awt::FocusEvent aEvent
;
568 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
569 aEvent
.FocusFlags
= static_cast<sal_Int16
>(rVclWindowEvent
.GetWindow()->GetGetFocusFlags());
570 aEvent
.Temporary
= false;
571 mpImpl
->getFocusListeners().focusGained( aEvent
);
576 case VclEventId::ControlLoseFocus
:
577 case VclEventId::WindowLoseFocus
:
579 if ( ( rVclWindowEvent
.GetWindow()->IsCompoundControl()
580 && rVclWindowEvent
.GetId() == VclEventId::ControlLoseFocus
582 || ( !rVclWindowEvent
.GetWindow()->IsCompoundControl()
583 && rVclWindowEvent
.GetId() == VclEventId::WindowLoseFocus
587 if ( mpImpl
->getFocusListeners().getLength() )
589 css::awt::FocusEvent aEvent
;
590 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
591 aEvent
.FocusFlags
= static_cast<sal_Int16
>(rVclWindowEvent
.GetWindow()->GetGetFocusFlags());
592 aEvent
.Temporary
= false;
594 vcl::Window
* pNext
= Application::GetFocusWindow();
597 // Don't care about internals if this control is compound
598 vcl::Window
* pNextC
= pNext
;
599 while ( pNextC
&& !pNextC
->IsCompoundControl() )
600 pNextC
= pNextC
->GetParent();
604 pNext
->GetComponentInterface();
605 aEvent
.NextFocus
= static_cast<cppu::OWeakObject
*>(pNext
->GetWindowPeer());
607 mpImpl
->getFocusListeners().focusLost( aEvent
);
612 case VclEventId::WindowMinimize
:
614 if ( mpImpl
->getTopWindowListeners().getLength() )
616 css::lang::EventObject aEvent
;
617 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
618 mpImpl
->getTopWindowListeners().windowMinimized( aEvent
);
622 case VclEventId::WindowNormalize
:
624 if ( mpImpl
->getTopWindowListeners().getLength() )
626 css::lang::EventObject aEvent
;
627 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
628 mpImpl
->getTopWindowListeners().windowNormalized( aEvent
);
632 case VclEventId::WindowKeyInput
:
634 if ( mpImpl
->getKeyListeners().getLength() )
636 css::awt::KeyEvent
aEvent( VCLUnoHelper::createKeyEvent(
637 *static_cast<KeyEvent
*>(rVclWindowEvent
.GetData()), *this
639 mpImpl
->getKeyListeners().keyPressed( aEvent
);
643 case VclEventId::WindowKeyUp
:
645 if ( mpImpl
->getKeyListeners().getLength() )
647 css::awt::KeyEvent
aEvent( VCLUnoHelper::createKeyEvent(
648 *static_cast<KeyEvent
*>(rVclWindowEvent
.GetData()), *this
650 mpImpl
->getKeyListeners().keyReleased( aEvent
);
654 case VclEventId::WindowCommand
:
656 CommandEvent
* pCmdEvt
= static_cast<CommandEvent
*>(rVclWindowEvent
.GetData());
657 if ( mpImpl
->getMouseListeners().getLength() && ( pCmdEvt
->GetCommand() == CommandEventId::ContextMenu
) )
659 // CommandEventId::ContextMenu als mousePressed mit PopupTrigger = sal_True versenden...
660 Point aWhere
= static_cast< CommandEvent
* >( rVclWindowEvent
.GetData() )->GetMousePosPixel();
661 if ( !pCmdEvt
->IsMouseEvent() )
662 { // for keyboard events, we set the coordinates to -1,-1. This is a slight HACK, but the current API
663 // handles a context menu command as special case of a mouse event, which is simply wrong.
664 // Without extending the API, we would not have another chance to notify listeners of a
665 // keyboard-triggered context menu request
666 aWhere
= Point( -1, -1 );
669 MouseEvent
aMEvt( aWhere
, 1, MouseEventModifiers::SIMPLECLICK
, MOUSE_LEFT
, 0 );
670 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( aMEvt
, *this ) );
671 aEvent
.PopupTrigger
= true;
673 Callback aCallback
= [ this, aEvent
]()
674 { this->mpImpl
->getMouseListeners().mousePressed( aEvent
); };
676 ImplExecuteAsyncWithoutSolarLock( aCallback
);
680 case VclEventId::WindowMouseMove
:
682 MouseEvent
* pMouseEvt
= static_cast<MouseEvent
*>(rVclWindowEvent
.GetData());
683 if ( mpImpl
->getMouseListeners().getLength() && ( pMouseEvt
->IsEnterWindow() || pMouseEvt
->IsLeaveWindow() ) )
685 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt
, *this ) );
686 bool const isEnter(pMouseEvt
->IsEnterWindow());
687 Callback aCallback
= [ this, isEnter
, aEvent
]()
688 { MouseListenerMultiplexer
& rMouseListeners
= this->mpImpl
->getMouseListeners();
690 ? rMouseListeners
.mouseEntered(aEvent
)
691 : rMouseListeners
.mouseExited(aEvent
); };
693 ImplExecuteAsyncWithoutSolarLock( aCallback
);
696 if ( mpImpl
->getMouseMotionListeners().getLength() && !pMouseEvt
->IsEnterWindow() && !pMouseEvt
->IsLeaveWindow() )
698 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( *pMouseEvt
, *this ) );
699 aEvent
.ClickCount
= 0;
700 if ( pMouseEvt
->GetMode() & MouseEventModifiers::SIMPLEMOVE
)
701 mpImpl
->getMouseMotionListeners().mouseMoved( aEvent
);
703 mpImpl
->getMouseMotionListeners().mouseDragged( aEvent
);
707 case VclEventId::WindowMouseButtonDown
:
709 if ( mpImpl
->getMouseListeners().getLength() )
711 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( *static_cast<MouseEvent
*>(rVclWindowEvent
.GetData()), *this ) );
712 Callback aCallback
= [ this, aEvent
]()
713 { this->mpImpl
->getMouseListeners().mousePressed( aEvent
); };
714 ImplExecuteAsyncWithoutSolarLock( aCallback
);
718 case VclEventId::WindowMouseButtonUp
:
720 if ( mpImpl
->getMouseListeners().getLength() )
722 awt::MouseEvent
aEvent( VCLUnoHelper::createMouseEvent( *static_cast<MouseEvent
*>(rVclWindowEvent
.GetData()), *this ) );
724 Callback aCallback
= [ this, aEvent
]()
725 { this->mpImpl
->getMouseListeners().mouseReleased( aEvent
); };
726 ImplExecuteAsyncWithoutSolarLock( aCallback
);
730 case VclEventId::WindowStartDocking
:
732 if ( mpImpl
->getDockableWindowListeners().getLength() )
734 DockingData
*pData
= static_cast<DockingData
*>(rVclWindowEvent
.GetData());
738 css::awt::DockingEvent aEvent
;
739 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
740 aEvent
.TrackingRectangle
= AWTRectangle( pData
->maTrackRect
);
741 aEvent
.MousePos
.X
= pData
->maMousePos
.X();
742 aEvent
.MousePos
.Y
= pData
->maMousePos
.Y();
743 aEvent
.bLiveMode
= false;
744 aEvent
.bInteractive
= true;
746 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::startDocking
, aEvent
);
751 case VclEventId::WindowDocking
:
753 if ( mpImpl
->getDockableWindowListeners().getLength() )
755 DockingData
*pData
= static_cast<DockingData
*>(rVclWindowEvent
.GetData());
759 css::awt::DockingEvent aEvent
;
760 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
761 aEvent
.TrackingRectangle
= AWTRectangle( pData
->maTrackRect
);
762 aEvent
.MousePos
.X
= pData
->maMousePos
.X();
763 aEvent
.MousePos
.Y
= pData
->maMousePos
.Y();
764 aEvent
.bLiveMode
= false;
765 aEvent
.bInteractive
= true;
767 Reference
< XDockableWindowListener
> xFirstListener
;
768 ::comphelper::OInterfaceIteratorHelper2
aIter( mpImpl
->getDockableWindowListeners() );
769 while ( aIter
.hasMoreElements() && !xFirstListener
.is() )
771 xFirstListener
.set( aIter
.next(), UNO_QUERY
);
774 css::awt::DockingData aDockingData
=
775 xFirstListener
->docking( aEvent
);
776 pData
->maTrackRect
= VCLRectangle( aDockingData
.TrackingRectangle
);
777 pData
->mbFloating
= aDockingData
.bFloating
;
782 case VclEventId::WindowEndDocking
:
784 if ( mpImpl
->getDockableWindowListeners().getLength() )
786 EndDockingData
*pData
= static_cast<EndDockingData
*>(rVclWindowEvent
.GetData());
790 css::awt::EndDockingEvent aEvent
;
791 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
792 aEvent
.WindowRectangle
= AWTRectangle( pData
->maWindowRect
);
793 aEvent
.bFloating
= pData
->mbFloating
;
794 aEvent
.bCancelled
= pData
->mbCancelled
;
795 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endDocking
, aEvent
);
800 case VclEventId::WindowPrepareToggleFloating
:
802 if ( mpImpl
->getDockableWindowListeners().getLength() )
804 sal_Bool
*p_bFloating
= static_cast<sal_Bool
*>(rVclWindowEvent
.GetData());
806 css::lang::EventObject aEvent
;
807 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
809 Reference
< XDockableWindowListener
> xFirstListener
;
810 ::comphelper::OInterfaceIteratorHelper2
aIter( mpImpl
->getDockableWindowListeners() );
811 while ( aIter
.hasMoreElements() && !xFirstListener
.is() )
813 xFirstListener
.set( aIter
.next(), UNO_QUERY
);
816 *p_bFloating
= xFirstListener
->prepareToggleFloatingMode( aEvent
);
820 case VclEventId::WindowToggleFloating
:
822 if ( mpImpl
->getDockableWindowListeners().getLength() )
824 css::lang::EventObject aEvent
;
825 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
826 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::toggleFloatingMode
, aEvent
);
830 case VclEventId::WindowEndPopupMode
:
832 if ( mpImpl
->getDockableWindowListeners().getLength() )
834 EndPopupModeData
*pData
= static_cast<EndPopupModeData
*>(rVclWindowEvent
.GetData());
838 css::awt::EndPopupModeEvent aEvent
;
839 aEvent
.Source
= static_cast<cppu::OWeakObject
*>(this);
840 aEvent
.FloatingPosition
.X
= pData
->maFloatingPos
.X();
841 aEvent
.FloatingPosition
.Y
= pData
->maFloatingPos
.Y();
842 aEvent
.bTearoff
= pData
->mbTearoff
;
843 mpImpl
->getDockableWindowListeners().notifyEach( &XDockableWindowListener::endPopupMode
, aEvent
);
852 uno::Reference
< accessibility::XAccessibleContext
> VCLXWindow::CreateAccessibleContext()
854 SolarMutexGuard aGuard
;
855 return getAccessibleFactory().createAccessibleContext( this );
858 void VCLXWindow::SetSynthesizingVCLEvent( bool _b
)
860 mpImpl
->mbSynthesizingVCLEvent
= _b
;
863 bool VCLXWindow::IsSynthesizingVCLEvent() const
865 return mpImpl
->mbSynthesizingVCLEvent
;
868 Size
VCLXWindow::ImplCalcWindowSize( const Size
& rOutSz
) const
872 VclPtr
<vcl::Window
> pWindow
= GetWindow();
875 sal_Int32 nLeft
, nTop
, nRight
, nBottom
;
876 pWindow
->GetBorder( nLeft
, nTop
, nRight
, nBottom
);
877 aSz
.Width() += nLeft
+nRight
;
878 aSz
.Height() += nTop
+nBottom
;
884 // css::lang::XUnoTunnel
885 sal_Int64
VCLXWindow::getSomething( const css::uno::Sequence
< sal_Int8
>& rIdentifier
)
887 if( ( rIdentifier
.getLength() == 16 ) && ( 0 == memcmp( VCLXWindow::GetUnoTunnelId().getConstArray(), rIdentifier
.getConstArray(), 16 ) ) )
889 return sal::static_int_cast
< sal_Int64
>(reinterpret_cast< sal_IntPtr
>(this));
891 return VCLXDevice::getSomething( rIdentifier
);
895 class theVCLXWindowUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theVCLXWindowUnoTunnelId
> {};
897 const css::uno::Sequence
< sal_Int8
>& VCLXWindow::GetUnoTunnelId() throw()
899 return theVCLXWindowUnoTunnelId::get().getSeq();
901 VCLXWindow
* VCLXWindow::GetImplementation( const css::uno::Reference
< css::uno::XInterface
>& rxIFace
)
903 css::uno::Reference
< css::lang::XUnoTunnel
> xUT( rxIFace
, css::uno::UNO_QUERY
);
904 return xUT
.is() ? reinterpret_cast<VCLXWindow
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething( VCLXWindow::GetUnoTunnelId() ))) : nullptr;
908 // css::lang::Component
909 void VCLXWindow::dispose( )
911 SolarMutexGuard aGuard
;
913 mpImpl
->mxViewGraphics
= nullptr;
915 if ( !mpImpl
->mbDisposing
)
917 mpImpl
->mbDisposing
= true;
923 VclPtr
<OutputDevice
> pOutDev
= GetOutputDevice();
924 SetWindow( nullptr ); // so that handlers are logged off, if necessary (virtual)
925 SetOutputDevice( nullptr );
926 pOutDev
.disposeAndClear();
929 // #i14103# dispose the accessible context after the window has been destroyed,
930 // otherwise the old value in the child event fired in VCLXAccessibleComponent::ProcessWindowEvent()
931 // for VclEventId::WindowChildDestroyed contains a reference to an already disposed accessible object
934 css::uno::Reference
< css::lang::XComponent
> xComponent( mpImpl
->mxAccessibleContext
, css::uno::UNO_QUERY
);
935 if ( xComponent
.is() )
936 xComponent
->dispose();
938 catch ( const css::uno::Exception
& )
940 OSL_FAIL( "VCLXWindow::dispose: could not dispose the accessible context!" );
942 mpImpl
->mxAccessibleContext
.clear();
944 mpImpl
->mbDisposing
= false;
948 void VCLXWindow::addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
)
950 SolarMutexGuard aGuard
;
952 mpImpl
->getEventListeners().addInterface( rxListener
);
955 void VCLXWindow::removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& rxListener
)
957 SolarMutexGuard aGuard
;
959 mpImpl
->getEventListeners().removeInterface( rxListener
);
964 void VCLXWindow::setPosSize( sal_Int32 X
, sal_Int32 Y
, sal_Int32 Width
, sal_Int32 Height
, sal_Int16 Flags
)
966 SolarMutexGuard aGuard
;
970 if( vcl::Window::GetDockingManager()->IsDockable( GetWindow() ) )
971 vcl::Window::GetDockingManager()->SetPosSizePixel( GetWindow() , X
, Y
, Width
, Height
, static_cast<PosSizeFlags
>(Flags
) );
973 GetWindow()->setPosSizePixel( X
, Y
, Width
, Height
, static_cast<PosSizeFlags
>(Flags
) );
977 css::awt::Rectangle
VCLXWindow::getPosSize( )
979 SolarMutexGuard aGuard
;
981 css::awt::Rectangle aBounds
;
984 if( vcl::Window::GetDockingManager()->IsDockable( GetWindow() ) )
985 aBounds
= AWTRectangle( vcl::Window::GetDockingManager()->GetPosSizePixel( GetWindow() ) );
987 aBounds
= AWTRectangle( tools::Rectangle( GetWindow()->GetPosPixel(), GetWindow()->GetSizePixel() ) );
993 void VCLXWindow::setVisible( sal_Bool bVisible
)
995 SolarMutexGuard aGuard
;
997 VclPtr
<vcl::Window
> pWindow
= GetWindow();
1000 mpImpl
->setDirectVisible( bVisible
);
1001 pWindow
->Show( bVisible
&& mpImpl
->isEnableVisible() );
1005 void VCLXWindow::setEnable( sal_Bool bEnable
)
1007 SolarMutexGuard aGuard
;
1009 VclPtr
<vcl::Window
> pWindow
= GetWindow();
1012 pWindow
->Enable( bEnable
, false ); // #95824# without children!
1013 pWindow
->EnableInput( bEnable
);
1017 void VCLXWindow::setFocus( )
1019 SolarMutexGuard aGuard
;
1022 GetWindow()->GrabFocus();
1025 void VCLXWindow::addWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& rxListener
)
1027 SolarMutexGuard aGuard
;
1029 mpImpl
->getWindowListeners().addInterface( rxListener
);
1031 Reference
< XWindowListener2
> xListener2( rxListener
, UNO_QUERY
);
1032 if ( xListener2
.is() )
1033 mpImpl
->getWindow2Listeners().addInterface( xListener2
);
1035 // #100119# Get all resize events, even if height or width 0, or invisible
1037 GetWindow()->EnableAllResize();
1040 void VCLXWindow::removeWindowListener( const css::uno::Reference
< css::awt::XWindowListener
>& rxListener
)
1042 SolarMutexGuard aGuard
;
1044 Reference
< XWindowListener2
> xListener2( rxListener
, UNO_QUERY
);
1045 if ( xListener2
.is() )
1046 mpImpl
->getWindow2Listeners().removeInterface( xListener2
);
1048 mpImpl
->getWindowListeners().removeInterface( rxListener
);
1051 void VCLXWindow::addFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& rxListener
)
1053 SolarMutexGuard aGuard
;
1054 mpImpl
->getFocusListeners().addInterface( rxListener
);
1057 void VCLXWindow::removeFocusListener( const css::uno::Reference
< css::awt::XFocusListener
>& rxListener
)
1059 SolarMutexGuard aGuard
;
1060 mpImpl
->getFocusListeners().removeInterface( rxListener
);
1063 void VCLXWindow::addKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& rxListener
)
1065 SolarMutexGuard aGuard
;
1066 mpImpl
->getKeyListeners().addInterface( rxListener
);
1069 void VCLXWindow::removeKeyListener( const css::uno::Reference
< css::awt::XKeyListener
>& rxListener
)
1071 SolarMutexGuard aGuard
;
1072 mpImpl
->getKeyListeners().removeInterface( rxListener
);
1075 void VCLXWindow::addMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& rxListener
)
1077 SolarMutexGuard aGuard
;
1078 mpImpl
->getMouseListeners().addInterface( rxListener
);
1081 void VCLXWindow::removeMouseListener( const css::uno::Reference
< css::awt::XMouseListener
>& rxListener
)
1083 SolarMutexGuard aGuard
;
1084 mpImpl
->getMouseListeners().removeInterface( rxListener
);
1087 void VCLXWindow::addMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& rxListener
)
1089 SolarMutexGuard aGuard
;
1090 mpImpl
->getMouseMotionListeners().addInterface( rxListener
);
1093 void VCLXWindow::removeMouseMotionListener( const css::uno::Reference
< css::awt::XMouseMotionListener
>& rxListener
)
1095 SolarMutexGuard aGuard
;
1096 mpImpl
->getMouseMotionListeners().removeInterface( rxListener
);
1099 void VCLXWindow::addPaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& rxListener
)
1101 SolarMutexGuard aGuard
;
1102 mpImpl
->getPaintListeners().addInterface( rxListener
);
1105 void VCLXWindow::removePaintListener( const css::uno::Reference
< css::awt::XPaintListener
>& rxListener
)
1107 SolarMutexGuard aGuard
;
1108 mpImpl
->getPaintListeners().removeInterface( rxListener
);
1111 // css::awt::XWindowPeer
1112 css::uno::Reference
< css::awt::XToolkit
> VCLXWindow::getToolkit( )
1114 // no guard. nothing to guard here.
1115 // 82463 - 12/21/00 - fs
1116 return Application::GetVCLToolkit();
1119 void VCLXWindow::setPointer( const css::uno::Reference
< css::awt::XPointer
>& rxPointer
)
1121 SolarMutexGuard aGuard
;
1123 VCLXPointer
* pPointer
= VCLXPointer::GetImplementation( rxPointer
);
1126 mpImpl
->mxPointer
= rxPointer
;
1128 GetWindow()->SetPointer( pPointer
->GetPointer() );
1132 void VCLXWindow::setBackground( sal_Int32 nColor
)
1134 SolarMutexGuard aGuard
;
1138 Color
aColor( (sal_uInt32
)nColor
);
1139 GetWindow()->SetBackground( aColor
);
1140 GetWindow()->SetControlBackground( aColor
);
1142 WindowType eWinType
= GetWindow()->GetType();
1143 if ( ( eWinType
== WindowType::WINDOW
) ||
1144 ( eWinType
== WindowType::WORKWINDOW
) ||
1145 ( eWinType
== WindowType::FLOATINGWINDOW
) )
1147 GetWindow()->Invalidate();
1152 void VCLXWindow::invalidate( sal_Int16 nInvalidateFlags
)
1154 SolarMutexGuard aGuard
;
1157 GetWindow()->Invalidate( static_cast<InvalidateFlags
>(nInvalidateFlags
) );
1160 void VCLXWindow::invalidateRect( const css::awt::Rectangle
& rRect
, sal_Int16 nInvalidateFlags
)
1162 SolarMutexGuard aGuard
;
1165 GetWindow()->Invalidate( VCLRectangle(rRect
), static_cast<InvalidateFlags
>(nInvalidateFlags
) );
1169 // css::awt::XVclWindowPeer
1170 sal_Bool
VCLXWindow::isChild( const css::uno::Reference
< css::awt::XWindowPeer
>& rxPeer
)
1172 SolarMutexGuard aGuard
;
1174 bool bIsChild
= false;
1175 VclPtr
<vcl::Window
> pWindow
= GetWindow();
1178 VclPtr
<vcl::Window
> pPeerWindow
= VCLUnoHelper::GetWindow( rxPeer
);
1179 bIsChild
= pPeerWindow
&& pWindow
->IsChild( pPeerWindow
);
1185 void VCLXWindow::setDesignMode( sal_Bool bOn
)
1187 SolarMutexGuard aGuard
;
1189 mpImpl
->mbDesignMode
= bOn
;
1192 sal_Bool
VCLXWindow::isDesignMode( )
1194 SolarMutexGuard aGuard
;
1195 return mpImpl
->mbDesignMode
;
1198 void VCLXWindow::enableClipSiblings( sal_Bool bClip
)
1200 SolarMutexGuard aGuard
;
1203 GetWindow()->EnableClipSiblings( bClip
);
1206 void VCLXWindow::setForeground( sal_Int32 nColor
)
1208 SolarMutexGuard aGuard
;
1212 Color
aColor( (sal_uInt32
)nColor
);
1213 GetWindow()->SetControlForeground( aColor
);
1217 void VCLXWindow::setControlFont( const css::awt::FontDescriptor
& rFont
)
1219 SolarMutexGuard aGuard
;
1222 GetWindow()->SetControlFont( VCLUnoHelper::CreateFont( rFont
, GetWindow()->GetControlFont() ) );
1225 void VCLXWindow::getStyles( sal_Int16 nType
, css::awt::FontDescriptor
& Font
, sal_Int32
& ForegroundColor
, sal_Int32
& BackgroundColor
)
1227 SolarMutexGuard aGuard
;
1231 const StyleSettings
& rStyleSettings
= GetWindow()->GetSettings().GetStyleSettings();
1235 case css::awt::Style::FRAME
:
1237 Font
= VCLUnoHelper::CreateFontDescriptor( rStyleSettings
.GetAppFont() );
1238 ForegroundColor
= rStyleSettings
.GetWindowTextColor().GetColor();
1239 BackgroundColor
= rStyleSettings
.GetWindowColor().GetColor();
1242 case css::awt::Style::DIALOG
:
1244 Font
= VCLUnoHelper::CreateFontDescriptor( rStyleSettings
.GetAppFont() );
1245 ForegroundColor
= rStyleSettings
.GetDialogTextColor().GetColor();
1246 BackgroundColor
= rStyleSettings
.GetDialogColor().GetColor();
1249 default: OSL_FAIL( "VCLWindow::getStyles() - unknown Type" );
1257 static void setColorSettings( vcl::Window
* _pWindow
, const css::uno::Any
& _rValue
,
1258 void (StyleSettings::*pSetter
)( const Color
& ), const Color
& (StyleSettings::*pGetter
)( ) const )
1260 sal_Int32 nColor
= 0;
1261 if ( !( _rValue
>>= nColor
) )
1262 nColor
= (Application::GetSettings().GetStyleSettings().*pGetter
)().GetColor();
1264 AllSettings aSettings
= _pWindow
->GetSettings();
1265 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
1267 (aStyleSettings
.*pSetter
)( Color( nColor
) );
1269 aSettings
.SetStyleSettings( aStyleSettings
);
1270 _pWindow
->SetSettings( aSettings
, true );
1274 // Terminated by BASEPROPERTY_NOTFOUND (or 0)
1275 void VCLXWindow::PushPropertyIds( std::vector
< sal_uInt16
> &rIds
,
1279 va_start( pVarArgs
, nFirstId
);
1281 for ( int nId
= nFirstId
; nId
!= BASEPROPERTY_NOTFOUND
;
1282 nId
= va_arg( pVarArgs
, int ) )
1283 rIds
.push_back( (sal_uInt16
) nId
);
1288 void VCLXWindow::ImplGetPropertyIds( std::vector
< sal_uInt16
> &rIds
, bool bWithDefaults
)
1290 // These are common across ~all VCLXWindow derived classes
1292 PushPropertyIds( rIds
,
1294 BASEPROPERTY_BACKGROUNDCOLOR
,
1295 BASEPROPERTY_BORDER
,
1296 BASEPROPERTY_BORDERCOLOR
,
1297 BASEPROPERTY_DEFAULTCONTROL
,
1298 BASEPROPERTY_ENABLED
,
1299 BASEPROPERTY_FONTDESCRIPTOR
,
1300 BASEPROPERTY_HELPTEXT
,
1301 BASEPROPERTY_HELPURL
,
1303 BASEPROPERTY_PRINTABLE
,
1304 BASEPROPERTY_ENABLEVISIBLE
, // for visibility
1305 BASEPROPERTY_TABSTOP
,
1308 // lovely hack from:
1309 // void UnoControlModel::ImplRegisterProperty( sal_uInt16 nPropId )
1310 std::vector
< sal_uInt16
>::const_iterator iter
;
1311 for( iter
= rIds
.begin(); iter
!= rIds
.end(); ++iter
) {
1312 if( *iter
== BASEPROPERTY_FONTDESCRIPTOR
)
1314 // some properties are not included in the FontDescriptor, but every time
1315 // when we have a FontDescriptor we want to have these properties too.
1316 // => Easier to register the here, instead everywhere where I register the FontDescriptor...
1318 rIds
.push_back( BASEPROPERTY_TEXTCOLOR
);
1319 rIds
.push_back( BASEPROPERTY_TEXTLINECOLOR
);
1320 rIds
.push_back( BASEPROPERTY_FONTRELIEF
);
1321 rIds
.push_back( BASEPROPERTY_FONTEMPHASISMARK
);
1327 void VCLXWindow::GetPropertyIds( std::vector
< sal_uInt16
>& _out_rIds
)
1329 return ImplGetPropertyIds( _out_rIds
, mpImpl
->mbWithDefaultProps
);
1332 ::comphelper::OInterfaceContainerHelper2
& VCLXWindow::GetContainerListeners()
1334 return mpImpl
->getContainerListeners();
1337 ::comphelper::OInterfaceContainerHelper2
& VCLXWindow::GetTopWindowListeners()
1339 return mpImpl
->getTopWindowListeners();
1344 void lcl_updateWritingMode( vcl::Window
& _rWindow
, const sal_Int16 _nWritingMode
, const sal_Int16 _nContextWritingMode
)
1346 bool bEnableRTL
= false;
1347 switch ( _nWritingMode
)
1349 case WritingMode2::LR_TB
: bEnableRTL
= false; break;
1350 case WritingMode2::RL_TB
: bEnableRTL
= true; break;
1351 case WritingMode2::CONTEXT
:
1353 // consult our ContextWritingMode. If it has an explicit RTL/LTR value, then use
1354 // it. If it doesn't (but is CONTEXT itself), then just ask the parent window of our
1355 // own window for its RTL mode
1356 switch ( _nContextWritingMode
)
1358 case WritingMode2::LR_TB
: bEnableRTL
= false; break;
1359 case WritingMode2::RL_TB
: bEnableRTL
= true; break;
1360 case WritingMode2::CONTEXT
:
1362 const vcl::Window
* pParent
= _rWindow
.GetParent();
1363 OSL_ENSURE( pParent
, "lcl_updateWritingMode: cannot determine context's writing mode!" );
1365 bEnableRTL
= pParent
->IsRTLEnabled();
1372 OSL_FAIL( "lcl_updateWritingMode: unsupported WritingMode!" );
1373 } // switch ( nWritingMode )
1375 _rWindow
.EnableRTL( bEnableRTL
);
1379 void VCLXWindow::setProperty( const OUString
& PropertyName
, const css::uno::Any
& Value
)
1381 SolarMutexGuard aGuard
;
1383 VclPtr
<vcl::Window
> pWindow
= GetWindow();
1387 bool bVoid
= Value
.getValueType().getTypeClass() == css::uno::TypeClass_VOID
;
1389 WindowType eWinType
= pWindow
->GetType();
1390 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1391 switch ( nPropType
)
1393 case BASEPROPERTY_REFERENCE_DEVICE
:
1395 Control
* pControl
= dynamic_cast< Control
* >( pWindow
.get() );
1396 OSL_ENSURE( pControl
, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
1399 Reference
< XDevice
> xDevice( Value
, UNO_QUERY
);
1400 OutputDevice
* pDevice
= VCLUnoHelper::GetOutputDevice( xDevice
);
1401 pControl
->SetReferenceDevice( pDevice
);
1405 case BASEPROPERTY_CONTEXT_WRITING_MODE
:
1407 OSL_VERIFY( Value
>>= mpImpl
->mnContextWritingMode
);
1408 if ( mpImpl
->mnWritingMode
== WritingMode2::CONTEXT
)
1409 lcl_updateWritingMode( *pWindow
, mpImpl
->mnWritingMode
, mpImpl
->mnContextWritingMode
);
1413 case BASEPROPERTY_WRITING_MODE
:
1415 bool bProperType
= ( Value
>>= mpImpl
->mnWritingMode
);
1416 OSL_ENSURE( bProperType
, "VCLXWindow::setProperty( 'WritingMode' ): illegal value type!" );
1418 lcl_updateWritingMode( *pWindow
, mpImpl
->mnWritingMode
, mpImpl
->mnContextWritingMode
);
1422 case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
:
1424 sal_uInt16
nWheelBehavior( css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
);
1425 OSL_VERIFY( Value
>>= nWheelBehavior
);
1427 AllSettings aSettings
= pWindow
->GetSettings();
1428 MouseSettings aMouseSettings
= aSettings
.GetMouseSettings();
1430 MouseWheelBehaviour
nVclBehavior( MouseWheelBehaviour::FocusOnly
);
1431 switch ( nWheelBehavior
)
1433 case css::awt::MouseWheelBehavior::SCROLL_DISABLED
: nVclBehavior
= MouseWheelBehaviour::Disable
; break;
1434 case css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
: nVclBehavior
= MouseWheelBehaviour::FocusOnly
; break;
1435 case css::awt::MouseWheelBehavior::SCROLL_ALWAYS
: nVclBehavior
= MouseWheelBehaviour::ALWAYS
; break;
1437 OSL_FAIL( "VCLXWindow::setProperty( 'MouseWheelBehavior' ): illegal property value!" );
1440 aMouseSettings
.SetWheelBehavior( nVclBehavior
);
1441 aSettings
.SetMouseSettings( aMouseSettings
);
1442 pWindow
->SetSettings( aSettings
, true );
1446 case BASEPROPERTY_NATIVE_WIDGET_LOOK
:
1448 bool bEnable( true );
1449 OSL_VERIFY( Value
>>= bEnable
);
1450 pWindow
->EnableNativeWidget( bEnable
);
1454 case BASEPROPERTY_PLUGINPARENT
:
1456 // set parent handle
1457 SetSystemParent_Impl( Value
);
1461 case BASEPROPERTY_ENABLED
:
1468 case BASEPROPERTY_ENABLEVISIBLE
:
1473 if( b
!= mpImpl
->isEnableVisible() )
1475 mpImpl
->setEnableVisible( b
);
1476 pWindow
->Show( b
&& mpImpl
->isDirectVisible() );
1481 case BASEPROPERTY_TEXT
:
1482 case BASEPROPERTY_LABEL
:
1483 case BASEPROPERTY_TITLE
:
1486 if ( Value
>>= aText
)
1490 case WindowType::OKBUTTON
:
1491 case WindowType::CANCELBUTTON
:
1492 case WindowType::HELPBUTTON
:
1493 // Standard Button: overwrite only if not empty.
1494 if (!aText
.isEmpty())
1495 pWindow
->SetText( aText
);
1499 pWindow
->SetText( aText
);
1505 case BASEPROPERTY_ACCESSIBLENAME
:
1508 if ( Value
>>= aText
)
1509 pWindow
->SetAccessibleName( aText
);
1512 case BASEPROPERTY_HELPURL
:
1515 if ( Value
>>= aURL
)
1517 INetURLObject
aHelpURL( aURL
);
1518 if ( aHelpURL
.GetProtocol() == INetProtocol::Hid
)
1519 pWindow
->SetHelpId( OUStringToOString( aHelpURL
.GetURLPath(), RTL_TEXTENCODING_UTF8
) );
1521 pWindow
->SetHelpId( OUStringToOString( aURL
, RTL_TEXTENCODING_UTF8
) );
1525 case BASEPROPERTY_HELPTEXT
:
1528 if ( Value
>>= aHelpText
)
1530 pWindow
->SetQuickHelpText( aHelpText
);
1534 case BASEPROPERTY_FONTDESCRIPTOR
:
1537 pWindow
->SetControlFont( vcl::Font() );
1540 css::awt::FontDescriptor aFont
;
1541 if ( Value
>>= aFont
)
1542 pWindow
->SetControlFont( VCLUnoHelper::CreateFont( aFont
, pWindow
->GetControlFont() ) );
1546 case BASEPROPERTY_FONTRELIEF
:
1548 sal_Int16 n
= sal_Int16();
1551 vcl::Font aFont
= pWindow
->GetControlFont();
1552 aFont
.SetRelief( (FontRelief
)n
);
1553 pWindow
->SetControlFont( aFont
);
1557 case BASEPROPERTY_FONTEMPHASISMARK
:
1559 sal_Int16 n
= sal_Int16();
1562 vcl::Font aFont
= pWindow
->GetControlFont();
1563 aFont
.SetEmphasisMark( (FontEmphasisMark
)n
);
1564 pWindow
->SetControlFont( aFont
);
1568 case BASEPROPERTY_BACKGROUNDCOLOR
:
1573 // set dialog color for default
1574 case WindowType::DIALOG
:
1575 case WindowType::MESSBOX
:
1576 case WindowType::INFOBOX
:
1577 case WindowType::WARNINGBOX
:
1578 case WindowType::ERRORBOX
:
1579 case WindowType::QUERYBOX
:
1580 case WindowType::TABPAGE
:
1582 Color aColor
= pWindow
->GetSettings().GetStyleSettings().GetDialogColor();
1583 pWindow
->SetBackground( aColor
);
1584 pWindow
->SetControlBackground( aColor
);
1588 case WindowType::FIXEDTEXT
:
1589 case WindowType::CHECKBOX
:
1590 case WindowType::RADIOBUTTON
:
1591 case WindowType::GROUPBOX
:
1592 case WindowType::FIXEDLINE
:
1594 // support transparency only for special controls
1595 pWindow
->SetBackground();
1596 pWindow
->SetControlBackground();
1597 pWindow
->SetPaintTransparent( true );
1603 // default code which enables transparency for
1604 // compound controls. It's not real transparency
1605 // as most of these controls repaint their client
1606 // area completely new.
1607 if ( pWindow
->IsCompoundControl() )
1608 pWindow
->SetBackground();
1609 pWindow
->SetControlBackground();
1616 sal_Int32 nColor
= 0;
1617 if ( Value
>>= nColor
)
1619 Color
aColor( nColor
);
1620 pWindow
->SetControlBackground( aColor
);
1621 pWindow
->SetBackground( aColor
);
1624 // reset paint transparent mode
1625 case WindowType::FIXEDTEXT
:
1626 case WindowType::CHECKBOX
:
1627 case WindowType::RADIOBUTTON
:
1628 case WindowType::GROUPBOX
:
1629 case WindowType::FIXEDLINE
:
1630 pWindow
->SetPaintTransparent( false );
1635 pWindow
->Invalidate(); // Invalidate if control does not respond to it
1639 case BASEPROPERTY_TEXTCOLOR
:
1642 pWindow
->SetControlForeground();
1646 sal_Int32 nColor
= 0;
1647 if ( Value
>>= nColor
)
1649 Color
aColor( nColor
);
1650 pWindow
->SetTextColor( aColor
);
1651 pWindow
->SetControlForeground( aColor
);
1655 case BASEPROPERTY_TEXTLINECOLOR
:
1658 pWindow
->SetTextLineColor();
1662 sal_Int32 nColor
= 0;
1663 if ( Value
>>= nColor
)
1665 Color
aColor( nColor
);
1666 pWindow
->SetTextLineColor( aColor
);
1670 case BASEPROPERTY_FILLCOLOR
:
1672 pWindow
->SetFillColor();
1675 sal_Int32 nColor
= 0;
1676 if ( Value
>>= nColor
)
1678 Color
aColor( nColor
);
1679 pWindow
->SetFillColor( aColor
);
1683 case BASEPROPERTY_LINECOLOR
:
1685 pWindow
->SetLineColor();
1688 sal_Int32 nColor
= 0;
1689 if ( Value
>>= nColor
)
1691 Color
aColor( nColor
);
1692 pWindow
->SetLineColor( aColor
);
1696 case BASEPROPERTY_BORDER
:
1698 WinBits nStyle
= pWindow
->GetStyle();
1699 sal_uInt16 nTmp
= 0;
1701 WindowBorderStyle nBorder
= static_cast<WindowBorderStyle
>(nTmp
);
1702 if ( !bool(nBorder
) )
1704 pWindow
->SetStyle( nStyle
& ~WB_BORDER
);
1708 pWindow
->SetStyle( nStyle
| WB_BORDER
);
1709 pWindow
->SetBorderStyle( nBorder
);
1713 case BASEPROPERTY_TABSTOP
:
1715 WinBits nStyle
= pWindow
->GetStyle() & ~WB_TABSTOP
;
1721 nStyle
|= WB_TABSTOP
;
1723 nStyle
|= WB_NOTABSTOP
;
1725 pWindow
->SetStyle( nStyle
);
1728 case BASEPROPERTY_VERTICALALIGN
:
1730 VerticalAlignment eAlign
= css::style::VerticalAlignment::VerticalAlignment_MAKE_FIXED_SIZE
;
1731 WinBits nStyle
= pWindow
->GetStyle();
1732 nStyle
&= ~(WB_TOP
|WB_VCENTER
|WB_BOTTOM
);
1737 case VerticalAlignment_TOP
:
1740 case VerticalAlignment_MIDDLE
:
1741 nStyle
|= WB_VCENTER
;
1743 case VerticalAlignment_BOTTOM
:
1744 nStyle
|= WB_BOTTOM
;
1746 default: ; // for warning free code, MAKE_FIXED_SIZE
1748 pWindow
->SetStyle( nStyle
);
1751 case BASEPROPERTY_ALIGN
:
1753 sal_Int16 nAlign
= PROPERTY_ALIGN_LEFT
;
1756 case WindowType::COMBOBOX
:
1757 case WindowType::PUSHBUTTON
:
1758 case WindowType::OKBUTTON
:
1759 case WindowType::CANCELBUTTON
:
1760 case WindowType::HELPBUTTON
:
1761 nAlign
= PROPERTY_ALIGN_CENTER
;
1763 case WindowType::FIXEDTEXT
:
1764 case WindowType::EDIT
:
1765 case WindowType::MULTILINEEDIT
:
1766 case WindowType::CHECKBOX
:
1767 case WindowType::RADIOBUTTON
:
1768 case WindowType::LISTBOX
:
1770 WinBits nStyle
= pWindow
->GetStyle();
1771 nStyle
&= ~(WB_LEFT
|WB_CENTER
|WB_RIGHT
);
1774 if ( nAlign
== PROPERTY_ALIGN_LEFT
)
1776 else if ( nAlign
== PROPERTY_ALIGN_CENTER
)
1777 nStyle
|= WB_CENTER
;
1780 pWindow
->SetStyle( nStyle
);
1787 case BASEPROPERTY_MULTILINE
:
1789 if ( ( eWinType
== WindowType::FIXEDTEXT
)
1790 || ( eWinType
== WindowType::CHECKBOX
)
1791 || ( eWinType
== WindowType::RADIOBUTTON
)
1792 || ( eWinType
== WindowType::PUSHBUTTON
)
1793 || ( eWinType
== WindowType::OKBUTTON
)
1794 || ( eWinType
== WindowType::CANCELBUTTON
)
1795 || ( eWinType
== WindowType::HELPBUTTON
)
1798 WinBits nStyle
= pWindow
->GetStyle();
1799 bool bMulti
= false;
1802 nStyle
|= WB_WORDBREAK
;
1804 nStyle
&= ~WB_WORDBREAK
;
1805 pWindow
->SetStyle( nStyle
);
1809 case BASEPROPERTY_ORIENTATION
:
1811 if ( eWinType
== WindowType::FIXEDLINE
)
1813 sal_Int32 nOrientation
= 0;
1814 if ( Value
>>= nOrientation
)
1816 WinBits nStyle
= pWindow
->GetStyle();
1817 nStyle
&= ~(WB_HORZ
|WB_VERT
);
1818 if ( nOrientation
== 0 )
1823 pWindow
->SetStyle( nStyle
);
1828 case BASEPROPERTY_AUTOMNEMONICS
:
1830 bool bAutoMnemonics
= false;
1831 Value
>>= bAutoMnemonics
;
1832 AllSettings aSettings
= pWindow
->GetSettings();
1833 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
1834 if ( aStyleSettings
.GetAutoMnemonic() != bAutoMnemonics
)
1836 aStyleSettings
.SetAutoMnemonic( bAutoMnemonics
);
1837 aSettings
.SetStyleSettings( aStyleSettings
);
1838 pWindow
->SetSettings( aSettings
);
1842 case BASEPROPERTY_MOUSETRANSPARENT
:
1844 bool bMouseTransparent
= false;
1845 Value
>>= bMouseTransparent
;
1846 pWindow
->SetMouseTransparent( bMouseTransparent
);
1849 case BASEPROPERTY_PAINTTRANSPARENT
:
1851 bool bPaintTransparent
= false;
1852 Value
>>= bPaintTransparent
;
1853 pWindow
->SetPaintTransparent( bPaintTransparent
);
1854 // pWindow->SetBackground();
1858 case BASEPROPERTY_REPEAT
:
1860 bool bRepeat( false );
1863 WinBits nStyle
= pWindow
->GetStyle();
1865 nStyle
|= WB_REPEAT
;
1867 nStyle
&= ~WB_REPEAT
;
1868 pWindow
->SetStyle( nStyle
);
1872 case BASEPROPERTY_REPEAT_DELAY
:
1874 sal_Int32 nRepeatDelay
= 0;
1875 if ( Value
>>= nRepeatDelay
)
1877 AllSettings aSettings
= pWindow
->GetSettings();
1878 MouseSettings aMouseSettings
= aSettings
.GetMouseSettings();
1880 aMouseSettings
.SetButtonRepeat( nRepeatDelay
);
1881 aSettings
.SetMouseSettings( aMouseSettings
);
1883 pWindow
->SetSettings( aSettings
, true );
1888 case BASEPROPERTY_SYMBOL_COLOR
:
1889 ::toolkit::setColorSettings( pWindow
, Value
, &StyleSettings::SetButtonTextColor
, &StyleSettings::GetButtonTextColor
);
1892 case BASEPROPERTY_BORDERCOLOR
:
1893 ::toolkit::setColorSettings( pWindow
, Value
, &StyleSettings::SetMonoColor
, &StyleSettings::GetMonoColor
);
1895 case BASEPROPERTY_DEFAULTCONTROL
:
1904 css::uno::Any
VCLXWindow::getProperty( const OUString
& PropertyName
)
1906 SolarMutexGuard aGuard
;
1908 css::uno::Any aProp
;
1911 WindowType eWinType
= GetWindow()->GetType();
1912 sal_uInt16 nPropType
= GetPropertyId( PropertyName
);
1913 switch ( nPropType
)
1915 case BASEPROPERTY_REFERENCE_DEVICE
:
1917 VclPtr
<Control
> pControl
= GetAsDynamic
<Control
>();
1918 OSL_ENSURE( pControl
, "VCLXWindow::setProperty( RefDevice ): need a Control for this!" );
1922 VCLXDevice
* pDevice
= new VCLXDevice
;
1923 pDevice
->SetOutputDevice( pControl
->GetReferenceDevice() );
1924 aProp
<<= Reference
< XDevice
>( pDevice
);
1928 case BASEPROPERTY_CONTEXT_WRITING_MODE
:
1929 aProp
<<= mpImpl
->mnContextWritingMode
;
1932 case BASEPROPERTY_WRITING_MODE
:
1933 aProp
<<= mpImpl
->mnWritingMode
;
1936 case BASEPROPERTY_MOUSE_WHEEL_BEHAVIOUR
:
1938 MouseWheelBehaviour nVclBehavior
= GetWindow()->GetSettings().GetMouseSettings().GetWheelBehavior();
1939 sal_uInt16 nBehavior
= css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
;
1940 switch ( nVclBehavior
)
1942 case MouseWheelBehaviour::Disable
: nBehavior
= css::awt::MouseWheelBehavior::SCROLL_DISABLED
; break;
1943 case MouseWheelBehaviour::FocusOnly
: nBehavior
= css::awt::MouseWheelBehavior::SCROLL_FOCUS_ONLY
; break;
1944 case MouseWheelBehaviour::ALWAYS
: nBehavior
= css::awt::MouseWheelBehavior::SCROLL_ALWAYS
; break;
1946 OSL_FAIL( "VCLXWindow::getProperty( 'MouseWheelBehavior' ): illegal VCL value!" );
1948 aProp
<<= nBehavior
;
1952 case BASEPROPERTY_NATIVE_WIDGET_LOOK
:
1953 aProp
<<= GetWindow()->IsNativeWidgetEnabled();
1956 case BASEPROPERTY_ENABLED
:
1957 aProp
<<= GetWindow()->IsEnabled();
1960 case BASEPROPERTY_ENABLEVISIBLE
:
1961 aProp
<<= mpImpl
->isEnableVisible();
1964 case BASEPROPERTY_HIGHCONTRASTMODE
:
1965 aProp
<<= GetWindow()->GetSettings().GetStyleSettings().GetHighContrastMode();
1968 case BASEPROPERTY_TEXT
:
1969 case BASEPROPERTY_LABEL
:
1970 case BASEPROPERTY_TITLE
:
1972 OUString aText
= GetWindow()->GetText();
1976 case BASEPROPERTY_ACCESSIBLENAME
:
1978 OUString aText
= GetWindow()->GetAccessibleName();
1982 case BASEPROPERTY_HELPTEXT
:
1984 OUString aText
= GetWindow()->GetQuickHelpText();
1988 case BASEPROPERTY_HELPURL
:
1990 OUString
aHelpId( OStringToOUString( GetWindow()->GetHelpId(), RTL_TEXTENCODING_UTF8
) );
1994 case BASEPROPERTY_FONTDESCRIPTOR
:
1996 vcl::Font aFont
= GetWindow()->GetControlFont();
1997 css::awt::FontDescriptor aFD
= VCLUnoHelper::CreateFontDescriptor( aFont
);
2001 case BASEPROPERTY_BACKGROUNDCOLOR
:
2002 aProp
<<= (sal_Int32
) GetWindow()->GetControlBackground().GetColor();
2004 case BASEPROPERTY_DISPLAYBACKGROUNDCOLOR
:
2005 aProp
<<= (sal_Int32
) GetWindow()->GetDisplayBackground().GetColor().GetColor();
2007 case BASEPROPERTY_FONTRELIEF
:
2008 aProp
<<= (sal_Int16
) GetWindow()->GetControlFont().GetRelief();
2010 case BASEPROPERTY_FONTEMPHASISMARK
:
2011 aProp
<<= (sal_Int16
) GetWindow()->GetControlFont().GetEmphasisMark();
2013 case BASEPROPERTY_TEXTCOLOR
:
2014 aProp
<<= (sal_Int32
) GetWindow()->GetControlForeground().GetColor();
2016 case BASEPROPERTY_TEXTLINECOLOR
:
2017 aProp
<<= (sal_Int32
) GetWindow()->GetTextLineColor().GetColor();
2019 case BASEPROPERTY_FILLCOLOR
:
2020 aProp
<<= (sal_Int32
) GetWindow()->GetFillColor().GetColor();
2022 case BASEPROPERTY_LINECOLOR
:
2023 aProp
<<= (sal_Int32
) GetWindow()->GetLineColor().GetColor();
2025 case BASEPROPERTY_BORDER
:
2027 WindowBorderStyle nBorder
= WindowBorderStyle::NONE
;
2028 if ( GetWindow()->GetStyle() & WB_BORDER
)
2029 nBorder
= GetWindow()->GetBorderStyle();
2030 aProp
<<= static_cast<sal_uInt16
>(nBorder
);
2033 case BASEPROPERTY_TABSTOP
:
2034 aProp
<<= ( GetWindow()->GetStyle() & WB_TABSTOP
) != 0;
2036 case BASEPROPERTY_VERTICALALIGN
:
2038 WinBits nStyle
= GetWindow()->GetStyle();
2039 if ( nStyle
& WB_TOP
)
2040 aProp
<<= VerticalAlignment_TOP
;
2041 else if ( nStyle
& WB_VCENTER
)
2042 aProp
<<= VerticalAlignment_MIDDLE
;
2043 else if ( nStyle
& WB_BOTTOM
)
2044 aProp
<<= VerticalAlignment_BOTTOM
;
2047 case BASEPROPERTY_ALIGN
:
2051 case WindowType::FIXEDTEXT
:
2052 case WindowType::EDIT
:
2053 case WindowType::MULTILINEEDIT
:
2054 case WindowType::CHECKBOX
:
2055 case WindowType::RADIOBUTTON
:
2056 case WindowType::LISTBOX
:
2057 case WindowType::COMBOBOX
:
2058 case WindowType::PUSHBUTTON
:
2059 case WindowType::OKBUTTON
:
2060 case WindowType::CANCELBUTTON
:
2061 case WindowType::HELPBUTTON
:
2063 WinBits nStyle
= GetWindow()->GetStyle();
2064 if ( nStyle
& WB_LEFT
)
2065 aProp
<<= (sal_Int16
) PROPERTY_ALIGN_LEFT
;
2066 else if ( nStyle
& WB_CENTER
)
2067 aProp
<<= (sal_Int16
) PROPERTY_ALIGN_CENTER
;
2068 else if ( nStyle
& WB_RIGHT
)
2069 aProp
<<= (sal_Int16
) PROPERTY_ALIGN_RIGHT
;
2076 case BASEPROPERTY_MULTILINE
:
2078 if ( ( eWinType
== WindowType::FIXEDTEXT
)
2079 || ( eWinType
== WindowType::CHECKBOX
)
2080 || ( eWinType
== WindowType::RADIOBUTTON
)
2081 || ( eWinType
== WindowType::PUSHBUTTON
)
2082 || ( eWinType
== WindowType::OKBUTTON
)
2083 || ( eWinType
== WindowType::CANCELBUTTON
)
2084 || ( eWinType
== WindowType::HELPBUTTON
)
2086 aProp
<<= ( GetWindow()->GetStyle() & WB_WORDBREAK
) != 0;
2089 case BASEPROPERTY_AUTOMNEMONICS
:
2091 bool bAutoMnemonics
= GetWindow()->GetSettings().GetStyleSettings().GetAutoMnemonic();
2092 aProp
<<= bAutoMnemonics
;
2095 case BASEPROPERTY_MOUSETRANSPARENT
:
2097 bool bMouseTransparent
= GetWindow()->IsMouseTransparent();
2098 aProp
<<= bMouseTransparent
;
2101 case BASEPROPERTY_PAINTTRANSPARENT
:
2103 bool bPaintTransparent
= GetWindow()->IsPaintTransparent();
2104 aProp
<<= bPaintTransparent
;
2108 case BASEPROPERTY_REPEAT
:
2109 aProp
<<= ( 0 != ( GetWindow()->GetStyle() & WB_REPEAT
) );
2112 case BASEPROPERTY_REPEAT_DELAY
:
2114 sal_Int32 nButtonRepeat
= GetWindow()->GetSettings().GetMouseSettings().GetButtonRepeat();
2115 aProp
<<= nButtonRepeat
;
2119 case BASEPROPERTY_SYMBOL_COLOR
:
2120 aProp
<<= (sal_Int32
)GetWindow()->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
2123 case BASEPROPERTY_BORDERCOLOR
:
2124 aProp
<<= (sal_Int32
)GetWindow()->GetSettings().GetStyleSettings().GetMonoColor().GetColor();
2132 // css::awt::XLayoutConstrains
2133 css::awt::Size
VCLXWindow::getMinimumSize( )
2135 SolarMutexGuard aGuard
;
2137 // Use this method only for those components which can be created through
2138 // css::awt::Toolkit , but do not have an interface
2143 WindowType nWinType
= GetWindow()->GetType();
2146 case WindowType::CONTROL
:
2147 aSz
.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*12;
2148 aSz
.Height() = GetWindow()->GetTextHeight()+2*6;
2151 case WindowType::PATTERNBOX
:
2152 case WindowType::NUMERICBOX
:
2153 case WindowType::METRICBOX
:
2154 case WindowType::CURRENCYBOX
:
2155 case WindowType::DATEBOX
:
2156 case WindowType::TIMEBOX
:
2157 case WindowType::LONGCURRENCYBOX
:
2158 aSz
.Width() = GetWindow()->GetTextWidth( GetWindow()->GetText() )+2*2;
2159 aSz
.Height() = GetWindow()->GetTextHeight()+2*2;
2161 case WindowType::SCROLLBARBOX
:
2162 return VCLXScrollBar::implGetMinimumSize( GetWindow() );
2164 aSz
= GetWindow()->get_preferred_size();
2168 return css::awt::Size( aSz
.Width(), aSz
.Height() );
2171 css::awt::Size
VCLXWindow::getPreferredSize( )
2173 return getMinimumSize();
2176 css::awt::Size
VCLXWindow::calcAdjustedSize( const css::awt::Size
& rNewSize
)
2178 SolarMutexGuard aGuard
;
2180 css::awt::Size
aNewSize( rNewSize
);
2181 css::awt::Size aMinSize
= getMinimumSize();
2183 if ( aNewSize
.Width
< aMinSize
.Width
)
2184 aNewSize
.Width
= aMinSize
.Width
;
2185 if ( aNewSize
.Height
< aMinSize
.Height
)
2186 aNewSize
.Height
= aMinSize
.Height
;
2193 sal_Bool
VCLXWindow::setGraphics( const css::uno::Reference
< css::awt::XGraphics
>& rxDevice
)
2195 SolarMutexGuard aGuard
;
2197 if ( VCLUnoHelper::GetOutputDevice( rxDevice
) )
2198 mpImpl
->mxViewGraphics
= rxDevice
;
2200 mpImpl
->mxViewGraphics
= nullptr;
2202 return mpImpl
->mxViewGraphics
.is();
2205 css::uno::Reference
< css::awt::XGraphics
> VCLXWindow::getGraphics( )
2207 SolarMutexGuard aGuard
;
2209 return mpImpl
->mxViewGraphics
;
2212 css::awt::Size
VCLXWindow::getSize( )
2214 SolarMutexGuard aGuard
;
2218 aSz
= GetWindow()->GetSizePixel();
2219 return css::awt::Size( aSz
.Width(), aSz
.Height() );
2222 void VCLXWindow::draw( sal_Int32 nX
, sal_Int32 nY
)
2224 SolarMutexGuard aGuard
;
2226 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2230 if ( isDesignMode() || mpImpl
->isEnableVisible() )
2232 OutputDevice
* pDev
= VCLUnoHelper::GetOutputDevice( mpImpl
->mxViewGraphics
);
2234 pDev
= pWindow
->GetParent();
2235 TabPage
* pTabPage
= dynamic_cast< TabPage
* >( pWindow
.get() );
2238 Point
aPos( nX
, nY
);
2239 Size aSize
= pWindow
->GetSizePixel();
2241 aPos
= pDev
->PixelToLogic( aPos
);
2242 aSize
= pDev
->PixelToLogic( aSize
);
2244 pTabPage
->Draw( pDev
, aPos
, aSize
, DrawFlags::NONE
);
2248 Point
aPos( nX
, nY
);
2250 if ( pWindow
->GetParent() && !pWindow
->IsSystemWindow() && ( pWindow
->GetParent() == pDev
) )
2252 // #i40647# don't draw here if this is a recursive call
2253 // sometimes this is called recursively, because the Update call on the parent
2254 // (strangely) triggers another paint. Prevent a stack overflow here
2255 // Yes, this is only fixing symptoms for the moment ....
2256 // #i40647# / 2005-01-18 / frank.schoenheit@sun.com
2257 if ( !mpImpl
->getDrawingOntoParent_ref() )
2259 ::comphelper::FlagGuard
aDrawingflagGuard( mpImpl
->getDrawingOntoParent_ref() );
2261 bool bWasVisible
= pWindow
->IsVisible();
2262 Point
aOldPos( pWindow
->GetPosPixel() );
2264 if ( bWasVisible
&& aOldPos
== aPos
)
2270 pWindow
->SetPosPixel( aPos
);
2272 // Update parent first to avoid painting the parent upon the update
2273 // of this window, as it may otherwise cause the parent
2274 // to hide this window again
2275 if( pWindow
->GetParent() )
2276 pWindow
->GetParent()->Update();
2280 pWindow
->SetParentUpdateMode( false );
2282 pWindow
->SetParentUpdateMode( true );
2284 pWindow
->SetPosPixel( aOldPos
);
2291 Size aSz
= pWindow
->GetSizePixel();
2292 aSz
= pDev
->PixelToLogic( aSz
);
2293 Point aP
= pDev
->PixelToLogic( aPos
);
2295 vcl::PDFExtOutDevData
* pPDFExport
= dynamic_cast<vcl::PDFExtOutDevData
*>(pDev
->GetExtOutDevData());
2296 bool bDrawSimple
= ( pDev
->GetOutDevType() == OUTDEV_PRINTER
)
2297 || ( pDev
->GetOutDevViewType() == OutDevViewType::PrintPreview
)
2298 || ( pPDFExport
!= nullptr );
2301 pWindow
->Draw( pDev
, aP
, aSz
, DrawFlags::NoControls
);
2305 bool bOldNW
=pWindow
->IsNativeWidgetEnabled();
2307 pWindow
->EnableNativeWidget(false);
2308 pWindow
->PaintToDevice( pDev
, aP
, aSz
);
2310 pWindow
->EnableNativeWidget();
2316 void VCLXWindow::setZoom( float fZoomX
, float /*fZoomY*/ )
2318 SolarMutexGuard aGuard
;
2322 // Fraction::Fraction takes a double, but we have a float only.
2323 // The implicit conversion from float to double can result in a precision loss, i.e. 1.2 is converted to
2324 // 1.200000000047something. To prevent this, we convert explicitly to double, and round it.
2325 double nZoom( fZoomX
);
2326 Fraction
aZoom(::rtl::math::round(nZoom
, 4));
2327 aZoom
.ReduceInaccurate(10); // to avoid runovers and BigInt mapping
2328 GetWindow()->SetZoom(aZoom
);
2332 // css::lang::XEventListener
2333 void SAL_CALL
VCLXWindow::disposing( const css::lang::EventObject
& _rSource
)
2335 SolarMutexGuard aGuard
;
2337 // check if it comes from our AccessibleContext
2338 uno::Reference
< uno::XInterface
> aAC( mpImpl
->mxAccessibleContext
, uno::UNO_QUERY
);
2339 uno::Reference
< uno::XInterface
> xSource( _rSource
.Source
, uno::UNO_QUERY
);
2341 if ( aAC
.get() == xSource
.get() )
2343 mpImpl
->mxAccessibleContext
.clear();
2347 // css::accessibility::XAccessible
2348 css::uno::Reference
< css::accessibility::XAccessibleContext
> VCLXWindow::getAccessibleContext( )
2350 using namespace ::com::sun::star
;
2352 SolarMutexGuard aGuard
;
2356 return uno::Reference
< accessibility::XAccessibleContext
>();
2358 if ( !mpImpl
->mxAccessibleContext
.is() && GetWindow() )
2360 mpImpl
->mxAccessibleContext
= CreateAccessibleContext();
2362 // add as event listener to this component
2363 // in case somebody disposes it, we do not want to have a (though weak) reference to a dead
2365 uno::Reference
< lang::XComponent
> xComp( mpImpl
->mxAccessibleContext
, uno::UNO_QUERY
);
2367 xComp
->addEventListener( this );
2370 return mpImpl
->mxAccessibleContext
;
2373 // css::awt::XDockable
2374 void SAL_CALL
VCLXWindow::addDockableWindowListener( const css::uno::Reference
< css::awt::XDockableWindowListener
>& xListener
)
2376 SolarMutexGuard aGuard
;
2378 if ( xListener
.is() )
2379 mpImpl
->getDockableWindowListeners().addInterface( xListener
);
2383 void SAL_CALL
VCLXWindow::removeDockableWindowListener( const css::uno::Reference
< css::awt::XDockableWindowListener
>& xListener
)
2385 SolarMutexGuard aGuard
;
2387 mpImpl
->getDockableWindowListeners().removeInterface( xListener
);
2390 void SAL_CALL
VCLXWindow::enableDocking( sal_Bool bEnable
)
2392 SolarMutexGuard aGuard
;
2394 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2396 pWindow
->EnableDocking( bEnable
);
2399 sal_Bool SAL_CALL
VCLXWindow::isFloating( )
2401 SolarMutexGuard aGuard
;
2403 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2405 return vcl::Window::GetDockingManager()->IsFloating( pWindow
);
2410 void SAL_CALL
VCLXWindow::setFloatingMode( sal_Bool bFloating
)
2412 SolarMutexGuard aGuard
;
2414 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2416 vcl::Window::GetDockingManager()->SetFloatingMode( pWindow
, bFloating
);
2419 sal_Bool SAL_CALL
VCLXWindow::isLocked( )
2421 SolarMutexGuard aGuard
;
2423 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2425 return vcl::Window::GetDockingManager()->IsLocked( pWindow
);
2430 void SAL_CALL
VCLXWindow::lock( )
2432 SolarMutexGuard aGuard
;
2434 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2435 if( pWindow
&& !vcl::Window::GetDockingManager()->IsFloating( pWindow
) )
2436 vcl::Window::GetDockingManager()->Lock( pWindow
);
2439 void SAL_CALL
VCLXWindow::unlock( )
2441 SolarMutexGuard aGuard
;
2443 VclPtr
<vcl::Window
> pWindow
= GetWindow();
2444 if( pWindow
&& !vcl::Window::GetDockingManager()->IsFloating( pWindow
) )
2445 vcl::Window::GetDockingManager()->Unlock( pWindow
);
2448 void SAL_CALL
VCLXWindow::startPopupMode( const css::awt::Rectangle
& )
2450 // TODO: remove interface in the next incompatible build
2453 sal_Bool SAL_CALL
VCLXWindow::isInPopupMode( )
2455 // TODO: remove interface in the next incompatible build
2460 // css::awt::XWindow2
2462 void SAL_CALL
VCLXWindow::setOutputSize( const css::awt::Size
& aSize
)
2464 SolarMutexGuard aGuard
;
2465 VclPtr
<vcl::Window
> pWindow
;
2466 if( (pWindow
= GetWindow()) != nullptr )
2468 DockingWindow
*pDockingWindow
= dynamic_cast< DockingWindow
* >(pWindow
.get());
2469 if( pDockingWindow
)
2470 pDockingWindow
->SetOutputSizePixel( VCLSize( aSize
) );
2472 pWindow
->SetOutputSizePixel( VCLSize( aSize
) );
2476 css::awt::Size SAL_CALL
VCLXWindow::getOutputSize( )
2478 SolarMutexGuard aGuard
;
2479 VclPtr
<vcl::Window
> pWindow
;
2480 if( (pWindow
= GetWindow()) != nullptr )
2482 DockingWindow
*pDockingWindow
= dynamic_cast< DockingWindow
* >(pWindow
.get());
2483 if( pDockingWindow
)
2484 return AWTSize( pDockingWindow
->GetOutputSizePixel() );
2486 return AWTSize( pWindow
->GetOutputSizePixel() );
2489 return css::awt::Size();
2492 sal_Bool SAL_CALL
VCLXWindow::isVisible( )
2494 SolarMutexGuard aGuard
;
2496 return GetWindow()->IsVisible();
2501 sal_Bool SAL_CALL
VCLXWindow::isActive( )
2503 SolarMutexGuard aGuard
;
2505 return GetWindow()->IsActive();
2511 sal_Bool SAL_CALL
VCLXWindow::isEnabled( )
2513 SolarMutexGuard aGuard
;
2515 return GetWindow()->IsEnabled();
2520 sal_Bool SAL_CALL
VCLXWindow::hasFocus( )
2522 SolarMutexGuard aGuard
;
2524 return GetWindow()->HasFocus();
2529 // css::beans::XPropertySetInfo
2531 UnoPropertyArrayHelper
*
2532 VCLXWindow::GetPropHelper()
2534 SolarMutexGuard aGuard
;
2535 if ( mpImpl
->mpPropHelper
== nullptr )
2537 std::vector
< sal_uInt16
> aIDs
;
2538 GetPropertyIds( aIDs
);
2539 mpImpl
->mpPropHelper
.reset( new UnoPropertyArrayHelper( aIDs
) );
2541 return mpImpl
->mpPropHelper
.get();
2544 css::uno::Sequence
< css::beans::Property
> SAL_CALL
2545 VCLXWindow::getProperties()
2547 return GetPropHelper()->getProperties();
2549 css::beans::Property SAL_CALL
2550 VCLXWindow::getPropertyByName( const OUString
& rName
)
2552 return GetPropHelper()->getPropertyByName( rName
);
2556 VCLXWindow::hasPropertyByName( const OUString
& rName
)
2558 return GetPropHelper()->hasPropertyByName( rName
);
2561 Reference
< XStyleSettings
> SAL_CALL
VCLXWindow::getStyleSettings()
2563 return mpImpl
->getStyleSettings();
2566 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */