diff options
author | Andreas Schlüns <as@openoffice.org> | 2000-10-12 09:33:51 +0000 |
---|---|---|
committer | Andreas Schlüns <as@openoffice.org> | 2000-10-12 09:33:51 +0000 |
commit | 24689da47f00038fdeeb8edc8e6b071a67aacc51 (patch) | |
tree | 65d3c1078fbc00b94f0b9233ad9896bcc6eb8bde /UnoControls/source/base | |
parent | 0c04c3b443ab2ca75fc03e05c14822a6bb0cffa2 (diff) |
#78521# support window listener mechanism for derived controls
Diffstat (limited to 'UnoControls/source/base')
-rw-r--r-- | UnoControls/source/base/basecontainercontrol.cxx | 11 | ||||
-rw-r--r-- | UnoControls/source/base/basecontrol.cxx | 71 |
2 files changed, 74 insertions, 8 deletions
diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx index 81733b3eecba..48ccda4d7519 100644 --- a/UnoControls/source/base/basecontainercontrol.cxx +++ b/UnoControls/source/base/basecontainercontrol.cxx @@ -2,9 +2,9 @@ * * $RCSfile: basecontainercontrol.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:11:17 $ + * last change: $Author: as $ $Date: 2000-10-12 10:33:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -279,9 +279,10 @@ void SAL_CALL BaseContainerControl::dispose() throw( RuntimeException ) } m_pControlInfoList->Clear(); + for ( nCount = 0; nCount < nCtrls; ++nCount ) { - pCtrls [ nCount ] -> removeEventListener ( this ) ; + pCtrls [ nCount ] -> removeEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ) ; pCtrls [ nCount ] -> dispose ( ) ; } @@ -330,7 +331,7 @@ void SAL_CALL BaseContainerControl::addControl ( const OUString& rName, const Re // initialize new control pNewControl->xControl->setContext ( (OWeakObject*)this ) ; - pNewControl->xControl->addEventListener ( this ) ; + pNewControl->xControl->addEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) ) ; // when container has a peer ... if (getPeer().is()) @@ -395,7 +396,7 @@ void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > if ( rControl == pControl->xControl ) { //.is it found ... remove listener from control - pControl->xControl->removeEventListener ( this ) ; + pControl->xControl->removeEventListener (static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) )) ; pControl->xControl->setContext ( Reference< XInterface > () ) ; // ... free memory diff --git a/UnoControls/source/base/basecontrol.cxx b/UnoControls/source/base/basecontrol.cxx index 1587bebac74d..217bbe85a4e9 100644 --- a/UnoControls/source/base/basecontrol.cxx +++ b/UnoControls/source/base/basecontrol.cxx @@ -2,9 +2,9 @@ * * $RCSfile: basecontrol.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:11:17 $ + * last change: $Author: as $ $Date: 2000-10-12 10:33:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -218,6 +218,7 @@ Sequence< Type > SAL_CALL BaseControl::getTypes() throw( RuntimeException ) { // Create a static typecollection ... static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XPaintListener >*)NULL ) , + ::getCppuType(( const Reference< XWindowListener>*)NULL ) , ::getCppuType(( const Reference< XView >*)NULL ) , ::getCppuType(( const Reference< XWindow >*)NULL ) , ::getCppuType(( const Reference< XServiceInfo >*)NULL ) , @@ -286,6 +287,7 @@ Any SAL_CALL BaseControl::queryAggregation( const Type& aType ) throw( RuntimeEx // Attention: XTypeProvider and XInterface are supported by OComponentHelper! Any aReturn ( ::cppu::queryInterface( aType , static_cast< XPaintListener*> ( this ) , + static_cast< XWindowListener*> ( this ) , static_cast< XView* > ( this ) , static_cast< XWindow* > ( this ) , static_cast< XServiceInfo* > ( this ) , @@ -446,6 +448,7 @@ void SAL_CALL BaseControl::createPeer( const Reference< XToolkit >& xToo if ( m_xGraphicsPeer.is() == sal_True ) { addPaintListener( this ); + addWindowListener( this ); } // PosSize_POSSIZE defined in <stardiv/uno/awt/window.hxx> @@ -831,6 +834,7 @@ void SAL_CALL BaseControl::disposing( const EventObject& aSource ) throw( Runtim if ( m_xGraphicsPeer.is() == sal_True ) { removePaintListener( this ); + removeWindowListener( this ); m_xGraphicsPeer = Reference< XGraphics >(); } @@ -856,6 +860,56 @@ void SAL_CALL BaseControl::windowPaint( const PaintEvent& aEvent ) throw( Runtim } //____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::windowResized( const WindowEvent& aEvent ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + m_nWidth = aEvent.Width ; + m_nHeight = aEvent.Height ; + WindowEvent aMappedEvent = aEvent; + aMappedEvent.X = 0; + aMappedEvent.Y = 0; + impl_recalcLayout( aMappedEvent ); +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::windowMoved( const WindowEvent& aEvent ) throw( RuntimeException ) +{ + // Ready for multithreading + MutexGuard aGuard( m_aMutex ); + + m_nWidth = aEvent.Width ; + m_nHeight = aEvent.Height ; + WindowEvent aMappedEvent = aEvent; + aMappedEvent.X = 0; + aMappedEvent.Y = 0; + impl_recalcLayout( aMappedEvent ); +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::windowShown( const EventObject& aEvent ) throw( RuntimeException ) +{ +} + +//____________________________________________________________________________________________________________ +// XWindowListener +//____________________________________________________________________________________________________________ + +void SAL_CALL BaseControl::windowHidden( const EventObject& aEvent ) throw( RuntimeException ) +{ +} + +//____________________________________________________________________________________________________________ // impl but public method to register service in DLL // (In this BASE-implementation not implemented! Overwrite it in derived classes.) //____________________________________________________________________________________________________________ @@ -927,7 +981,7 @@ const sal_Int32& BaseControl::impl_getHeight() WindowDescriptor* BaseControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer ) { // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!! - // - if you will change the descriptor-values, you must override thid virtuell function + // - if you will change the descriptor-values, you must override this virtuell function // - the caller must release the memory for this dynamical descriptor !!! WindowDescriptor* pDescriptor = new WindowDescriptor ; @@ -959,6 +1013,16 @@ void BaseControl::impl_paint( sal_Int32 nX , // protected method //____________________________________________________________________________________________________________ +void BaseControl::impl_recalcLayout( const WindowEvent& aEvent ) +{ + // We need as virtual function to support automaticly resizing of derived controls! + // But we make it not pure virtual because it's not neccessary for all derived classes! +} + +//____________________________________________________________________________________________________________ +// protected method +//____________________________________________________________________________________________________________ + Reference< XInterface > BaseControl::impl_getDelegator() { return m_xDelegator ; @@ -975,6 +1039,7 @@ void BaseControl::impl_releasePeer() if ( m_xGraphicsPeer.is() == sal_True ) { removePaintListener( this ); + removeWindowListener( this ); m_xGraphicsPeer = Reference< XGraphics >(); } |