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 .
20 #include "basecontrol.hxx"
22 #include <com/sun/star/awt/XDevice.hpp>
23 #include <com/sun/star/awt/XDisplayBitmap.hpp>
24 #include <com/sun/star/awt/DeviceInfo.hpp>
25 #include <com/sun/star/awt/WindowAttribute.hpp>
26 #include <com/sun/star/awt/PosSize.hpp>
27 #include <com/sun/star/awt/Toolkit.hpp>
28 #include <comphelper/processfactory.hxx>
29 #include <cppuhelper/supportsservice.hxx>
30 #include <cppuhelper/typeprovider.hxx>
32 //____________________________________________________________________________________________________________
34 //____________________________________________________________________________________________________________
36 using namespace ::cppu
;
37 using namespace ::osl
;
38 using namespace ::rtl
;
39 using namespace ::com::sun::star::uno
;
40 using namespace ::com::sun::star::lang
;
41 using namespace ::com::sun::star::awt
;
43 namespace unocontrols
{
45 #define DEFAULT_PMULTIPLEXER NULL
48 #define DEFAULT_WIDTH 100
49 #define DEFAULT_HEIGHT 100
50 #define DEFAULT_VISIBLE sal_False
51 #define DEFAULT_INDESIGNMODE sal_False
52 #define DEFAULT_ENABLE sal_True
54 //____________________________________________________________________________________________________________
56 //____________________________________________________________________________________________________________
58 BaseControl::BaseControl( const Reference
< XComponentContext
>& rxContext
)
59 : IMPL_MutexContainer ( )
60 , OComponentHelper ( m_aMutex
)
61 , m_xComponentContext ( rxContext
)
62 , m_pMultiplexer ( DEFAULT_PMULTIPLEXER
)
65 , m_nWidth ( DEFAULT_WIDTH
)
66 , m_nHeight ( DEFAULT_HEIGHT
)
67 , m_bVisible ( DEFAULT_VISIBLE
)
68 , m_bInDesignMode ( DEFAULT_INDESIGNMODE
)
69 , m_bEnable ( DEFAULT_ENABLE
)
73 BaseControl::~BaseControl()
77 //____________________________________________________________________________________________________________
79 //____________________________________________________________________________________________________________
81 Any SAL_CALL
BaseControl::queryInterface( const Type
& rType
) throw( RuntimeException
)
84 if ( m_xDelegator
.is() == sal_True
)
86 // If an delegator exist, forward question to his queryInterface.
87 // Delegator will ask his own queryAggregation!
88 aReturn
= m_xDelegator
->queryInterface( rType
);
92 // If an delegator unknown, forward question to own queryAggregation.
93 aReturn
= queryAggregation( rType
);
99 //____________________________________________________________________________________________________________
101 //____________________________________________________________________________________________________________
103 void SAL_CALL
BaseControl::acquire() throw()
106 // Don't use mutex or guard in this method!!! Is a method of XInterface.
108 // Forward to baseclass
109 OComponentHelper::acquire();
112 //____________________________________________________________________________________________________________
114 //____________________________________________________________________________________________________________
116 void SAL_CALL
BaseControl::release() throw()
119 // Don't use mutex or guard in this method!!! Is a method of XInterface.
121 // Forward to baseclass
122 OComponentHelper::release();
125 //____________________________________________________________________________________________________________
127 //____________________________________________________________________________________________________________
129 Sequence
< Type
> SAL_CALL
BaseControl::getTypes() throw( RuntimeException
)
131 // Optimize this method !
132 // We initialize a static variable only one time. And we don't must use a mutex at every call!
133 // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
134 static OTypeCollection
* pTypeCollection
= NULL
;
136 if ( pTypeCollection
== NULL
)
138 // Ready for multithreading; get global mutex for first call of this method only! see before
139 MutexGuard
aGuard( Mutex::getGlobalMutex() );
141 // Control these pointer again ... it can be, that another instance will be faster then these!
142 if ( pTypeCollection
== NULL
)
144 // Create a static typecollection ...
145 static OTypeCollection
aTypeCollection( ::getCppuType(( const Reference
< XPaintListener
>*)NULL
) ,
146 ::getCppuType(( const Reference
< XWindowListener
>*)NULL
) ,
147 ::getCppuType(( const Reference
< XView
>*)NULL
) ,
148 ::getCppuType(( const Reference
< XWindow
>*)NULL
) ,
149 ::getCppuType(( const Reference
< XServiceInfo
>*)NULL
) ,
150 ::getCppuType(( const Reference
< XControl
>*)NULL
) ,
151 OComponentHelper::getTypes()
154 // ... and set his address to static pointer!
155 pTypeCollection
= &aTypeCollection
;
159 return pTypeCollection
->getTypes();
162 //____________________________________________________________________________________________________________
164 //____________________________________________________________________________________________________________
166 Sequence
< sal_Int8
> SAL_CALL
BaseControl::getImplementationId() throw( RuntimeException
)
168 // Create one Id for all instances of this class.
169 // Use ethernet address to do this! (sal_True)
171 // Optimize this method
172 // We initialize a static variable only one time. And we don't must use a mutex at every call!
173 // For the first call; pID is NULL - for the second call pID is different from NULL!
174 static OImplementationId
* pID
= NULL
;
178 // Ready for multithreading; get global mutex for first call of this method only! see before
179 MutexGuard
aGuard( Mutex::getGlobalMutex() );
181 // Control these pointer again ... it can be, that another instance will be faster then these!
184 // Create a new static ID ...
185 static OImplementationId
aID( sal_False
);
186 // ... and set his address to static pointer!
191 return pID
->getImplementationId();
194 //____________________________________________________________________________________________________________
196 //____________________________________________________________________________________________________________
198 void SAL_CALL
BaseControl::setDelegator( const Reference
< XInterface
>& xDel
) throw( RuntimeException
)
200 // Ready for multithreading
201 MutexGuard
aGuard( m_aMutex
);
205 //____________________________________________________________________________________________________________
207 //____________________________________________________________________________________________________________
209 Any SAL_CALL
BaseControl::queryAggregation( const Type
& aType
) throw( RuntimeException
)
211 // Ask for my own supported interfaces ...
212 // Attention: XTypeProvider and XInterface are supported by OComponentHelper!
213 Any
aReturn ( ::cppu::queryInterface( aType
,
214 static_cast< XPaintListener
*> ( this ) ,
215 static_cast< XWindowListener
*> ( this ) ,
216 static_cast< XView
* > ( this ) ,
217 static_cast< XWindow
* > ( this ) ,
218 static_cast< XServiceInfo
* > ( this ) ,
219 static_cast< XControl
* > ( this )
223 // If searched interface supported by this class ...
224 if ( aReturn
.hasValue() == sal_True
)
226 // ... return this information.
231 // Else; ... ask baseclass for interfaces!
232 return OComponentHelper::queryAggregation( aType
);
236 //____________________________________________________________________________________________________________
238 //____________________________________________________________________________________________________________
240 OUString SAL_CALL
BaseControl::getImplementationName() throw( RuntimeException
)
242 return impl_getStaticImplementationName();
245 //____________________________________________________________________________________________________________
247 //____________________________________________________________________________________________________________
249 sal_Bool SAL_CALL
BaseControl::supportsService( const OUString
& sServiceName
) throw( RuntimeException
)
251 return cppu::supportsService(this, sServiceName
);
254 //____________________________________________________________________________________________________________
256 //____________________________________________________________________________________________________________
258 Sequence
< OUString
> SAL_CALL
BaseControl::getSupportedServiceNames() throw( RuntimeException
)
260 return impl_getStaticSupportedServiceNames();
263 //____________________________________________________________________________________________________________
265 //____________________________________________________________________________________________________________
267 void SAL_CALL
BaseControl::dispose() throw( RuntimeException
)
269 // Ready for multithreading
270 MutexGuard
aGuard( m_aMutex
);
272 if ( m_pMultiplexer
!= NULL
)
274 // to all other paint, focus, etc.
275 m_pMultiplexer
->disposeAndClear();
278 // set the service manager to disposed
279 OComponentHelper::dispose();
281 // release context and peer
282 m_xContext
= Reference
< XInterface
>();
286 if ( m_xGraphicsView
.is() == sal_True
)
288 m_xGraphicsView
= Reference
< XGraphics
>();
292 //____________________________________________________________________________________________________________
294 //____________________________________________________________________________________________________________
296 void SAL_CALL
BaseControl::addEventListener( const Reference
< XEventListener
>& xListener
) throw( RuntimeException
)
298 // Ready for multithreading
299 MutexGuard
aGuard( m_aMutex
);
300 OComponentHelper::addEventListener( xListener
);
303 //____________________________________________________________________________________________________________
305 //____________________________________________________________________________________________________________
307 void SAL_CALL
BaseControl::removeEventListener( const Reference
< XEventListener
>& xListener
) throw( RuntimeException
)
309 // Ready for multithreading
310 MutexGuard
aGuard( m_aMutex
);
311 OComponentHelper::removeEventListener( xListener
);
314 //____________________________________________________________________________________________________________
316 //____________________________________________________________________________________________________________
318 void SAL_CALL
BaseControl::createPeer( const Reference
< XToolkit
>& xToolkit
,
319 const Reference
< XWindowPeer
>& xParentPeer
) throw( RuntimeException
)
321 // Ready for multithreading
322 MutexGuard
aGuard( m_aMutex
);
324 if ( m_xPeer
.is() == sal_False
)
326 // use method "BaseControl::getWindowDescriptor()" fot change window attributes !!!
327 WindowDescriptor
* pDescriptor
= impl_getWindowDescriptor( xParentPeer
);
329 if ( m_bVisible
== sal_True
)
331 pDescriptor
->WindowAttributes
|= WindowAttribute::SHOW
;
334 // very slow under remote conditions!
335 // create the window on the server
336 Reference
< XToolkit
> xLocalToolkit
= xToolkit
;
337 if ( xLocalToolkit
.is() == sal_False
)
339 // but first create well known toolkit, if it not exist
340 xLocalToolkit
= Reference
< XToolkit
> ( Toolkit::create(m_xComponentContext
), UNO_QUERY_THROW
);
342 m_xPeer
= xLocalToolkit
->createWindow( *pDescriptor
);
343 m_xPeerWindow
= Reference
< XWindow
>( m_xPeer
, UNO_QUERY
);
345 // don't forget to release the memory!
348 if ( m_xPeerWindow
.is() == sal_True
)
350 if ( m_pMultiplexer
!= NULL
)
352 m_pMultiplexer
->setPeer( m_xPeerWindow
);
355 // create new referenz to xgraphics for painting on a peer
356 // and add a paint listener
357 Reference
< XDevice
> xDevice( m_xPeerWindow
, UNO_QUERY
);
359 if ( xDevice
.is() == sal_True
)
361 m_xGraphicsPeer
= xDevice
->createGraphics();
364 if ( m_xGraphicsPeer
.is() == sal_True
)
366 addPaintListener( this );
367 addWindowListener( this );
370 // PosSize_POSSIZE defined in <stardiv/uno/awt/window.hxx>
371 m_xPeerWindow
->setPosSize( m_nX
, m_nY
, m_nWidth
, m_nHeight
, PosSize::POSSIZE
);
372 m_xPeerWindow
->setEnable( m_bEnable
);
373 m_xPeerWindow
->setVisible( m_bVisible
&& !m_bInDesignMode
);
378 //____________________________________________________________________________________________________________
380 //____________________________________________________________________________________________________________
382 void SAL_CALL
BaseControl::setContext( const Reference
< XInterface
>& xContext
) throw( RuntimeException
)
384 // Ready for multithreading
385 MutexGuard
aGuard( m_aMutex
);
386 m_xContext
= xContext
;
389 //____________________________________________________________________________________________________________
391 //____________________________________________________________________________________________________________
393 void SAL_CALL
BaseControl::setDesignMode( sal_Bool bOn
) throw( RuntimeException
)
395 // Ready for multithreading
396 MutexGuard
aGuard( m_aMutex
);
397 m_bInDesignMode
= bOn
;
400 //____________________________________________________________________________________________________________
402 //____________________________________________________________________________________________________________
404 Reference
< XInterface
> SAL_CALL
BaseControl::getContext() throw( RuntimeException
)
406 // Ready for multithreading
407 MutexGuard
aGuard( m_aMutex
);
411 //____________________________________________________________________________________________________________
413 //____________________________________________________________________________________________________________
415 Reference
< XWindowPeer
> SAL_CALL
BaseControl::getPeer() throw( RuntimeException
)
417 // Ready for multithreading
418 MutexGuard
aGuard( m_aMutex
);
422 //____________________________________________________________________________________________________________
424 //____________________________________________________________________________________________________________
426 Reference
< XView
> SAL_CALL
BaseControl::getView() throw( RuntimeException
)
428 // Ready for multithreading
429 MutexGuard
aGuard( m_aMutex
);
430 return Reference
< XView
>( (OWeakObject
*)this, UNO_QUERY
);
433 //____________________________________________________________________________________________________________
435 //____________________________________________________________________________________________________________
437 sal_Bool SAL_CALL
BaseControl::isDesignMode() throw( RuntimeException
)
439 // Ready for multithreading
440 MutexGuard
aGuard( m_aMutex
);
441 return m_bInDesignMode
;
444 //____________________________________________________________________________________________________________
446 //____________________________________________________________________________________________________________
448 sal_Bool SAL_CALL
BaseControl::isTransparent() throw( RuntimeException
)
453 //____________________________________________________________________________________________________________
455 //____________________________________________________________________________________________________________
457 void SAL_CALL
BaseControl::setPosSize( sal_Int32 nX
,
461 sal_Int16 nFlags
) throw( RuntimeException
)
463 // - change size and position of window and save the values
464 // - "nFlags" declared in <stardiv/uno/awt/window.hxx> ("#define PosSize_X .....")
466 // Ready for multithreading
467 MutexGuard
aGuard( m_aMutex
);
469 sal_Bool bChanged
= sal_False
;
471 if ( nFlags
& PosSize::X
)
473 bChanged
|= m_nX
!= nX
, m_nX
= nX
;
476 if ( nFlags
& PosSize::Y
)
478 bChanged
|= m_nY
!= nY
, m_nY
= nY
;
481 if ( nFlags
& PosSize::WIDTH
)
483 bChanged
|= m_nWidth
!= nWidth
, m_nWidth
= nWidth
;
486 if ( nFlags
& PosSize::HEIGHT
)
488 bChanged
|= m_nHeight
!= nHeight
, m_nHeight
= nHeight
;
491 if ( bChanged
&& m_xPeerWindow
.is() )
493 m_xPeerWindow
->setPosSize( m_nX
, m_nY
, m_nWidth
, m_nHeight
, nFlags
);
497 //____________________________________________________________________________________________________________
499 //____________________________________________________________________________________________________________
501 void SAL_CALL
BaseControl::setVisible( sal_Bool bVisible
) throw( RuntimeException
)
503 // Ready for multithreading
504 MutexGuard
aGuard( m_aMutex
);
506 // Set new state of flag
507 m_bVisible
= bVisible
;
509 if ( m_xPeerWindow
.is() == sal_True
)
511 // Set it also on peerwindow
512 m_xPeerWindow
->setVisible( m_bVisible
);
516 //____________________________________________________________________________________________________________
518 //____________________________________________________________________________________________________________
520 void SAL_CALL
BaseControl::setEnable( sal_Bool bEnable
) throw( RuntimeException
)
522 // Ready for multithreading
523 MutexGuard
aGuard( m_aMutex
);
525 // Set new state of flag
526 m_bEnable
= bEnable
;
528 if ( m_xPeerWindow
.is() == sal_True
)
530 // Set it also on peerwindow
531 m_xPeerWindow
->setEnable( m_bEnable
);
535 //____________________________________________________________________________________________________________
537 //____________________________________________________________________________________________________________
539 void SAL_CALL
BaseControl::setFocus() throw( RuntimeException
)
541 // Ready for multithreading
542 MutexGuard
aGuard( m_aMutex
);
544 if ( m_xPeerWindow
.is() == sal_True
)
546 m_xPeerWindow
->setFocus();
550 //____________________________________________________________________________________________________________
552 //____________________________________________________________________________________________________________
554 Rectangle SAL_CALL
BaseControl::getPosSize() throw( RuntimeException
)
556 // Ready for multithreading
557 MutexGuard
aGuard( m_aMutex
);
558 return Rectangle( m_nX
, m_nY
, m_nWidth
, m_nHeight
);
561 //____________________________________________________________________________________________________________
563 //____________________________________________________________________________________________________________
565 void SAL_CALL
BaseControl::addWindowListener( const Reference
< XWindowListener
>& xListener
) throw( RuntimeException
)
567 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XWindowListener
>*)0), xListener
);
570 //____________________________________________________________________________________________________________
572 //____________________________________________________________________________________________________________
574 void SAL_CALL
BaseControl::addFocusListener( const Reference
< XFocusListener
>& xListener
) throw( RuntimeException
)
576 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XFocusListener
>*)0), xListener
);
579 //____________________________________________________________________________________________________________
581 //____________________________________________________________________________________________________________
583 void SAL_CALL
BaseControl::addKeyListener( const Reference
< XKeyListener
>& xListener
) throw( RuntimeException
)
585 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XKeyListener
>*)0), xListener
);
588 //____________________________________________________________________________________________________________
590 //____________________________________________________________________________________________________________
592 void SAL_CALL
BaseControl::addMouseListener( const Reference
< XMouseListener
>& xListener
) throw( RuntimeException
)
594 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XMouseListener
>*)0), xListener
);
597 //____________________________________________________________________________________________________________
599 //____________________________________________________________________________________________________________
601 void SAL_CALL
BaseControl::addMouseMotionListener( const Reference
< XMouseMotionListener
>& xListener
) throw( RuntimeException
)
603 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XMouseMotionListener
>*)0), xListener
);
606 //____________________________________________________________________________________________________________
608 //____________________________________________________________________________________________________________
610 void SAL_CALL
BaseControl::addPaintListener( const Reference
< XPaintListener
>& xListener
) throw( RuntimeException
)
612 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XPaintListener
>*)0), xListener
);
615 //____________________________________________________________________________________________________________
617 //____________________________________________________________________________________________________________
619 void SAL_CALL
BaseControl::removeWindowListener( const Reference
< XWindowListener
>& xListener
) throw( RuntimeException
)
621 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XWindowListener
>*)0), xListener
);
624 //____________________________________________________________________________________________________________
626 //____________________________________________________________________________________________________________
628 void SAL_CALL
BaseControl::removeFocusListener( const Reference
< XFocusListener
>& xListener
) throw( RuntimeException
)
630 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XFocusListener
>*)0), xListener
);
633 //____________________________________________________________________________________________________________
635 //____________________________________________________________________________________________________________
637 void SAL_CALL
BaseControl::removeKeyListener( const Reference
< XKeyListener
>& xListener
) throw( RuntimeException
)
639 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XKeyListener
>*)0), xListener
);
642 //____________________________________________________________________________________________________________
644 //____________________________________________________________________________________________________________
646 void SAL_CALL
BaseControl::removeMouseListener( const Reference
< XMouseListener
>& xListener
) throw( RuntimeException
)
648 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XMouseListener
>*)0), xListener
);
651 //____________________________________________________________________________________________________________
653 //____________________________________________________________________________________________________________
655 void SAL_CALL
BaseControl::removeMouseMotionListener( const Reference
< XMouseMotionListener
>& xListener
) throw( RuntimeException
)
657 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XMouseMotionListener
>*)0), xListener
);
660 //____________________________________________________________________________________________________________
662 //____________________________________________________________________________________________________________
664 void SAL_CALL
BaseControl::removePaintListener( const Reference
< XPaintListener
>& xListener
) throw( RuntimeException
)
666 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XPaintListener
>*)0), xListener
);
669 //____________________________________________________________________________________________________________
671 //____________________________________________________________________________________________________________
673 void SAL_CALL
BaseControl::draw( sal_Int32 nX
,
674 sal_Int32 nY
) throw( RuntimeException
)
676 // Ready for multithreading
677 MutexGuard
aGuard( m_aMutex
);
679 // - paint to an view
680 // - use the method "paint()"
681 // - see also "windowPaint()"
682 impl_paint( nX
, nY
, m_xGraphicsView
);
685 //____________________________________________________________________________________________________________
687 //____________________________________________________________________________________________________________
689 sal_Bool SAL_CALL
BaseControl::setGraphics( const Reference
< XGraphics
>& xDevice
) throw( RuntimeException
)
691 // - set the graphics for an view
692 // - in this class exist 2 graphics-member ... one for peer[_xGraphicsPeer] and one for view[_xGraphicsView]
693 // - they are used by "windowPaint() and draw()", forwarded to "paint ()"
694 sal_Bool bReturn
= sal_False
;
695 if ( xDevice
.is() == sal_True
)
697 // Ready for multithreading
698 MutexGuard
aGuard( m_aMutex
);
700 m_xGraphicsView
= xDevice
;
707 //____________________________________________________________________________________________________________
709 //____________________________________________________________________________________________________________
711 void SAL_CALL
BaseControl::setZoom( float /*fZoomX*/ ,
712 float /*fZoomY*/ ) throw( RuntimeException
)
714 // Not implemented yet
717 //____________________________________________________________________________________________________________
719 //____________________________________________________________________________________________________________
721 Reference
< XGraphics
> SAL_CALL
BaseControl::getGraphics() throw( RuntimeException
)
723 // Ready for multithreading
724 MutexGuard
aGuard( m_aMutex
);
725 return m_xGraphicsView
;
728 //____________________________________________________________________________________________________________
730 //____________________________________________________________________________________________________________
732 Size SAL_CALL
BaseControl::getSize() throw( RuntimeException
)
734 // Ready for multithreading
735 MutexGuard
aGuard( m_aMutex
);
736 return Size( m_nWidth
, m_nHeight
);
739 //____________________________________________________________________________________________________________
741 //____________________________________________________________________________________________________________
743 void SAL_CALL
BaseControl::disposing( const EventObject
& /*aSource*/ ) throw( RuntimeException
)
745 // Ready for multithreading
746 MutexGuard
aGuard( m_aMutex
);
748 // - release ALL references
750 if ( m_xGraphicsPeer
.is() == sal_True
)
752 removePaintListener( this );
753 removeWindowListener( this );
754 m_xGraphicsPeer
= Reference
< XGraphics
>();
757 if ( m_xGraphicsView
.is() == sal_True
)
759 m_xGraphicsView
= Reference
< XGraphics
>();
763 //____________________________________________________________________________________________________________
765 //____________________________________________________________________________________________________________
767 void SAL_CALL
BaseControl::windowPaint( const PaintEvent
& /*aEvent*/ ) throw( RuntimeException
)
769 // Ready for multithreading
770 MutexGuard
aGuard( m_aMutex
);
772 // - repaint the peer
773 // - use the method "paint ()" for painting on a peer and a print device !!!
774 // - see also "draw ()"
775 impl_paint( 0, 0, m_xGraphicsPeer
);
778 //____________________________________________________________________________________________________________
780 //____________________________________________________________________________________________________________
782 void SAL_CALL
BaseControl::windowResized( const WindowEvent
& aEvent
) throw( RuntimeException
)
784 // Ready for multithreading
785 MutexGuard
aGuard( m_aMutex
);
787 m_nWidth
= aEvent
.Width
;
788 m_nHeight
= aEvent
.Height
;
789 WindowEvent aMappedEvent
= aEvent
;
792 impl_recalcLayout( aMappedEvent
);
795 //____________________________________________________________________________________________________________
797 //____________________________________________________________________________________________________________
799 void SAL_CALL
BaseControl::windowMoved( const WindowEvent
& aEvent
) throw( RuntimeException
)
801 // Ready for multithreading
802 MutexGuard
aGuard( m_aMutex
);
804 m_nWidth
= aEvent
.Width
;
805 m_nHeight
= aEvent
.Height
;
806 WindowEvent aMappedEvent
= aEvent
;
809 impl_recalcLayout( aMappedEvent
);
812 //____________________________________________________________________________________________________________
814 //____________________________________________________________________________________________________________
816 void SAL_CALL
BaseControl::windowShown( const EventObject
& /*aEvent*/ ) throw( RuntimeException
)
820 //____________________________________________________________________________________________________________
822 //____________________________________________________________________________________________________________
824 void SAL_CALL
BaseControl::windowHidden( const EventObject
& /*aEvent*/ ) throw( RuntimeException
)
828 //____________________________________________________________________________________________________________
829 // impl but public method to register service in DLL
830 // (In this BASE-implementation not implemented! Overwrite it in derived classes.)
831 //____________________________________________________________________________________________________________
833 const Sequence
< OUString
> BaseControl::impl_getStaticSupportedServiceNames()
835 return Sequence
< OUString
>();
838 //____________________________________________________________________________________________________________
839 // impl but public method to register service in DLL
840 // (In this BASE-implementation not implemented! Overwrite it in derived classes.)
841 //____________________________________________________________________________________________________________
843 const OUString
BaseControl::impl_getStaticImplementationName()
848 //____________________________________________________________________________________________________________
850 //____________________________________________________________________________________________________________
852 const Reference
< XComponentContext
> BaseControl::impl_getComponentContext()
854 return m_xComponentContext
;
857 //____________________________________________________________________________________________________________
859 //____________________________________________________________________________________________________________
861 const Reference
< XWindow
> BaseControl::impl_getPeerWindow()
863 return m_xPeerWindow
;
866 //____________________________________________________________________________________________________________
868 //____________________________________________________________________________________________________________
870 const Reference
< XGraphics
> BaseControl::impl_getGraphicsPeer()
872 return m_xGraphicsPeer
;
875 //____________________________________________________________________________________________________________
877 //____________________________________________________________________________________________________________
879 const sal_Int32
& BaseControl::impl_getWidth()
884 //____________________________________________________________________________________________________________
886 //____________________________________________________________________________________________________________
888 const sal_Int32
& BaseControl::impl_getHeight()
893 //____________________________________________________________________________________________________________
895 //____________________________________________________________________________________________________________
897 WindowDescriptor
* BaseControl::impl_getWindowDescriptor( const Reference
< XWindowPeer
>& xParentPeer
)
899 // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!!
900 // - if you will change the descriptor-values, you must override this virtuell function
901 // - the caller must release the memory for this dynamical descriptor !!!
903 WindowDescriptor
* pDescriptor
= new WindowDescriptor
;
905 pDescriptor
->Type
= WindowClass_SIMPLE
;
906 pDescriptor
->WindowServiceName
= "window" ;
907 pDescriptor
->ParentIndex
= -1 ;
908 pDescriptor
->Parent
= xParentPeer
;
909 pDescriptor
->Bounds
= getPosSize () ;
910 pDescriptor
->WindowAttributes
= 0 ;
915 //____________________________________________________________________________________________________________
917 //____________________________________________________________________________________________________________
919 void BaseControl::impl_paint( sal_Int32
/*nX*/ ,
921 const Reference
< XGraphics
>& /*xGraphics*/ )
923 // - one paint method for peer AND view !!!
924 // (see also => "windowPaint()" and "draw()")
925 // - not used in this implementation, but its not necessary to make it pure virtual !!!
928 //____________________________________________________________________________________________________________
930 //____________________________________________________________________________________________________________
932 void BaseControl::impl_recalcLayout( const WindowEvent
& /*aEvent*/ )
934 // We need as virtual function to support automaticly resizing of derived controls!
935 // But we make it not pure virtual because it's not necessary for all derived classes!
938 //____________________________________________________________________________________________________________
940 //____________________________________________________________________________________________________________
942 Reference
< XInterface
> BaseControl::impl_getDelegator()
944 return m_xDelegator
;
947 //____________________________________________________________________________________________________________
949 //____________________________________________________________________________________________________________
951 void BaseControl::impl_releasePeer()
953 if ( m_xPeer
.is() == sal_True
)
955 if ( m_xGraphicsPeer
.is() == sal_True
)
957 removePaintListener( this );
958 removeWindowListener( this );
959 m_xGraphicsPeer
= Reference
< XGraphics
>();
963 m_xPeerWindow
= Reference
< XWindow
>();
964 m_xPeer
= Reference
< XWindowPeer
>();
966 if ( m_pMultiplexer
!= NULL
)
968 // take changes on multiplexer
969 m_pMultiplexer
->setPeer( Reference
< XWindow
>() );
974 //____________________________________________________________________________________________________________
976 //____________________________________________________________________________________________________________
978 OMRCListenerMultiplexerHelper
* BaseControl::impl_getMultiplexer()
980 if ( m_pMultiplexer
== NULL
)
982 m_pMultiplexer
= new OMRCListenerMultiplexerHelper( (XWindow
*)this, m_xPeerWindow
);
983 m_xMultiplexer
= Reference
< XInterface
>( (OWeakObject
*)m_pMultiplexer
, UNO_QUERY
);
986 return m_pMultiplexer
;
989 } // namespace unocontrols
991 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */