10841af79SAndrew Rist /**************************************************************
2*d69df039Smseidel  *
30841af79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
40841af79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
50841af79SAndrew Rist  * distributed with this work for additional information
60841af79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
70841af79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
80841af79SAndrew Rist  * "License"); you may not use this file except in compliance
90841af79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d69df039Smseidel  *
110841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d69df039Smseidel  *
130841af79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
140841af79SAndrew Rist  * software distributed under the License is distributed on an
150841af79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
160841af79SAndrew Rist  * KIND, either express or implied.  See the License for the
170841af79SAndrew Rist  * specific language governing permissions and limitations
180841af79SAndrew Rist  * under the License.
19*d69df039Smseidel  *
200841af79SAndrew Rist  *************************************************************/
210841af79SAndrew Rist 
220841af79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir #include <accessibility/extended/listboxaccessible.hxx>
27cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir //........................................................................
30cdf0e10cSrcweir namespace accessibility
31cdf0e10cSrcweir {
32cdf0e10cSrcweir //........................................................................
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 	//====================================================================
35cdf0e10cSrcweir 	//= ListBoxAccessibleBase
36cdf0e10cSrcweir 	//====================================================================
37cdf0e10cSrcweir 	//--------------------------------------------------------------------
ListBoxAccessibleBase(SvTreeListBox & _rWindow)38cdf0e10cSrcweir 	ListBoxAccessibleBase::ListBoxAccessibleBase( SvTreeListBox& _rWindow )
39cdf0e10cSrcweir 		:m_pWindow( &_rWindow )
40cdf0e10cSrcweir 	{
41cdf0e10cSrcweir 		m_pWindow->AddEventListener( LINK( this, ListBoxAccessibleBase, WindowEventListener ) );
42cdf0e10cSrcweir 	}
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 	//--------------------------------------------------------------------
~ListBoxAccessibleBase()45cdf0e10cSrcweir 	ListBoxAccessibleBase::~ListBoxAccessibleBase( )
46cdf0e10cSrcweir 	{
47cdf0e10cSrcweir 		if ( m_pWindow )
48cdf0e10cSrcweir 		{
49cdf0e10cSrcweir 			// cannot call "dispose" here, as it is abstract, so the VTABLE of the derived class
50cdf0e10cSrcweir 			// is not intact anymore
51cdf0e10cSrcweir 			// so we call our "disposing" only
52cdf0e10cSrcweir 			disposing();
53cdf0e10cSrcweir 		}
54cdf0e10cSrcweir 	}
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	//--------------------------------------------------------------------
IMPL_LINK(ListBoxAccessibleBase,WindowEventListener,VclSimpleEvent *,pEvent)57cdf0e10cSrcweir 	IMPL_LINK( ListBoxAccessibleBase, WindowEventListener, VclSimpleEvent*, pEvent )
58cdf0e10cSrcweir 	{
59*d69df039Smseidel 		DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "ListBoxAccessibleBase::WindowEventListener: unexpected WindowEvent!" );
60*d69df039Smseidel 		if ( pEvent && pEvent->ISA( VclWindowEvent ) )
61*d69df039Smseidel 		{
62*d69df039Smseidel 			DBG_ASSERT( static_cast< VclWindowEvent* >( pEvent )->GetWindow() , "ListBoxAccessibleBase::WindowEventListener: no event window!" );
63*d69df039Smseidel 			DBG_ASSERT( static_cast< VclWindowEvent* >( pEvent )->GetWindow() == m_pWindow, "ListBoxAccessibleBase::WindowEventListener: where did this come from?" );
64cdf0e10cSrcweir 
65*d69df039Smseidel 			ProcessWindowEvent( *static_cast< VclWindowEvent* >( pEvent ) );
66*d69df039Smseidel 		}
67*d69df039Smseidel 		return 0;
68cdf0e10cSrcweir 	}
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
disposing()71cdf0e10cSrcweir 	void ListBoxAccessibleBase::disposing()
72cdf0e10cSrcweir 	{
73cdf0e10cSrcweir 		if ( m_pWindow )
74cdf0e10cSrcweir 			m_pWindow->RemoveEventListener( LINK( this, ListBoxAccessibleBase, WindowEventListener ) );
75cdf0e10cSrcweir 		m_pWindow = NULL;
76cdf0e10cSrcweir 	}
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
ProcessWindowEvent(const VclWindowEvent & _rVclWindowEvent)79cdf0e10cSrcweir 	void ListBoxAccessibleBase::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent )
80cdf0e10cSrcweir 	{
81cdf0e10cSrcweir 		if ( isAlive() )
82cdf0e10cSrcweir 		{
83cdf0e10cSrcweir 			switch ( _rVclWindowEvent.GetId() )
84cdf0e10cSrcweir 			{
85*d69df039Smseidel 				case VCLEVENT_OBJECT_DYING :
86cdf0e10cSrcweir 				{
87*d69df039Smseidel 					if ( m_pWindow )
88*d69df039Smseidel 						m_pWindow->RemoveEventListener( LINK( this, ListBoxAccessibleBase, WindowEventListener ) );
89*d69df039Smseidel 					m_pWindow = NULL;
90cdf0e10cSrcweir 					dispose();
91cdf0e10cSrcweir 					break;
92cdf0e10cSrcweir 				}
93cdf0e10cSrcweir 			}
94cdf0e10cSrcweir 		}
95cdf0e10cSrcweir 	}
96cdf0e10cSrcweir 
97cdf0e10cSrcweir //........................................................................
98cdf0e10cSrcweir }	// namespace accessibility
99cdf0e10cSrcweir //........................................................................
100