diff options
author | Malte Timmermann <mt@openoffice.org> | 2001-07-26 11:24:37 +0000 |
---|---|---|
committer | Malte Timmermann <mt@openoffice.org> | 2001-07-26 11:24:37 +0000 |
commit | cdd10baa433734468a5787a6a3c0b7818f463479 (patch) | |
tree | b280dc58036953ce19566a70c96c0cf2bcb4f30e | |
parent | 29c97d1515f9defc5b50177fde4cc146a130fbdb (diff) |
#86374# CheckBoxes are supporting XButton now...
-rw-r--r-- | toolkit/inc/toolkit/awt/vclxwindows.hxx | 17 | ||||
-rw-r--r-- | toolkit/inc/toolkit/controls/unocontrols.hxx | 15 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 50 | ||||
-rw-r--r-- | toolkit/source/controls/unocontrols.cxx | 50 |
4 files changed, 108 insertions, 24 deletions
diff --git a/toolkit/inc/toolkit/awt/vclxwindows.hxx b/toolkit/inc/toolkit/awt/vclxwindows.hxx index 93b94c6cf6e0..67627600b509 100644 --- a/toolkit/inc/toolkit/awt/vclxwindows.hxx +++ b/toolkit/inc/toolkit/awt/vclxwindows.hxx @@ -2,9 +2,9 @@ * * $RCSfile: vclxwindows.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mt $ $Date: 2001-06-06 08:24:13 $ + * last change: $Author: mt $ $Date: 2001-07-26 12:21:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -395,10 +395,13 @@ public: // class VCLXCheckBox // ---------------------------------------------------- class VCLXCheckBox : public ::com::sun::star::awt::XCheckBox, + public ::com::sun::star::awt::XButton, public VCLXWindow { private: - ItemListenerMultiplexer maItemListeners; + ItemListenerMultiplexer maItemListeners; + ActionListenerMultiplexer maActionListeners; + ::rtl::OUString maActionCommand; protected: DECL_LINK( ClickHdl, CheckBox* ); @@ -430,6 +433,11 @@ public: void SAL_CALL setLabel( const ::rtl::OUString& Label ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL enableTriState( sal_Bool b ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::awt::XButton: + void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL setActionCommand( const ::rtl::OUString& Command ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::awt::XLayoutConstrains ::com::sun::star::awt::Size SAL_CALL getMinimumSize( ) throw(::com::sun::star::uno::RuntimeException); ::com::sun::star::awt::Size SAL_CALL getPreferredSize( ) throw(::com::sun::star::uno::RuntimeException); @@ -448,8 +456,7 @@ class VCLXRadioButton : public ::com::sun::star::awt::XRadioButton, public VCLXWindow { private: - ItemListenerMultiplexer maItemListeners; - + ItemListenerMultiplexer maItemListeners; ActionListenerMultiplexer maActionListeners; ::rtl::OUString maActionCommand; diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx index ccc4c28664ae..1a12a099d6d3 100644 --- a/toolkit/inc/toolkit/controls/unocontrols.hxx +++ b/toolkit/inc/toolkit/controls/unocontrols.hxx @@ -2,9 +2,9 @@ * * $RCSfile: unocontrols.hxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: mt $ $Date: 2001-06-18 09:25:14 $ + * last change: $Author: mt $ $Date: 2001-07-26 12:21:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -780,13 +780,15 @@ public: // class UnoCheckBoxControl // ---------------------------------------------------- class UnoCheckBoxControl : public UnoControlBase, + public ::com::sun::star::awt::XButton, public ::com::sun::star::awt::XCheckBox, public ::com::sun::star::awt::XItemListener, public ::com::sun::star::awt::XLayoutConstrains { private: - ItemListenerMultiplexer maItemListeners; - ::rtl::OUString maLabel; + ItemListenerMultiplexer maItemListeners; + ActionListenerMultiplexer maActionListeners; + ::rtl::OUString maActionCommand; public: @@ -809,6 +811,11 @@ public: // ::com::sun::star::awt::XControl sal_Bool SAL_CALL isTransparent( ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::awt::XButton + void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL setActionCommand( const ::rtl::OUString& Command ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::awt::XCheckBox void SAL_CALL addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l ) throw(::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 02d96fa435d2..7ed615ea75cd 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -2,9 +2,9 @@ * * $RCSfile: vclxwindows.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: mt $ $Date: 2001-06-29 12:02:46 $ + * last change: $Author: mt $ $Date: 2001-07-26 12:24:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -481,7 +481,7 @@ void VCLXImageControl::complete( sal_Int32 Status, const ::com::sun::star::uno:: // ---------------------------------------------------- // class VCLXCheckBox // ---------------------------------------------------- -VCLXCheckBox::VCLXCheckBox() : maItemListeners( *this ) +VCLXCheckBox::VCLXCheckBox() : maItemListeners( *this ), maActionListeners( *this ) { } @@ -509,13 +509,15 @@ void VCLXCheckBox::SetWindow( Window* pWindow ) ::com::sun::star::uno::Any VCLXCheckBox::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { ::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( ::com::sun::star::awt::XButton*, this ), SAL_STATIC_CAST( ::com::sun::star::awt::XCheckBox*, this ) ); return (aRet.hasValue() ? aRet : VCLXWindow::queryInterface( rType )); } // ::com::sun::star::lang::XTypeProvider IMPL_XTYPEPROVIDER_START( VCLXCheckBox ) - getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XButton>* ) NULL ), + getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCheckBox>* ) NULL ), VCLXWindow::getTypes() IMPL_XTYPEPROVIDER_END @@ -541,6 +543,24 @@ void VCLXCheckBox::removeItemListener( const ::com::sun::star::uno::Reference< : maItemListeners.removeInterface( l ); } +void VCLXCheckBox::addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l )throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.addInterface( l ); +} + +void VCLXCheckBox::removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener > & l ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionListeners.removeInterface( l ); +} + +void VCLXCheckBox::setActionCommand( const ::rtl::OUString& rCommand ) throw(::com::sun::star::uno::RuntimeException) +{ + ::vos::OGuard aGuard( GetMutex() ); + maActionCommand = rCommand; +} + void VCLXCheckBox::setLabel( const ::rtl::OUString& rLabel ) throw(::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( GetMutex() ); @@ -674,13 +694,23 @@ void VCLXCheckBox::setProperty( const ::rtl::OUString& PropertyName, const ::com IMPL_LINK( VCLXCheckBox, ClickHdl, CheckBox*, EMPTYARG ) { CheckBox* pCheckBox = (CheckBox*)GetWindow(); - if ( pCheckBox && maItemListeners.getLength() ) + if ( pCheckBox ) { - ::com::sun::star::awt::ItemEvent aEvent; - aEvent.Source = (::cppu::OWeakObject*)this; - aEvent.Highlighted = sal_False; - aEvent.Selected = pCheckBox->GetState(); - maItemListeners.itemStateChanged( aEvent ); + if ( maItemListeners.getLength() ) + { + ::com::sun::star::awt::ItemEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.Highlighted = sal_False; + aEvent.Selected = pCheckBox->GetState(); + maItemListeners.itemStateChanged( aEvent ); + } + if ( maActionListeners.getLength() ) + { + ::com::sun::star::awt::ActionEvent aEvent; + aEvent.Source = (::cppu::OWeakObject*)this; + aEvent.ActionCommand = maActionCommand; + maActionListeners.actionPerformed( aEvent ); + } } return 1; } diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index b7d00df21f1d..5bbe638bb9a7 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unocontrols.cxx,v $ * - * $Revision: 1.28 $ + * $Revision: 1.29 $ * - * last change: $Author: mt $ $Date: 2001-06-22 11:18:38 $ + * last change: $Author: mt $ $Date: 2001-07-26 12:23:46 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1353,7 +1353,8 @@ void UnoButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToo { UnoControl::createPeer( rxToolkit, rParentPeer ); - uno::Reference < awt::XButton > xButton( mxPeer, uno::UNO_QUERY ); + uno::Reference < awt::XButton > xButton( mxPeer, uno::UNO_QUERY ); + xButton->setActionCommand( maActionCommand ); if ( maActionListeners.getLength() ) xButton->addActionListener( &maActionListeners ); } @@ -1847,7 +1848,8 @@ void UnoRadioButtonControl::createPeer( const uno::Reference< awt::XToolkit > & uno::Reference < awt::XRadioButton > xRadioButton( mxPeer, uno::UNO_QUERY ); xRadioButton->addItemListener( this ); - uno::Reference < awt::XButton > xButton( mxPeer, uno::UNO_QUERY ); + uno::Reference < awt::XButton > xButton( mxPeer, uno::UNO_QUERY ); + xButton->setActionCommand( maActionCommand ); if ( maActionListeners.getLength() ) xButton->addActionListener( &maActionListeners ); } @@ -1998,7 +2000,7 @@ uno::Reference< beans::XPropertySetInfo > UnoControlCheckBoxModel::getPropertySe // class UnoCheckBoxControl // ---------------------------------------------------- UnoCheckBoxControl::UnoCheckBoxControl() - : maItemListeners( *this ) + : maItemListeners( *this ), maActionListeners( *this ) { maComponentInfos.nWidth = 100; maComponentInfos.nHeight = 12; @@ -2013,6 +2015,7 @@ UnoCheckBoxControl::UnoCheckBoxControl() uno::Any UnoCheckBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException) { uno::Any aRet = ::cppu::queryInterface( rType, + SAL_STATIC_CAST( awt::XButton*, this ), SAL_STATIC_CAST( awt::XCheckBox*, this ), SAL_STATIC_CAST( awt::XItemListener*, this ), SAL_STATIC_CAST( lang::XEventListener*, SAL_STATIC_CAST( awt::XItemListener*, this ) ), @@ -2022,6 +2025,7 @@ uno::Any UnoCheckBoxControl::queryAggregation( const uno::Type & rType ) throw(u // lang::XTypeProvider IMPL_XTYPEPROVIDER_START( UnoCheckBoxControl ) + getCppuType( ( uno::Reference< awt::XButton>* ) NULL ), getCppuType( ( uno::Reference< awt::XCheckBox>* ) NULL ), getCppuType( ( uno::Reference< awt::XItemListener>* ) NULL ), getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ), @@ -2047,6 +2051,11 @@ void UnoCheckBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxT uno::Reference < awt::XCheckBox > xCheckBox( mxPeer, uno::UNO_QUERY ); xCheckBox->addItemListener( this ); + + uno::Reference < awt::XButton > xButton( mxPeer, uno::UNO_QUERY ); + xButton->setActionCommand( maActionCommand ); + if ( maActionListeners.getLength() ) + xButton->addActionListener( &maActionListeners ); } void UnoCheckBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException) @@ -2059,6 +2068,37 @@ void UnoCheckBoxControl::removeItemListener(const uno::Reference < awt::XItemLis maItemListeners.removeInterface( l ); } +void UnoCheckBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) +{ + maActionListeners.addInterface( l ); + if( mxPeer.is() && maActionListeners.getLength() == 1 ) + { + uno::Reference < awt::XButton > xButton( mxPeer, uno::UNO_QUERY ); + xButton->addActionListener( &maActionListeners ); + } +} + +void UnoCheckBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException) +{ + if( mxPeer.is() && maActionListeners.getLength() == 1 ) + { + uno::Reference < awt::XButton > xButton( mxPeer, uno::UNO_QUERY ); + xButton->removeActionListener( &maActionListeners ); + } + maActionListeners.removeInterface( l ); +} + +void UnoCheckBoxControl::setActionCommand( const ::rtl::OUString& rCommand ) throw(uno::RuntimeException) +{ + maActionCommand = rCommand; + if ( mxPeer.is() ) + { + uno::Reference < awt::XButton > xButton( mxPeer, uno::UNO_QUERY ); + xButton->setActionCommand( rCommand ); + } +} + + void UnoCheckBoxControl::setLabel( const ::rtl::OUString& rLabel ) throw(uno::RuntimeException) { uno::Any aAny; |