1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 //____________________________________________________________________________________________________________
31 //____________________________________________________________________________________________________________
33 #include "basecontrol.hxx"
35 //____________________________________________________________________________________________________________
36 // includes of other projects
37 //____________________________________________________________________________________________________________
38 #include <com/sun/star/awt/XDevice.hpp>
39 #include <com/sun/star/awt/XDisplayBitmap.hpp>
40 #include <com/sun/star/awt/DeviceInfo.hpp>
41 #include <com/sun/star/awt/WindowAttribute.hpp>
42 #include <com/sun/star/awt/PosSize.hpp>
43 #include <cppuhelper/typeprovider.hxx>
45 //____________________________________________________________________________________________________________
46 // includes of my own project
47 //____________________________________________________________________________________________________________
49 //____________________________________________________________________________________________________________
51 //____________________________________________________________________________________________________________
53 using namespace ::cppu
;
54 using namespace ::osl
;
55 using namespace ::rtl
;
56 using namespace ::com::sun::star::uno
;
57 using namespace ::com::sun::star::lang
;
58 using namespace ::com::sun::star::awt
;
60 namespace unocontrols
{
62 //____________________________________________________________________________________________________________
64 //____________________________________________________________________________________________________________
66 #define DEFAULT_PMULTIPLEXER NULL
69 #define DEFAULT_WIDTH 100
70 #define DEFAULT_HEIGHT 100
71 #define DEFAULT_VISIBLE sal_False
72 #define DEFAULT_INDESIGNMODE sal_False
73 #define DEFAULT_ENABLE sal_True
74 #define SERVICE_VCLTOOLKIT "com.sun.star.awt.Toolkit"
76 //____________________________________________________________________________________________________________
78 //____________________________________________________________________________________________________________
80 BaseControl::BaseControl( const Reference
< XMultiServiceFactory
>& xFactory
)
81 : IMPL_MutexContainer ( )
82 , OComponentHelper ( m_aMutex
)
83 , m_xFactory ( xFactory
)
84 , m_pMultiplexer ( DEFAULT_PMULTIPLEXER
)
87 , m_nWidth ( DEFAULT_WIDTH
)
88 , m_nHeight ( DEFAULT_HEIGHT
)
89 , m_bVisible ( DEFAULT_VISIBLE
)
90 , m_bInDesignMode ( DEFAULT_INDESIGNMODE
)
91 , m_bEnable ( DEFAULT_ENABLE
)
95 BaseControl::~BaseControl()
99 //____________________________________________________________________________________________________________
101 //____________________________________________________________________________________________________________
103 Any SAL_CALL
BaseControl::queryInterface( const Type
& rType
) throw( RuntimeException
)
106 if ( m_xDelegator
.is() == sal_True
)
108 // If an delegator exist, forward question to his queryInterface.
109 // Delegator will ask his own queryAggregation!
110 aReturn
= m_xDelegator
->queryInterface( rType
);
114 // If an delegator unknown, forward question to own queryAggregation.
115 aReturn
= queryAggregation( rType
);
121 //____________________________________________________________________________________________________________
123 //____________________________________________________________________________________________________________
125 void SAL_CALL
BaseControl::acquire() throw()
128 // Don't use mutex or guard in this method!!! Is a method of XInterface.
130 // Forward to baseclass
131 OComponentHelper::acquire();
134 //____________________________________________________________________________________________________________
136 //____________________________________________________________________________________________________________
138 void SAL_CALL
BaseControl::release() throw()
141 // Don't use mutex or guard in this method!!! Is a method of XInterface.
143 // Forward to baseclass
144 OComponentHelper::release();
147 //____________________________________________________________________________________________________________
149 //____________________________________________________________________________________________________________
151 Sequence
< Type
> SAL_CALL
BaseControl::getTypes() throw( RuntimeException
)
153 // Optimize this method !
154 // We initialize a static variable only one time. And we don't must use a mutex at every call!
155 // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
156 static OTypeCollection
* pTypeCollection
= NULL
;
158 if ( pTypeCollection
== NULL
)
160 // Ready for multithreading; get global mutex for first call of this method only! see before
161 MutexGuard
aGuard( Mutex::getGlobalMutex() );
163 // Control these pointer again ... it can be, that another instance will be faster then these!
164 if ( pTypeCollection
== NULL
)
166 // Create a static typecollection ...
167 static OTypeCollection
aTypeCollection( ::getCppuType(( const Reference
< XPaintListener
>*)NULL
) ,
168 ::getCppuType(( const Reference
< XWindowListener
>*)NULL
) ,
169 ::getCppuType(( const Reference
< XView
>*)NULL
) ,
170 ::getCppuType(( const Reference
< XWindow
>*)NULL
) ,
171 ::getCppuType(( const Reference
< XServiceInfo
>*)NULL
) ,
172 ::getCppuType(( const Reference
< XControl
>*)NULL
) ,
173 OComponentHelper::getTypes()
176 // ... and set his address to static pointer!
177 pTypeCollection
= &aTypeCollection
;
181 return pTypeCollection
->getTypes();
184 //____________________________________________________________________________________________________________
186 //____________________________________________________________________________________________________________
188 Sequence
< sal_Int8
> SAL_CALL
BaseControl::getImplementationId() throw( RuntimeException
)
190 // Create one Id for all instances of this class.
191 // Use ethernet address to do this! (sal_True)
193 // Optimize this method
194 // We initialize a static variable only one time. And we don't must use a mutex at every call!
195 // For the first call; pID is NULL - for the second call pID is different from NULL!
196 static OImplementationId
* pID
= NULL
;
200 // Ready for multithreading; get global mutex for first call of this method only! see before
201 MutexGuard
aGuard( Mutex::getGlobalMutex() );
203 // Control these pointer again ... it can be, that another instance will be faster then these!
206 // Create a new static ID ...
207 static OImplementationId
aID( sal_False
);
208 // ... and set his address to static pointer!
213 return pID
->getImplementationId();
216 //____________________________________________________________________________________________________________
218 //____________________________________________________________________________________________________________
220 void SAL_CALL
BaseControl::setDelegator( const Reference
< XInterface
>& xDel
) throw( RuntimeException
)
222 // Ready for multithreading
223 MutexGuard
aGuard( m_aMutex
);
227 //____________________________________________________________________________________________________________
229 //____________________________________________________________________________________________________________
231 Any SAL_CALL
BaseControl::queryAggregation( const Type
& aType
) throw( RuntimeException
)
233 // Ask for my own supported interfaces ...
234 // Attention: XTypeProvider and XInterface are supported by OComponentHelper!
235 Any
aReturn ( ::cppu::queryInterface( aType
,
236 static_cast< XPaintListener
*> ( this ) ,
237 static_cast< XWindowListener
*> ( this ) ,
238 static_cast< XView
* > ( this ) ,
239 static_cast< XWindow
* > ( this ) ,
240 static_cast< XServiceInfo
* > ( this ) ,
241 static_cast< XControl
* > ( this )
245 // If searched interface supported by this class ...
246 if ( aReturn
.hasValue() == sal_True
)
248 // ... return this information.
253 // Else; ... ask baseclass for interfaces!
254 return OComponentHelper::queryAggregation( aType
);
258 //____________________________________________________________________________________________________________
260 //____________________________________________________________________________________________________________
262 OUString SAL_CALL
BaseControl::getImplementationName() throw( RuntimeException
)
264 return impl_getStaticImplementationName();
267 //____________________________________________________________________________________________________________
269 //____________________________________________________________________________________________________________
271 sal_Bool SAL_CALL
BaseControl::supportsService( const OUString
& sServiceName
) throw( RuntimeException
)
273 Sequence
< OUString
> seqServiceNames
= getSupportedServiceNames();
274 const OUString
* pArray
= seqServiceNames
.getConstArray();
275 for ( sal_Int32 nCounter
=0; nCounter
<seqServiceNames
.getLength(); nCounter
++ )
277 if ( pArray
[nCounter
] == sServiceName
)
285 //____________________________________________________________________________________________________________
287 //____________________________________________________________________________________________________________
289 Sequence
< OUString
> SAL_CALL
BaseControl::getSupportedServiceNames() throw( RuntimeException
)
291 return impl_getStaticSupportedServiceNames();
294 //____________________________________________________________________________________________________________
296 //____________________________________________________________________________________________________________
298 void SAL_CALL
BaseControl::dispose() throw( RuntimeException
)
300 // Ready for multithreading
301 MutexGuard
aGuard( m_aMutex
);
303 if ( m_pMultiplexer
!= NULL
)
305 // to all other paint, focus, etc.
306 m_pMultiplexer
->disposeAndClear();
309 // set the service manager to disposed
310 OComponentHelper::dispose();
312 // release context and peer
313 m_xContext
= Reference
< XInterface
>();
317 if ( m_xGraphicsView
.is() == sal_True
)
319 m_xGraphicsView
= Reference
< XGraphics
>();
323 //____________________________________________________________________________________________________________
325 //____________________________________________________________________________________________________________
327 void SAL_CALL
BaseControl::addEventListener( const Reference
< XEventListener
>& xListener
) throw( RuntimeException
)
329 // Ready for multithreading
330 MutexGuard
aGuard( m_aMutex
);
331 OComponentHelper::addEventListener( xListener
);
334 //____________________________________________________________________________________________________________
336 //____________________________________________________________________________________________________________
338 void SAL_CALL
BaseControl::removeEventListener( const Reference
< XEventListener
>& xListener
) throw( RuntimeException
)
340 // Ready for multithreading
341 MutexGuard
aGuard( m_aMutex
);
342 OComponentHelper::removeEventListener( xListener
);
345 //____________________________________________________________________________________________________________
347 //____________________________________________________________________________________________________________
349 void SAL_CALL
BaseControl::createPeer( const Reference
< XToolkit
>& xToolkit
,
350 const Reference
< XWindowPeer
>& xParentPeer
) throw( RuntimeException
)
352 // Ready for multithreading
353 MutexGuard
aGuard( m_aMutex
);
355 if ( m_xPeer
.is() == sal_False
)
357 // use method "BaseControl::getWindowDescriptor()" fot change window attributes !!!
358 WindowDescriptor
* pDescriptor
= impl_getWindowDescriptor( xParentPeer
);
360 if ( m_bVisible
== sal_True
)
362 pDescriptor
->WindowAttributes
|= WindowAttribute::SHOW
;
365 // very slow under remote conditions!
366 // create the window on the server
367 Reference
< XToolkit
> xLocalToolkit
= xToolkit
;
368 if ( xLocalToolkit
.is() == sal_False
)
370 // but first create wellknown toolkit, if it not exist
371 xLocalToolkit
= Reference
< XToolkit
> ( m_xFactory
->createInstance( SERVICE_VCLTOOLKIT
), UNO_QUERY
);
373 m_xPeer
= xLocalToolkit
->createWindow( *pDescriptor
);
374 m_xPeerWindow
= Reference
< XWindow
>( m_xPeer
, UNO_QUERY
);
376 // don't forget to release the memory!
379 if ( m_xPeerWindow
.is() == sal_True
)
381 if ( m_pMultiplexer
!= NULL
)
383 m_pMultiplexer
->setPeer( m_xPeerWindow
);
386 // create new referenz to xgraphics for painting on a peer
387 // and add a paint listener
388 Reference
< XDevice
> xDevice( m_xPeerWindow
, UNO_QUERY
);
390 if ( xDevice
.is() == sal_True
)
392 m_xGraphicsPeer
= xDevice
->createGraphics();
395 if ( m_xGraphicsPeer
.is() == sal_True
)
397 addPaintListener( this );
398 addWindowListener( this );
401 // PosSize_POSSIZE defined in <stardiv/uno/awt/window.hxx>
402 m_xPeerWindow
->setPosSize( m_nX
, m_nY
, m_nWidth
, m_nHeight
, PosSize::POSSIZE
);
403 m_xPeerWindow
->setEnable( m_bEnable
);
404 m_xPeerWindow
->setVisible( m_bVisible
&& !m_bInDesignMode
);
409 //____________________________________________________________________________________________________________
411 //____________________________________________________________________________________________________________
413 void SAL_CALL
BaseControl::setContext( const Reference
< XInterface
>& xContext
) throw( RuntimeException
)
415 // Ready for multithreading
416 MutexGuard
aGuard( m_aMutex
);
417 m_xContext
= xContext
;
420 //____________________________________________________________________________________________________________
422 //____________________________________________________________________________________________________________
424 void SAL_CALL
BaseControl::setDesignMode( sal_Bool bOn
) throw( RuntimeException
)
426 // Ready for multithreading
427 MutexGuard
aGuard( m_aMutex
);
428 m_bInDesignMode
= bOn
;
431 //____________________________________________________________________________________________________________
433 //____________________________________________________________________________________________________________
435 Reference
< XInterface
> SAL_CALL
BaseControl::getContext() throw( RuntimeException
)
437 // Ready for multithreading
438 MutexGuard
aGuard( m_aMutex
);
442 //____________________________________________________________________________________________________________
444 //____________________________________________________________________________________________________________
446 Reference
< XWindowPeer
> SAL_CALL
BaseControl::getPeer() throw( RuntimeException
)
448 // Ready for multithreading
449 MutexGuard
aGuard( m_aMutex
);
453 //____________________________________________________________________________________________________________
455 //____________________________________________________________________________________________________________
457 Reference
< XView
> SAL_CALL
BaseControl::getView() throw( RuntimeException
)
459 // Ready for multithreading
460 MutexGuard
aGuard( m_aMutex
);
461 return Reference
< XView
>( (OWeakObject
*)this, UNO_QUERY
);
464 //____________________________________________________________________________________________________________
466 //____________________________________________________________________________________________________________
468 sal_Bool SAL_CALL
BaseControl::isDesignMode() throw( RuntimeException
)
470 // Ready for multithreading
471 MutexGuard
aGuard( m_aMutex
);
472 return m_bInDesignMode
;
475 //____________________________________________________________________________________________________________
477 //____________________________________________________________________________________________________________
479 sal_Bool SAL_CALL
BaseControl::isTransparent() throw( RuntimeException
)
484 //____________________________________________________________________________________________________________
486 //____________________________________________________________________________________________________________
488 void SAL_CALL
BaseControl::setPosSize( sal_Int32 nX
,
492 sal_Int16 nFlags
) throw( RuntimeException
)
494 // - change size and position of window and save the values
495 // - "nFlags" declared in <stardiv/uno/awt/window.hxx> ("#define PosSize_X .....")
497 // Ready for multithreading
498 MutexGuard
aGuard( m_aMutex
);
500 sal_Bool bChanged
= sal_False
;
502 if ( nFlags
& PosSize::X
)
504 bChanged
|= m_nX
!= nX
, m_nX
= nX
;
507 if ( nFlags
& PosSize::Y
)
509 bChanged
|= m_nY
!= nY
, m_nY
= nY
;
512 if ( nFlags
& PosSize::WIDTH
)
514 bChanged
|= m_nWidth
!= nWidth
, m_nWidth
= nWidth
;
517 if ( nFlags
& PosSize::HEIGHT
)
519 bChanged
|= m_nHeight
!= nHeight
, m_nHeight
= nHeight
;
522 if ( bChanged
&& m_xPeerWindow
.is() )
524 m_xPeerWindow
->setPosSize( m_nX
, m_nY
, m_nWidth
, m_nHeight
, nFlags
);
528 //____________________________________________________________________________________________________________
530 //____________________________________________________________________________________________________________
532 void SAL_CALL
BaseControl::setVisible( sal_Bool bVisible
) throw( RuntimeException
)
534 // Ready for multithreading
535 MutexGuard
aGuard( m_aMutex
);
537 // Set new state of flag
538 m_bVisible
= bVisible
;
540 if ( m_xPeerWindow
.is() == sal_True
)
542 // Set it also on peerwindow
543 m_xPeerWindow
->setVisible( m_bVisible
);
547 //____________________________________________________________________________________________________________
549 //____________________________________________________________________________________________________________
551 void SAL_CALL
BaseControl::setEnable( sal_Bool bEnable
) throw( RuntimeException
)
553 // Ready for multithreading
554 MutexGuard
aGuard( m_aMutex
);
556 // Set new state of flag
557 m_bEnable
= bEnable
;
559 if ( m_xPeerWindow
.is() == sal_True
)
561 // Set it also on peerwindow
562 m_xPeerWindow
->setEnable( m_bEnable
);
566 //____________________________________________________________________________________________________________
568 //____________________________________________________________________________________________________________
570 void SAL_CALL
BaseControl::setFocus() throw( RuntimeException
)
572 // Ready for multithreading
573 MutexGuard
aGuard( m_aMutex
);
575 if ( m_xPeerWindow
.is() == sal_True
)
577 m_xPeerWindow
->setFocus();
581 //____________________________________________________________________________________________________________
583 //____________________________________________________________________________________________________________
585 Rectangle SAL_CALL
BaseControl::getPosSize() throw( RuntimeException
)
587 // Ready for multithreading
588 MutexGuard
aGuard( m_aMutex
);
589 return Rectangle( m_nX
, m_nY
, m_nWidth
, m_nHeight
);
592 //____________________________________________________________________________________________________________
594 //____________________________________________________________________________________________________________
596 void SAL_CALL
BaseControl::addWindowListener( const Reference
< XWindowListener
>& xListener
) throw( RuntimeException
)
598 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XWindowListener
>*)0), xListener
);
601 //____________________________________________________________________________________________________________
603 //____________________________________________________________________________________________________________
605 void SAL_CALL
BaseControl::addFocusListener( const Reference
< XFocusListener
>& xListener
) throw( RuntimeException
)
607 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XFocusListener
>*)0), xListener
);
610 //____________________________________________________________________________________________________________
612 //____________________________________________________________________________________________________________
614 void SAL_CALL
BaseControl::addKeyListener( const Reference
< XKeyListener
>& xListener
) throw( RuntimeException
)
616 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XKeyListener
>*)0), xListener
);
619 //____________________________________________________________________________________________________________
621 //____________________________________________________________________________________________________________
623 void SAL_CALL
BaseControl::addMouseListener( const Reference
< XMouseListener
>& xListener
) throw( RuntimeException
)
625 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XMouseListener
>*)0), xListener
);
628 //____________________________________________________________________________________________________________
630 //____________________________________________________________________________________________________________
632 void SAL_CALL
BaseControl::addMouseMotionListener( const Reference
< XMouseMotionListener
>& xListener
) throw( RuntimeException
)
634 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XMouseMotionListener
>*)0), xListener
);
637 //____________________________________________________________________________________________________________
639 //____________________________________________________________________________________________________________
641 void SAL_CALL
BaseControl::addPaintListener( const Reference
< XPaintListener
>& xListener
) throw( RuntimeException
)
643 impl_getMultiplexer()->advise( ::getCppuType(( const Reference
< XPaintListener
>*)0), xListener
);
646 //____________________________________________________________________________________________________________
648 //____________________________________________________________________________________________________________
650 void SAL_CALL
BaseControl::removeWindowListener( const Reference
< XWindowListener
>& xListener
) throw( RuntimeException
)
652 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XWindowListener
>*)0), xListener
);
655 //____________________________________________________________________________________________________________
657 //____________________________________________________________________________________________________________
659 void SAL_CALL
BaseControl::removeFocusListener( const Reference
< XFocusListener
>& xListener
) throw( RuntimeException
)
661 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XFocusListener
>*)0), xListener
);
664 //____________________________________________________________________________________________________________
666 //____________________________________________________________________________________________________________
668 void SAL_CALL
BaseControl::removeKeyListener( const Reference
< XKeyListener
>& xListener
) throw( RuntimeException
)
670 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XKeyListener
>*)0), xListener
);
673 //____________________________________________________________________________________________________________
675 //____________________________________________________________________________________________________________
677 void SAL_CALL
BaseControl::removeMouseListener( const Reference
< XMouseListener
>& xListener
) throw( RuntimeException
)
679 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XMouseListener
>*)0), xListener
);
682 //____________________________________________________________________________________________________________
684 //____________________________________________________________________________________________________________
686 void SAL_CALL
BaseControl::removeMouseMotionListener( const Reference
< XMouseMotionListener
>& xListener
) throw( RuntimeException
)
688 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XMouseMotionListener
>*)0), xListener
);
691 //____________________________________________________________________________________________________________
693 //____________________________________________________________________________________________________________
695 void SAL_CALL
BaseControl::removePaintListener( const Reference
< XPaintListener
>& xListener
) throw( RuntimeException
)
697 impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference
< XPaintListener
>*)0), xListener
);
700 //____________________________________________________________________________________________________________
702 //____________________________________________________________________________________________________________
704 void SAL_CALL
BaseControl::draw( sal_Int32 nX
,
705 sal_Int32 nY
) throw( RuntimeException
)
707 // Ready for multithreading
708 MutexGuard
aGuard( m_aMutex
);
710 // - paint to an view
711 // - use the method "paint()"
712 // - see also "windowPaint()"
713 impl_paint( nX
, nY
, m_xGraphicsView
);
716 //____________________________________________________________________________________________________________
718 //____________________________________________________________________________________________________________
720 sal_Bool SAL_CALL
BaseControl::setGraphics( const Reference
< XGraphics
>& xDevice
) throw( RuntimeException
)
722 // - set the graphics for an view
723 // - in this class exist 2 graphics-member ... one for peer[_xGraphicsPeer] and one for view[_xGraphicsView]
724 // - they are used by "windowPaint() and draw()", forwarded to "paint ()"
725 sal_Bool bReturn
= sal_False
;
726 if ( xDevice
.is() == sal_True
)
728 // Ready for multithreading
729 MutexGuard
aGuard( m_aMutex
);
731 m_xGraphicsView
= xDevice
;
738 //____________________________________________________________________________________________________________
740 //____________________________________________________________________________________________________________
742 void SAL_CALL
BaseControl::setZoom( float /*fZoomX*/ ,
743 float /*fZoomY*/ ) throw( RuntimeException
)
745 // Not implemented yet
748 //____________________________________________________________________________________________________________
750 //____________________________________________________________________________________________________________
752 Reference
< XGraphics
> SAL_CALL
BaseControl::getGraphics() throw( RuntimeException
)
754 // Ready for multithreading
755 MutexGuard
aGuard( m_aMutex
);
756 return m_xGraphicsView
;
759 //____________________________________________________________________________________________________________
761 //____________________________________________________________________________________________________________
763 Size SAL_CALL
BaseControl::getSize() throw( RuntimeException
)
765 // Ready for multithreading
766 MutexGuard
aGuard( m_aMutex
);
767 return Size( m_nWidth
, m_nHeight
);
770 //____________________________________________________________________________________________________________
772 //____________________________________________________________________________________________________________
774 void SAL_CALL
BaseControl::disposing( const EventObject
& /*aSource*/ ) throw( RuntimeException
)
776 // Ready for multithreading
777 MutexGuard
aGuard( m_aMutex
);
779 // - release ALL references
781 if ( m_xGraphicsPeer
.is() == sal_True
)
783 removePaintListener( this );
784 removeWindowListener( this );
785 m_xGraphicsPeer
= Reference
< XGraphics
>();
788 if ( m_xGraphicsView
.is() == sal_True
)
790 m_xGraphicsView
= Reference
< XGraphics
>();
794 //____________________________________________________________________________________________________________
796 //____________________________________________________________________________________________________________
798 void SAL_CALL
BaseControl::windowPaint( const PaintEvent
& /*aEvent*/ ) throw( RuntimeException
)
800 // Ready for multithreading
801 MutexGuard
aGuard( m_aMutex
);
803 // - repaint the peer
804 // - use the method "paint ()" for painting on a peer and a print device !!!
805 // - see also "draw ()"
806 impl_paint( 0, 0, m_xGraphicsPeer
);
809 //____________________________________________________________________________________________________________
811 //____________________________________________________________________________________________________________
813 void SAL_CALL
BaseControl::windowResized( const WindowEvent
& aEvent
) throw( RuntimeException
)
815 // Ready for multithreading
816 MutexGuard
aGuard( m_aMutex
);
818 m_nWidth
= aEvent
.Width
;
819 m_nHeight
= aEvent
.Height
;
820 WindowEvent aMappedEvent
= aEvent
;
823 impl_recalcLayout( aMappedEvent
);
826 //____________________________________________________________________________________________________________
828 //____________________________________________________________________________________________________________
830 void SAL_CALL
BaseControl::windowMoved( const WindowEvent
& aEvent
) throw( RuntimeException
)
832 // Ready for multithreading
833 MutexGuard
aGuard( m_aMutex
);
835 m_nWidth
= aEvent
.Width
;
836 m_nHeight
= aEvent
.Height
;
837 WindowEvent aMappedEvent
= aEvent
;
840 impl_recalcLayout( aMappedEvent
);
843 //____________________________________________________________________________________________________________
845 //____________________________________________________________________________________________________________
847 void SAL_CALL
BaseControl::windowShown( const EventObject
& /*aEvent*/ ) throw( RuntimeException
)
851 //____________________________________________________________________________________________________________
853 //____________________________________________________________________________________________________________
855 void SAL_CALL
BaseControl::windowHidden( const EventObject
& /*aEvent*/ ) throw( RuntimeException
)
859 //____________________________________________________________________________________________________________
860 // impl but public method to register service in DLL
861 // (In this BASE-implementation not implemented! Overwrite it in derived classes.)
862 //____________________________________________________________________________________________________________
864 const Sequence
< OUString
> BaseControl::impl_getStaticSupportedServiceNames()
866 return Sequence
< OUString
>();
869 //____________________________________________________________________________________________________________
870 // impl but public method to register service in DLL
871 // (In this BASE-implementation not implemented! Overwrite it in derived classes.)
872 //____________________________________________________________________________________________________________
874 const OUString
BaseControl::impl_getStaticImplementationName()
879 //____________________________________________________________________________________________________________
881 //____________________________________________________________________________________________________________
883 const Reference
< XMultiServiceFactory
> BaseControl::impl_getMultiServiceFactory()
888 //____________________________________________________________________________________________________________
890 //____________________________________________________________________________________________________________
892 const Reference
< XWindow
> BaseControl::impl_getPeerWindow()
894 return m_xPeerWindow
;
897 //____________________________________________________________________________________________________________
899 //____________________________________________________________________________________________________________
901 const Reference
< XGraphics
> BaseControl::impl_getGraphicsPeer()
903 return m_xGraphicsPeer
;
906 //____________________________________________________________________________________________________________
908 //____________________________________________________________________________________________________________
910 const sal_Int32
& BaseControl::impl_getWidth()
915 //____________________________________________________________________________________________________________
917 //____________________________________________________________________________________________________________
919 const sal_Int32
& BaseControl::impl_getHeight()
924 //____________________________________________________________________________________________________________
926 //____________________________________________________________________________________________________________
928 WindowDescriptor
* BaseControl::impl_getWindowDescriptor( const Reference
< XWindowPeer
>& xParentPeer
)
930 // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!!
931 // - if you will change the descriptor-values, you must override this virtuell function
932 // - the caller must release the memory for this dynamical descriptor !!!
934 WindowDescriptor
* pDescriptor
= new WindowDescriptor
;
936 pDescriptor
->Type
= WindowClass_SIMPLE
;
937 pDescriptor
->WindowServiceName
= "window" ;
938 pDescriptor
->ParentIndex
= -1 ;
939 pDescriptor
->Parent
= xParentPeer
;
940 pDescriptor
->Bounds
= getPosSize () ;
941 pDescriptor
->WindowAttributes
= 0 ;
946 //____________________________________________________________________________________________________________
948 //____________________________________________________________________________________________________________
950 void BaseControl::impl_paint( sal_Int32
/*nX*/ ,
952 const Reference
< XGraphics
>& /*xGraphics*/ )
954 // - one paint method for peer AND view !!!
955 // (see also => "windowPaint()" and "draw()")
956 // - not used in this implementation, but its not necessary to make it pure virtual !!!
959 //____________________________________________________________________________________________________________
961 //____________________________________________________________________________________________________________
963 void BaseControl::impl_recalcLayout( const WindowEvent
& /*aEvent*/ )
965 // We need as virtual function to support automaticly resizing of derived controls!
966 // But we make it not pure virtual because it's not neccessary for all derived classes!
969 //____________________________________________________________________________________________________________
971 //____________________________________________________________________________________________________________
973 Reference
< XInterface
> BaseControl::impl_getDelegator()
975 return m_xDelegator
;
978 //____________________________________________________________________________________________________________
980 //____________________________________________________________________________________________________________
982 void BaseControl::impl_releasePeer()
984 if ( m_xPeer
.is() == sal_True
)
986 if ( m_xGraphicsPeer
.is() == sal_True
)
988 removePaintListener( this );
989 removeWindowListener( this );
990 m_xGraphicsPeer
= Reference
< XGraphics
>();
994 m_xPeerWindow
= Reference
< XWindow
>();
995 m_xPeer
= Reference
< XWindowPeer
>();
997 if ( m_pMultiplexer
!= NULL
)
999 // take changes on multiplexer
1000 m_pMultiplexer
->setPeer( Reference
< XWindow
>() );
1005 //____________________________________________________________________________________________________________
1007 //____________________________________________________________________________________________________________
1009 OMRCListenerMultiplexerHelper
* BaseControl::impl_getMultiplexer()
1011 if ( m_pMultiplexer
== NULL
)
1013 m_pMultiplexer
= new OMRCListenerMultiplexerHelper( (XWindow
*)this, m_xPeerWindow
);
1014 m_xMultiplexer
= Reference
< XInterface
>( (OWeakObject
*)m_pMultiplexer
, UNO_QUERY
);
1017 return m_pMultiplexer
;
1020 } // namespace unocontrols
1022 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */