xref: /AOO41X/main/svtools/source/contnr/svimpbox.cxx (revision 5900e8ec128faec89519683efce668ccd8cc6084)
1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5900e8ecSAndrew Rist  * distributed with this work for additional information
6*5900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*5900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*5900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist  * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*5900e8ecSAndrew Rist  * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*5900e8ecSAndrew Rist  *************************************************************/
21*5900e8ecSAndrew Rist 
22*5900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir #include <vcl/svapp.hxx>
27cdf0e10cSrcweir #include <vcl/salnativewidgets.hxx>
28cdf0e10cSrcweir #include <vcl/help.hxx>
29cdf0e10cSrcweir #include <svtools/tabbar.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <stack>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #define _SVTREEBX_CXX
34cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
35cdf0e10cSrcweir #include <svtools/svlbox.hxx>
36cdf0e10cSrcweir #include <svimpbox.hxx>
37cdf0e10cSrcweir #include <rtl/instance.hxx>
38cdf0e10cSrcweir #include <svtools/svtdata.hxx>
39cdf0e10cSrcweir #include <tools/wintypes.hxx>
40cdf0e10cSrcweir #include <svtools/svtools.hrc>
41cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #define NODE_BMP_TABDIST_NOTVALID 	-2000000
44cdf0e10cSrcweir #define FIRST_ENTRY_TAB				1
45cdf0e10cSrcweir 
46cdf0e10cSrcweir // #i27063# (pl), #i32300# (pb) never access VCL after DeInitVCL - also no destructors
47cdf0e10cSrcweir Image*	SvImpLBox::s_pDefCollapsed		= NULL;
48cdf0e10cSrcweir Image*	SvImpLBox::s_pDefExpanded		= NULL;
49cdf0e10cSrcweir Image*	SvImpLBox::s_pDefCollapsedHC	= NULL;
50cdf0e10cSrcweir Image*	SvImpLBox::s_pDefExpandedHC		= NULL;
51cdf0e10cSrcweir sal_Int32 SvImpLBox::s_nImageRefCount	= 0;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir SvImpLBox::SvImpLBox( SvTreeListBox* pLBView, SvLBoxTreeList* pLBTree, WinBits nWinStyle) :
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 	pTabBar( NULL ),
56cdf0e10cSrcweir 	aVerSBar( pLBView, WB_DRAG | WB_VSCROLL ),
57cdf0e10cSrcweir 	aHorSBar( pLBView, WB_DRAG | WB_HSCROLL ),
58cdf0e10cSrcweir 	aScrBarBox( pLBView ),
59cdf0e10cSrcweir 	aOutputSize( 0, 0 ),
60cdf0e10cSrcweir 	aSelEng( pLBView, (FunctionSet*)0 ),
61cdf0e10cSrcweir 	aFctSet( this, &aSelEng, pLBView ),
62cdf0e10cSrcweir     nExtendedWinBits( 0 ),
63cdf0e10cSrcweir     bAreChildrenTransient( sal_True ),
64cdf0e10cSrcweir 	pIntlWrapper( NULL ) // #102891# -----------------------
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	osl_incrementInterlockedCount(&s_nImageRefCount);
67cdf0e10cSrcweir 	pView = pLBView;
68cdf0e10cSrcweir 	pTree = pLBTree;
69cdf0e10cSrcweir 	aSelEng.SetFunctionSet( (FunctionSet*)&aFctSet );
70cdf0e10cSrcweir 	aSelEng.ExpandSelectionOnMouseMove( sal_False );
71cdf0e10cSrcweir 	SetStyle( nWinStyle );
72cdf0e10cSrcweir 	SetSelectionMode( SINGLE_SELECTION );
73cdf0e10cSrcweir 	SetDragDropMode( 0 );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	aVerSBar.SetScrollHdl( LINK( this, SvImpLBox, ScrollUpDownHdl ) );
76cdf0e10cSrcweir 	aHorSBar.SetScrollHdl( LINK( this, SvImpLBox, ScrollLeftRightHdl ) );
77cdf0e10cSrcweir 	aHorSBar.SetEndScrollHdl( LINK( this, SvImpLBox, EndScrollHdl ) );
78cdf0e10cSrcweir 	aVerSBar.SetEndScrollHdl( LINK( this, SvImpLBox, EndScrollHdl ) );
79cdf0e10cSrcweir 	aVerSBar.SetRange( Range(0,0) );
80cdf0e10cSrcweir 	aVerSBar.Hide();
81cdf0e10cSrcweir 	aHorSBar.SetRange( Range(0,0) );
82cdf0e10cSrcweir 	aHorSBar.SetPageSize( 24 ); // Pixel
83cdf0e10cSrcweir 	aHorSBar.SetLineSize( 8 ); // Pixel
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	nHorSBarHeight = (short)aHorSBar.GetSizePixel().Height();
86cdf0e10cSrcweir 	nVerSBarWidth = (short)aVerSBar.GetSizePixel().Width();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	pStartEntry	= 0;
89cdf0e10cSrcweir 	pCursor 			= 0;
90cdf0e10cSrcweir 	pAnchor				= 0;
91cdf0e10cSrcweir 	nVisibleCount  		= 0; 	// Anzahl Daten-Zeilen im Control
92cdf0e10cSrcweir 	nNodeBmpTabDistance = NODE_BMP_TABDIST_NOTVALID;
93cdf0e10cSrcweir 	nYoffsNodeBmp 		= 0;
94cdf0e10cSrcweir 	nNodeBmpWidth		= 0;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	bAsyncBeginDrag		= sal_False;
97cdf0e10cSrcweir 	aAsyncBeginDragTimer.SetTimeout( 0 );
98cdf0e10cSrcweir 	aAsyncBeginDragTimer.SetTimeoutHdl( LINK(this,SvImpLBox,BeginDragHdl));
99cdf0e10cSrcweir 	// Button-Animation in Listbox
100cdf0e10cSrcweir 	pActiveButton = 0;
101cdf0e10cSrcweir 	pActiveEntry = 0;
102cdf0e10cSrcweir 	pActiveTab = 0;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	nFlags = 0;
105cdf0e10cSrcweir 	nCurTabPos = FIRST_ENTRY_TAB;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	aEditTimer.SetTimeout( 800 );
108cdf0e10cSrcweir 	aEditTimer.SetTimeoutHdl( LINK(this,SvImpLBox,EditTimerCall) );
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 	nMostRight = -1;
111cdf0e10cSrcweir 	pMostRightEntry = 0;
112cdf0e10cSrcweir 	nCurUserEvent = 0xffffffff;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	bUpdateMode = sal_True;
115cdf0e10cSrcweir 	bInVScrollHdl = sal_False;
116cdf0e10cSrcweir 	nFlags |= F_FILLING;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	bSubLstOpRet = bSubLstOpLR = bContextMenuHandling = bIsCellFocusEnabled = sal_False;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir SvImpLBox::~SvImpLBox()
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	aEditTimer.Stop();
124cdf0e10cSrcweir 	StopUserEvent();
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	// #102891# ---------------------
127cdf0e10cSrcweir 	if( pIntlWrapper )
128cdf0e10cSrcweir 		delete pIntlWrapper;
129cdf0e10cSrcweir 	if ( osl_decrementInterlockedCount(&s_nImageRefCount) == 0 )
130cdf0e10cSrcweir 	{
131cdf0e10cSrcweir 		DELETEZ(s_pDefCollapsed);
132cdf0e10cSrcweir 		DELETEZ(s_pDefExpanded);
133cdf0e10cSrcweir 		DELETEZ(s_pDefCollapsedHC);
134cdf0e10cSrcweir 		DELETEZ(s_pDefExpandedHC);
135cdf0e10cSrcweir 	}
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir // #102891# --------------------
139cdf0e10cSrcweir void SvImpLBox::UpdateIntlWrapper()
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	const ::com::sun::star::lang::Locale & aNewLocale = Application::GetSettings().GetLocale();
142cdf0e10cSrcweir 	if( !pIntlWrapper )
143cdf0e10cSrcweir 		pIntlWrapper = new IntlWrapper( ::comphelper::getProcessServiceFactory(), aNewLocale );
144cdf0e10cSrcweir 	else
145cdf0e10cSrcweir 	{
146cdf0e10cSrcweir 		const ::com::sun::star::lang::Locale &aLocale = pIntlWrapper->getLocale();
147cdf0e10cSrcweir 		if( aLocale.Language != aNewLocale.Language || // different Locale from the older one
148cdf0e10cSrcweir 			aLocale.Country != aNewLocale.Country ||
149cdf0e10cSrcweir 			aLocale.Variant != aNewLocale.Variant )
150cdf0e10cSrcweir 		{
151cdf0e10cSrcweir 			delete pIntlWrapper;
152cdf0e10cSrcweir 			pIntlWrapper = new IntlWrapper( ::comphelper::getProcessServiceFactory(), aNewLocale );
153cdf0e10cSrcweir 		}
154cdf0e10cSrcweir 	}
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir // #97680# ----------------------
158cdf0e10cSrcweir short SvImpLBox::UpdateContextBmpWidthVector( SvLBoxEntry* pEntry, short nWidth )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	DBG_ASSERT( pView->pModel, "View and Model aren't valid!" );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	sal_uInt16 nDepth = pView->pModel->GetDepth( pEntry );
163cdf0e10cSrcweir 	// initialize vector if necessary
164cdf0e10cSrcweir 	std::vector< short >::size_type nSize = aContextBmpWidthVector.size();
165cdf0e10cSrcweir 	while ( nDepth > nSize )
166cdf0e10cSrcweir 	{
167cdf0e10cSrcweir 		aContextBmpWidthVector.resize( nSize + 1 );
168cdf0e10cSrcweir 		aContextBmpWidthVector.at( nSize ) = nWidth;
169cdf0e10cSrcweir 		++nSize;
170cdf0e10cSrcweir 	}
171cdf0e10cSrcweir 	if( aContextBmpWidthVector.size() == nDepth )
172cdf0e10cSrcweir 	{
173cdf0e10cSrcweir 		aContextBmpWidthVector.resize( nDepth + 1 );
174cdf0e10cSrcweir 		aContextBmpWidthVector.at( nDepth ) = 0;
175cdf0e10cSrcweir 	}
176cdf0e10cSrcweir 	short nContextBmpWidth = aContextBmpWidthVector[ nDepth ];
177cdf0e10cSrcweir 	if( nContextBmpWidth < nWidth )
178cdf0e10cSrcweir 	{
179cdf0e10cSrcweir 		aContextBmpWidthVector.at( nDepth ) = nWidth;
180cdf0e10cSrcweir 		return nWidth;
181cdf0e10cSrcweir 	}
182cdf0e10cSrcweir 	else
183cdf0e10cSrcweir 		return nContextBmpWidth;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir void SvImpLBox::UpdateContextBmpWidthVectorFromMovedEntry( SvLBoxEntry* pEntry )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir 	DBG_ASSERT( pEntry, "Moved Entry is invalid!" );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) );
191cdf0e10cSrcweir 	short nExpWidth = (short)pBmpItem->GetBitmap1().GetSizePixel().Width();
192cdf0e10cSrcweir 	short nColWidth = (short)pBmpItem->GetBitmap2().GetSizePixel().Width();
193cdf0e10cSrcweir 	short nMax = Max(nExpWidth, nColWidth);
194cdf0e10cSrcweir 	UpdateContextBmpWidthVector( pEntry, nMax );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	if( pEntry->HasChilds() ) // recursive call, whether expanded or not
197cdf0e10cSrcweir 	{
198cdf0e10cSrcweir 		SvLBoxEntry* pChild = pView->FirstChild( pEntry );
199cdf0e10cSrcweir 		DBG_ASSERT( pChild, "The first child is invalid!" );
200cdf0e10cSrcweir 		do
201cdf0e10cSrcweir 		{
202cdf0e10cSrcweir 			UpdateContextBmpWidthVectorFromMovedEntry( pChild );
203cdf0e10cSrcweir 			pChild = pView->Next( pChild );
204cdf0e10cSrcweir 		} while ( pChild );
205cdf0e10cSrcweir 	}
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir void SvImpLBox::UpdateContextBmpWidthMax( SvLBoxEntry* pEntry )
209cdf0e10cSrcweir {
210cdf0e10cSrcweir 	sal_uInt16 nDepth = pView->pModel->GetDepth( pEntry );
211cdf0e10cSrcweir 	if( aContextBmpWidthVector.size() < 1 )
212cdf0e10cSrcweir 		return;
213cdf0e10cSrcweir 	short nWidth = aContextBmpWidthVector[ nDepth ];
214cdf0e10cSrcweir 	if( nWidth != pView->nContextBmpWidthMax ) {
215cdf0e10cSrcweir 		pView->nContextBmpWidthMax = nWidth;
216cdf0e10cSrcweir 		nFlags |= F_IGNORE_CHANGED_TABS;
217cdf0e10cSrcweir 		pView->SetTabs();
218cdf0e10cSrcweir 		nFlags &= ~F_IGNORE_CHANGED_TABS;
219cdf0e10cSrcweir 	}
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
222cdf0e10cSrcweir void SvImpLBox::CalcCellFocusRect( SvLBoxEntry* pEntry, Rectangle& rRect )
223cdf0e10cSrcweir {
224cdf0e10cSrcweir 	if ( pEntry && bIsCellFocusEnabled )
225cdf0e10cSrcweir 	{
226cdf0e10cSrcweir 		if ( nCurTabPos > FIRST_ENTRY_TAB )
227cdf0e10cSrcweir 		{
228cdf0e10cSrcweir 			SvLBoxItem* pItem = pCursor->GetItem( nCurTabPos );
229cdf0e10cSrcweir 			rRect.Left() = pView->GetTab( pCursor, pItem )->GetPos();
230cdf0e10cSrcweir 		}
231cdf0e10cSrcweir         if ( pCursor->ItemCount() > ( nCurTabPos + 1 ) )
232cdf0e10cSrcweir         {
233cdf0e10cSrcweir             SvLBoxItem* pNextItem = pCursor->GetItem( nCurTabPos + 1 );
234cdf0e10cSrcweir             long nRight = pView->GetTab( pCursor, pNextItem )->GetPos() - 1;
235cdf0e10cSrcweir             if ( nRight < rRect.Right() )
236cdf0e10cSrcweir                 rRect.Right() = nRight;
237cdf0e10cSrcweir         }
238cdf0e10cSrcweir 	}
239cdf0e10cSrcweir }
240cdf0e10cSrcweir 
241cdf0e10cSrcweir void SvImpLBox::SetStyle( WinBits i_nWinStyle )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir 	m_nStyle = i_nWinStyle;
244cdf0e10cSrcweir 	if ( ( m_nStyle & WB_SIMPLEMODE) && ( aSelEng.GetSelectionMode() == MULTIPLE_SELECTION ) )
245cdf0e10cSrcweir 		aSelEng.AddAlways( sal_True );
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir void SvImpLBox::SetExtendedWindowBits( ExtendedWinBits _nBits )
249cdf0e10cSrcweir {
250cdf0e10cSrcweir 	nExtendedWinBits = _nBits;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir // Das Model darf hier nicht mehr angefasst werden
254cdf0e10cSrcweir void SvImpLBox::Clear()
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	StopUserEvent();
257cdf0e10cSrcweir 	pStartEntry	= 0;
258cdf0e10cSrcweir 	pAnchor = 0;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir 	pActiveButton = 0;
261cdf0e10cSrcweir 	pActiveEntry = 0;
262cdf0e10cSrcweir 	pActiveTab = 0;
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	nMostRight = -1;
265cdf0e10cSrcweir 	pMostRightEntry = 0;
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 	// Der Cursor darf hier nicht mehr angefasst werden!
268cdf0e10cSrcweir 	if( pCursor )
269cdf0e10cSrcweir 	{
270cdf0e10cSrcweir 		if( pView->HasFocus() )
271cdf0e10cSrcweir 			pView->HideFocus();
272cdf0e10cSrcweir 		pCursor = 0;
273cdf0e10cSrcweir 	}
274cdf0e10cSrcweir 	aVerSBar.Hide();
275cdf0e10cSrcweir 	aVerSBar.SetThumbPos( 0 );
276cdf0e10cSrcweir 	Range aRange( 0, 0 );
277cdf0e10cSrcweir 	aVerSBar.SetRange( aRange );
278cdf0e10cSrcweir 	aOutputSize = pView->Control::GetOutputSizePixel();
279cdf0e10cSrcweir 	nFlags &= ~(F_VER_SBARSIZE_WITH_HBAR | F_HOR_SBARSIZE_WITH_VBAR );
280cdf0e10cSrcweir 	if( pTabBar )
281cdf0e10cSrcweir 	{
282cdf0e10cSrcweir 		aOutputSize.Height() -= nHorSBarHeight;
283cdf0e10cSrcweir 		nFlags |= F_VER_SBARSIZE_WITH_HBAR;
284cdf0e10cSrcweir 	}
285cdf0e10cSrcweir 	if( !pTabBar )
286cdf0e10cSrcweir 		aHorSBar.Hide();
287cdf0e10cSrcweir 	aHorSBar.SetThumbPos( 0 );
288cdf0e10cSrcweir 	MapMode aMapMode( pView->GetMapMode());
289cdf0e10cSrcweir 	aMapMode.SetOrigin( Point(0,0) );
290cdf0e10cSrcweir 	pView->Control::SetMapMode( aMapMode );
291cdf0e10cSrcweir 	aHorSBar.SetRange( aRange );
292cdf0e10cSrcweir 	aHorSBar.SetSizePixel(Size(aOutputSize.Width(),nHorSBarHeight));
293cdf0e10cSrcweir 	pView->SetClipRegion();
294cdf0e10cSrcweir 	if( GetUpdateMode() )
295cdf0e10cSrcweir 		pView->Invalidate( GetVisibleArea() );
296cdf0e10cSrcweir 	nFlags |= F_FILLING;
297cdf0e10cSrcweir 	if( !aHorSBar.IsVisible() && !aVerSBar.IsVisible() )
298cdf0e10cSrcweir 		aScrBarBox.Hide();
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	// #97680# ---------
301cdf0e10cSrcweir 	aContextBmpWidthVector.clear();
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir // *********************************************************************
305cdf0e10cSrcweir // Painten, Navigieren, Scrollen
306cdf0e10cSrcweir // *********************************************************************
307cdf0e10cSrcweir 
308cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvImpLBox, EndScrollHdl, ScrollBar *, EMPTYARG )
309cdf0e10cSrcweir {
310cdf0e10cSrcweir 	if( nFlags & F_ENDSCROLL_SET_VIS_SIZE )
311cdf0e10cSrcweir 	{
312cdf0e10cSrcweir 		aVerSBar.SetVisibleSize( nNextVerVisSize );
313cdf0e10cSrcweir 		nFlags &= ~F_ENDSCROLL_SET_VIS_SIZE;
314cdf0e10cSrcweir 	}
315cdf0e10cSrcweir 	EndScroll();
316cdf0e10cSrcweir 	return 0;
317cdf0e10cSrcweir }
318cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvImpLBox, EndScrollHdl, ScrollBar *, pScrollBar )
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 
321cdf0e10cSrcweir // Handler vertikale ScrollBar
322cdf0e10cSrcweir 
323cdf0e10cSrcweir IMPL_LINK( SvImpLBox, ScrollUpDownHdl, ScrollBar *, pScrollBar )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	DBG_ASSERT(!bInVScrollHdl,"Scroll-Handler ueberholt sich!");
326cdf0e10cSrcweir 	long nDelta = pScrollBar->GetDelta();
327cdf0e10cSrcweir 	if( !nDelta )
328cdf0e10cSrcweir 		return 0;
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 	nFlags &= (~F_FILLING);
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	bInVScrollHdl = sal_True;
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 	if( pView->IsEditingActive() )
335cdf0e10cSrcweir 	{
336cdf0e10cSrcweir 		pView->EndEditing( sal_True ); // Cancel
337cdf0e10cSrcweir 		pView->Update();
338cdf0e10cSrcweir 	}
339cdf0e10cSrcweir 	BeginScroll();
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 	if( nDelta > 0 )
342cdf0e10cSrcweir 	{
343cdf0e10cSrcweir 		if( nDelta == 1 )
344cdf0e10cSrcweir 			CursorDown();
345cdf0e10cSrcweir 		else
346cdf0e10cSrcweir 			PageDown( (sal_uInt16) nDelta );
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 	else
349cdf0e10cSrcweir 	{
350cdf0e10cSrcweir 		nDelta *= (-1);
351cdf0e10cSrcweir 		if( nDelta == 1 )
352cdf0e10cSrcweir 			CursorUp();
353cdf0e10cSrcweir 		else
354cdf0e10cSrcweir 			PageUp( (sal_uInt16) nDelta );
355cdf0e10cSrcweir 	}
356cdf0e10cSrcweir 	bInVScrollHdl = sal_False;
357cdf0e10cSrcweir 	return 0;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 
361cdf0e10cSrcweir void SvImpLBox::CursorDown()
362cdf0e10cSrcweir {
363cdf0e10cSrcweir 	SvLBoxEntry* pNextFirstToDraw = (SvLBoxEntry*)(pView->NextVisible( pStartEntry));
364cdf0e10cSrcweir 	if( pNextFirstToDraw )
365cdf0e10cSrcweir 	{
366cdf0e10cSrcweir 		nFlags &= (~F_FILLING);
367cdf0e10cSrcweir 		pView->NotifyScrolling( -1 );
368cdf0e10cSrcweir 		ShowCursor( sal_False );
369cdf0e10cSrcweir 		pView->Update();
370cdf0e10cSrcweir 		pStartEntry = pNextFirstToDraw;
371cdf0e10cSrcweir 		Rectangle aArea( GetVisibleArea() );
372cdf0e10cSrcweir 		pView->Scroll( 0, -(pView->GetEntryHeight()), aArea, SCROLL_NOCHILDREN );
373cdf0e10cSrcweir 		pView->Update();
374cdf0e10cSrcweir 		ShowCursor( sal_True );
375cdf0e10cSrcweir 		pView->NotifyScrolled();
376cdf0e10cSrcweir 	}
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir void SvImpLBox::CursorUp()
380cdf0e10cSrcweir {
381cdf0e10cSrcweir 	SvLBoxEntry* pPrevFirstToDraw = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry));
382cdf0e10cSrcweir 	if( pPrevFirstToDraw )
383cdf0e10cSrcweir 	{
384cdf0e10cSrcweir 		nFlags &= (~F_FILLING);
385cdf0e10cSrcweir 		long nEntryHeight = pView->GetEntryHeight();
386cdf0e10cSrcweir 		pView->NotifyScrolling( 1 );
387cdf0e10cSrcweir 		ShowCursor( sal_False );
388cdf0e10cSrcweir 		pView->Update();
389cdf0e10cSrcweir 		pStartEntry = pPrevFirstToDraw;
390cdf0e10cSrcweir 		Rectangle aArea( GetVisibleArea() );
391cdf0e10cSrcweir 		aArea.Bottom() -= nEntryHeight;
392cdf0e10cSrcweir 		pView->Scroll( 0, nEntryHeight, aArea, SCROLL_NOCHILDREN );
393cdf0e10cSrcweir 		pView->Update();
394cdf0e10cSrcweir 		ShowCursor( sal_True );
395cdf0e10cSrcweir 		pView->NotifyScrolled();
396cdf0e10cSrcweir 	}
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir void SvImpLBox::PageDown( sal_uInt16 nDelta )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir 	sal_uInt16 nRealDelta = nDelta;
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 	if( !nDelta )
404cdf0e10cSrcweir 		return;
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	SvLBoxEntry* pNext;
407cdf0e10cSrcweir 	pNext = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nRealDelta ));
408cdf0e10cSrcweir 	if( (sal_uLong)pNext == (sal_uLong)pStartEntry )
409cdf0e10cSrcweir 		return;
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 	ShowCursor( sal_False );
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 	nFlags &= (~F_FILLING);
414cdf0e10cSrcweir 	pView->Update();
415cdf0e10cSrcweir 	pStartEntry = pNext;
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 	if( nRealDelta >= nVisibleCount )
418cdf0e10cSrcweir 	{
419cdf0e10cSrcweir 		pView->Invalidate( GetVisibleArea() );
420cdf0e10cSrcweir 		pView->Update();
421cdf0e10cSrcweir 	}
422cdf0e10cSrcweir 	else
423cdf0e10cSrcweir 	{
424cdf0e10cSrcweir 		long nScroll = nRealDelta * (-1);
425cdf0e10cSrcweir 		pView->NotifyScrolling( nScroll );
426cdf0e10cSrcweir 		Rectangle aArea( GetVisibleArea() );
427cdf0e10cSrcweir 		nScroll = pView->GetEntryHeight()*nRealDelta;
428cdf0e10cSrcweir 		nScroll = -nScroll;
429cdf0e10cSrcweir 		pView->Update();
430cdf0e10cSrcweir 		pView->Scroll( 0, nScroll, aArea, SCROLL_NOCHILDREN );
431cdf0e10cSrcweir 		pView->Update();
432cdf0e10cSrcweir 		pView->NotifyScrolled();
433cdf0e10cSrcweir 	}
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 	ShowCursor( sal_True );
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir void SvImpLBox::PageUp( sal_uInt16 nDelta )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir 	sal_uInt16 nRealDelta = nDelta;
441cdf0e10cSrcweir 	if( !nDelta )
442cdf0e10cSrcweir 		return;
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 	SvLBoxEntry* pPrev = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry, nRealDelta ));
445cdf0e10cSrcweir 	if( (sal_uLong)pPrev == (sal_uLong)pStartEntry )
446cdf0e10cSrcweir 		return;
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 	nFlags &= (~F_FILLING);
449cdf0e10cSrcweir 	ShowCursor( sal_False );
450cdf0e10cSrcweir 
451cdf0e10cSrcweir 	pView->Update();
452cdf0e10cSrcweir 	pStartEntry = pPrev;
453cdf0e10cSrcweir 	if( nRealDelta >= nVisibleCount )
454cdf0e10cSrcweir 	{
455cdf0e10cSrcweir 		pView->Invalidate( GetVisibleArea() );
456cdf0e10cSrcweir 		pView->Update();
457cdf0e10cSrcweir 	}
458cdf0e10cSrcweir 	else
459cdf0e10cSrcweir 	{
460cdf0e10cSrcweir 		long nEntryHeight = pView->GetEntryHeight();
461cdf0e10cSrcweir 		pView->NotifyScrolling( (long)nRealDelta );
462cdf0e10cSrcweir 		Rectangle aArea( GetVisibleArea() );
463cdf0e10cSrcweir 		pView->Update();
464cdf0e10cSrcweir 		pView->Scroll( 0, nEntryHeight*nRealDelta, aArea, SCROLL_NOCHILDREN );
465cdf0e10cSrcweir 		pView->Update();
466cdf0e10cSrcweir 		pView->NotifyScrolled();
467cdf0e10cSrcweir 	}
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 	ShowCursor( sal_True );
470cdf0e10cSrcweir }
471cdf0e10cSrcweir 
472cdf0e10cSrcweir void SvImpLBox::KeyUp( sal_Bool bPageUp, sal_Bool bNotifyScroll )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	if( !aVerSBar.IsVisible() )
475cdf0e10cSrcweir 		return;
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 	long nDelta;
478cdf0e10cSrcweir 	if( bPageUp )
479cdf0e10cSrcweir 		nDelta = aVerSBar.GetPageSize();
480cdf0e10cSrcweir 	else
481cdf0e10cSrcweir 		nDelta = 1;
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	long nThumbPos = aVerSBar.GetThumbPos();
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	if( nThumbPos < nDelta )
486cdf0e10cSrcweir 		nDelta = nThumbPos;
487cdf0e10cSrcweir 
488cdf0e10cSrcweir 	if( nDelta <= 0 )
489cdf0e10cSrcweir 		return;
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 	nFlags &= (~F_FILLING);
492cdf0e10cSrcweir 	if( bNotifyScroll )
493cdf0e10cSrcweir 		BeginScroll();
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 	aVerSBar.SetThumbPos( nThumbPos - nDelta );
496cdf0e10cSrcweir 	if( bPageUp )
497cdf0e10cSrcweir 		PageUp( (short)nDelta );
498cdf0e10cSrcweir 	else
499cdf0e10cSrcweir 		CursorUp();
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 	if( bNotifyScroll )
502cdf0e10cSrcweir 		EndScroll();
503cdf0e10cSrcweir }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 
506cdf0e10cSrcweir void SvImpLBox::KeyDown( sal_Bool bPageDown, sal_Bool bNotifyScroll )
507cdf0e10cSrcweir {
508cdf0e10cSrcweir 	if( !aVerSBar.IsVisible() )
509cdf0e10cSrcweir 		return;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 	long nDelta;
512cdf0e10cSrcweir 	if( bPageDown )
513cdf0e10cSrcweir 		nDelta = aVerSBar.GetPageSize();
514cdf0e10cSrcweir 	else
515cdf0e10cSrcweir 		nDelta = 1;
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 	long nThumbPos = aVerSBar.GetThumbPos();
518cdf0e10cSrcweir 	long nVisibleSize = aVerSBar.GetVisibleSize();
519cdf0e10cSrcweir 	long nRange = aVerSBar.GetRange().Len();
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 	long nTmp = nThumbPos+nVisibleSize;
522cdf0e10cSrcweir 	while( (nDelta > 0) && (nTmp+nDelta) >= nRange )
523cdf0e10cSrcweir 		nDelta--;
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 	if( nDelta <= 0 )
526cdf0e10cSrcweir 		return;
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 	nFlags &= (~F_FILLING);
529cdf0e10cSrcweir 	if( bNotifyScroll )
530cdf0e10cSrcweir 		BeginScroll();
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 	aVerSBar.SetThumbPos( nThumbPos+nDelta );
533cdf0e10cSrcweir 	if( bPageDown )
534cdf0e10cSrcweir 		PageDown( (short)nDelta );
535cdf0e10cSrcweir 	else
536cdf0e10cSrcweir 		CursorDown();
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 	if( bNotifyScroll )
539cdf0e10cSrcweir 		EndScroll();
540cdf0e10cSrcweir }
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 
544cdf0e10cSrcweir void SvImpLBox::InvalidateEntriesFrom( long nY ) const
545cdf0e10cSrcweir {
546cdf0e10cSrcweir 	if( !(nFlags & F_IN_PAINT ))
547cdf0e10cSrcweir 	{
548cdf0e10cSrcweir 		Rectangle aRect( GetVisibleArea() );
549cdf0e10cSrcweir 		aRect.Top() = nY;
550cdf0e10cSrcweir 		pView->Invalidate( aRect );
551cdf0e10cSrcweir 	}
552cdf0e10cSrcweir }
553cdf0e10cSrcweir 
554cdf0e10cSrcweir void SvImpLBox::InvalidateEntry( long nY ) const
555cdf0e10cSrcweir {
556cdf0e10cSrcweir 	if( !(nFlags & F_IN_PAINT ))
557cdf0e10cSrcweir 	{
558cdf0e10cSrcweir 		Rectangle aRect( GetVisibleArea() );
559cdf0e10cSrcweir 		long nMaxBottom = aRect.Bottom();
560cdf0e10cSrcweir 		aRect.Top() = nY;
561cdf0e10cSrcweir 		aRect.Bottom() = nY; aRect.Bottom() += pView->GetEntryHeight();
562cdf0e10cSrcweir 		if( aRect.Top() > nMaxBottom )
563cdf0e10cSrcweir 			return;
564cdf0e10cSrcweir 		if( aRect.Bottom() > nMaxBottom )
565cdf0e10cSrcweir 			aRect.Bottom() = nMaxBottom;
566cdf0e10cSrcweir 		pView->Invalidate( aRect );
567cdf0e10cSrcweir 	}
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
570cdf0e10cSrcweir void SvImpLBox::InvalidateEntry( SvLBoxEntry* pEntry )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir 	if( GetUpdateMode() )
573cdf0e10cSrcweir 	{
574cdf0e10cSrcweir 		long nPrev = nMostRight;
575cdf0e10cSrcweir 		SetMostRight( pEntry );
576cdf0e10cSrcweir 		if( nPrev < nMostRight )
577cdf0e10cSrcweir 			ShowVerSBar();
578cdf0e10cSrcweir 	}
579cdf0e10cSrcweir 	if( !(nFlags & F_IN_PAINT ))
580cdf0e10cSrcweir 	{
581cdf0e10cSrcweir 		sal_Bool bHasFocusRect = sal_False;
582cdf0e10cSrcweir 		if( pEntry==pCursor && pView->HasFocus() )
583cdf0e10cSrcweir 		{
584cdf0e10cSrcweir 			bHasFocusRect = sal_True;
585cdf0e10cSrcweir 			ShowCursor( sal_False );
586cdf0e10cSrcweir 		}
587cdf0e10cSrcweir 		InvalidateEntry( GetEntryLine( pEntry ) );
588cdf0e10cSrcweir 		if( bHasFocusRect )
589cdf0e10cSrcweir 			ShowCursor( sal_True );
590cdf0e10cSrcweir 	}
591cdf0e10cSrcweir }
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 
594cdf0e10cSrcweir void SvImpLBox::RecalcFocusRect()
595cdf0e10cSrcweir {
596cdf0e10cSrcweir 	if( pView->HasFocus() && pCursor )
597cdf0e10cSrcweir 	{
598cdf0e10cSrcweir 		pView->HideFocus();
599cdf0e10cSrcweir 		long nY = GetEntryLine( pCursor );
600cdf0e10cSrcweir 		Rectangle aRect = pView->GetFocusRect( pCursor, nY );
601cdf0e10cSrcweir 		CalcCellFocusRect( pCursor, aRect );
602cdf0e10cSrcweir 		Region aOldClip( pView->GetClipRegion());
603cdf0e10cSrcweir 		Region aClipRegion( GetClipRegionRect() );
604cdf0e10cSrcweir 		pView->SetClipRegion( aClipRegion );
605cdf0e10cSrcweir 		pView->ShowFocus( aRect );
606cdf0e10cSrcweir 		pView->SetClipRegion( aOldClip );
607cdf0e10cSrcweir 	}
608cdf0e10cSrcweir }
609cdf0e10cSrcweir 
610cdf0e10cSrcweir //
611cdf0e10cSrcweir //  Setzt Cursor. Passt bei SingleSelection die Selektion an
612cdf0e10cSrcweir //
613cdf0e10cSrcweir 
614cdf0e10cSrcweir void SvImpLBox::SetCursor( SvLBoxEntry* pEntry, sal_Bool bForceNoSelect )
615cdf0e10cSrcweir {
616cdf0e10cSrcweir 	SvViewDataEntry* pViewDataNewCur = 0;
617cdf0e10cSrcweir 	if( pEntry )
618cdf0e10cSrcweir 		pViewDataNewCur= pView->GetViewDataEntry(pEntry);
619cdf0e10cSrcweir 	if( pEntry &&
620cdf0e10cSrcweir 		pEntry == pCursor &&
621cdf0e10cSrcweir 		pViewDataNewCur->HasFocus() &&
622cdf0e10cSrcweir 		pViewDataNewCur->IsSelected())
623cdf0e10cSrcweir 	{
624cdf0e10cSrcweir 		return;
625cdf0e10cSrcweir 	}
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 	// if this cursor is not selectable, find first visible that is and use it
628cdf0e10cSrcweir 	while( pEntry && pViewDataNewCur && !pViewDataNewCur->IsSelectable() )
629cdf0e10cSrcweir 	{
630cdf0e10cSrcweir 		pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
631cdf0e10cSrcweir 		pViewDataNewCur = pEntry ? pView->GetViewDataEntry(pEntry) : 0;
632cdf0e10cSrcweir 	}
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 	SvLBoxEntry* pOldCursor = pCursor;
635cdf0e10cSrcweir 	if( pCursor && pEntry != pCursor )
636cdf0e10cSrcweir 	{
637cdf0e10cSrcweir 		pView->SetEntryFocus( pCursor, sal_False );
638cdf0e10cSrcweir 		if( bSimpleTravel )
639cdf0e10cSrcweir 			pView->Select( pCursor, sal_False );
640cdf0e10cSrcweir 		pView->HideFocus();
641cdf0e10cSrcweir 	}
642cdf0e10cSrcweir 	pCursor = pEntry;
643cdf0e10cSrcweir 	if( pCursor )
644cdf0e10cSrcweir 	{
645cdf0e10cSrcweir 		pViewDataNewCur->SetFocus( sal_True );
646cdf0e10cSrcweir 		if(!bForceNoSelect && bSimpleTravel && !(nFlags & F_DESEL_ALL) && GetUpdateMode())
647cdf0e10cSrcweir 		{
648cdf0e10cSrcweir 			pView->Select( pCursor, sal_True );
649cdf0e10cSrcweir 		}
650cdf0e10cSrcweir 		// Mehrfachselektion: Im Cursor-Move selektieren, wenn
651cdf0e10cSrcweir 		// nicht im Add-Mode (Ctrl-F8)
652cdf0e10cSrcweir 		else if( GetUpdateMode() &&
653cdf0e10cSrcweir 				 pView->GetSelectionMode() == MULTIPLE_SELECTION &&
654cdf0e10cSrcweir 				 !(nFlags & F_DESEL_ALL) && !aSelEng.IsAddMode() &&
655cdf0e10cSrcweir 				 !bForceNoSelect )
656cdf0e10cSrcweir 		{
657cdf0e10cSrcweir 			pView->Select( pCursor, sal_True );
658cdf0e10cSrcweir 		}
659cdf0e10cSrcweir 		else
660cdf0e10cSrcweir 		{
661cdf0e10cSrcweir 			ShowCursor( sal_True );
662cdf0e10cSrcweir 		}
663cdf0e10cSrcweir 
664cdf0e10cSrcweir 		if( pAnchor )
665cdf0e10cSrcweir 		{
666cdf0e10cSrcweir 			DBG_ASSERT(aSelEng.GetSelectionMode() != SINGLE_SELECTION,"Mode?");
667cdf0e10cSrcweir 			SetAnchorSelection( pOldCursor, pCursor );
668cdf0e10cSrcweir 		}
669cdf0e10cSrcweir 	}
670cdf0e10cSrcweir 	nFlags &= (~F_DESEL_ALL);
671cdf0e10cSrcweir 
672cdf0e10cSrcweir     pView->OnCurrentEntryChanged();
673cdf0e10cSrcweir }
674cdf0e10cSrcweir 
675cdf0e10cSrcweir void SvImpLBox::ShowCursor( sal_Bool bShow )
676cdf0e10cSrcweir {
677cdf0e10cSrcweir 	if( !bShow || !pCursor || !pView->HasFocus() )
678cdf0e10cSrcweir 	{
679cdf0e10cSrcweir 		Region aOldClip( pView->GetClipRegion());
680cdf0e10cSrcweir 		Region aClipRegion( GetClipRegionRect() );
681cdf0e10cSrcweir 		pView->SetClipRegion( aClipRegion );
682cdf0e10cSrcweir 		pView->HideFocus();
683cdf0e10cSrcweir 		pView->SetClipRegion( aOldClip );
684cdf0e10cSrcweir 	}
685cdf0e10cSrcweir 	else
686cdf0e10cSrcweir 	{
687cdf0e10cSrcweir 		long nY = GetEntryLine( pCursor );
688cdf0e10cSrcweir 		Rectangle aRect = pView->GetFocusRect( pCursor, nY );
689cdf0e10cSrcweir 		CalcCellFocusRect( pCursor, aRect );
690cdf0e10cSrcweir 		Region aOldClip( pView->GetClipRegion());
691cdf0e10cSrcweir 		Region aClipRegion( GetClipRegionRect() );
692cdf0e10cSrcweir 		pView->SetClipRegion( aClipRegion );
693cdf0e10cSrcweir 		pView->ShowFocus( aRect );
694cdf0e10cSrcweir 		pView->SetClipRegion( aOldClip );
695cdf0e10cSrcweir 	}
696cdf0e10cSrcweir }
697cdf0e10cSrcweir 
698cdf0e10cSrcweir 
699cdf0e10cSrcweir 
700cdf0e10cSrcweir void SvImpLBox::UpdateAll( sal_Bool bInvalidateCompleteView,
701cdf0e10cSrcweir 	sal_Bool bUpdateVerScrollBar )
702cdf0e10cSrcweir {
703cdf0e10cSrcweir 	if( bUpdateVerScrollBar )
704cdf0e10cSrcweir 		FindMostRight(0);
705cdf0e10cSrcweir 	aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1 ) );
706cdf0e10cSrcweir 	SyncVerThumb();
707cdf0e10cSrcweir 	FillView();
708cdf0e10cSrcweir 	ShowVerSBar();
709cdf0e10cSrcweir 	if( bSimpleTravel && pCursor && pView->HasFocus() )
710cdf0e10cSrcweir 		pView->Select( pCursor, sal_True );
711cdf0e10cSrcweir 	ShowCursor( sal_True );
712cdf0e10cSrcweir 	if( bInvalidateCompleteView )
713cdf0e10cSrcweir 		pView->Invalidate();
714cdf0e10cSrcweir 	else
715cdf0e10cSrcweir 		pView->Invalidate( GetVisibleArea() );
716cdf0e10cSrcweir }
717cdf0e10cSrcweir 
718cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvImpLBox, ScrollLeftRightHdl, ScrollBar *, pScrollBar )
719cdf0e10cSrcweir {
720cdf0e10cSrcweir 	long nDelta = pScrollBar->GetDelta();
721cdf0e10cSrcweir 	if( nDelta )
722cdf0e10cSrcweir 	{
723cdf0e10cSrcweir 		if( pView->IsEditingActive() )
724cdf0e10cSrcweir 		{
725cdf0e10cSrcweir 			pView->EndEditing( sal_True ); // Cancel
726cdf0e10cSrcweir 			pView->Update();
727cdf0e10cSrcweir 		}
728cdf0e10cSrcweir 		pView->nFocusWidth = -1;
729cdf0e10cSrcweir 		KeyLeftRight( nDelta );
730cdf0e10cSrcweir 	}
731cdf0e10cSrcweir 	return 0;
732cdf0e10cSrcweir }
733cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvImpLBox, ScrollLeftRightHdl, ScrollBar *, pScrollBar )
734cdf0e10cSrcweir 
735cdf0e10cSrcweir void SvImpLBox::KeyLeftRight( long nDelta )
736cdf0e10cSrcweir {
737cdf0e10cSrcweir 	if( !(nFlags & F_IN_RESIZE) )
738cdf0e10cSrcweir 		pView->Update();
739cdf0e10cSrcweir 	BeginScroll();
740cdf0e10cSrcweir 	nFlags &= (~F_FILLING);
741cdf0e10cSrcweir 	pView->NotifyScrolling( 0 ); // 0 == horizontales Scrolling
742cdf0e10cSrcweir 	ShowCursor( sal_False );
743cdf0e10cSrcweir 
744cdf0e10cSrcweir 	// neuen Origin berechnen
745cdf0e10cSrcweir 	long nPos = aHorSBar.GetThumbPos();
746cdf0e10cSrcweir 	Point aOrigin( -nPos, 0 );
747cdf0e10cSrcweir 
748cdf0e10cSrcweir 	MapMode aMapMode( pView->GetMapMode() );
749cdf0e10cSrcweir 	aMapMode.SetOrigin( aOrigin );
750cdf0e10cSrcweir 	pView->SetMapMode( aMapMode );
751cdf0e10cSrcweir 
752cdf0e10cSrcweir 	if( !(nFlags & F_IN_RESIZE) )
753cdf0e10cSrcweir 	{
754cdf0e10cSrcweir 		Rectangle aRect( GetVisibleArea() );
755cdf0e10cSrcweir 		pView->Scroll( -nDelta, 0, aRect, SCROLL_NOCHILDREN );
756cdf0e10cSrcweir 	}
757cdf0e10cSrcweir 	else
758cdf0e10cSrcweir 		pView->Invalidate();
759cdf0e10cSrcweir 	RecalcFocusRect();
760cdf0e10cSrcweir 	ShowCursor( sal_True );
761cdf0e10cSrcweir 	pView->NotifyScrolled();
762cdf0e10cSrcweir }
763cdf0e10cSrcweir 
764cdf0e10cSrcweir 
765cdf0e10cSrcweir // gibt letzten Eintrag zurueck, wenn Position unter
766cdf0e10cSrcweir // dem letzten Eintrag ist
767cdf0e10cSrcweir SvLBoxEntry* SvImpLBox::GetClickedEntry( const Point& rPoint ) const
768cdf0e10cSrcweir {
769cdf0e10cSrcweir     DBG_ASSERT( pView->GetModel(), "SvImpLBox::GetClickedEntry: how can this ever happen? Please tell me (frank.schoenheit@sun.com) how to reproduce!" );
770cdf0e10cSrcweir     if ( !pView->GetModel() )
771cdf0e10cSrcweir         // this is quite impossible. Nevertheless, stack traces from the crash reporter
772cdf0e10cSrcweir         // suggest it isn't. Okay, make it safe, and wait for somebody to reproduce it
773cdf0e10cSrcweir         // reliably :-\ ....
774cdf0e10cSrcweir         // #122359# / 2005-05-23 / frank.schoenheit@sun.com
775cdf0e10cSrcweir         return NULL;
776cdf0e10cSrcweir     if( pView->GetEntryCount() == 0 || !pStartEntry || !pView->GetEntryHeight())
777cdf0e10cSrcweir 		return 0;
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 	sal_uInt16 nClickedEntry = (sal_uInt16)(rPoint.Y() / pView->GetEntryHeight() );
780cdf0e10cSrcweir 	sal_uInt16 nTemp = nClickedEntry;
781cdf0e10cSrcweir 	SvLBoxEntry* pEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nTemp ));
782cdf0e10cSrcweir 	return pEntry;
783cdf0e10cSrcweir }
784cdf0e10cSrcweir 
785cdf0e10cSrcweir //
786cdf0e10cSrcweir //  prueft, ob der Eintrag "richtig" getroffen wurde
787cdf0e10cSrcweir //  (Focusrect+ ContextBitmap bei TreeListBox)
788cdf0e10cSrcweir //
789cdf0e10cSrcweir sal_Bool SvImpLBox::EntryReallyHit(SvLBoxEntry* pEntry,const Point& rPosPixel,long nLine)
790cdf0e10cSrcweir {
791cdf0e10cSrcweir 	sal_Bool bRet;
792cdf0e10cSrcweir 	// bei "besonderen" Entries (mit CheckButtons usw.) sind wir
793cdf0e10cSrcweir 	// nicht so pingelig
794cdf0e10cSrcweir 	if( pEntry->ItemCount() >= 3 )
795cdf0e10cSrcweir 		return sal_True;
796cdf0e10cSrcweir 
797cdf0e10cSrcweir 	Rectangle aRect( pView->GetFocusRect( pEntry, nLine ));
798cdf0e10cSrcweir 	aRect.Right() = GetOutputSize().Width() - pView->GetMapMode().GetOrigin().X();
799cdf0e10cSrcweir 	if( pView->IsA() == SV_LISTBOX_ID_TREEBOX )
800cdf0e10cSrcweir 	{
801cdf0e10cSrcweir 		SvLBoxContextBmp* pBmp = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
802cdf0e10cSrcweir 		aRect.Left() -= pBmp->GetSize(pView,pEntry).Width();
803cdf0e10cSrcweir 		aRect.Left() -= 4; // etwas Speilraum lassen
804cdf0e10cSrcweir 	}
805cdf0e10cSrcweir 	Point aPos( rPosPixel );
806cdf0e10cSrcweir 	aPos -= pView->GetMapMode().GetOrigin();
807cdf0e10cSrcweir 	if( aRect.IsInside( aPos ) )
808cdf0e10cSrcweir 		bRet = sal_True;
809cdf0e10cSrcweir 	else
810cdf0e10cSrcweir 		bRet = sal_False;
811cdf0e10cSrcweir 	return bRet;
812cdf0e10cSrcweir }
813cdf0e10cSrcweir 
814cdf0e10cSrcweir 
815cdf0e10cSrcweir // gibt 0 zurueck, wenn Position unter dem letzten Eintrag ist
816cdf0e10cSrcweir SvLBoxEntry* SvImpLBox::GetEntry( const Point& rPoint ) const
817cdf0e10cSrcweir {
818cdf0e10cSrcweir 	if( (pView->GetEntryCount() == 0) || !pStartEntry ||
819cdf0e10cSrcweir         (rPoint.Y() > aOutputSize.Height())
820cdf0e10cSrcweir         || !pView->GetEntryHeight())
821cdf0e10cSrcweir 		return 0;
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 	sal_uInt16 nClickedEntry = (sal_uInt16)(rPoint.Y() / pView->GetEntryHeight() );
824cdf0e10cSrcweir 	sal_uInt16 nTemp = nClickedEntry;
825cdf0e10cSrcweir 	SvLBoxEntry* pEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nTemp ));
826cdf0e10cSrcweir 	if( nTemp != nClickedEntry )
827cdf0e10cSrcweir 		pEntry = 0;
828cdf0e10cSrcweir 	return pEntry;
829cdf0e10cSrcweir }
830cdf0e10cSrcweir 
831cdf0e10cSrcweir 
832cdf0e10cSrcweir SvLBoxEntry* SvImpLBox::MakePointVisible(const Point& rPoint,sal_Bool bNotifyScroll)
833cdf0e10cSrcweir {
834cdf0e10cSrcweir 	if( !pCursor )
835cdf0e10cSrcweir 		return 0;
836cdf0e10cSrcweir 	long nY = rPoint.Y();
837cdf0e10cSrcweir 	SvLBoxEntry* pEntry = 0;
838cdf0e10cSrcweir 	long nMax = aOutputSize.Height();
839cdf0e10cSrcweir 	if( nY < 0 || nY >= nMax ) // aOutputSize.Height() )
840cdf0e10cSrcweir 	{
841cdf0e10cSrcweir 		if( nY < 0 )
842cdf0e10cSrcweir 			pEntry = (SvLBoxEntry*)(pView->PrevVisible( pCursor ));
843cdf0e10cSrcweir 		else
844cdf0e10cSrcweir 			pEntry = (SvLBoxEntry*)(pView->NextVisible( pCursor ));
845cdf0e10cSrcweir 
846cdf0e10cSrcweir 		if( pEntry && pEntry != pCursor )
847cdf0e10cSrcweir 			pView->SetEntryFocus( pCursor, sal_False );
848cdf0e10cSrcweir 
849cdf0e10cSrcweir 		if( nY < 0 )
850cdf0e10cSrcweir 			KeyUp( sal_False, bNotifyScroll );
851cdf0e10cSrcweir 		else
852cdf0e10cSrcweir 			KeyDown( sal_False, bNotifyScroll );
853cdf0e10cSrcweir 	}
854cdf0e10cSrcweir 	else
855cdf0e10cSrcweir 	{
856cdf0e10cSrcweir 		pEntry = GetClickedEntry( rPoint );
857cdf0e10cSrcweir 		if( !pEntry )
858cdf0e10cSrcweir 		{
859cdf0e10cSrcweir 			sal_uInt16 nSteps = 0xFFFF;
860cdf0e10cSrcweir 			// LastVisible ist noch nicht implementiert!
861cdf0e10cSrcweir 			pEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nSteps ));
862cdf0e10cSrcweir 		}
863cdf0e10cSrcweir 		if( pEntry )
864cdf0e10cSrcweir 		{
865cdf0e10cSrcweir 			if( pEntry != pCursor &&
866cdf0e10cSrcweir 				 aSelEng.GetSelectionMode() == SINGLE_SELECTION
867cdf0e10cSrcweir 			)
868cdf0e10cSrcweir 				pView->Select( pCursor, sal_False );
869cdf0e10cSrcweir 		}
870cdf0e10cSrcweir 	}
871cdf0e10cSrcweir 	return pEntry;
872cdf0e10cSrcweir }
873cdf0e10cSrcweir 
874cdf0e10cSrcweir Rectangle SvImpLBox::GetClipRegionRect() const
875cdf0e10cSrcweir {
876cdf0e10cSrcweir 	Point aOrigin( pView->GetMapMode().GetOrigin() );
877cdf0e10cSrcweir 	aOrigin.X() *= -1; // Umrechnung Dokumentkoord.
878cdf0e10cSrcweir 	Rectangle aClipRect( aOrigin, aOutputSize );
879cdf0e10cSrcweir 	aClipRect.Bottom()++;
880cdf0e10cSrcweir 	return aClipRect;
881cdf0e10cSrcweir }
882cdf0e10cSrcweir 
883cdf0e10cSrcweir 
884cdf0e10cSrcweir void SvImpLBox::Paint( const Rectangle& rRect )
885cdf0e10cSrcweir {
886cdf0e10cSrcweir 	if( !pView->GetVisibleCount() )
887cdf0e10cSrcweir 		return;
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 	nFlags |= F_IN_PAINT;
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 	if( nFlags & F_FILLING )
892cdf0e10cSrcweir 	{
893cdf0e10cSrcweir 		SvLBoxEntry* pFirst = pView->First();
894cdf0e10cSrcweir 		if( pFirst != pStartEntry )
895cdf0e10cSrcweir 		{
896cdf0e10cSrcweir 			ShowCursor( sal_False );
897cdf0e10cSrcweir 			pStartEntry = pView->First();
898cdf0e10cSrcweir 			aVerSBar.SetThumbPos( 0 );
899cdf0e10cSrcweir 			StopUserEvent();
900cdf0e10cSrcweir 			ShowCursor( sal_True );
901cdf0e10cSrcweir 			nCurUserEvent = Application::PostUserEvent(LINK(this,SvImpLBox,MyUserEvent),(void*)1);
902cdf0e10cSrcweir 			return;
903cdf0e10cSrcweir 		}
904cdf0e10cSrcweir 	}
905cdf0e10cSrcweir 
906cdf0e10cSrcweir 	if( !pStartEntry )
907cdf0e10cSrcweir 	{
908cdf0e10cSrcweir 		pStartEntry = pView->First();
909cdf0e10cSrcweir 	}
910cdf0e10cSrcweir 
911cdf0e10cSrcweir #ifdef XX_OV
912cdf0e10cSrcweir 	sal_uLong nXAbsPos = (sal_uInt16)pTree->GetAbsPos( pStartEntry );
913cdf0e10cSrcweir 	sal_uLong nXVisPos = pView->GetVisiblePos( pStartEntry );
914cdf0e10cSrcweir 	SvLBoxString* pXStr = (SvLBoxString*)pStartEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING);
915cdf0e10cSrcweir #endif
916cdf0e10cSrcweir 
917cdf0e10cSrcweir 
918cdf0e10cSrcweir 
919cdf0e10cSrcweir 	if( nNodeBmpTabDistance == NODE_BMP_TABDIST_NOTVALID )
920cdf0e10cSrcweir 		SetNodeBmpTabDistance();
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 	long nRectHeight = rRect.GetHeight();
923cdf0e10cSrcweir 	long nEntryHeight = pView->GetEntryHeight();
924cdf0e10cSrcweir 
925cdf0e10cSrcweir 	// Bereich der zu zeichnenden Entries berechnen
926cdf0e10cSrcweir 	sal_uInt16 nStartLine = (sal_uInt16)( rRect.Top() / nEntryHeight );
927cdf0e10cSrcweir 	sal_uInt16 nCount = (sal_uInt16)( nRectHeight / nEntryHeight );
928cdf0e10cSrcweir 		nCount += 2; // keine Zeile vergessen
929cdf0e10cSrcweir 
930cdf0e10cSrcweir 	long nY = nStartLine * nEntryHeight;
931cdf0e10cSrcweir 	SvLBoxEntry* pEntry = pStartEntry;
932cdf0e10cSrcweir 	while( nStartLine && pEntry )
933cdf0e10cSrcweir 	{
934cdf0e10cSrcweir 		pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
935cdf0e10cSrcweir 		nStartLine--;
936cdf0e10cSrcweir 	}
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 	Region aClipRegion( GetClipRegionRect() );
939cdf0e10cSrcweir 
940cdf0e10cSrcweir 	// erst die Linien Zeichnen, dann clippen!
941cdf0e10cSrcweir 	pView->SetClipRegion();
942cdf0e10cSrcweir 	if( m_nStyle & ( WB_HASLINES | WB_HASLINESATROOT ) )
943cdf0e10cSrcweir 		DrawNet();
944cdf0e10cSrcweir 
945cdf0e10cSrcweir 	pView->SetClipRegion( aClipRegion );
946cdf0e10cSrcweir 
947cdf0e10cSrcweir 	for( sal_uInt16 n=0; n< nCount && pEntry; n++ )
948cdf0e10cSrcweir 	{
949cdf0e10cSrcweir 		/*long nMaxRight=*/
950cdf0e10cSrcweir 		pView->PaintEntry1( pEntry, nY, 0xffff, sal_True );
951cdf0e10cSrcweir 		nY += nEntryHeight;
952cdf0e10cSrcweir 		pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
953cdf0e10cSrcweir 	}
954cdf0e10cSrcweir 
955cdf0e10cSrcweir     if ( !pCursor && ( ( nExtendedWinBits & EWB_NO_AUTO_CURENTRY ) == 0 ) )
956cdf0e10cSrcweir 	{
957cdf0e10cSrcweir         // do not select if multiselection or explicit set
958cdf0e10cSrcweir         sal_Bool bNotSelect = ( aSelEng.GetSelectionMode() == MULTIPLE_SELECTION )
959cdf0e10cSrcweir                 || ( ( m_nStyle & WB_NOINITIALSELECTION ) == WB_NOINITIALSELECTION );
960cdf0e10cSrcweir         SetCursor( pStartEntry, bNotSelect );
961cdf0e10cSrcweir 	}
962cdf0e10cSrcweir 
963cdf0e10cSrcweir     nFlags &= (~F_DESEL_ALL);
964cdf0e10cSrcweir 	pView->SetClipRegion();
965cdf0e10cSrcweir 	Rectangle aRect;
966cdf0e10cSrcweir 	if( !(nFlags & F_PAINTED) )
967cdf0e10cSrcweir 	{
968cdf0e10cSrcweir 		nFlags |= F_PAINTED;
969cdf0e10cSrcweir 		RepaintScrollBars();
970cdf0e10cSrcweir 	}
971cdf0e10cSrcweir 	nFlags &= (~F_IN_PAINT);
972cdf0e10cSrcweir }
973cdf0e10cSrcweir 
974cdf0e10cSrcweir void SvImpLBox::MakeVisible( SvLBoxEntry* pEntry, sal_Bool bMoveToTop )
975cdf0e10cSrcweir {
976cdf0e10cSrcweir 	if( !pEntry )
977cdf0e10cSrcweir 		return;
978cdf0e10cSrcweir 
979cdf0e10cSrcweir 	sal_Bool bInView = IsEntryInView( pEntry );
980cdf0e10cSrcweir 
981cdf0e10cSrcweir 	if( bInView && (!bMoveToTop || pStartEntry == pEntry) )
982cdf0e10cSrcweir 		return;  // ist schon sichtbar
983cdf0e10cSrcweir 
984cdf0e10cSrcweir 	if( pStartEntry || (m_nStyle & WB_FORCE_MAKEVISIBLE) )
985cdf0e10cSrcweir 		nFlags &= (~F_FILLING);
986cdf0e10cSrcweir 	if( !bInView )
987cdf0e10cSrcweir 	{
988cdf0e10cSrcweir 		if( !pView->IsEntryVisible(pEntry) )  // Parent(s) zugeklappt ?
989cdf0e10cSrcweir 		{
990cdf0e10cSrcweir 			SvLBoxEntry* pParent = pView->GetParent( pEntry );
991cdf0e10cSrcweir 			while( pParent )
992cdf0e10cSrcweir 			{
993cdf0e10cSrcweir 				if( !pView->IsExpanded( pParent ) )
994cdf0e10cSrcweir 				{
995cdf0e10cSrcweir                     #ifdef DBG_UTIL
996cdf0e10cSrcweir                     sal_Bool bRet =
997cdf0e10cSrcweir                     #endif
998cdf0e10cSrcweir 					    pView->Expand( pParent );
999cdf0e10cSrcweir 					DBG_ASSERT(bRet,"Not expanded!");
1000cdf0e10cSrcweir 				}
1001cdf0e10cSrcweir 				pParent = pView->GetParent( pParent );
1002cdf0e10cSrcweir 			}
1003cdf0e10cSrcweir 			// Passen Childs der Parents in View oder muessen wir scrollen ?
1004cdf0e10cSrcweir 			if( IsEntryInView( pEntry ) && !bMoveToTop )
1005cdf0e10cSrcweir 				return;  // Scrollen nicht noetig -> tschuess
1006cdf0e10cSrcweir 		}
1007cdf0e10cSrcweir 	}
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 	pStartEntry = pEntry;
1010cdf0e10cSrcweir 	ShowCursor( sal_False );
1011cdf0e10cSrcweir 	FillView();
1012cdf0e10cSrcweir 	aVerSBar.SetThumbPos( (long)(pView->GetVisiblePos( pStartEntry )) );
1013cdf0e10cSrcweir 	ShowCursor( sal_True );
1014cdf0e10cSrcweir 	pView->Invalidate();
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir void SvImpLBox::RepaintSelectionItems()
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir 	if( !pView->GetVisibleCount() )
1021cdf0e10cSrcweir 		return;
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir 	if( !pStartEntry )
1024cdf0e10cSrcweir 		pStartEntry = pView->First();
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir 	if( nNodeBmpTabDistance == NODE_BMP_TABDIST_NOTVALID )
1027cdf0e10cSrcweir 		SetNodeBmpTabDistance();
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir 	ShowCursor( sal_False );
1030cdf0e10cSrcweir 
1031cdf0e10cSrcweir 	long nEntryHeight = pView->GetEntryHeight();
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir 	sal_uLong nCount = nVisibleCount;
1034cdf0e10cSrcweir 	long nY = 0;
1035cdf0e10cSrcweir 	SvLBoxEntry* pEntry = pStartEntry;
1036cdf0e10cSrcweir 	for( sal_uLong n=0; n< nCount && pEntry; n++ )
1037cdf0e10cSrcweir 	{
1038cdf0e10cSrcweir 		pView->PaintEntry1( pEntry, nY, 0xffff ); //wg. ItemsetBrowser SV_LBOXTAB_SHOW_SELECTION );
1039cdf0e10cSrcweir 		nY += nEntryHeight;
1040cdf0e10cSrcweir 		pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
1041cdf0e10cSrcweir 	}
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir 	ShowCursor( sal_True );
1044cdf0e10cSrcweir }
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir void SvImpLBox::DrawNet()
1048cdf0e10cSrcweir {
1049cdf0e10cSrcweir 	if( pView->GetVisibleCount() < 2 && !pStartEntry->HasChildsOnDemand() &&
1050cdf0e10cSrcweir 		!pStartEntry->HasChilds() )
1051cdf0e10cSrcweir 		return;
1052cdf0e10cSrcweir 
1053cdf0e10cSrcweir     //for platforms who don't have nets, DrawNativeControl does nothing and return true
1054cdf0e10cSrcweir     //so that SvImpLBox::DrawNet() doesn't draw anything too
1055cdf0e10cSrcweir  	if(pView->IsNativeControlSupported( CTRL_LISTNET, PART_ENTIRE_CONTROL)) {
1056cdf0e10cSrcweir         ImplControlValue	aControlValue;
1057cdf0e10cSrcweir         Point  aTemp(0,0);   // temporary needed for g++ 3.3.5
1058cdf0e10cSrcweir         Rectangle aCtrlRegion( aTemp, Size( 0, 0 ) );
1059cdf0e10cSrcweir         ControlState		nState = CTRL_STATE_ENABLED;
1060cdf0e10cSrcweir         if( pView->DrawNativeControl( CTRL_LISTNET, PART_ENTIRE_CONTROL,
1061cdf0e10cSrcweir                                       aCtrlRegion, nState, aControlValue, rtl::OUString() ) )
1062cdf0e10cSrcweir         {
1063cdf0e10cSrcweir             return;
1064cdf0e10cSrcweir         }
1065cdf0e10cSrcweir 
1066cdf0e10cSrcweir     }
1067cdf0e10cSrcweir 
1068cdf0e10cSrcweir 	long nEntryHeight = pView->GetEntryHeight();
1069cdf0e10cSrcweir 	long nEntryHeightDIV2 = nEntryHeight / 2;
1070cdf0e10cSrcweir 	if( nEntryHeightDIV2 && !(nEntryHeight & 0x0001))
1071cdf0e10cSrcweir 		nEntryHeightDIV2--;
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir 	SvLBoxEntry* pChild;
1074cdf0e10cSrcweir 	SvLBoxEntry* pEntry = pStartEntry;
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir 	SvLBoxTab* pFirstDynamicTab = pView->GetFirstDynamicTab();
1077cdf0e10cSrcweir 	while( pTree->GetDepth( pEntry ) > 0 )
1078cdf0e10cSrcweir 		pEntry = pView->GetParent( pEntry );
1079cdf0e10cSrcweir 	sal_uInt16 nOffs = (sal_uInt16)(pView->GetVisiblePos( pStartEntry ) -
1080cdf0e10cSrcweir 							pView->GetVisiblePos( pEntry ));
1081cdf0e10cSrcweir 	long nY = 0;
1082cdf0e10cSrcweir 	nY -= ( nOffs * nEntryHeight );
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir 	DBG_ASSERT(pFirstDynamicTab,"No Tree!");
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir 	Color aOldLineColor = pView->GetLineColor();
1087cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = pView->GetSettings().GetStyleSettings();
1088cdf0e10cSrcweir 	Color aCol= rStyleSettings.GetFaceColor();
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir 	if( aCol.IsRGBEqual( pView->GetBackground().GetColor()) )
1091cdf0e10cSrcweir 		aCol = rStyleSettings.GetShadowColor();
1092cdf0e10cSrcweir 	pView->SetLineColor( aCol );
1093cdf0e10cSrcweir 	Point aPos1, aPos2;
1094cdf0e10cSrcweir 	sal_uInt16 nDistance;
1095cdf0e10cSrcweir 	sal_uLong nMax = nVisibleCount + nOffs + 1;
1096cdf0e10cSrcweir 
1097cdf0e10cSrcweir 	const Image& rExpandedNodeBitmap = GetExpandedNodeBmp();
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir 	for( sal_uLong n=0; n< nMax && pEntry; n++ )
1100cdf0e10cSrcweir 	{
1101cdf0e10cSrcweir 		if( pView->IsExpanded(pEntry) )
1102cdf0e10cSrcweir 		{
1103cdf0e10cSrcweir 			aPos1.X() = pView->GetTabPos(pEntry, pFirstDynamicTab);
1104cdf0e10cSrcweir 			// wenn keine ContextBitmap, dann etwas nach rechts
1105cdf0e10cSrcweir 			// unter den ersten Text (Node.Bmp ebenfalls
1106cdf0e10cSrcweir 			if( !pView->nContextBmpWidthMax )
1107cdf0e10cSrcweir 				aPos1.X() += rExpandedNodeBitmap.GetSizePixel().Width() / 2;
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir 			aPos1.Y() = nY;
1110cdf0e10cSrcweir 			aPos1.Y() += nEntryHeightDIV2;
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir 			pChild = pView->FirstChild( pEntry );
1113cdf0e10cSrcweir 			DBG_ASSERT(pChild,"Child?");
1114cdf0e10cSrcweir 			pChild = pTree->LastSibling( pChild );
1115cdf0e10cSrcweir 			nDistance = (sal_uInt16)(pView->GetVisiblePos(pChild) -
1116cdf0e10cSrcweir 								 pView->GetVisiblePos(pEntry));
1117cdf0e10cSrcweir 			aPos2 = aPos1;
1118cdf0e10cSrcweir 			aPos2.Y() += nDistance * nEntryHeight;
1119cdf0e10cSrcweir 			pView->DrawLine( aPos1, aPos2 );
1120cdf0e10cSrcweir 		}
1121cdf0e10cSrcweir 		// Sichtbar im Control ?
1122cdf0e10cSrcweir 		if( n>= nOffs && ((m_nStyle & WB_HASLINESATROOT) || !pTree->IsAtRootDepth(pEntry)))
1123cdf0e10cSrcweir 		{
1124cdf0e10cSrcweir 			// kann aPos1 recyclet werden ?
1125cdf0e10cSrcweir 			if( !pView->IsExpanded(pEntry) )
1126cdf0e10cSrcweir 			{
1127cdf0e10cSrcweir 				// njet
1128cdf0e10cSrcweir 				aPos1.X() = pView->GetTabPos(pEntry, pFirstDynamicTab);
1129cdf0e10cSrcweir 				// wenn keine ContextBitmap, dann etwas nach rechts
1130cdf0e10cSrcweir 				// unter den ersten Text (Node.Bmp ebenfalls
1131cdf0e10cSrcweir 				if( !pView->nContextBmpWidthMax )
1132cdf0e10cSrcweir 					aPos1.X() += rExpandedNodeBitmap.GetSizePixel().Width() / 2;
1133cdf0e10cSrcweir 				aPos1.Y() = nY;
1134cdf0e10cSrcweir 				aPos1.Y() += nEntryHeightDIV2;
1135cdf0e10cSrcweir 				aPos2.X() = aPos1.X();
1136cdf0e10cSrcweir 			}
1137cdf0e10cSrcweir 			aPos2.Y() = aPos1.Y();
1138cdf0e10cSrcweir 			aPos2.X() -= pView->GetIndent();
1139cdf0e10cSrcweir 			pView->DrawLine( aPos1, aPos2 );
1140cdf0e10cSrcweir 		}
1141cdf0e10cSrcweir 		nY += nEntryHeight;
1142cdf0e10cSrcweir 		pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
1143cdf0e10cSrcweir 	}
1144cdf0e10cSrcweir 	if( m_nStyle & WB_HASLINESATROOT )
1145cdf0e10cSrcweir 	{
1146cdf0e10cSrcweir 		pEntry = pView->First();
1147cdf0e10cSrcweir 		aPos1.X() = pView->GetTabPos( pEntry, pFirstDynamicTab);
1148cdf0e10cSrcweir 		// wenn keine ContextBitmap, dann etwas nach rechts
1149cdf0e10cSrcweir 		// unter den ersten Text (Node.Bmp ebenfalls
1150cdf0e10cSrcweir 		if( !pView->nContextBmpWidthMax )
1151cdf0e10cSrcweir 			aPos1.X() += rExpandedNodeBitmap.GetSizePixel().Width() / 2;
1152cdf0e10cSrcweir 		aPos1.X() -=  pView->GetIndent();
1153cdf0e10cSrcweir 		aPos1.Y() = GetEntryLine( pEntry );
1154cdf0e10cSrcweir 		aPos1.Y() += nEntryHeightDIV2;
1155cdf0e10cSrcweir 		pChild = pTree->LastSibling( pEntry );
1156cdf0e10cSrcweir 		aPos2.X() = aPos1.X();
1157cdf0e10cSrcweir 		aPos2.Y() = GetEntryLine( pChild );
1158cdf0e10cSrcweir 		aPos2.Y() += nEntryHeightDIV2;
1159cdf0e10cSrcweir 		pView->DrawLine( aPos1, aPos2 );
1160cdf0e10cSrcweir 	}
1161cdf0e10cSrcweir 	pView->SetLineColor( aOldLineColor );
1162cdf0e10cSrcweir }
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir static long GetOptSize( TabBar* pTabBar )
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir 	return pTabBar->CalcWindowSizePixel().Width();
1168cdf0e10cSrcweir }
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir void SvImpLBox::PositionScrollBars( Size& rSize, sal_uInt16 nMask )
1171cdf0e10cSrcweir {
1172cdf0e10cSrcweir 	long nOverlap = 0;
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 	Size aVerSize( nVerSBarWidth, rSize.Height() );
1175cdf0e10cSrcweir 	Size aHorSize( rSize.Width(), nHorSBarHeight );
1176cdf0e10cSrcweir 	long nTabBarWidth = 0;
1177cdf0e10cSrcweir 	if( pTabBar )
1178cdf0e10cSrcweir 	{
1179cdf0e10cSrcweir 		nTabBarWidth = GetOptSize( pTabBar );
1180cdf0e10cSrcweir 		long nMaxWidth = (rSize.Width() * 700) / 1000;
1181cdf0e10cSrcweir 		if( nTabBarWidth > nMaxWidth )
1182cdf0e10cSrcweir 		{
1183cdf0e10cSrcweir 			nTabBarWidth = nMaxWidth;
1184cdf0e10cSrcweir 			pTabBar->SetStyle( pTabBar->GetStyle() | WB_MINSCROLL );
1185cdf0e10cSrcweir 		}
1186cdf0e10cSrcweir 		else
1187cdf0e10cSrcweir 		{
1188cdf0e10cSrcweir 			WinBits nStyle = pTabBar->GetStyle();
1189cdf0e10cSrcweir 			nStyle &= ~(WB_MINSCROLL);
1190cdf0e10cSrcweir 			pTabBar->SetStyle( nStyle );
1191cdf0e10cSrcweir 		}
1192cdf0e10cSrcweir 		aHorSize.Width() -= nTabBarWidth;
1193cdf0e10cSrcweir 		Size aTabSize( pTabBar->GetSizePixel() );
1194cdf0e10cSrcweir 		aTabSize.Width() = nTabBarWidth;
1195cdf0e10cSrcweir 		pTabBar->SetSizePixel( aTabSize );
1196cdf0e10cSrcweir 	}
1197cdf0e10cSrcweir 	if( nMask & 0x0001 )
1198cdf0e10cSrcweir 		aHorSize.Width() -= nVerSBarWidth;
1199cdf0e10cSrcweir 	if( nMask & 0x0002 )
1200cdf0e10cSrcweir 		aVerSize.Height() -= nHorSBarHeight;
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir 	aVerSize.Height() += 2 * nOverlap;
1203cdf0e10cSrcweir 	Point aVerPos( rSize.Width() - aVerSize.Width() + nOverlap, -nOverlap );
1204cdf0e10cSrcweir 	aVerSBar.SetPosSizePixel( aVerPos, aVerSize );
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir 	aHorSize.Width() += 2 * nOverlap;
1207cdf0e10cSrcweir 	Point aHorPos( -nOverlap, rSize.Height() - aHorSize.Height() + nOverlap );
1208cdf0e10cSrcweir 	if( pTabBar )
1209cdf0e10cSrcweir 		pTabBar->SetPosPixel( aHorPos );
1210cdf0e10cSrcweir 	aHorPos.X() += nTabBarWidth;
1211cdf0e10cSrcweir 	aHorSBar.SetPosSizePixel( aHorPos, aHorSize );
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir 	if( nMask & 0x0001 )
1214cdf0e10cSrcweir 		rSize.Width() = aVerPos.X();
1215cdf0e10cSrcweir 	if( nMask & 0x0002 )
1216cdf0e10cSrcweir 		rSize.Height() = aHorPos.Y();
1217cdf0e10cSrcweir 	if( pTabBar )
1218cdf0e10cSrcweir 		pTabBar->Show();
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir 	if( (nMask & (0x0001|0x0002)) == (0x0001|0x0002) )
1221cdf0e10cSrcweir 		aScrBarBox.Show();
1222cdf0e10cSrcweir 	else
1223cdf0e10cSrcweir 		aScrBarBox.Hide();
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir }
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir // nResult: Bit0 == VerSBar Bit1 == HorSBar
1228cdf0e10cSrcweir sal_uInt16 SvImpLBox::AdjustScrollBars( Size& rSize )
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir 	long nEntryHeight = pView->GetEntryHeight();
1231cdf0e10cSrcweir 	if( !nEntryHeight )
1232cdf0e10cSrcweir 		return 0;
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir 	sal_uInt16 nResult = 0;
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir 	Size aOSize( pView->Control::GetOutputSizePixel() );
1237cdf0e10cSrcweir 
1238cdf0e10cSrcweir     const WinBits nWindowStyle = pView->GetStyle();
1239cdf0e10cSrcweir 	sal_Bool bVerSBar = ( nWindowStyle & WB_VSCROLL ) != 0;
1240cdf0e10cSrcweir 	sal_Bool bHorBar = sal_False;
1241cdf0e10cSrcweir 	long nMaxRight = aOSize.Width(); //GetOutputSize().Width();
1242cdf0e10cSrcweir 	Point aOrigin( pView->GetMapMode().GetOrigin() );
1243cdf0e10cSrcweir 	aOrigin.X() *= -1;
1244cdf0e10cSrcweir 	nMaxRight += aOrigin.X() - 1;
1245cdf0e10cSrcweir 	long nVis = nMostRight - aOrigin.X();
1246cdf0e10cSrcweir 	if( pTabBar || (
1247cdf0e10cSrcweir 		(nWindowStyle & WB_HSCROLL) &&
1248cdf0e10cSrcweir 		(nVis < nMostRight || nMaxRight < nMostRight) ))
1249cdf0e10cSrcweir 		bHorBar = sal_True;
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir 	// Anzahl aller nicht eingeklappten Eintraege
1252cdf0e10cSrcweir 	sal_uLong nTotalCount = pView->GetVisibleCount();
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir 	// Anzahl in der View sichtbarer Eintraege
1255cdf0e10cSrcweir 	nVisibleCount = aOSize.Height() / nEntryHeight;
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir 	// muessen wir eine vertikale Scrollbar einblenden?
1258cdf0e10cSrcweir     if( bVerSBar || nTotalCount > nVisibleCount )
1259cdf0e10cSrcweir 	{
1260cdf0e10cSrcweir 		nResult = 1;
1261cdf0e10cSrcweir 		nFlags |= F_HOR_SBARSIZE_WITH_VBAR;
1262cdf0e10cSrcweir 		nMaxRight -= nVerSBarWidth;
1263cdf0e10cSrcweir 		if( !bHorBar )
1264cdf0e10cSrcweir 		{
1265cdf0e10cSrcweir 			if( (nWindowStyle & WB_HSCROLL) &&
1266cdf0e10cSrcweir 				(nVis < nMostRight || nMaxRight < nMostRight) )
1267cdf0e10cSrcweir 				bHorBar = sal_True;
1268cdf0e10cSrcweir 		}
1269cdf0e10cSrcweir 	}
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir 	// muessen wir eine horizontale Scrollbar einblenden?
1272cdf0e10cSrcweir 	if( bHorBar )
1273cdf0e10cSrcweir 	{
1274cdf0e10cSrcweir 		nResult |= 0x0002;
1275cdf0e10cSrcweir 		// die Anzahl der in der View sichtbaren Eintraege
1276cdf0e10cSrcweir 		// muss neu berechnet werden, da die horizontale
1277cdf0e10cSrcweir 		// ScrollBar eingeblendet wird
1278cdf0e10cSrcweir 		nVisibleCount =  (aOSize.Height() - nHorSBarHeight) / nEntryHeight;
1279cdf0e10cSrcweir 		// eventuell brauchen wir jetzt doch eine vertikale ScrollBar
1280cdf0e10cSrcweir 		if( !(nResult & 0x0001) &&
1281cdf0e10cSrcweir             ((nTotalCount > nVisibleCount) || bVerSBar) )
1282cdf0e10cSrcweir 		{
1283cdf0e10cSrcweir 			nResult = 3;
1284cdf0e10cSrcweir 			nFlags |= F_VER_SBARSIZE_WITH_HBAR;
1285cdf0e10cSrcweir 		}
1286cdf0e10cSrcweir 	}
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir 	PositionScrollBars( aOSize, nResult );
1289cdf0e10cSrcweir 
1290cdf0e10cSrcweir 	// Range, VisibleRange usw. anpassen
1291cdf0e10cSrcweir 
1292cdf0e10cSrcweir 	// Output-Size aktualisieren, falls wir scrollen muessen
1293cdf0e10cSrcweir 	Rectangle aRect;
1294cdf0e10cSrcweir 	aRect.SetSize( aOSize );
1295cdf0e10cSrcweir 	aSelEng.SetVisibleArea( aRect );
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir 	// Vertikale ScrollBar
1298cdf0e10cSrcweir 	long nTemp = (long)nVisibleCount;
1299cdf0e10cSrcweir 	nTemp--;
1300cdf0e10cSrcweir 	if( nTemp != aVerSBar.GetVisibleSize() )
1301cdf0e10cSrcweir 	{
1302cdf0e10cSrcweir 		if( !bInVScrollHdl )
1303cdf0e10cSrcweir 		{
1304cdf0e10cSrcweir 			aVerSBar.SetPageSize( nTemp - 1 );
1305cdf0e10cSrcweir 			aVerSBar.SetVisibleSize( nTemp );
1306cdf0e10cSrcweir 		}
1307cdf0e10cSrcweir 		else
1308cdf0e10cSrcweir 		{
1309cdf0e10cSrcweir 			nFlags |= F_ENDSCROLL_SET_VIS_SIZE;
1310cdf0e10cSrcweir 			nNextVerVisSize = nTemp;
1311cdf0e10cSrcweir 		}
1312cdf0e10cSrcweir 	}
1313cdf0e10cSrcweir 
1314cdf0e10cSrcweir 	// Horizontale ScrollBar
1315cdf0e10cSrcweir 	nTemp = aHorSBar.GetThumbPos();
1316cdf0e10cSrcweir 	aHorSBar.SetVisibleSize( aOSize.Width() );
1317cdf0e10cSrcweir 	long nNewThumbPos = aHorSBar.GetThumbPos();
1318cdf0e10cSrcweir 	Range aRange( aHorSBar.GetRange() );
1319cdf0e10cSrcweir 	if( aRange.Max() < nMostRight+25 )
1320cdf0e10cSrcweir 	{
1321cdf0e10cSrcweir 		aRange.Max() = nMostRight+25;
1322cdf0e10cSrcweir 		aHorSBar.SetRange( aRange );
1323cdf0e10cSrcweir 	}
1324cdf0e10cSrcweir 
1325cdf0e10cSrcweir 	if( nTemp != nNewThumbPos )
1326cdf0e10cSrcweir 	{
1327cdf0e10cSrcweir 		nTemp = nNewThumbPos - nTemp;
1328cdf0e10cSrcweir 		if( pView->IsEditingActive() )
1329cdf0e10cSrcweir 		{
1330cdf0e10cSrcweir 			pView->EndEditing( sal_True ); // Cancel
1331cdf0e10cSrcweir 			pView->Update();
1332cdf0e10cSrcweir 		}
1333cdf0e10cSrcweir 		pView->nFocusWidth = -1;
1334cdf0e10cSrcweir 		KeyLeftRight( nTemp );
1335cdf0e10cSrcweir 	}
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir 	if( nResult & 0x0001 )
1338cdf0e10cSrcweir 		aVerSBar.Show();
1339cdf0e10cSrcweir 	else
1340cdf0e10cSrcweir 		aVerSBar.Hide();
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir 	if( nResult & 0x0002 )
1343cdf0e10cSrcweir 		aHorSBar.Show();
1344cdf0e10cSrcweir 	else
1345cdf0e10cSrcweir 	{
1346cdf0e10cSrcweir 		if( !pTabBar )
1347cdf0e10cSrcweir 			aHorSBar.Hide();
1348cdf0e10cSrcweir 	}
1349cdf0e10cSrcweir 	rSize = aOSize;
1350cdf0e10cSrcweir 	return nResult;
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir 
1353cdf0e10cSrcweir void SvImpLBox::InitScrollBarBox()
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir 	aScrBarBox.SetSizePixel( Size(nVerSBarWidth, nHorSBarHeight) );
1356cdf0e10cSrcweir 	Size aSize( pView->Control::GetOutputSizePixel() );
1357cdf0e10cSrcweir 	aScrBarBox.SetPosPixel( Point(aSize.Width()-nVerSBarWidth, aSize.Height()-nHorSBarHeight));
1358cdf0e10cSrcweir }
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir void SvImpLBox::Resize()
1361cdf0e10cSrcweir {
1362cdf0e10cSrcweir 	Size aSize( pView->Control::GetOutputSizePixel());
1363cdf0e10cSrcweir 	if( aSize.Width() <= 0 || aSize.Height() <= 0 )
1364cdf0e10cSrcweir 		return;
1365cdf0e10cSrcweir 	nFlags |= F_IN_RESIZE;
1366cdf0e10cSrcweir 	InitScrollBarBox();
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir 	if( pView->GetEntryHeight())
1369cdf0e10cSrcweir 	{
1370cdf0e10cSrcweir 		AdjustScrollBars( aOutputSize );
1371cdf0e10cSrcweir 		FillView();
1372cdf0e10cSrcweir 	}
1373cdf0e10cSrcweir 	// !!!HACK, da in Floating- & Docking-Windows nach Resizes
1374cdf0e10cSrcweir 	// die Scrollbars nicht richtig, bzw. ueberhaupt nicht gezeichnet werden
1375cdf0e10cSrcweir 	if( aHorSBar.IsVisible())
1376cdf0e10cSrcweir 		aHorSBar.Invalidate();
1377cdf0e10cSrcweir 	if( aVerSBar.IsVisible())
1378cdf0e10cSrcweir 		aVerSBar.Invalidate();
1379cdf0e10cSrcweir 	nFlags &= (~(F_IN_RESIZE | F_PAINTED));
1380cdf0e10cSrcweir }
1381cdf0e10cSrcweir 
1382cdf0e10cSrcweir void SvImpLBox::FillView()
1383cdf0e10cSrcweir {
1384cdf0e10cSrcweir 	if( !pStartEntry )
1385cdf0e10cSrcweir 	{
1386cdf0e10cSrcweir 		sal_uInt16 nVisibleViewCount = (sal_uInt16)(pView->GetVisibleCount());
1387cdf0e10cSrcweir 		sal_uInt16 nTempThumb = (sal_uInt16)aVerSBar.GetThumbPos();
1388cdf0e10cSrcweir 		if( nTempThumb >= nVisibleViewCount )
1389cdf0e10cSrcweir 			nTempThumb = nVisibleViewCount - 1;
1390cdf0e10cSrcweir 		pStartEntry = (SvLBoxEntry*)(pView->GetEntryAtVisPos(nTempThumb));
1391cdf0e10cSrcweir 	}
1392cdf0e10cSrcweir 	if( pStartEntry )
1393cdf0e10cSrcweir 	{
1394cdf0e10cSrcweir 		sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos( (SvLBoxEntry*)(pView->LastVisible())));
1395cdf0e10cSrcweir 		sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry ));
1396cdf0e10cSrcweir 		sal_uInt16 nCurDispEntries = nLast-nThumb+1;
1397cdf0e10cSrcweir 		if( nCurDispEntries <  nVisibleCount )
1398cdf0e10cSrcweir 		{
1399cdf0e10cSrcweir 			ShowCursor( sal_False );
1400cdf0e10cSrcweir 			// Fenster fuellen, indem der Thumb schrittweise
1401cdf0e10cSrcweir 			// nach oben bewegt wird
1402cdf0e10cSrcweir 			sal_Bool bFound = sal_False;
1403cdf0e10cSrcweir 			SvLBoxEntry* pTemp = pStartEntry;
1404cdf0e10cSrcweir 			while( nCurDispEntries < nVisibleCount && pTemp )
1405cdf0e10cSrcweir 			{
1406cdf0e10cSrcweir 				pTemp = (SvLBoxEntry*)(pView->PrevVisible(pStartEntry));
1407cdf0e10cSrcweir 				if( pTemp )
1408cdf0e10cSrcweir 				{
1409cdf0e10cSrcweir 					nThumb--;
1410cdf0e10cSrcweir 					pStartEntry = pTemp;
1411cdf0e10cSrcweir 					nCurDispEntries++;
1412cdf0e10cSrcweir 					bFound = sal_True;
1413cdf0e10cSrcweir 				}
1414cdf0e10cSrcweir 			}
1415cdf0e10cSrcweir 			if( bFound )
1416cdf0e10cSrcweir 			{
1417cdf0e10cSrcweir 				aVerSBar.SetThumbPos( nThumb );
1418cdf0e10cSrcweir 				ShowCursor( sal_True );	// Focusrect neu berechnen
1419cdf0e10cSrcweir 				pView->Invalidate();
1420cdf0e10cSrcweir 			}
1421cdf0e10cSrcweir 		}
1422cdf0e10cSrcweir 	}
1423cdf0e10cSrcweir }
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir 
1428cdf0e10cSrcweir void SvImpLBox::ShowVerSBar()
1429cdf0e10cSrcweir {
1430cdf0e10cSrcweir 	sal_Bool bVerBar = ( pView->GetStyle() & WB_VSCROLL ) != 0;
1431cdf0e10cSrcweir 	sal_uLong nVis = 0;
1432cdf0e10cSrcweir 	if( !bVerBar )
1433cdf0e10cSrcweir 		nVis = pView->GetVisibleCount();
1434cdf0e10cSrcweir 	if( bVerBar || (nVisibleCount && nVis > (sal_uLong)(nVisibleCount-1)) )
1435cdf0e10cSrcweir 	{
1436cdf0e10cSrcweir 		if( !aVerSBar.IsVisible() )
1437cdf0e10cSrcweir 		{
1438cdf0e10cSrcweir 			pView->nFocusWidth = -1;
1439cdf0e10cSrcweir 			AdjustScrollBars( aOutputSize );
1440cdf0e10cSrcweir 			if( GetUpdateMode() )
1441cdf0e10cSrcweir 				aVerSBar.Update();
1442cdf0e10cSrcweir 		}
1443cdf0e10cSrcweir 	}
1444cdf0e10cSrcweir 	else
1445cdf0e10cSrcweir 	{
1446cdf0e10cSrcweir 		if( aVerSBar.IsVisible() )
1447cdf0e10cSrcweir 		{
1448cdf0e10cSrcweir 			pView->nFocusWidth = -1;
1449cdf0e10cSrcweir 			AdjustScrollBars( aOutputSize );
1450cdf0e10cSrcweir 		}
1451cdf0e10cSrcweir 	}
1452cdf0e10cSrcweir 
1453cdf0e10cSrcweir 	long nMaxRight = GetOutputSize().Width();
1454cdf0e10cSrcweir 	Point aPos( pView->GetMapMode().GetOrigin() );
1455cdf0e10cSrcweir 	aPos.X() *= -1; // Umrechnung Dokumentkoord.
1456cdf0e10cSrcweir 	nMaxRight = nMaxRight + aPos.X() - 1;
1457cdf0e10cSrcweir 	if( nMaxRight < nMostRight  )
1458cdf0e10cSrcweir 	{
1459cdf0e10cSrcweir 		if( !aHorSBar.IsVisible() )
1460cdf0e10cSrcweir 		{
1461cdf0e10cSrcweir 			pView->nFocusWidth = -1;
1462cdf0e10cSrcweir 			AdjustScrollBars( aOutputSize );
1463cdf0e10cSrcweir 			if( GetUpdateMode() )
1464cdf0e10cSrcweir 				aHorSBar.Update();
1465cdf0e10cSrcweir 		}
1466cdf0e10cSrcweir 		else
1467cdf0e10cSrcweir 		{
1468cdf0e10cSrcweir 			Range aRange( aHorSBar.GetRange() );
1469cdf0e10cSrcweir 			if( aRange.Max() < nMostRight+25 )
1470cdf0e10cSrcweir 			{
1471cdf0e10cSrcweir 				aRange.Max() = nMostRight+25;
1472cdf0e10cSrcweir 				aHorSBar.SetRange( aRange );
1473cdf0e10cSrcweir 			}
1474cdf0e10cSrcweir 			else
1475cdf0e10cSrcweir 			{
1476cdf0e10cSrcweir 				pView->nFocusWidth = -1;
1477cdf0e10cSrcweir 				AdjustScrollBars( aOutputSize );
1478cdf0e10cSrcweir 			}
1479cdf0e10cSrcweir 		}
1480cdf0e10cSrcweir 	}
1481cdf0e10cSrcweir 	else
1482cdf0e10cSrcweir 	{
1483cdf0e10cSrcweir 		if( aHorSBar.IsVisible() )
1484cdf0e10cSrcweir 		{
1485cdf0e10cSrcweir 			pView->nFocusWidth = -1;
1486cdf0e10cSrcweir 			AdjustScrollBars( aOutputSize );
1487cdf0e10cSrcweir 		}
1488cdf0e10cSrcweir 	}
1489cdf0e10cSrcweir }
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir 
1492cdf0e10cSrcweir void SvImpLBox::SyncVerThumb()
1493cdf0e10cSrcweir {
1494cdf0e10cSrcweir 	if( pStartEntry )
1495cdf0e10cSrcweir 	{
1496cdf0e10cSrcweir 		long nEntryPos = pView->GetVisiblePos( pStartEntry );
1497cdf0e10cSrcweir 		aVerSBar.SetThumbPos( nEntryPos );
1498cdf0e10cSrcweir 	}
1499cdf0e10cSrcweir 	else
1500cdf0e10cSrcweir 		aVerSBar.SetThumbPos( 0 );
1501cdf0e10cSrcweir }
1502cdf0e10cSrcweir 
1503cdf0e10cSrcweir sal_Bool SvImpLBox::IsEntryInView( SvLBoxEntry* pEntry ) const
1504cdf0e10cSrcweir {
1505cdf0e10cSrcweir 	// Parent eingeklappt
1506cdf0e10cSrcweir 	if( !pView->IsEntryVisible(pEntry) )
1507cdf0e10cSrcweir 		return sal_False;
1508cdf0e10cSrcweir 	long nY = GetEntryLine( pEntry );
1509cdf0e10cSrcweir 	if( nY < 0 )
1510cdf0e10cSrcweir 		return sal_False;
1511cdf0e10cSrcweir 	long nMax = nVisibleCount * pView->GetEntryHeight();
1512cdf0e10cSrcweir 	if( nY >= nMax )
1513cdf0e10cSrcweir 		return sal_False;
1514cdf0e10cSrcweir 	return sal_True;
1515cdf0e10cSrcweir }
1516cdf0e10cSrcweir 
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir long SvImpLBox::GetEntryLine( SvLBoxEntry* pEntry ) const
1519cdf0e10cSrcweir {
1520cdf0e10cSrcweir 	if(!pStartEntry )
1521cdf0e10cSrcweir 		return -1; // unsichtbare Position
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir 	long nFirstVisPos = pView->GetVisiblePos( pStartEntry );
1524cdf0e10cSrcweir 	long nEntryVisPos = pView->GetVisiblePos( pEntry );
1525cdf0e10cSrcweir 	nFirstVisPos = nEntryVisPos - nFirstVisPos;
1526cdf0e10cSrcweir 	nFirstVisPos *= pView->GetEntryHeight();
1527cdf0e10cSrcweir 	return nFirstVisPos;
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir 
1530cdf0e10cSrcweir void SvImpLBox::SetEntryHeight( short /* nHeight */ )
1531cdf0e10cSrcweir {
1532cdf0e10cSrcweir 	SetNodeBmpYOffset( GetExpandedNodeBmp() );
1533cdf0e10cSrcweir 	SetNodeBmpYOffset( GetCollapsedNodeBmp() );
1534cdf0e10cSrcweir 	if(!pView->HasViewData()) // stehen wir im Clear?
1535cdf0e10cSrcweir 	{
1536cdf0e10cSrcweir 		Size aSize = pView->Control::GetOutputSizePixel();
1537cdf0e10cSrcweir 		AdjustScrollBars( aSize );
1538cdf0e10cSrcweir 	}
1539cdf0e10cSrcweir 	else
1540cdf0e10cSrcweir 	{
1541cdf0e10cSrcweir 		Resize();
1542cdf0e10cSrcweir 		if( GetUpdateMode() )
1543cdf0e10cSrcweir 			pView->Invalidate();
1544cdf0e10cSrcweir 	}
1545cdf0e10cSrcweir }
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir // ***********************************************************************
1550cdf0e10cSrcweir // Callback-Functions
1551cdf0e10cSrcweir // ***********************************************************************
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir void SvImpLBox::IndentChanged( short /* nIndentPixel */ ) {}
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir void SvImpLBox::EntryExpanded( SvLBoxEntry* pEntry )
1556cdf0e10cSrcweir {
1557cdf0e10cSrcweir 	// SelAllDestrAnch( sal_False, sal_True ); //DeselectAll();
1558cdf0e10cSrcweir 	if( GetUpdateMode() )
1559cdf0e10cSrcweir 	{
1560cdf0e10cSrcweir 		ShowCursor( sal_False );
1561cdf0e10cSrcweir 		long nY = GetEntryLine( pEntry );
1562cdf0e10cSrcweir 		if( IsLineVisible(nY) )
1563cdf0e10cSrcweir 		{
1564cdf0e10cSrcweir 			InvalidateEntriesFrom( nY );
1565cdf0e10cSrcweir 			FindMostRight( pEntry, 0  );
1566cdf0e10cSrcweir 		}
1567cdf0e10cSrcweir 		aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1 ) );
1568cdf0e10cSrcweir 		// falls vor dem Thumb expandiert wurde, muss
1569cdf0e10cSrcweir 		// die Thumb-Position korrigiert werden.
1570cdf0e10cSrcweir 		SyncVerThumb();
1571cdf0e10cSrcweir 		ShowVerSBar();
1572cdf0e10cSrcweir 		ShowCursor( sal_True );
1573cdf0e10cSrcweir 	}
1574cdf0e10cSrcweir }
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir void SvImpLBox::EntryCollapsed( SvLBoxEntry* pEntry )
1577cdf0e10cSrcweir {
1578cdf0e10cSrcweir 	if( !pView->IsEntryVisible( pEntry ) )
1579cdf0e10cSrcweir 		return;
1580cdf0e10cSrcweir 
1581cdf0e10cSrcweir 	ShowCursor( sal_False );
1582cdf0e10cSrcweir 
1583cdf0e10cSrcweir 	if( !pMostRightEntry || pTree->IsChild( pEntry,pMostRightEntry ) )
1584cdf0e10cSrcweir 	{
1585cdf0e10cSrcweir 		FindMostRight(0);
1586cdf0e10cSrcweir 	}
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir 	if( pStartEntry )
1589cdf0e10cSrcweir 	{
1590cdf0e10cSrcweir 		long nOldThumbPos   = aVerSBar.GetThumbPos();
1591cdf0e10cSrcweir 		sal_uLong nVisList      = pView->GetVisibleCount();
1592cdf0e10cSrcweir 		aVerSBar.SetRange( Range(0, nVisList-1) );
1593cdf0e10cSrcweir 		long nNewThumbPos   = aVerSBar.GetThumbPos();
1594cdf0e10cSrcweir 		if( nNewThumbPos != nOldThumbPos  )
1595cdf0e10cSrcweir 		{
1596cdf0e10cSrcweir 			pStartEntry = pView->First();
1597cdf0e10cSrcweir 			sal_uInt16 nDistance = (sal_uInt16)nNewThumbPos;
1598cdf0e10cSrcweir 			if( nDistance )
1599cdf0e10cSrcweir 				pStartEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry,
1600cdf0e10cSrcweir 														nDistance));
1601cdf0e10cSrcweir 			if( GetUpdateMode() )
1602cdf0e10cSrcweir 				pView->Invalidate();
1603cdf0e10cSrcweir 		}
1604cdf0e10cSrcweir 		else
1605cdf0e10cSrcweir 			SyncVerThumb();
1606cdf0e10cSrcweir 		ShowVerSBar();
1607cdf0e10cSrcweir 	}
1608cdf0e10cSrcweir 	// wurde Cursor eingeklappt ?
1609cdf0e10cSrcweir 	if( pTree->IsChild( pEntry, pCursor ) )
1610cdf0e10cSrcweir 		SetCursor( pEntry );
1611cdf0e10cSrcweir 	if( GetUpdateMode() )
1612cdf0e10cSrcweir 		ShowVerSBar();
1613cdf0e10cSrcweir 	ShowCursor( sal_True );
1614cdf0e10cSrcweir 	if( GetUpdateMode() && pCursor )
1615cdf0e10cSrcweir 		pView->Select( pCursor, sal_True );
1616cdf0e10cSrcweir }
1617cdf0e10cSrcweir 
1618cdf0e10cSrcweir void SvImpLBox::CollapsingEntry( SvLBoxEntry* pEntry )
1619cdf0e10cSrcweir {
1620cdf0e10cSrcweir 	if( !pView->IsEntryVisible( pEntry ) || !pStartEntry )
1621cdf0e10cSrcweir 		return;
1622cdf0e10cSrcweir 
1623cdf0e10cSrcweir 	SelAllDestrAnch( sal_False, sal_True ); // deselectall
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir 	// ist der eingeklappte Parent sichtbar ?
1626cdf0e10cSrcweir 	long nY = GetEntryLine( pEntry );
1627cdf0e10cSrcweir 	if( IsLineVisible(nY) )
1628cdf0e10cSrcweir 	{
1629cdf0e10cSrcweir 		if( GetUpdateMode() )
1630cdf0e10cSrcweir 			InvalidateEntriesFrom( nY );
1631cdf0e10cSrcweir 	}
1632cdf0e10cSrcweir 	else
1633cdf0e10cSrcweir 	{
1634cdf0e10cSrcweir 		if( pTree->IsChild(pEntry, pStartEntry) )
1635cdf0e10cSrcweir 		{
1636cdf0e10cSrcweir 			pStartEntry = pEntry;
1637cdf0e10cSrcweir 			if( GetUpdateMode() )
1638cdf0e10cSrcweir 				pView->Invalidate();
1639cdf0e10cSrcweir 		}
1640cdf0e10cSrcweir 	}
1641cdf0e10cSrcweir }
1642cdf0e10cSrcweir 
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir void SvImpLBox::SetNodeBmpYOffset( const Image& rBmp )
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir 	Size aSize;
1647cdf0e10cSrcweir 	nYoffsNodeBmp = pView->GetHeightOffset( rBmp, aSize );
1648cdf0e10cSrcweir 	nNodeBmpWidth = aSize.Width();
1649cdf0e10cSrcweir }
1650cdf0e10cSrcweir 
1651cdf0e10cSrcweir void SvImpLBox::SetNodeBmpTabDistance()
1652cdf0e10cSrcweir {
1653cdf0e10cSrcweir 	nNodeBmpTabDistance = -pView->GetIndent();
1654cdf0e10cSrcweir 	if( pView->nContextBmpWidthMax )
1655cdf0e10cSrcweir 	{
1656cdf0e10cSrcweir 		// nur, wenn der erste dynamische Tab zentriert ist
1657cdf0e10cSrcweir 		// (setze ich momentan voraus)
1658cdf0e10cSrcweir 		Size aSize = GetExpandedNodeBmp().GetSizePixel();
1659cdf0e10cSrcweir 		nNodeBmpTabDistance -= aSize.Width() / 2;
1660cdf0e10cSrcweir 	}
1661cdf0e10cSrcweir }
1662cdf0e10cSrcweir 
1663cdf0e10cSrcweir //
1664cdf0e10cSrcweir // korrigiert bei SingleSelection den Cursor
1665cdf0e10cSrcweir //
1666cdf0e10cSrcweir void SvImpLBox::EntrySelected( SvLBoxEntry* pEntry, sal_Bool bSelect )
1667cdf0e10cSrcweir {
1668cdf0e10cSrcweir 	if( nFlags & F_IGNORE_SELECT )
1669cdf0e10cSrcweir 		return;
1670cdf0e10cSrcweir 
1671cdf0e10cSrcweir 	/*
1672cdf0e10cSrcweir 	if( (m_nStyle & WB_HIDESELECTION) && pEntry && !pView->HasFocus() )
1673cdf0e10cSrcweir 	{
1674cdf0e10cSrcweir 		SvViewData* pViewData = pView->GetViewData( pEntry );
1675cdf0e10cSrcweir 		pViewData->SetCursored( bSelect );
1676cdf0e10cSrcweir 	}
1677cdf0e10cSrcweir 	*/
1678cdf0e10cSrcweir 
1679cdf0e10cSrcweir 	nFlags &= (~F_DESEL_ALL);
1680cdf0e10cSrcweir 	if( bSelect &&
1681cdf0e10cSrcweir 		aSelEng.GetSelectionMode() == SINGLE_SELECTION &&
1682cdf0e10cSrcweir 		pEntry != pCursor )
1683cdf0e10cSrcweir 	{
1684cdf0e10cSrcweir 		SetCursor( pEntry );
1685cdf0e10cSrcweir 		DBG_ASSERT(pView->GetSelectionCount()==1,"selection count?");
1686cdf0e10cSrcweir 	}
1687cdf0e10cSrcweir 
1688cdf0e10cSrcweir 	if( GetUpdateMode() && pView->IsEntryVisible(pEntry) )
1689cdf0e10cSrcweir 	{
1690cdf0e10cSrcweir 		long nY = GetEntryLine( pEntry );
1691cdf0e10cSrcweir 		if( IsLineVisible( nY ) )
1692cdf0e10cSrcweir 		{
1693cdf0e10cSrcweir 			ShowCursor( sal_False );
1694cdf0e10cSrcweir 			pView->PaintEntry1( pEntry, nY, 0xffff ); // wg. ItemsetBrowser SV_LBOXTAB_SHOW_SELECTION );
1695cdf0e10cSrcweir 			ShowCursor( sal_True );
1696cdf0e10cSrcweir 		}
1697cdf0e10cSrcweir 	}
1698cdf0e10cSrcweir }
1699cdf0e10cSrcweir 
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir void SvImpLBox::RemovingEntry( SvLBoxEntry* pEntry )
1702cdf0e10cSrcweir {
1703cdf0e10cSrcweir 	DestroyAnchor();
1704cdf0e10cSrcweir 
1705cdf0e10cSrcweir 	if( !pView->IsEntryVisible( pEntry ) )
1706cdf0e10cSrcweir 	{
1707cdf0e10cSrcweir 		// wenn Parent eingeklappt, dann tschuess
1708cdf0e10cSrcweir 		nFlags |= F_REMOVED_ENTRY_INVISIBLE;
1709cdf0e10cSrcweir 		return;
1710cdf0e10cSrcweir 	}
1711cdf0e10cSrcweir 
1712cdf0e10cSrcweir 	if( pEntry == pMostRightEntry || (
1713cdf0e10cSrcweir 		pEntry->HasChilds() && pView->IsExpanded(pEntry) &&
1714cdf0e10cSrcweir 		pTree->IsChild(pEntry, pMostRightEntry)))
1715cdf0e10cSrcweir 	{
1716cdf0e10cSrcweir 		nFlags |= F_REMOVED_RECALC_MOST_RIGHT;
1717cdf0e10cSrcweir 	}
1718cdf0e10cSrcweir 
1719cdf0e10cSrcweir 	SvLBoxEntry* pOldStartEntry = pStartEntry;
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir 	SvLBoxEntry* pParent = (SvLBoxEntry*)(pView->GetModel()->GetParent(pEntry));
1722cdf0e10cSrcweir 
1723cdf0e10cSrcweir 	if( pParent && pView->GetModel()->GetChildList(pParent)->Count() == 1 )
1724cdf0e10cSrcweir 	{
1725cdf0e10cSrcweir 		DBG_ASSERT( pView->IsExpanded( pParent ), "Parent not expanded");
1726cdf0e10cSrcweir 		pParent->SetFlags( pParent->GetFlags() | SV_ENTRYFLAG_NO_NODEBMP);
1727cdf0e10cSrcweir 		InvalidateEntry( pParent );
1728cdf0e10cSrcweir 	}
1729cdf0e10cSrcweir 
1730cdf0e10cSrcweir 	if( pCursor && pTree->IsChild( pEntry, pCursor) )
1731cdf0e10cSrcweir 		pCursor = pEntry;
1732cdf0e10cSrcweir 	if( pStartEntry && pTree->IsChild(pEntry,pStartEntry) )
1733cdf0e10cSrcweir 		pStartEntry = pEntry;
1734cdf0e10cSrcweir 
1735cdf0e10cSrcweir 	SvLBoxEntry* pTemp;
1736cdf0e10cSrcweir 	if( pCursor && pCursor == pEntry )
1737cdf0e10cSrcweir 	{
1738cdf0e10cSrcweir 		if( bSimpleTravel )
1739cdf0e10cSrcweir 			pView->Select( pCursor, sal_False );
1740cdf0e10cSrcweir 		ShowCursor( sal_False );	// Focus-Rect weg
1741cdf0e10cSrcweir 		// NextSibling, weil auch Childs des Cursors geloescht werden
1742cdf0e10cSrcweir 		pTemp = pView->NextSibling( pCursor );
1743cdf0e10cSrcweir 		if( !pTemp )
1744cdf0e10cSrcweir 			pTemp = (SvLBoxEntry*)(pView->PrevVisible( pCursor ));
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir 		SetCursor( pTemp, sal_True );
1747cdf0e10cSrcweir 	}
1748cdf0e10cSrcweir 	if( pStartEntry && pStartEntry == pEntry )
1749cdf0e10cSrcweir 	{
1750cdf0e10cSrcweir 		pTemp = pView->NextSibling( pStartEntry );
1751cdf0e10cSrcweir 		if( !pTemp )
1752cdf0e10cSrcweir 			pTemp = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry ));
1753cdf0e10cSrcweir 		pStartEntry = pTemp;
1754cdf0e10cSrcweir 	}
1755cdf0e10cSrcweir 	if( GetUpdateMode())
1756cdf0e10cSrcweir 	{
1757cdf0e10cSrcweir 		// wenns der letzte ist, muss invalidiert werden, damit die Linien
1758cdf0e10cSrcweir 		// richtig gezeichnet (in diesem Fall geloescht) werden.
1759cdf0e10cSrcweir 		if( pStartEntry && (pStartEntry != pOldStartEntry || pEntry == (SvLBoxEntry*)pView->GetModel()->Last()) )
1760cdf0e10cSrcweir 		{
1761cdf0e10cSrcweir 			aVerSBar.SetThumbPos( pView->GetVisiblePos( pStartEntry ));
1762cdf0e10cSrcweir 			pView->Invalidate( GetVisibleArea() );
1763cdf0e10cSrcweir 		}
1764cdf0e10cSrcweir 		else
1765cdf0e10cSrcweir 			InvalidateEntriesFrom( GetEntryLine( pEntry ) );
1766cdf0e10cSrcweir 	}
1767cdf0e10cSrcweir }
1768cdf0e10cSrcweir 
1769cdf0e10cSrcweir void SvImpLBox::EntryRemoved()
1770cdf0e10cSrcweir {
1771cdf0e10cSrcweir 	if( nFlags & F_REMOVED_ENTRY_INVISIBLE )
1772cdf0e10cSrcweir 	{
1773cdf0e10cSrcweir 		nFlags &= (~F_REMOVED_ENTRY_INVISIBLE);
1774cdf0e10cSrcweir 		return;
1775cdf0e10cSrcweir 	}
1776cdf0e10cSrcweir 	if( !pStartEntry )
1777cdf0e10cSrcweir 		pStartEntry = pTree->First();
1778cdf0e10cSrcweir 	if( !pCursor )
1779cdf0e10cSrcweir 		SetCursor( pStartEntry, sal_True );
1780cdf0e10cSrcweir 
1781cdf0e10cSrcweir 	if( pCursor && (bSimpleTravel || !pView->GetSelectionCount() ))
1782cdf0e10cSrcweir 		pView->Select( pCursor, sal_True );
1783cdf0e10cSrcweir 
1784cdf0e10cSrcweir 	if( GetUpdateMode())
1785cdf0e10cSrcweir 	{
1786cdf0e10cSrcweir 		if( nFlags & F_REMOVED_RECALC_MOST_RIGHT )
1787cdf0e10cSrcweir 			FindMostRight(0);
1788cdf0e10cSrcweir 		aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1 ) );
1789cdf0e10cSrcweir 		FillView();
1790cdf0e10cSrcweir 		if( pStartEntry )
1791cdf0e10cSrcweir 			// falls ueber dem Thumb geloescht wurde
1792cdf0e10cSrcweir 			aVerSBar.SetThumbPos( pView->GetVisiblePos( pStartEntry) );
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir 		ShowVerSBar();
1795cdf0e10cSrcweir 		if( pCursor && pView->HasFocus() && !pView->IsSelected(pCursor) )
1796cdf0e10cSrcweir 		{
1797cdf0e10cSrcweir 			if( pView->GetSelectionCount() )
1798cdf0e10cSrcweir 			{
1799cdf0e10cSrcweir 				// ist ein benachbarter Eintrag selektiert?
1800cdf0e10cSrcweir 				SvLBoxEntry* pNextCursor = (SvLBoxEntry*)pView->PrevVisible( pCursor );
1801cdf0e10cSrcweir 				if( !pNextCursor || !pView->IsSelected( pNextCursor ))
1802cdf0e10cSrcweir 					pNextCursor = (SvLBoxEntry*)pView->NextVisible( pCursor );
1803cdf0e10cSrcweir 				if( !pNextCursor || !pView->IsSelected( pNextCursor ))
1804cdf0e10cSrcweir 					// kein Nachbar selektiert: Ersten selektierten nehmen
1805cdf0e10cSrcweir 					pNextCursor = pView->FirstSelected();
1806cdf0e10cSrcweir 				SetCursor( pNextCursor );
1807cdf0e10cSrcweir 				MakeVisible( pCursor );
1808cdf0e10cSrcweir 			}
1809cdf0e10cSrcweir 			else
1810cdf0e10cSrcweir 				pView->Select( pCursor, sal_True );
1811cdf0e10cSrcweir 		}
1812cdf0e10cSrcweir 		ShowCursor( sal_True );
1813cdf0e10cSrcweir 	}
1814cdf0e10cSrcweir 	nFlags &= (~F_REMOVED_RECALC_MOST_RIGHT);
1815cdf0e10cSrcweir }
1816cdf0e10cSrcweir 
1817cdf0e10cSrcweir 
1818cdf0e10cSrcweir void SvImpLBox::MovingEntry( SvLBoxEntry* pEntry )
1819cdf0e10cSrcweir {
1820cdf0e10cSrcweir 	int bDeselAll = nFlags & F_DESEL_ALL;
1821cdf0e10cSrcweir 	SelAllDestrAnch( sal_False, sal_True );  // DeselectAll();
1822cdf0e10cSrcweir 	if( !bDeselAll )
1823cdf0e10cSrcweir 		nFlags &= (~F_DESEL_ALL);
1824cdf0e10cSrcweir 
1825cdf0e10cSrcweir 	if( pEntry == pCursor )
1826cdf0e10cSrcweir 		ShowCursor( sal_False );
1827cdf0e10cSrcweir 	if( IsEntryInView( pEntry ) )
1828cdf0e10cSrcweir 		pView->Invalidate();
1829cdf0e10cSrcweir 	if( pEntry == pStartEntry )
1830cdf0e10cSrcweir 	{
1831cdf0e10cSrcweir 		SvLBoxEntry* pNew = 0;
1832cdf0e10cSrcweir 		if( !pEntry->HasChilds() )
1833cdf0e10cSrcweir 		{
1834cdf0e10cSrcweir 			pNew = (SvLBoxEntry*)(pView->NextVisible( pStartEntry ));
1835cdf0e10cSrcweir 			if( !pNew )
1836cdf0e10cSrcweir 				pNew = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry ));
1837cdf0e10cSrcweir 		}
1838cdf0e10cSrcweir 		else
1839cdf0e10cSrcweir 		{
1840cdf0e10cSrcweir 			pNew = pTree->NextSibling( pEntry );
1841cdf0e10cSrcweir 			if( !pNew )
1842cdf0e10cSrcweir 				pNew = pTree->PrevSibling( pEntry );
1843cdf0e10cSrcweir 		}
1844cdf0e10cSrcweir 		pStartEntry = pNew;
1845cdf0e10cSrcweir 	}
1846cdf0e10cSrcweir }
1847cdf0e10cSrcweir 
1848cdf0e10cSrcweir void SvImpLBox::EntryMoved( SvLBoxEntry* pEntry )
1849cdf0e10cSrcweir {
1850cdf0e10cSrcweir 	// #97680# --------------
1851cdf0e10cSrcweir 	UpdateContextBmpWidthVectorFromMovedEntry( pEntry );
1852cdf0e10cSrcweir 
1853cdf0e10cSrcweir     if ( !pStartEntry )
1854cdf0e10cSrcweir         // this might happen if the only entry in the view is moved to its very same position
1855cdf0e10cSrcweir         // #i97346#
1856cdf0e10cSrcweir         pStartEntry = pView->First();
1857cdf0e10cSrcweir 
1858cdf0e10cSrcweir 	aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1));
1859cdf0e10cSrcweir 	sal_uInt16 nFirstPos = (sal_uInt16)pTree->GetAbsPos( pStartEntry );
1860cdf0e10cSrcweir 	sal_uInt16 nNewPos = (sal_uInt16)pTree->GetAbsPos( pEntry );
1861cdf0e10cSrcweir 	FindMostRight(0);
1862cdf0e10cSrcweir 	if( nNewPos < nFirstPos ) //!!!Notloesung
1863cdf0e10cSrcweir 		pStartEntry = pEntry;
1864cdf0e10cSrcweir 	// #97702# ---------------
1865cdf0e10cSrcweir 	SyncVerThumb();
1866cdf0e10cSrcweir 	if( pEntry == pCursor )
1867cdf0e10cSrcweir 	{
1868cdf0e10cSrcweir 		if( pView->IsEntryVisible( pCursor ) )
1869cdf0e10cSrcweir 			ShowCursor( sal_True );
1870cdf0e10cSrcweir 		else
1871cdf0e10cSrcweir 		{
1872cdf0e10cSrcweir 			SvLBoxEntry* pParent = pEntry;
1873cdf0e10cSrcweir 			do {
1874cdf0e10cSrcweir 				pParent = pTree->GetParent( pParent );
1875cdf0e10cSrcweir 			}
1876cdf0e10cSrcweir 			while( !pView->IsEntryVisible( pParent ) );
1877cdf0e10cSrcweir 			SetCursor( pParent );
1878cdf0e10cSrcweir 		}
1879cdf0e10cSrcweir 	}
1880cdf0e10cSrcweir 	if( IsEntryInView( pEntry ) )
1881cdf0e10cSrcweir 		pView->Invalidate();
1882cdf0e10cSrcweir }
1883cdf0e10cSrcweir 
1884cdf0e10cSrcweir 
1885cdf0e10cSrcweir 
1886cdf0e10cSrcweir void SvImpLBox::EntryInserted( SvLBoxEntry* pEntry )
1887cdf0e10cSrcweir {
1888cdf0e10cSrcweir 	if( GetUpdateMode() )
1889cdf0e10cSrcweir 	{
1890cdf0e10cSrcweir 		SvLBoxEntry* pParent = (SvLBoxEntry*)pTree->GetParent(pEntry);
1891cdf0e10cSrcweir 		if( pParent && pTree->GetChildList(pParent)->Count() == 1 )
1892cdf0e10cSrcweir 			// Pluszeichen zeichnen
1893cdf0e10cSrcweir 			pTree->InvalidateEntry( pParent );
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir 		if( !pView->IsEntryVisible( pEntry ) )
1896cdf0e10cSrcweir 			return;
1897cdf0e10cSrcweir 		int bDeselAll = nFlags & F_DESEL_ALL;
1898cdf0e10cSrcweir 		if( bDeselAll )
1899cdf0e10cSrcweir 			SelAllDestrAnch( sal_False, sal_True );
1900cdf0e10cSrcweir 		else
1901cdf0e10cSrcweir 			DestroyAnchor();
1902cdf0e10cSrcweir 		//	nFlags &= (~F_DESEL_ALL);
1903cdf0e10cSrcweir //		ShowCursor( sal_False ); // falls sich Cursor nach unten verschiebt
1904cdf0e10cSrcweir 		long nY = GetEntryLine( pEntry );
1905cdf0e10cSrcweir 		sal_Bool bEntryVisible = IsLineVisible( nY );
1906cdf0e10cSrcweir 		if( bEntryVisible )
1907cdf0e10cSrcweir 		{
1908cdf0e10cSrcweir 			ShowCursor( sal_False ); // falls sich Cursor nach unten verschiebt
1909cdf0e10cSrcweir 			nY -= pView->GetEntryHeight(); // wg. Linien
1910cdf0e10cSrcweir 			InvalidateEntriesFrom( nY );
1911cdf0e10cSrcweir 		}
1912cdf0e10cSrcweir 		else if( pStartEntry && nY < GetEntryLine(pStartEntry) )
1913cdf0e10cSrcweir 		{
1914cdf0e10cSrcweir 			// pruefen, ob die View komplett gefuellt ist. Wenn
1915cdf0e10cSrcweir 			// nicht, dann pStartEntry und den Cursor anpassen
1916cdf0e10cSrcweir 			// (automatisches scrollen)
1917cdf0e10cSrcweir 			sal_uInt16 nLast = (sal_uInt16)(pView->GetVisiblePos( (SvLBoxEntry*)(pView->LastVisible())));
1918cdf0e10cSrcweir 			sal_uInt16 nThumb = (sal_uInt16)(pView->GetVisiblePos( pStartEntry ));
1919cdf0e10cSrcweir 			sal_uInt16 nCurDispEntries = nLast-nThumb+1;
1920cdf0e10cSrcweir 			if( nCurDispEntries < nVisibleCount )
1921cdf0e10cSrcweir 			{
1922cdf0e10cSrcweir 				// beim naechsten Paint-Event setzen
1923cdf0e10cSrcweir 				pStartEntry = 0;
1924cdf0e10cSrcweir 				SetCursor( 0 );
1925cdf0e10cSrcweir 				pView->Invalidate();
1926cdf0e10cSrcweir 			}
1927cdf0e10cSrcweir 		}
1928cdf0e10cSrcweir 		else if( !pStartEntry )
1929cdf0e10cSrcweir 			pView->Invalidate();
1930cdf0e10cSrcweir 
1931cdf0e10cSrcweir 		// die Linien invalidieren
1932cdf0e10cSrcweir 		/*
1933cdf0e10cSrcweir 		if( (bEntryVisible || bPrevEntryVisible) &&
1934cdf0e10cSrcweir 			(m_nStyle & ( WB_HASLINES | WB_HASLINESATROOT )) )
1935cdf0e10cSrcweir 		{
1936cdf0e10cSrcweir 			SvLBoxTab* pTab = pView->GetFirstDynamicTab();
1937cdf0e10cSrcweir 			if( pTab )
1938cdf0e10cSrcweir 			{
1939cdf0e10cSrcweir 				long nDX = pView->GetTabPos( pEntry, pTab );
1940cdf0e10cSrcweir 				Point aTmpPoint;
1941cdf0e10cSrcweir 				Size aSize( nDX, nY );
1942cdf0e10cSrcweir 				Rectangle aRect( aTmpPoint, aSize );
1943cdf0e10cSrcweir 				pView->Invalidate( aRect );
1944cdf0e10cSrcweir 			}
1945cdf0e10cSrcweir 		}
1946cdf0e10cSrcweir 		*/
1947cdf0e10cSrcweir 
1948cdf0e10cSrcweir 		SetMostRight( pEntry );
1949cdf0e10cSrcweir 		aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1));
1950cdf0e10cSrcweir 		SyncVerThumb(); // falls vor Thumb eingefuegt wurde
1951cdf0e10cSrcweir 		ShowVerSBar();
1952cdf0e10cSrcweir 		ShowCursor( sal_True );
1953cdf0e10cSrcweir 		if( pStartEntry != pView->First() && (nFlags & F_FILLING) )
1954cdf0e10cSrcweir 			pView->Update();
1955cdf0e10cSrcweir 	}
1956cdf0e10cSrcweir }
1957cdf0e10cSrcweir 
1958cdf0e10cSrcweir 
1959cdf0e10cSrcweir 
1960cdf0e10cSrcweir // ********************************************************************
1961cdf0e10cSrcweir // Eventhandler
1962cdf0e10cSrcweir // ********************************************************************
1963cdf0e10cSrcweir 
1964cdf0e10cSrcweir 
1965cdf0e10cSrcweir // ****** Steuerung der Controlanimation
1966cdf0e10cSrcweir 
1967cdf0e10cSrcweir sal_Bool SvImpLBox::ButtonDownCheckCtrl(const MouseEvent& rMEvt, SvLBoxEntry* pEntry,
1968cdf0e10cSrcweir 								   long nY	)
1969cdf0e10cSrcweir {
1970cdf0e10cSrcweir 	SvLBoxItem* pItem = pView->GetItem(pEntry,rMEvt.GetPosPixel().X(),&pActiveTab);
1971cdf0e10cSrcweir 	if( pItem && (pItem->IsA()==SV_ITEM_ID_LBOXBUTTON))
1972cdf0e10cSrcweir 	{
1973cdf0e10cSrcweir 		pActiveButton = (SvLBoxButton*)pItem;
1974cdf0e10cSrcweir 		pActiveEntry = pEntry;
1975cdf0e10cSrcweir 		if( pCursor == pActiveEntry )
1976cdf0e10cSrcweir 			pView->HideFocus();
1977cdf0e10cSrcweir 		pView->CaptureMouse();
1978cdf0e10cSrcweir 		pActiveButton->SetStateHilighted( sal_True );
1979cdf0e10cSrcweir 		pView->PaintEntry1( pActiveEntry, nY,
1980cdf0e10cSrcweir 					SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER |
1981cdf0e10cSrcweir 					SV_LBOXTAB_ADJUST_RIGHT );
1982cdf0e10cSrcweir 		return sal_True;
1983cdf0e10cSrcweir 	}
1984cdf0e10cSrcweir 	else
1985cdf0e10cSrcweir 		pActiveButton = 0;
1986cdf0e10cSrcweir 	return sal_False;
1987cdf0e10cSrcweir }
1988cdf0e10cSrcweir 
1989cdf0e10cSrcweir sal_Bool SvImpLBox::MouseMoveCheckCtrl( const MouseEvent& rMEvt, SvLBoxEntry* pEntry)
1990cdf0e10cSrcweir {
1991cdf0e10cSrcweir 	if( pActiveButton )
1992cdf0e10cSrcweir 	{
1993cdf0e10cSrcweir 		long nY;
1994cdf0e10cSrcweir 		long nMouseX = rMEvt.GetPosPixel().X();
1995cdf0e10cSrcweir 		if( pEntry == pActiveEntry &&
1996cdf0e10cSrcweir 			 pView->GetItem(pActiveEntry, nMouseX) == pActiveButton )
1997cdf0e10cSrcweir 		{
1998cdf0e10cSrcweir 			if( !pActiveButton->IsStateHilighted() )
1999cdf0e10cSrcweir 			{
2000cdf0e10cSrcweir 				pActiveButton->SetStateHilighted(sal_True );
2001cdf0e10cSrcweir 				nY = GetEntryLine( pActiveEntry );
2002cdf0e10cSrcweir 				pView->PaintEntry1( pActiveEntry, nY,
2003cdf0e10cSrcweir 					SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER |
2004cdf0e10cSrcweir 					SV_LBOXTAB_ADJUST_RIGHT );
2005cdf0e10cSrcweir 			}
2006cdf0e10cSrcweir 		}
2007cdf0e10cSrcweir 		else
2008cdf0e10cSrcweir 		{
2009cdf0e10cSrcweir 			if( pActiveButton->IsStateHilighted() )
2010cdf0e10cSrcweir 			{
2011cdf0e10cSrcweir 				pActiveButton->SetStateHilighted(sal_False );
2012cdf0e10cSrcweir 				nY = GetEntryLine( pActiveEntry );
2013cdf0e10cSrcweir 				pView->PaintEntry1( pActiveEntry, nY, SV_LBOXTAB_PUSHABLE );
2014cdf0e10cSrcweir 			}
2015cdf0e10cSrcweir 		}
2016cdf0e10cSrcweir 		return sal_True;
2017cdf0e10cSrcweir 	}
2018cdf0e10cSrcweir 	return sal_False;
2019cdf0e10cSrcweir }
2020cdf0e10cSrcweir 
2021cdf0e10cSrcweir sal_Bool SvImpLBox::ButtonUpCheckCtrl( const MouseEvent& rMEvt )
2022cdf0e10cSrcweir {
2023cdf0e10cSrcweir 	if( pActiveButton )
2024cdf0e10cSrcweir 	{
2025cdf0e10cSrcweir 		pView->ReleaseMouse();
2026cdf0e10cSrcweir 		SvLBoxEntry* pEntry = GetClickedEntry( rMEvt.GetPosPixel() );
2027cdf0e10cSrcweir 		long nY = GetEntryLine( pActiveEntry );
2028cdf0e10cSrcweir 		pActiveButton->SetStateHilighted( sal_False );
2029cdf0e10cSrcweir 		long nMouseX = rMEvt.GetPosPixel().X();
2030cdf0e10cSrcweir 		if( pEntry == pActiveEntry &&
2031cdf0e10cSrcweir 			 pView->GetItem( pActiveEntry, nMouseX ) == pActiveButton )
2032cdf0e10cSrcweir 			pActiveButton->ClickHdl( pView, pActiveEntry );
2033cdf0e10cSrcweir 		pView->PaintEntry1( pActiveEntry, nY,
2034cdf0e10cSrcweir 					SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER |
2035cdf0e10cSrcweir 					SV_LBOXTAB_ADJUST_RIGHT );
2036cdf0e10cSrcweir 		if( pCursor == pActiveEntry )
2037cdf0e10cSrcweir 			ShowCursor( sal_True );
2038cdf0e10cSrcweir 		pActiveButton = 0;
2039cdf0e10cSrcweir 		pActiveEntry = 0;
2040cdf0e10cSrcweir 		pActiveTab = 0;
2041cdf0e10cSrcweir 		return sal_True;
2042cdf0e10cSrcweir 	}
2043cdf0e10cSrcweir 	return sal_False;
2044cdf0e10cSrcweir }
2045cdf0e10cSrcweir 
2046cdf0e10cSrcweir // ******* Steuerung Plus/Minus-Button zum Expandieren/Kollabieren
2047cdf0e10cSrcweir 
2048cdf0e10cSrcweir // sal_False == kein Expand/Collapse-Button getroffen
2049cdf0e10cSrcweir sal_Bool SvImpLBox::IsNodeButton( const Point& rPosPixel, SvLBoxEntry* pEntry ) const
2050cdf0e10cSrcweir {
2051cdf0e10cSrcweir 	if( !pEntry->HasChilds() && !pEntry->HasChildsOnDemand() )
2052cdf0e10cSrcweir 		return sal_False;
2053cdf0e10cSrcweir 
2054cdf0e10cSrcweir 	SvLBoxTab* pFirstDynamicTab = pView->GetFirstDynamicTab();
2055cdf0e10cSrcweir 	if( !pFirstDynamicTab )
2056cdf0e10cSrcweir 		return sal_False;
2057cdf0e10cSrcweir 
2058cdf0e10cSrcweir 	long nMouseX = rPosPixel.X();
2059cdf0e10cSrcweir 	// in Doc-Koords umrechnen
2060cdf0e10cSrcweir 	Point aOrigin( pView->GetMapMode().GetOrigin() );
2061cdf0e10cSrcweir 	nMouseX -= aOrigin.X();
2062cdf0e10cSrcweir 
2063cdf0e10cSrcweir 	long nX = pView->GetTabPos( pEntry, pFirstDynamicTab);
2064cdf0e10cSrcweir 	nX += nNodeBmpTabDistance;
2065cdf0e10cSrcweir 	if( nMouseX < nX )
2066cdf0e10cSrcweir 		return sal_False;
2067cdf0e10cSrcweir 	nX += nNodeBmpWidth;
2068cdf0e10cSrcweir 	if( nMouseX > nX )
2069cdf0e10cSrcweir 		return sal_False;
2070cdf0e10cSrcweir 	return sal_True;
2071cdf0e10cSrcweir }
2072cdf0e10cSrcweir 
2073cdf0e10cSrcweir // sal_False == hit no node button
2074cdf0e10cSrcweir sal_Bool SvImpLBox::ButtonDownCheckExpand( const MouseEvent& rMEvt, SvLBoxEntry* pEntry, long /* nY */ )
2075cdf0e10cSrcweir {
2076cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
2077cdf0e10cSrcweir 
2078cdf0e10cSrcweir 	if ( pView->IsEditingActive() && pEntry == pView->pEdEntry )
2079cdf0e10cSrcweir 		// inplace editing -> nothing to do
2080cdf0e10cSrcweir 		bRet = sal_True;
2081cdf0e10cSrcweir 	else if ( IsNodeButton( rMEvt.GetPosPixel(), pEntry ) )
2082cdf0e10cSrcweir 	{
2083cdf0e10cSrcweir 		if ( pView->IsExpanded( pEntry ) )
2084cdf0e10cSrcweir 		{
2085cdf0e10cSrcweir 			pView->EndEditing( sal_True );
2086cdf0e10cSrcweir 			pView->Collapse( pEntry );
2087cdf0e10cSrcweir 		}
2088cdf0e10cSrcweir 		else
2089cdf0e10cSrcweir 		{
2090cdf0e10cSrcweir 			// you can expand an entry, which is in editing
2091cdf0e10cSrcweir 			pView->Expand( pEntry );
2092cdf0e10cSrcweir 		}
2093cdf0e10cSrcweir 		bRet = sal_True;
2094cdf0e10cSrcweir 	}
2095cdf0e10cSrcweir 
2096cdf0e10cSrcweir 	return bRet;
2097cdf0e10cSrcweir }
2098cdf0e10cSrcweir 
2099cdf0e10cSrcweir void SvImpLBox::MouseButtonDown( const MouseEvent& rMEvt )
2100cdf0e10cSrcweir {
2101cdf0e10cSrcweir 	if ( !rMEvt.IsLeft() && !rMEvt.IsRight())
2102cdf0e10cSrcweir 		return;
2103cdf0e10cSrcweir 
2104cdf0e10cSrcweir #ifdef OS2
2105cdf0e10cSrcweir 	// unter OS/2 kommt zwischen MouseButtonDown und
2106cdf0e10cSrcweir 	// MouseButtonUp ein MouseMove
2107cdf0e10cSrcweir 	nFlags |= F_IGNORE_NEXT_MOUSEMOVE;
2108cdf0e10cSrcweir #endif
2109cdf0e10cSrcweir 	aEditTimer.Stop();
2110cdf0e10cSrcweir 	Point aPos( rMEvt.GetPosPixel());
2111cdf0e10cSrcweir 
2112cdf0e10cSrcweir 	if( aPos.X() > aOutputSize.Width() || aPos.Y() > aOutputSize.Height() )
2113cdf0e10cSrcweir 		return;
2114cdf0e10cSrcweir 
2115cdf0e10cSrcweir 	SvLBoxEntry* pEntry = GetEntry( aPos );
2116cdf0e10cSrcweir 	if ( pEntry != pCursor )
2117cdf0e10cSrcweir 		// new entry selected -> reset current tab position to first tab
2118cdf0e10cSrcweir 		nCurTabPos = FIRST_ENTRY_TAB;
2119cdf0e10cSrcweir 	nFlags &= (~F_FILLING);
2120cdf0e10cSrcweir 	pView->GrabFocus();
2121cdf0e10cSrcweir 	// #120417# the entry can still be invalid!
2122cdf0e10cSrcweir     if( !pEntry || !pView->GetViewData( pEntry ))
2123cdf0e10cSrcweir 		return;
2124cdf0e10cSrcweir 
2125cdf0e10cSrcweir 	long nY = GetEntryLine( pEntry );
2126cdf0e10cSrcweir 	// Node-Button?
2127cdf0e10cSrcweir 	if( ButtonDownCheckExpand( rMEvt, pEntry, nY ) )
2128cdf0e10cSrcweir 		return;
2129cdf0e10cSrcweir 
2130cdf0e10cSrcweir 	if( !EntryReallyHit(pEntry,aPos,nY))
2131cdf0e10cSrcweir 		return;
2132cdf0e10cSrcweir 
2133cdf0e10cSrcweir 	SvLBoxItem* pXItem = pView->GetItem( pEntry, aPos.X() );
2134cdf0e10cSrcweir 	if( pXItem )
2135cdf0e10cSrcweir 	{
2136cdf0e10cSrcweir 		SvLBoxTab* pXTab = pView->GetTab( pEntry, pXItem );
2137cdf0e10cSrcweir 		if ( !rMEvt.IsMod1() && !rMEvt.IsMod2() && rMEvt.IsLeft() && pXTab->IsEditable()
2138cdf0e10cSrcweir 			&& pEntry == pView->FirstSelected() && NULL == pView->NextSelected( pEntry ) )
2139cdf0e10cSrcweir 				// #i8234# FirstSelected() and NextSelected() ensures, that inplace editing is only triggered, when only one entry is selected
2140cdf0e10cSrcweir 			nFlags |= F_START_EDITTIMER;
2141cdf0e10cSrcweir 		if ( !pView->IsSelected( pEntry ) )
2142cdf0e10cSrcweir 			nFlags &= ~F_START_EDITTIMER;
2143cdf0e10cSrcweir 	}
2144cdf0e10cSrcweir 
2145cdf0e10cSrcweir 
2146cdf0e10cSrcweir 	if( (rMEvt.GetClicks() % 2) == 0 )
2147cdf0e10cSrcweir 	{
2148cdf0e10cSrcweir 		nFlags &= (~F_START_EDITTIMER);
2149cdf0e10cSrcweir 		pView->pHdlEntry = pEntry;
2150cdf0e10cSrcweir 		if( pView->DoubleClickHdl() )
2151cdf0e10cSrcweir 		{
2152cdf0e10cSrcweir 			// falls im Handler der Eintrag geloescht wurde
2153cdf0e10cSrcweir 			pEntry = GetClickedEntry( aPos );
2154cdf0e10cSrcweir 			if( !pEntry )
2155cdf0e10cSrcweir 				return;
2156cdf0e10cSrcweir 			if( pEntry != pView->pHdlEntry )
2157cdf0e10cSrcweir 			{
2158cdf0e10cSrcweir 				// neu selektieren & tschuess
2159cdf0e10cSrcweir 				if( !bSimpleTravel && !aSelEng.IsAlwaysAdding())
2160cdf0e10cSrcweir 					SelAllDestrAnch( sal_False, sal_True ); // DeselectAll();
2161cdf0e10cSrcweir 				SetCursor( pEntry );
2162cdf0e10cSrcweir 
2163cdf0e10cSrcweir 				return;
2164cdf0e10cSrcweir 			}
2165cdf0e10cSrcweir 			if( pEntry->HasChilds() || pEntry->HasChildsOnDemand() )
2166cdf0e10cSrcweir 			{
2167cdf0e10cSrcweir 				if( pView->IsExpanded(pEntry) )
2168cdf0e10cSrcweir 					pView->Collapse( pEntry );
2169cdf0e10cSrcweir 				else
2170cdf0e10cSrcweir 					pView->Expand( pEntry );
2171cdf0e10cSrcweir 				if( pEntry == pCursor )  // nur wenn Entryitem angeklickt wurde
2172cdf0e10cSrcweir 										  // (Nodebutton ist kein Entryitem!)
2173cdf0e10cSrcweir 					pView->Select( pCursor, sal_True );
2174cdf0e10cSrcweir 				return;
2175cdf0e10cSrcweir 			}
2176cdf0e10cSrcweir 		}
2177cdf0e10cSrcweir 	}
2178cdf0e10cSrcweir 	else
2179cdf0e10cSrcweir 	{
2180cdf0e10cSrcweir 		// CheckButton? (TreeListBox: Check + Info)
2181cdf0e10cSrcweir 		if( ButtonDownCheckCtrl(rMEvt, pEntry, nY) == sal_True)
2182cdf0e10cSrcweir 			return;
2183cdf0e10cSrcweir 		// Inplace-Editing?
2184cdf0e10cSrcweir #if 0
2185cdf0e10cSrcweir 		if( rMEvt.IsMod2() && pView->IsInplaceEditingEnabled() )
2186cdf0e10cSrcweir 		{
2187cdf0e10cSrcweir 			SvLBoxItem* pItem = pView->GetItem( pEntry, aPos.X() );
2188cdf0e10cSrcweir 			if( pItem )
2189cdf0e10cSrcweir 				pView->EditingRequest( pEntry, pItem, aPos );
2190cdf0e10cSrcweir 			return;
2191cdf0e10cSrcweir 		}
2192cdf0e10cSrcweir #endif
2193cdf0e10cSrcweir 	}
2194cdf0e10cSrcweir     if ( aSelEng.GetSelectionMode() != NO_SELECTION )
2195cdf0e10cSrcweir 	    aSelEng.SelMouseButtonDown( rMEvt );
2196cdf0e10cSrcweir }
2197cdf0e10cSrcweir 
2198cdf0e10cSrcweir void SvImpLBox::MouseButtonUp( const MouseEvent& rMEvt)
2199cdf0e10cSrcweir {
2200cdf0e10cSrcweir #ifdef OS2
2201cdf0e10cSrcweir 	nFlags &= (~F_IGNORE_NEXT_MOUSEMOVE);
2202cdf0e10cSrcweir #endif
2203cdf0e10cSrcweir 	if ( !ButtonUpCheckCtrl( rMEvt ) && ( aSelEng.GetSelectionMode() != NO_SELECTION ) )
2204cdf0e10cSrcweir 		aSelEng.SelMouseButtonUp( rMEvt );
2205cdf0e10cSrcweir 	EndScroll();
2206cdf0e10cSrcweir 	if( nFlags & F_START_EDITTIMER )
2207cdf0e10cSrcweir 	{
2208cdf0e10cSrcweir 		nFlags &= (~F_START_EDITTIMER);
2209cdf0e10cSrcweir 		aEditClickPos = rMEvt.GetPosPixel();
2210cdf0e10cSrcweir 		aEditTimer.Start();
2211cdf0e10cSrcweir 	}
2212cdf0e10cSrcweir 
2213cdf0e10cSrcweir 	return;
2214cdf0e10cSrcweir }
2215cdf0e10cSrcweir 
2216cdf0e10cSrcweir void SvImpLBox::MouseMove( const MouseEvent& rMEvt)
2217cdf0e10cSrcweir {
2218cdf0e10cSrcweir #ifdef OS2
2219cdf0e10cSrcweir 	if( nFlags & F_IGNORE_NEXT_MOUSEMOVE )
2220cdf0e10cSrcweir 	{
2221cdf0e10cSrcweir 		nFlags &= (~F_IGNORE_NEXT_MOUSEMOVE);
2222cdf0e10cSrcweir 		return;
2223cdf0e10cSrcweir 	}
2224cdf0e10cSrcweir #endif
2225cdf0e10cSrcweir 	SvLBoxEntry* pEntry = GetClickedEntry( rMEvt.GetPosPixel() );
2226cdf0e10cSrcweir 	if ( !MouseMoveCheckCtrl( rMEvt, pEntry ) && ( aSelEng.GetSelectionMode() != NO_SELECTION ) )
2227cdf0e10cSrcweir 		aSelEng.SelMouseMove( rMEvt );
2228cdf0e10cSrcweir 	return;
2229cdf0e10cSrcweir }
2230cdf0e10cSrcweir 
2231cdf0e10cSrcweir sal_Bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
2232cdf0e10cSrcweir {
2233cdf0e10cSrcweir 	aEditTimer.Stop();
2234cdf0e10cSrcweir 	const KeyCode&	rKeyCode = rKEvt.GetKeyCode();
2235cdf0e10cSrcweir 
2236cdf0e10cSrcweir 	if( rKeyCode.IsMod2() )
2237cdf0e10cSrcweir 		return sal_False; // Alt-Taste nicht auswerten
2238cdf0e10cSrcweir 
2239cdf0e10cSrcweir 	nFlags &= (~F_FILLING);
2240cdf0e10cSrcweir 
2241cdf0e10cSrcweir 	if( !pCursor )
2242cdf0e10cSrcweir 		pCursor = pStartEntry;
2243cdf0e10cSrcweir 	if( !pCursor )
2244cdf0e10cSrcweir 		return sal_False;
2245cdf0e10cSrcweir 
2246cdf0e10cSrcweir 	sal_Bool bKeyUsed = sal_True;
2247cdf0e10cSrcweir 
2248cdf0e10cSrcweir 	sal_uInt16  nDelta = (sal_uInt16)aVerSBar.GetPageSize();
2249cdf0e10cSrcweir 	sal_uInt16  aCode = rKeyCode.GetCode();
2250cdf0e10cSrcweir 
2251cdf0e10cSrcweir 	sal_Bool    bShift = rKeyCode.IsShift();
2252cdf0e10cSrcweir 	sal_Bool    bMod1 = rKeyCode.IsMod1();
2253cdf0e10cSrcweir 
2254cdf0e10cSrcweir 	SvLBoxEntry* pNewCursor;
2255cdf0e10cSrcweir 
2256cdf0e10cSrcweir     const WinBits nWindowStyle = pView->GetStyle();
2257cdf0e10cSrcweir 	switch( aCode )
2258cdf0e10cSrcweir 	{
2259cdf0e10cSrcweir 		case KEY_UP:
2260cdf0e10cSrcweir 			if( !IsEntryInView( pCursor ) )
2261cdf0e10cSrcweir 				MakeVisible( pCursor );
2262cdf0e10cSrcweir 
2263cdf0e10cSrcweir 			pNewCursor = pCursor;
2264cdf0e10cSrcweir 			do
2265cdf0e10cSrcweir 			{
2266cdf0e10cSrcweir 				pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pNewCursor ));
2267cdf0e10cSrcweir 			} while( pNewCursor && !IsSelectable(pNewCursor) );
2268cdf0e10cSrcweir 
2269cdf0e10cSrcweir 			if ( pNewCursor )
2270cdf0e10cSrcweir 				// new entry selected -> reset current tab position to first tab
2271cdf0e10cSrcweir 				nCurTabPos = FIRST_ENTRY_TAB;
2272cdf0e10cSrcweir 			// if there is no next entry, take the current one
2273cdf0e10cSrcweir 			// this ensures that in case of _one_ entry in the list, this entry is selected when pressing
2274cdf0e10cSrcweir 			// the cursor key
2275cdf0e10cSrcweir 			// 06.09.20001 - 83416 - fs@openoffice.org
2276cdf0e10cSrcweir 			if ( !pNewCursor && pCursor )
2277cdf0e10cSrcweir 				pNewCursor = pCursor;
2278cdf0e10cSrcweir 
2279cdf0e10cSrcweir 			if( pNewCursor )
2280cdf0e10cSrcweir 			{
2281cdf0e10cSrcweir 				aSelEng.CursorPosChanging( bShift, bMod1 );
2282cdf0e10cSrcweir 				SetCursor( pNewCursor, bMod1 );		// no selection, when Ctrl is on
2283cdf0e10cSrcweir 				if( !IsEntryInView( pNewCursor ) )
2284cdf0e10cSrcweir 					KeyUp( sal_False );
2285cdf0e10cSrcweir 			}
2286cdf0e10cSrcweir 			break;
2287cdf0e10cSrcweir 
2288cdf0e10cSrcweir 		case KEY_DOWN:
2289cdf0e10cSrcweir 			if( !IsEntryInView( pCursor ) )
2290cdf0e10cSrcweir 				MakeVisible( pCursor );
2291cdf0e10cSrcweir 
2292cdf0e10cSrcweir 			pNewCursor = pCursor;
2293cdf0e10cSrcweir 			do
2294cdf0e10cSrcweir 			{
2295cdf0e10cSrcweir 				pNewCursor = (SvLBoxEntry*)(pView->NextVisible( pNewCursor ));
2296cdf0e10cSrcweir 			} while( pNewCursor && !IsSelectable(pNewCursor) );
2297cdf0e10cSrcweir 
2298cdf0e10cSrcweir 			if ( pNewCursor )
2299cdf0e10cSrcweir 				// new entry selected -> reset current tab position to first tab
2300cdf0e10cSrcweir 				nCurTabPos = FIRST_ENTRY_TAB;
2301cdf0e10cSrcweir 
2302cdf0e10cSrcweir 			// if there is no next entry, take the current one
2303cdf0e10cSrcweir 			// this ensures that in case of _one_ entry in the list, this entry is selected when pressing
2304cdf0e10cSrcweir 			// the cursor key
2305cdf0e10cSrcweir 			// 06.09.20001 - 83416 - frank.schoenheit@sun.com
2306cdf0e10cSrcweir 			if ( !pNewCursor && pCursor )
2307cdf0e10cSrcweir 				pNewCursor = pCursor;
2308cdf0e10cSrcweir 
2309cdf0e10cSrcweir 			if( pNewCursor )
2310cdf0e10cSrcweir 			{
2311cdf0e10cSrcweir 				aSelEng.CursorPosChanging( bShift, bMod1 );
2312cdf0e10cSrcweir 				if( IsEntryInView( pNewCursor ) )
2313cdf0e10cSrcweir 					SetCursor( pNewCursor, bMod1 );	// no selection, when Ctrl is on
2314cdf0e10cSrcweir 				else
2315cdf0e10cSrcweir 				{
2316cdf0e10cSrcweir 					if( pCursor )
2317cdf0e10cSrcweir 						pView->Select( pCursor, sal_False );
2318cdf0e10cSrcweir 					KeyDown( sal_False );
2319cdf0e10cSrcweir 					SetCursor( pNewCursor, bMod1 );	// no selection, when Ctrl is on
2320cdf0e10cSrcweir 				}
2321cdf0e10cSrcweir 			}
2322cdf0e10cSrcweir 			else
2323cdf0e10cSrcweir 				KeyDown( sal_False ); // weil ScrollBar-Range evtl. noch
2324cdf0e10cSrcweir 								  // scrollen erlaubt
2325cdf0e10cSrcweir 			break;
2326cdf0e10cSrcweir 
2327cdf0e10cSrcweir 		case KEY_RIGHT:
2328cdf0e10cSrcweir 		{
2329cdf0e10cSrcweir 			if( bSubLstOpLR && IsNowExpandable() )
2330cdf0e10cSrcweir 				pView->Expand( pCursor );
2331cdf0e10cSrcweir             else if ( bIsCellFocusEnabled && pCursor )
2332cdf0e10cSrcweir             {
2333cdf0e10cSrcweir                 if ( nCurTabPos < ( pView->TabCount() - 1 /*!2*/ ) )
2334cdf0e10cSrcweir                 {
2335cdf0e10cSrcweir                     ++nCurTabPos;
2336cdf0e10cSrcweir                     ShowCursor( sal_True );
2337cdf0e10cSrcweir                     CallEventListeners( VCLEVENT_LISTBOX_SELECT, pCursor );
2338cdf0e10cSrcweir                 }
2339cdf0e10cSrcweir             }
2340cdf0e10cSrcweir 			else if( nWindowStyle & WB_HSCROLL )
2341cdf0e10cSrcweir 			{
2342cdf0e10cSrcweir 				long	nThumb = aHorSBar.GetThumbPos();
2343cdf0e10cSrcweir 				nThumb += aHorSBar.GetLineSize();
2344cdf0e10cSrcweir 				long	nOldThumb = aHorSBar.GetThumbPos();
2345cdf0e10cSrcweir 				aHorSBar.SetThumbPos( nThumb );
2346cdf0e10cSrcweir 				nThumb = nOldThumb;
2347cdf0e10cSrcweir 				nThumb -= aHorSBar.GetThumbPos();
2348cdf0e10cSrcweir 				nThumb *= -1;
2349cdf0e10cSrcweir 				if( nThumb )
2350cdf0e10cSrcweir 				{
2351cdf0e10cSrcweir 					KeyLeftRight( nThumb );
2352cdf0e10cSrcweir 					EndScroll();
2353cdf0e10cSrcweir 				}
2354cdf0e10cSrcweir 			}
2355cdf0e10cSrcweir 			else
2356cdf0e10cSrcweir 				bKeyUsed = sal_False;
2357cdf0e10cSrcweir 			break;
2358cdf0e10cSrcweir 		}
2359cdf0e10cSrcweir 
2360cdf0e10cSrcweir 		case KEY_LEFT:
2361cdf0e10cSrcweir 		{
2362cdf0e10cSrcweir             if ( bIsCellFocusEnabled )
2363cdf0e10cSrcweir             {
2364cdf0e10cSrcweir                 if ( nCurTabPos > FIRST_ENTRY_TAB )
2365cdf0e10cSrcweir                 {
2366cdf0e10cSrcweir                     --nCurTabPos;
2367cdf0e10cSrcweir                     ShowCursor( sal_True );
2368cdf0e10cSrcweir                     CallEventListeners( VCLEVENT_LISTBOX_SELECT, pCursor );
2369cdf0e10cSrcweir                 }
2370cdf0e10cSrcweir             }
2371cdf0e10cSrcweir             else if ( nWindowStyle & WB_HSCROLL )
2372cdf0e10cSrcweir 			{
2373cdf0e10cSrcweir 				long	nThumb = aHorSBar.GetThumbPos();
2374cdf0e10cSrcweir 				nThumb -= aHorSBar.GetLineSize();
2375cdf0e10cSrcweir 				long	nOldThumb = aHorSBar.GetThumbPos();
2376cdf0e10cSrcweir 				aHorSBar.SetThumbPos( nThumb );
2377cdf0e10cSrcweir 				nThumb = nOldThumb;
2378cdf0e10cSrcweir 				nThumb -= aHorSBar.GetThumbPos();
2379cdf0e10cSrcweir 				if( nThumb )
2380cdf0e10cSrcweir 				{
2381cdf0e10cSrcweir 					KeyLeftRight( -nThumb );
2382cdf0e10cSrcweir 					EndScroll();
2383cdf0e10cSrcweir 				}
2384cdf0e10cSrcweir 				else if( bSubLstOpLR )
2385cdf0e10cSrcweir 				{
2386cdf0e10cSrcweir 					if( IsExpandable() && pView->IsExpanded( pCursor ) )
2387cdf0e10cSrcweir 						pView->Collapse( pCursor );
2388cdf0e10cSrcweir 					else
2389cdf0e10cSrcweir 					{
2390cdf0e10cSrcweir 						pNewCursor = pView->GetParent( pCursor );
2391cdf0e10cSrcweir 						if( pNewCursor )
2392cdf0e10cSrcweir 							SetCursor( pNewCursor );
2393cdf0e10cSrcweir 					}
2394cdf0e10cSrcweir 				}
2395cdf0e10cSrcweir 			}
2396cdf0e10cSrcweir 			else if( bSubLstOpLR && IsExpandable() )
2397cdf0e10cSrcweir 				pView->Collapse( pCursor );
2398cdf0e10cSrcweir 			else
2399cdf0e10cSrcweir 				bKeyUsed = sal_False;
2400cdf0e10cSrcweir 			break;
2401cdf0e10cSrcweir 		}
2402cdf0e10cSrcweir 
2403cdf0e10cSrcweir 		case KEY_PAGEUP:
2404cdf0e10cSrcweir 			if( !bMod1 )
2405cdf0e10cSrcweir 			{
2406cdf0e10cSrcweir 				pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pCursor, nDelta ));
2407cdf0e10cSrcweir 
2408cdf0e10cSrcweir 				while( nDelta && pNewCursor && !IsSelectable(pNewCursor) )
2409cdf0e10cSrcweir 				{
2410cdf0e10cSrcweir 					pNewCursor = (SvLBoxEntry*)(pView->NextVisible( pNewCursor ));
2411cdf0e10cSrcweir 					nDelta--;
2412cdf0e10cSrcweir 				}
2413cdf0e10cSrcweir 
2414cdf0e10cSrcweir 				if( nDelta )
2415cdf0e10cSrcweir 				{
2416cdf0e10cSrcweir 					DBG_ASSERT(pNewCursor&&(sal_uLong)pNewCursor!=(sal_uLong)pCursor,"Cursor?");
2417cdf0e10cSrcweir 					aSelEng.CursorPosChanging( bShift, bMod1 );
2418cdf0e10cSrcweir 					if( IsEntryInView( pNewCursor ) )
2419cdf0e10cSrcweir 						SetCursor( pNewCursor );
2420cdf0e10cSrcweir 					else
2421cdf0e10cSrcweir 					{
2422cdf0e10cSrcweir 						SetCursor( pNewCursor );
2423cdf0e10cSrcweir 						KeyUp( sal_True );
2424cdf0e10cSrcweir 					}
2425cdf0e10cSrcweir 				}
2426cdf0e10cSrcweir 			}
2427cdf0e10cSrcweir 			else
2428cdf0e10cSrcweir 				bKeyUsed = sal_False;
2429cdf0e10cSrcweir 			break;
2430cdf0e10cSrcweir 
2431cdf0e10cSrcweir 		case KEY_PAGEDOWN:
2432cdf0e10cSrcweir 			if( !bMod1 )
2433cdf0e10cSrcweir 			{
2434cdf0e10cSrcweir 				pNewCursor= (SvLBoxEntry*)(pView->NextVisible( pCursor, nDelta ));
2435cdf0e10cSrcweir 
2436cdf0e10cSrcweir 				while( nDelta && pNewCursor && !IsSelectable(pNewCursor) )
2437cdf0e10cSrcweir 				{
2438cdf0e10cSrcweir 					pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pNewCursor ));
2439cdf0e10cSrcweir 					nDelta--;
2440cdf0e10cSrcweir 				}
2441cdf0e10cSrcweir 
2442cdf0e10cSrcweir 				if( nDelta )
2443cdf0e10cSrcweir 				{
2444cdf0e10cSrcweir 					DBG_ASSERT(pNewCursor&&(sal_uLong)pNewCursor!=(sal_uLong)pCursor,"Cursor?");
2445cdf0e10cSrcweir 					aSelEng.CursorPosChanging( bShift, bMod1 );
2446cdf0e10cSrcweir 					if( IsEntryInView( pNewCursor ) )
2447cdf0e10cSrcweir 						SetCursor( pNewCursor );
2448cdf0e10cSrcweir 					else
2449cdf0e10cSrcweir 					{
2450cdf0e10cSrcweir 						SetCursor( pNewCursor );
2451cdf0e10cSrcweir 						KeyDown( sal_True );
2452cdf0e10cSrcweir 					}
2453cdf0e10cSrcweir 				}
2454cdf0e10cSrcweir 				else
2455cdf0e10cSrcweir 					KeyDown( sal_False ); // siehe KEY_DOWN
2456cdf0e10cSrcweir 			}
2457cdf0e10cSrcweir 			else
2458cdf0e10cSrcweir 				bKeyUsed = sal_False;
2459cdf0e10cSrcweir 			break;
2460cdf0e10cSrcweir 
2461cdf0e10cSrcweir 		case KEY_SPACE:
2462cdf0e10cSrcweir             if ( pView->GetSelectionMode() != NO_SELECTION )
2463cdf0e10cSrcweir             {
2464cdf0e10cSrcweir 			    if ( bMod1 )
2465cdf0e10cSrcweir 			    {
2466cdf0e10cSrcweir 				    if ( pView->GetSelectionMode() == MULTIPLE_SELECTION && !bShift )
2467cdf0e10cSrcweir 					    // toggle selection
2468cdf0e10cSrcweir 					    pView->Select( pCursor, !pView->IsSelected( pCursor ) );
2469cdf0e10cSrcweir 			    }
2470cdf0e10cSrcweir 			    else if ( !bShift /*&& !bMod1*/ )
2471cdf0e10cSrcweir 			    {
2472cdf0e10cSrcweir 				    if ( aSelEng.IsAddMode() )
2473cdf0e10cSrcweir                     {
2474cdf0e10cSrcweir 					    // toggle selection
2475cdf0e10cSrcweir 					    pView->Select( pCursor, !pView->IsSelected( pCursor ) );
2476cdf0e10cSrcweir                     }
2477cdf0e10cSrcweir 				    else if ( !pView->IsSelected( pCursor ) )
2478cdf0e10cSrcweir 				    {
2479cdf0e10cSrcweir 					    SelAllDestrAnch( sal_False );
2480cdf0e10cSrcweir 					    pView->Select( pCursor, sal_True );
2481cdf0e10cSrcweir 				    }
2482cdf0e10cSrcweir                     else
2483cdf0e10cSrcweir 				        bKeyUsed = sal_False;
2484cdf0e10cSrcweir 			    }
2485cdf0e10cSrcweir                 else
2486cdf0e10cSrcweir 				    bKeyUsed = sal_False;
2487cdf0e10cSrcweir             }
2488cdf0e10cSrcweir 			else
2489cdf0e10cSrcweir 				bKeyUsed = sal_False;
2490cdf0e10cSrcweir 			break;
2491cdf0e10cSrcweir 
2492cdf0e10cSrcweir 		case KEY_RETURN:
2493cdf0e10cSrcweir 			if( bSubLstOpRet && IsExpandable() )
2494cdf0e10cSrcweir 			{
2495cdf0e10cSrcweir 				if( pView->IsExpanded( pCursor ) )
2496cdf0e10cSrcweir 					pView->Collapse( pCursor );
2497cdf0e10cSrcweir 				else
2498cdf0e10cSrcweir 					pView->Expand( pCursor );
2499cdf0e10cSrcweir 			}
2500cdf0e10cSrcweir 			else
2501cdf0e10cSrcweir 				bKeyUsed = sal_False;
2502cdf0e10cSrcweir 			break;
2503cdf0e10cSrcweir 
2504cdf0e10cSrcweir 		case KEY_F2:
2505cdf0e10cSrcweir 			if( !bShift && !bMod1 )
2506cdf0e10cSrcweir 			{
2507cdf0e10cSrcweir 				aEditClickPos = Point( -1, -1 );
2508cdf0e10cSrcweir 				EditTimerCall( 0 );
2509cdf0e10cSrcweir 			}
2510cdf0e10cSrcweir 			else
2511cdf0e10cSrcweir 				bKeyUsed = sal_False;
2512cdf0e10cSrcweir 			break;
2513cdf0e10cSrcweir 
2514cdf0e10cSrcweir 		case KEY_F8:
2515cdf0e10cSrcweir 			if( bShift && pView->GetSelectionMode()==MULTIPLE_SELECTION &&
2516cdf0e10cSrcweir 				!(m_nStyle & WB_SIMPLEMODE))
2517cdf0e10cSrcweir 			{
2518cdf0e10cSrcweir 				if( aSelEng.IsAlwaysAdding() )
2519cdf0e10cSrcweir 					aSelEng.AddAlways( sal_False );
2520cdf0e10cSrcweir 				else
2521cdf0e10cSrcweir 					aSelEng.AddAlways( sal_True );
2522cdf0e10cSrcweir 			}
2523cdf0e10cSrcweir 			else
2524cdf0e10cSrcweir 				bKeyUsed = sal_False;
2525cdf0e10cSrcweir 			break;
2526cdf0e10cSrcweir 
2527cdf0e10cSrcweir 
2528cdf0e10cSrcweir #ifdef OV_DEBUG
2529cdf0e10cSrcweir 		case KEY_F9:
2530cdf0e10cSrcweir 			MakeVisible( pCursor );
2531cdf0e10cSrcweir 			break;
2532cdf0e10cSrcweir 		case KEY_F10:
2533cdf0e10cSrcweir 			pView->RemoveSelection();
2534cdf0e10cSrcweir 			break;
2535cdf0e10cSrcweir 		case KEY_DELETE:
2536cdf0e10cSrcweir 			pView->RemoveEntry( pCursor );
2537cdf0e10cSrcweir 			break;
2538cdf0e10cSrcweir #endif
2539cdf0e10cSrcweir 
2540cdf0e10cSrcweir 		case KEY_ADD:
2541cdf0e10cSrcweir 			if( pCursor )
2542cdf0e10cSrcweir 			{
2543cdf0e10cSrcweir 				if( !pView->IsExpanded(pCursor))
2544cdf0e10cSrcweir 					pView->Expand( pCursor );
2545cdf0e10cSrcweir 				if( bMod1 )
2546cdf0e10cSrcweir 				{
2547cdf0e10cSrcweir 					sal_uInt16 nRefDepth = pTree->GetDepth( pCursor );
2548cdf0e10cSrcweir 					SvLBoxEntry* pCur = pTree->Next( pCursor );
2549cdf0e10cSrcweir 					while( pCur && pTree->GetDepth(pCur) > nRefDepth )
2550cdf0e10cSrcweir 					{
2551cdf0e10cSrcweir 						if( pCur->HasChilds() && !pView->IsExpanded(pCur))
2552cdf0e10cSrcweir 							pView->Expand( pCur );
2553cdf0e10cSrcweir 						pCur = pTree->Next( pCur );
2554cdf0e10cSrcweir 					}
2555cdf0e10cSrcweir 				}
2556cdf0e10cSrcweir 			}
2557cdf0e10cSrcweir 			else
2558cdf0e10cSrcweir 				bKeyUsed = sal_False;
2559cdf0e10cSrcweir 			break;
2560cdf0e10cSrcweir 
2561cdf0e10cSrcweir 		case KEY_A:
2562cdf0e10cSrcweir 			if( bMod1 )
2563cdf0e10cSrcweir 				SelAllDestrAnch( sal_True );
2564cdf0e10cSrcweir 			else
2565cdf0e10cSrcweir 				bKeyUsed = sal_False;
2566cdf0e10cSrcweir 			break;
2567cdf0e10cSrcweir 
2568cdf0e10cSrcweir 		case KEY_SUBTRACT:
2569cdf0e10cSrcweir 			if( pCursor )
2570cdf0e10cSrcweir 			{
2571cdf0e10cSrcweir 				if( pView->IsExpanded(pCursor))
2572cdf0e10cSrcweir 					pView->Collapse( pCursor );
2573cdf0e10cSrcweir 				if( bMod1 )
2574cdf0e10cSrcweir 				{
2575cdf0e10cSrcweir 					// bis zur Root alle Parents einklappen
2576cdf0e10cSrcweir 					SvLBoxEntry* pParentToCollapse = (SvLBoxEntry*)pTree->GetRootLevelParent(pCursor);
2577cdf0e10cSrcweir 					if( pParentToCollapse )
2578cdf0e10cSrcweir 					{
2579cdf0e10cSrcweir 						sal_uInt16 nRefDepth;
2580cdf0e10cSrcweir 						// Sonderbehandlung Explorer: Befindet sich auf der
2581cdf0e10cSrcweir 						// Root nur ein Eintrag,dann den Root-Entry nicht
2582cdf0e10cSrcweir 						// einklappen
2583cdf0e10cSrcweir 						if( pTree->GetChildList(0)->Count() < 2 )
2584cdf0e10cSrcweir 						{
2585cdf0e10cSrcweir 							nRefDepth = 1;
2586cdf0e10cSrcweir 							pParentToCollapse = pCursor;
2587cdf0e10cSrcweir 							while( pTree->GetParent(pParentToCollapse) &&
2588cdf0e10cSrcweir 								   pTree->GetDepth( pTree->GetParent(pParentToCollapse)) > 0)
2589cdf0e10cSrcweir 							{
2590cdf0e10cSrcweir 								pParentToCollapse = pTree->GetParent(pParentToCollapse);
2591cdf0e10cSrcweir 							}
2592cdf0e10cSrcweir 						}
2593cdf0e10cSrcweir 						else
2594cdf0e10cSrcweir 							nRefDepth = 0;
2595cdf0e10cSrcweir 
2596cdf0e10cSrcweir 						if( pView->IsExpanded(pParentToCollapse) )
2597cdf0e10cSrcweir 							pView->Collapse( pParentToCollapse );
2598cdf0e10cSrcweir 						SvLBoxEntry* pCur = pTree->Next( pParentToCollapse );
2599cdf0e10cSrcweir 						while( pCur && pTree->GetDepth(pCur) > nRefDepth )
2600cdf0e10cSrcweir 						{
2601cdf0e10cSrcweir 							if( pCur->HasChilds() && pView->IsExpanded(pCur) )
2602cdf0e10cSrcweir 								pView->Collapse( pCur );
2603cdf0e10cSrcweir 							pCur = pTree->Next( pCur );
2604cdf0e10cSrcweir 						}
2605cdf0e10cSrcweir 					}
2606cdf0e10cSrcweir 				}
2607cdf0e10cSrcweir 			}
2608cdf0e10cSrcweir 			else
2609cdf0e10cSrcweir 				bKeyUsed = sal_False;
2610cdf0e10cSrcweir 			break;
2611cdf0e10cSrcweir 
2612cdf0e10cSrcweir 		case KEY_DIVIDE :
2613cdf0e10cSrcweir 			if( bMod1 )
2614cdf0e10cSrcweir 				SelAllDestrAnch( sal_True );
2615cdf0e10cSrcweir 			else
2616cdf0e10cSrcweir 				bKeyUsed = sal_False;
2617cdf0e10cSrcweir 			break;
2618cdf0e10cSrcweir 
2619cdf0e10cSrcweir 		case KEY_COMMA :
2620cdf0e10cSrcweir 			if( bMod1 )
2621cdf0e10cSrcweir 				SelAllDestrAnch( sal_False );
2622cdf0e10cSrcweir 			else
2623cdf0e10cSrcweir 				bKeyUsed = sal_False;
2624cdf0e10cSrcweir 			break;
2625cdf0e10cSrcweir 
2626cdf0e10cSrcweir 		case KEY_HOME :
2627cdf0e10cSrcweir 			pNewCursor = pView->GetModel()->First();
2628cdf0e10cSrcweir 
2629cdf0e10cSrcweir 			while( pNewCursor && !IsSelectable(pNewCursor) )
2630cdf0e10cSrcweir 			{
2631cdf0e10cSrcweir 				pNewCursor = (SvLBoxEntry*)(pView->NextVisible( pNewCursor ));
2632cdf0e10cSrcweir 			}
2633cdf0e10cSrcweir 
2634cdf0e10cSrcweir 			if( pNewCursor && pNewCursor != pCursor )
2635cdf0e10cSrcweir 			{
2636cdf0e10cSrcweir //				SelAllDestrAnch( sal_False );
2637cdf0e10cSrcweir 				aSelEng.CursorPosChanging( bShift, bMod1 );
2638cdf0e10cSrcweir 				SetCursor( pNewCursor );
2639cdf0e10cSrcweir 				if( !IsEntryInView( pNewCursor ) )
2640cdf0e10cSrcweir 					MakeVisible( pNewCursor );
2641cdf0e10cSrcweir 			}
2642cdf0e10cSrcweir 			else
2643cdf0e10cSrcweir 				bKeyUsed = sal_False;
2644cdf0e10cSrcweir 			break;
2645cdf0e10cSrcweir 
2646cdf0e10cSrcweir 		case KEY_END :
2647cdf0e10cSrcweir 			pNewCursor = pView->GetModel()->Last();
2648cdf0e10cSrcweir 
2649cdf0e10cSrcweir 			while( pNewCursor && !IsSelectable(pNewCursor) )
2650cdf0e10cSrcweir 			{
2651cdf0e10cSrcweir 				pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pNewCursor ));
2652cdf0e10cSrcweir 			}
2653cdf0e10cSrcweir 
2654cdf0e10cSrcweir 			if( pNewCursor && pNewCursor != pCursor)
2655cdf0e10cSrcweir 			{
2656cdf0e10cSrcweir //				SelAllDestrAnch( sal_False );
2657cdf0e10cSrcweir 				aSelEng.CursorPosChanging( bShift, bMod1 );
2658cdf0e10cSrcweir 				SetCursor( pNewCursor );
2659cdf0e10cSrcweir 				if( !IsEntryInView( pNewCursor ) )
2660cdf0e10cSrcweir 					MakeVisible( pNewCursor );
2661cdf0e10cSrcweir 			}
2662cdf0e10cSrcweir 			else
2663cdf0e10cSrcweir 				bKeyUsed = sal_False;
2664cdf0e10cSrcweir 			break;
2665cdf0e10cSrcweir 
2666cdf0e10cSrcweir 		case KEY_ESCAPE:
2667cdf0e10cSrcweir 		case KEY_TAB:
2668cdf0e10cSrcweir 		case KEY_DELETE:
2669cdf0e10cSrcweir 		case KEY_BACKSPACE:
2670cdf0e10cSrcweir 			// #105907# must not be handled because this quits dialogs and does other magic things...
2671cdf0e10cSrcweir 			// if there are other single keys which should not be handled, they can be added here
2672cdf0e10cSrcweir 			bKeyUsed = sal_False;
2673cdf0e10cSrcweir 			break;
2674cdf0e10cSrcweir 
2675cdf0e10cSrcweir 		default:
2676cdf0e10cSrcweir             // is there any reason why we should eat the events here? The only place where this is called
2677cdf0e10cSrcweir             // is from SvTreeListBox::KeyInput. If we set bKeyUsed to sal_True here, then the key input
2678cdf0e10cSrcweir             // is just silenced. However, we want SvLBox::KeyInput to get a chance, to do the QuickSelection
2679cdf0e10cSrcweir             // handling.
2680cdf0e10cSrcweir             // (The old code here which intentionally set bKeyUsed to TRUE said this was because of "quick search"
2681cdf0e10cSrcweir             // handling, but actually there was no quick search handling anymore. We just re-implemented it.)
2682cdf0e10cSrcweir             // #i31275# / 2009-06-16 / frank.schoenheit@sun.com
2683cdf0e10cSrcweir 			bKeyUsed = sal_False;
2684cdf0e10cSrcweir             break;
2685cdf0e10cSrcweir 	}
2686cdf0e10cSrcweir 	return bKeyUsed;
2687cdf0e10cSrcweir }
2688cdf0e10cSrcweir 
2689cdf0e10cSrcweir void __EXPORT SvImpLBox::GetFocus()
2690cdf0e10cSrcweir {
2691cdf0e10cSrcweir 	if( pCursor )
2692cdf0e10cSrcweir 	{
2693cdf0e10cSrcweir 		pView->SetEntryFocus( pCursor, sal_True );
2694cdf0e10cSrcweir 		ShowCursor( sal_True );
2695cdf0e10cSrcweir // auskommentiert wg. deselectall
2696cdf0e10cSrcweir //		if( bSimpleTravel && !pView->IsSelected(pCursor) )
2697cdf0e10cSrcweir //			pView->Select( pCursor, sal_True );
2698cdf0e10cSrcweir 	}
2699cdf0e10cSrcweir 	if( m_nStyle & WB_HIDESELECTION )
2700cdf0e10cSrcweir 	{
2701cdf0e10cSrcweir 		SvLBoxEntry* pEntry = pView->FirstSelected();
2702cdf0e10cSrcweir 		while( pEntry )
2703cdf0e10cSrcweir 		{
2704cdf0e10cSrcweir 			InvalidateEntry( pEntry );
2705cdf0e10cSrcweir 			pEntry = pView->NextSelected( pEntry );
2706cdf0e10cSrcweir 		}
2707cdf0e10cSrcweir 		/*
2708cdf0e10cSrcweir 		SvLBoxEntry* pEntry = pView->GetModel()->First();
2709cdf0e10cSrcweir 		while( pEntry )
2710cdf0e10cSrcweir 		{
2711cdf0e10cSrcweir 			SvViewData* pViewData = pView->GetViewData( pEntry );
2712cdf0e10cSrcweir 			if( pViewData->IsCursored() )
2713cdf0e10cSrcweir 			{
2714cdf0e10cSrcweir 				pViewData->SetCursored( sal_False );
2715cdf0e10cSrcweir 				InvalidateEntry( pEntry );
2716cdf0e10cSrcweir 			}
2717cdf0e10cSrcweir 			pEntry = pView->GetModel()->Next( pEntry );
2718cdf0e10cSrcweir 		}
2719cdf0e10cSrcweir 		*/
2720cdf0e10cSrcweir 
2721cdf0e10cSrcweir 
2722cdf0e10cSrcweir 	}
2723cdf0e10cSrcweir }
2724cdf0e10cSrcweir 
2725cdf0e10cSrcweir void __EXPORT SvImpLBox::LoseFocus()
2726cdf0e10cSrcweir {
2727cdf0e10cSrcweir 	aEditTimer.Stop();
2728cdf0e10cSrcweir 	if( pCursor )
2729cdf0e10cSrcweir 		pView->SetEntryFocus( pCursor,sal_False );
2730cdf0e10cSrcweir 	ShowCursor( sal_False );
2731cdf0e10cSrcweir 
2732cdf0e10cSrcweir 	if( m_nStyle & WB_HIDESELECTION )
2733cdf0e10cSrcweir 	{
2734cdf0e10cSrcweir 		SvLBoxEntry* pEntry = pView->FirstSelected();
2735cdf0e10cSrcweir 		while( pEntry )
2736cdf0e10cSrcweir 		{
2737cdf0e10cSrcweir 			//SvViewData* pViewData = pView->GetViewData( pEntry );
2738cdf0e10cSrcweir 			//pViewData->SetCursored( sal_True );
2739cdf0e10cSrcweir 			InvalidateEntry( pEntry );
2740cdf0e10cSrcweir 			pEntry = pView->NextSelected( pEntry );
2741cdf0e10cSrcweir 		}
2742cdf0e10cSrcweir 	}
2743cdf0e10cSrcweir }
2744cdf0e10cSrcweir 
2745cdf0e10cSrcweir 
2746cdf0e10cSrcweir // ********************************************************************
2747cdf0e10cSrcweir // SelectionEngine
2748cdf0e10cSrcweir // ********************************************************************
2749cdf0e10cSrcweir 
2750cdf0e10cSrcweir inline void SvImpLBox::SelectEntry( SvLBoxEntry* pEntry, sal_Bool bSelect )
2751cdf0e10cSrcweir {
2752cdf0e10cSrcweir 	pView->Select( pEntry, bSelect );
2753cdf0e10cSrcweir }
2754cdf0e10cSrcweir 
2755cdf0e10cSrcweir __EXPORT ImpLBSelEng::ImpLBSelEng( SvImpLBox* pImpl, SelectionEngine* pSEng,
2756cdf0e10cSrcweir 	SvTreeListBox* pV )
2757cdf0e10cSrcweir {
2758cdf0e10cSrcweir 	pImp = pImpl;
2759cdf0e10cSrcweir 	pSelEng = pSEng;
2760cdf0e10cSrcweir 	pView = pV;
2761cdf0e10cSrcweir }
2762cdf0e10cSrcweir 
2763cdf0e10cSrcweir __EXPORT ImpLBSelEng::~ImpLBSelEng()
2764cdf0e10cSrcweir {
2765cdf0e10cSrcweir }
2766cdf0e10cSrcweir 
2767cdf0e10cSrcweir void __EXPORT ImpLBSelEng::BeginDrag()
2768cdf0e10cSrcweir {
2769cdf0e10cSrcweir 	pImp->BeginDrag();
2770cdf0e10cSrcweir }
2771cdf0e10cSrcweir 
2772cdf0e10cSrcweir /*
2773cdf0e10cSrcweir void __EXPORT ImpLBSelEng::EndDrag( const Point& )
2774cdf0e10cSrcweir {
2775cdf0e10cSrcweir }
2776cdf0e10cSrcweir */
2777cdf0e10cSrcweir 
2778cdf0e10cSrcweir void __EXPORT ImpLBSelEng::CreateAnchor()
2779cdf0e10cSrcweir {
2780cdf0e10cSrcweir 	pImp->pAnchor = pImp->pCursor;
2781cdf0e10cSrcweir }
2782cdf0e10cSrcweir 
2783cdf0e10cSrcweir void __EXPORT ImpLBSelEng::DestroyAnchor()
2784cdf0e10cSrcweir {
2785cdf0e10cSrcweir 	pImp->pAnchor = 0;
2786cdf0e10cSrcweir }
2787cdf0e10cSrcweir 
2788cdf0e10cSrcweir /*
2789cdf0e10cSrcweir void __EXPORT ImpLBSelEng::CreateCursor()
2790cdf0e10cSrcweir {
2791cdf0e10cSrcweir 	pImp->pAnchor = 0;
2792cdf0e10cSrcweir }
2793cdf0e10cSrcweir */
2794cdf0e10cSrcweir 
2795cdf0e10cSrcweir 
2796cdf0e10cSrcweir sal_Bool __EXPORT ImpLBSelEng::SetCursorAtPoint(const Point& rPoint, sal_Bool bDontSelectAtCursor)
2797cdf0e10cSrcweir {
2798cdf0e10cSrcweir 	SvLBoxEntry* pNewCursor = pImp->MakePointVisible( rPoint );
2799cdf0e10cSrcweir 	if( pNewCursor != pImp->pCursor  )
2800cdf0e10cSrcweir 		pImp->BeginScroll();
2801cdf0e10cSrcweir 
2802cdf0e10cSrcweir 	if( pNewCursor )
2803cdf0e10cSrcweir 	{
2804cdf0e10cSrcweir 		// bei SimpleTravel wird in SetCursor selektiert und
2805cdf0e10cSrcweir 		// der Select-Handler gerufen
2806cdf0e10cSrcweir 		//if( !bDontSelectAtCursor && !pImp->bSimpleTravel )
2807cdf0e10cSrcweir 		//	pImp->SelectEntry( pNewCursor, sal_True );
2808cdf0e10cSrcweir 		pImp->SetCursor( pNewCursor, bDontSelectAtCursor );
2809cdf0e10cSrcweir 		return sal_True;
2810cdf0e10cSrcweir 	}
2811cdf0e10cSrcweir 	return sal_False;
2812cdf0e10cSrcweir }
2813cdf0e10cSrcweir 
2814cdf0e10cSrcweir sal_Bool __EXPORT ImpLBSelEng::IsSelectionAtPoint( const Point& rPoint )
2815cdf0e10cSrcweir {
2816cdf0e10cSrcweir 	SvLBoxEntry* pEntry = pImp->MakePointVisible( rPoint );
2817cdf0e10cSrcweir 	if( pEntry )
2818cdf0e10cSrcweir 		return pView->IsSelected(pEntry);
2819cdf0e10cSrcweir 	return sal_False;
2820cdf0e10cSrcweir }
2821cdf0e10cSrcweir 
2822cdf0e10cSrcweir void __EXPORT ImpLBSelEng::DeselectAtPoint( const Point& rPoint )
2823cdf0e10cSrcweir {
2824cdf0e10cSrcweir 	SvLBoxEntry* pEntry = pImp->MakePointVisible( rPoint );
2825cdf0e10cSrcweir 	if( !pEntry )
2826cdf0e10cSrcweir 		return;
2827cdf0e10cSrcweir 	pImp->SelectEntry( pEntry, sal_False );
2828cdf0e10cSrcweir }
2829cdf0e10cSrcweir 
2830cdf0e10cSrcweir /*
2831cdf0e10cSrcweir void __EXPORT ImpLBSelEng::SelectAtPoint( const Point& rPoint )
2832cdf0e10cSrcweir {
2833cdf0e10cSrcweir 	SvLBoxEntry* pEntry = pImp->MakePointVisible( rPoint );
2834cdf0e10cSrcweir 	if( !pEntry )
2835cdf0e10cSrcweir 		return;
2836cdf0e10cSrcweir 	pImp->SelectEntry( pEntry, sal_True );
2837cdf0e10cSrcweir }
2838cdf0e10cSrcweir */
2839cdf0e10cSrcweir 
2840cdf0e10cSrcweir void __EXPORT ImpLBSelEng::DeselectAll()
2841cdf0e10cSrcweir {
2842cdf0e10cSrcweir 	pImp->SelAllDestrAnch( sal_False, sal_False ); // SelectionEngine nicht resetten!
2843cdf0e10cSrcweir 	pImp->nFlags &= (~F_DESEL_ALL);
2844cdf0e10cSrcweir }
2845cdf0e10cSrcweir 
2846cdf0e10cSrcweir // ***********************************************************************
2847cdf0e10cSrcweir // Selektion
2848cdf0e10cSrcweir // ***********************************************************************
2849cdf0e10cSrcweir 
2850cdf0e10cSrcweir void SvImpLBox::SetAnchorSelection(SvLBoxEntry* pOldCursor,SvLBoxEntry* pNewCursor)
2851cdf0e10cSrcweir {
2852cdf0e10cSrcweir 	SvLBoxEntry* pEntry;
2853cdf0e10cSrcweir 	sal_uLong nAnchorVisPos = pView->GetVisiblePos( pAnchor );
2854cdf0e10cSrcweir 	sal_uLong nOldVisPos = pView->GetVisiblePos( pOldCursor );
2855cdf0e10cSrcweir 	sal_uLong nNewVisPos = pView->GetVisiblePos( pNewCursor );
2856cdf0e10cSrcweir 
2857cdf0e10cSrcweir 	if( nOldVisPos > nAnchorVisPos ||
2858cdf0e10cSrcweir 		( nAnchorVisPos==nOldVisPos && nNewVisPos > nAnchorVisPos) )
2859cdf0e10cSrcweir 	{
2860cdf0e10cSrcweir 		if( nNewVisPos > nOldVisPos )
2861cdf0e10cSrcweir 		{
2862cdf0e10cSrcweir 			pEntry = pOldCursor;
2863cdf0e10cSrcweir 			while( pEntry && pEntry != pNewCursor )
2864cdf0e10cSrcweir 			{
2865cdf0e10cSrcweir 				pView->Select( pEntry, sal_True );
2866cdf0e10cSrcweir 				pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2867cdf0e10cSrcweir 			}
2868cdf0e10cSrcweir 			if( pEntry )
2869cdf0e10cSrcweir 				pView->Select( pEntry, sal_True );
2870cdf0e10cSrcweir 			return;
2871cdf0e10cSrcweir 		}
2872cdf0e10cSrcweir 
2873cdf0e10cSrcweir 		if( nNewVisPos < nAnchorVisPos )
2874cdf0e10cSrcweir 		{
2875cdf0e10cSrcweir 			pEntry = pAnchor;
2876cdf0e10cSrcweir 			while( pEntry && pEntry != pOldCursor )
2877cdf0e10cSrcweir 			{
2878cdf0e10cSrcweir 				pView->Select( pEntry, sal_False );
2879cdf0e10cSrcweir 				pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2880cdf0e10cSrcweir 			}
2881cdf0e10cSrcweir 			if( pEntry )
2882cdf0e10cSrcweir 				pView->Select( pEntry, sal_False );
2883cdf0e10cSrcweir 
2884cdf0e10cSrcweir 			pEntry = pNewCursor;
2885cdf0e10cSrcweir 			while( pEntry && pEntry != pAnchor )
2886cdf0e10cSrcweir 			{
2887cdf0e10cSrcweir 				pView->Select( pEntry, sal_True );
2888cdf0e10cSrcweir 				pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2889cdf0e10cSrcweir 			}
2890cdf0e10cSrcweir 			if( pEntry )
2891cdf0e10cSrcweir 				pView->Select( pEntry, sal_True );
2892cdf0e10cSrcweir 			return;
2893cdf0e10cSrcweir 		}
2894cdf0e10cSrcweir 
2895cdf0e10cSrcweir 		if( nNewVisPos < nOldVisPos )
2896cdf0e10cSrcweir 		{
2897cdf0e10cSrcweir 			pEntry = pNewCursor;
2898cdf0e10cSrcweir 			pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2899cdf0e10cSrcweir 			while( pEntry && pEntry != pOldCursor )
2900cdf0e10cSrcweir 			{
2901cdf0e10cSrcweir 				pView->Select( pEntry, sal_False );
2902cdf0e10cSrcweir 				pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2903cdf0e10cSrcweir 			}
2904cdf0e10cSrcweir 			if( pEntry )
2905cdf0e10cSrcweir 				pView->Select( pEntry, sal_False );
2906cdf0e10cSrcweir 			return;
2907cdf0e10cSrcweir 		}
2908cdf0e10cSrcweir 	}
2909cdf0e10cSrcweir 	else
2910cdf0e10cSrcweir 	{
2911cdf0e10cSrcweir 		if( nNewVisPos < nOldVisPos )  // Vergroessern der Selektion
2912cdf0e10cSrcweir 		{
2913cdf0e10cSrcweir 			pEntry = pNewCursor;
2914cdf0e10cSrcweir 			while( pEntry && pEntry != pOldCursor )
2915cdf0e10cSrcweir 			{
2916cdf0e10cSrcweir 				pView->Select( pEntry, sal_True );
2917cdf0e10cSrcweir 				pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2918cdf0e10cSrcweir 			}
2919cdf0e10cSrcweir 			if( pEntry )
2920cdf0e10cSrcweir 				pView->Select( pEntry, sal_True );
2921cdf0e10cSrcweir 			return;
2922cdf0e10cSrcweir 		}
2923cdf0e10cSrcweir 
2924cdf0e10cSrcweir 		if( nNewVisPos > nAnchorVisPos )
2925cdf0e10cSrcweir 		{
2926cdf0e10cSrcweir 			pEntry = pOldCursor;
2927cdf0e10cSrcweir 			while( pEntry && pEntry != pAnchor )
2928cdf0e10cSrcweir 			{
2929cdf0e10cSrcweir 				pView->Select( pEntry, sal_False );
2930cdf0e10cSrcweir 				pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2931cdf0e10cSrcweir 			}
2932cdf0e10cSrcweir 			if( pEntry )
2933cdf0e10cSrcweir 				pView->Select( pEntry, sal_False );
2934cdf0e10cSrcweir 			pEntry = pAnchor;
2935cdf0e10cSrcweir 			while( pEntry && pEntry != pNewCursor )
2936cdf0e10cSrcweir 			{
2937cdf0e10cSrcweir 				pView->Select( pEntry, sal_True );
2938cdf0e10cSrcweir 				pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2939cdf0e10cSrcweir 			}
2940cdf0e10cSrcweir 			if( pEntry )
2941cdf0e10cSrcweir 				pView->Select( pEntry, sal_True );
2942cdf0e10cSrcweir 			return;
2943cdf0e10cSrcweir 		}
2944cdf0e10cSrcweir 
2945cdf0e10cSrcweir 		if( nNewVisPos > nOldVisPos )
2946cdf0e10cSrcweir 		{
2947cdf0e10cSrcweir 			pEntry = pOldCursor;
2948cdf0e10cSrcweir 			while( pEntry && pEntry != pNewCursor )
2949cdf0e10cSrcweir 			{
2950cdf0e10cSrcweir 				pView->Select( pEntry, sal_False );
2951cdf0e10cSrcweir 				pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
2952cdf0e10cSrcweir 			}
2953cdf0e10cSrcweir 			return;
2954cdf0e10cSrcweir 		}
2955cdf0e10cSrcweir 	}
2956cdf0e10cSrcweir }
2957cdf0e10cSrcweir 
2958cdf0e10cSrcweir void SvImpLBox::SelAllDestrAnch( sal_Bool bSelect, sal_Bool bDestroyAnchor,
2959cdf0e10cSrcweir 	sal_Bool bSingleSelToo )
2960cdf0e10cSrcweir {
2961cdf0e10cSrcweir 	SvLBoxEntry* pEntry;
2962cdf0e10cSrcweir 	nFlags &= (~F_DESEL_ALL);
2963cdf0e10cSrcweir 	if( bSelect && bSimpleTravel )
2964cdf0e10cSrcweir 	{
2965cdf0e10cSrcweir 		if( pCursor && !pView->IsSelected( pCursor ))
2966cdf0e10cSrcweir 		{
2967cdf0e10cSrcweir 			pView->Select( pCursor, sal_True );
2968cdf0e10cSrcweir 		}
2969cdf0e10cSrcweir 		return;
2970cdf0e10cSrcweir 	}
2971cdf0e10cSrcweir 	if( !bSelect && pView->GetSelectionCount() == 0 )
2972cdf0e10cSrcweir 	{
2973cdf0e10cSrcweir 		if( bSimpleTravel && ( !GetUpdateMode() || !pCursor) )
2974cdf0e10cSrcweir 			nFlags |= F_DESEL_ALL;
2975cdf0e10cSrcweir 		return;
2976cdf0e10cSrcweir 	}
2977cdf0e10cSrcweir 	if( bSelect && pView->GetSelectionCount() == pView->GetEntryCount())
2978cdf0e10cSrcweir 		return;
2979cdf0e10cSrcweir 	if( !bSingleSelToo && bSimpleTravel )
2980cdf0e10cSrcweir 		return;
2981cdf0e10cSrcweir 
2982cdf0e10cSrcweir 	if( !bSelect && pView->GetSelectionCount()==1 && pCursor &&
2983cdf0e10cSrcweir 		pView->IsSelected( pCursor ))
2984cdf0e10cSrcweir 	{
2985cdf0e10cSrcweir 		pView->Select( pCursor, sal_False );
2986cdf0e10cSrcweir 		if( bDestroyAnchor )
2987cdf0e10cSrcweir 			DestroyAnchor(); // Anker loeschen & SelectionEngine zuruecksetzen
2988cdf0e10cSrcweir 		else
2989cdf0e10cSrcweir 			pAnchor = 0; // internen Anker immer loeschen
2990cdf0e10cSrcweir 		return;
2991cdf0e10cSrcweir 	}
2992cdf0e10cSrcweir 
2993cdf0e10cSrcweir 	if( bSimpleTravel && !pCursor && !GetUpdateMode() )
2994cdf0e10cSrcweir 		nFlags |= F_DESEL_ALL;
2995cdf0e10cSrcweir 
2996cdf0e10cSrcweir 	ShowCursor( sal_False );
2997cdf0e10cSrcweir 	sal_Bool bUpdate = GetUpdateMode();
2998cdf0e10cSrcweir 
2999cdf0e10cSrcweir 	nFlags |= F_IGNORE_SELECT; // EntryInserted soll nix tun
3000cdf0e10cSrcweir 	pEntry = pTree->First();
3001cdf0e10cSrcweir 	while( pEntry )
3002cdf0e10cSrcweir 	{
3003cdf0e10cSrcweir 		if( pView->Select( pEntry, bSelect ) )
3004cdf0e10cSrcweir 		{
3005cdf0e10cSrcweir 			if( bUpdate && pView->IsEntryVisible(pEntry) )
3006cdf0e10cSrcweir 			{
3007cdf0e10cSrcweir 				long nY = GetEntryLine( pEntry );
3008cdf0e10cSrcweir 				if( IsLineVisible( nY ) )
3009cdf0e10cSrcweir 					pView->PaintEntry1( pEntry, nY, 0xffff ); // wg. ItemsetBrowser SV_LBOXTAB_SHOW_SELECTION );
3010cdf0e10cSrcweir 			}
3011cdf0e10cSrcweir 		}
3012cdf0e10cSrcweir 		pEntry = pTree->Next( pEntry );
3013cdf0e10cSrcweir 	}
3014cdf0e10cSrcweir 	nFlags &= ~F_IGNORE_SELECT;
3015cdf0e10cSrcweir 
3016cdf0e10cSrcweir 	if( bDestroyAnchor )
3017cdf0e10cSrcweir 		DestroyAnchor(); // Anker loeschen & SelectionEngine zuruecksetzen
3018cdf0e10cSrcweir 	else
3019cdf0e10cSrcweir 		pAnchor = 0; // internen Anker immer loeschen
3020cdf0e10cSrcweir 	ShowCursor( sal_True );
3021cdf0e10cSrcweir }
3022cdf0e10cSrcweir 
3023cdf0e10cSrcweir void SvImpLBox::SetSelectionMode( SelectionMode eSelMode  )
3024cdf0e10cSrcweir {
3025cdf0e10cSrcweir 	aSelEng.SetSelectionMode( eSelMode);
3026cdf0e10cSrcweir 	if( eSelMode == SINGLE_SELECTION )
3027cdf0e10cSrcweir 		bSimpleTravel = sal_True;
3028cdf0e10cSrcweir 	else
3029cdf0e10cSrcweir 		bSimpleTravel = sal_False;
3030cdf0e10cSrcweir 	if( (m_nStyle & WB_SIMPLEMODE) && (eSelMode == MULTIPLE_SELECTION) )
3031cdf0e10cSrcweir 		aSelEng.AddAlways( sal_True );
3032cdf0e10cSrcweir }
3033cdf0e10cSrcweir 
3034cdf0e10cSrcweir // ***********************************************************************
3035cdf0e10cSrcweir // Drag & Drop
3036cdf0e10cSrcweir // ***********************************************************************
3037cdf0e10cSrcweir 
3038cdf0e10cSrcweir void SvImpLBox::SetDragDropMode( DragDropMode eDDMode )
3039cdf0e10cSrcweir {
3040cdf0e10cSrcweir 	if( eDDMode && eDDMode != SV_DRAGDROP_APP_DROP )
3041cdf0e10cSrcweir 	{
3042cdf0e10cSrcweir 		aSelEng.ExpandSelectionOnMouseMove( sal_False );
3043cdf0e10cSrcweir 		aSelEng.EnableDrag( sal_True );
3044cdf0e10cSrcweir 	}
3045cdf0e10cSrcweir 	else
3046cdf0e10cSrcweir 	{
3047cdf0e10cSrcweir 		aSelEng.ExpandSelectionOnMouseMove( sal_True );
3048cdf0e10cSrcweir 		aSelEng.EnableDrag( sal_False );
3049cdf0e10cSrcweir 	}
3050cdf0e10cSrcweir }
3051cdf0e10cSrcweir 
3052cdf0e10cSrcweir void SvImpLBox::BeginDrag()
3053cdf0e10cSrcweir {
3054cdf0e10cSrcweir 	nFlags &= (~F_FILLING);
3055cdf0e10cSrcweir 	if( !bAsyncBeginDrag )
3056cdf0e10cSrcweir 	{
3057cdf0e10cSrcweir 		BeginScroll();
3058cdf0e10cSrcweir 		pView->StartDrag( 0, aSelEng.GetMousePosPixel() );
3059cdf0e10cSrcweir 		EndScroll();
3060cdf0e10cSrcweir 	}
3061cdf0e10cSrcweir 	else
3062cdf0e10cSrcweir 	{
3063cdf0e10cSrcweir 		aAsyncBeginDragPos = aSelEng.GetMousePosPixel();
3064cdf0e10cSrcweir 		aAsyncBeginDragTimer.Start();
3065cdf0e10cSrcweir 	}
3066cdf0e10cSrcweir }
3067cdf0e10cSrcweir 
3068cdf0e10cSrcweir IMPL_LINK( SvImpLBox, BeginDragHdl, void*, EMPTYARG )
3069cdf0e10cSrcweir {
3070cdf0e10cSrcweir 	pView->StartDrag( 0, aAsyncBeginDragPos );
3071cdf0e10cSrcweir 	return 0;
3072cdf0e10cSrcweir }
3073cdf0e10cSrcweir 
3074cdf0e10cSrcweir void SvImpLBox::PaintDDCursor( SvLBoxEntry* pInsertionPos )
3075cdf0e10cSrcweir {
3076cdf0e10cSrcweir 	long nY;
3077cdf0e10cSrcweir 	if( pInsertionPos )
3078cdf0e10cSrcweir 	{
3079cdf0e10cSrcweir 		nY = GetEntryLine( pInsertionPos );
3080cdf0e10cSrcweir 		nY += pView->GetEntryHeight();
3081cdf0e10cSrcweir 	}
3082cdf0e10cSrcweir 	else
3083cdf0e10cSrcweir 		nY = 1;
3084cdf0e10cSrcweir 	RasterOp eOldOp = pView->GetRasterOp();
3085cdf0e10cSrcweir 	pView->SetRasterOp( ROP_INVERT );
3086cdf0e10cSrcweir 	Color aOldLineColor = pView->GetLineColor();
3087cdf0e10cSrcweir 	pView->SetLineColor( Color( COL_BLACK ) );
3088cdf0e10cSrcweir 	pView->DrawLine( Point( 0, nY ), Point( aOutputSize.Width(), nY ) );
3089cdf0e10cSrcweir 	pView->SetLineColor( aOldLineColor );
3090cdf0e10cSrcweir 	pView->SetRasterOp( eOldOp );
3091cdf0e10cSrcweir }
3092cdf0e10cSrcweir /* -----------------26.08.2003 12:52-----------------
3093cdf0e10cSrcweir     Delete all sub menues of a PopupMenu, recursively
3094cdf0e10cSrcweir  --------------------------------------------------*/
3095cdf0e10cSrcweir void lcl_DeleteSubPopups(PopupMenu* pPopup)
3096cdf0e10cSrcweir {
3097cdf0e10cSrcweir     for(sal_uInt16 i = 0; i < pPopup->GetItemCount(); i++)
3098cdf0e10cSrcweir     {
3099cdf0e10cSrcweir         PopupMenu* pSubPopup = pPopup->GetPopupMenu( pPopup->GetItemId( i ));
3100cdf0e10cSrcweir         if(pSubPopup)
3101cdf0e10cSrcweir 		{
3102cdf0e10cSrcweir             lcl_DeleteSubPopups(pSubPopup);
3103cdf0e10cSrcweir 			delete pSubPopup;
3104cdf0e10cSrcweir 		}
3105cdf0e10cSrcweir     }
3106cdf0e10cSrcweir }
3107cdf0e10cSrcweir 
3108cdf0e10cSrcweir void SvImpLBox::Command( const CommandEvent& rCEvt )
3109cdf0e10cSrcweir {
3110cdf0e10cSrcweir 	sal_uInt16				nCommand = rCEvt.GetCommand();
3111cdf0e10cSrcweir 
3112cdf0e10cSrcweir     if( nCommand == COMMAND_CONTEXTMENU )
3113cdf0e10cSrcweir         aEditTimer.Stop();
3114cdf0e10cSrcweir 
3115cdf0e10cSrcweir 	// Rollmaus-Event?
3116cdf0e10cSrcweir 	if( ( ( nCommand == COMMAND_WHEEL ) || ( nCommand == COMMAND_STARTAUTOSCROLL ) || ( nCommand == COMMAND_AUTOSCROLL ) )
3117cdf0e10cSrcweir 		&& pView->HandleScrollCommand( rCEvt, &aHorSBar, &aVerSBar ) )
3118cdf0e10cSrcweir 			return;
3119cdf0e10cSrcweir 
3120cdf0e10cSrcweir 	if( bContextMenuHandling && nCommand == COMMAND_CONTEXTMENU )
3121cdf0e10cSrcweir 	{
3122cdf0e10cSrcweir 		Point	aPopupPos;
3123cdf0e10cSrcweir 		sal_Bool	bClickedIsFreePlace = sal_False;
3124cdf0e10cSrcweir 		std::stack<SvLBoxEntry*> aSelRestore;
3125cdf0e10cSrcweir 
3126cdf0e10cSrcweir 		if( rCEvt.IsMouseEvent() )
3127cdf0e10cSrcweir 		{	// change selection, if mouse pos doesn't fit to selection
3128cdf0e10cSrcweir 
3129cdf0e10cSrcweir 			aPopupPos = rCEvt.GetMousePosPixel();
3130cdf0e10cSrcweir 
3131cdf0e10cSrcweir 			SvLBoxEntry*	pClickedEntry = GetEntry( aPopupPos );
3132cdf0e10cSrcweir 			if( pClickedEntry )
3133cdf0e10cSrcweir 			{	// mouse in non empty area
3134cdf0e10cSrcweir 				sal_Bool				bClickedIsSelected = sal_False;
3135cdf0e10cSrcweir 
3136cdf0e10cSrcweir 				// collect the currently selected entries
3137cdf0e10cSrcweir 				SvLBoxEntry*		pSelected = pView->FirstSelected();
3138cdf0e10cSrcweir 				while( pSelected )
3139cdf0e10cSrcweir 				{
3140cdf0e10cSrcweir 					bClickedIsSelected |= ( pClickedEntry == pSelected );
3141cdf0e10cSrcweir 					pSelected = pView->NextSelected( pSelected );
3142cdf0e10cSrcweir 				}
3143cdf0e10cSrcweir 
3144cdf0e10cSrcweir 				// if the entry which the user clicked at is not selected
3145cdf0e10cSrcweir 				if( !bClickedIsSelected )
3146cdf0e10cSrcweir 				{	// deselect all other and select the clicked one
3147cdf0e10cSrcweir 					pView->SelectAll( sal_False );
3148cdf0e10cSrcweir 					pView->SetCursor( pClickedEntry );
3149cdf0e10cSrcweir 				}
3150cdf0e10cSrcweir 			}
3151cdf0e10cSrcweir 			else if( aSelEng.GetSelectionMode() == SINGLE_SELECTION )
3152cdf0e10cSrcweir 			{//modified by BerryJia for fixing Bug102739 2002-9-9 17:00(Beijing Time)
3153cdf0e10cSrcweir 				bClickedIsFreePlace = sal_True;
3154cdf0e10cSrcweir 				sal_Int32				nSelectedEntries = pView->GetSelectionCount();
3155cdf0e10cSrcweir 				SvLBoxEntry*		pSelected = pView->FirstSelected();
3156cdf0e10cSrcweir 				for(sal_uInt16 nSel = 0; nSel < nSelectedEntries; nSel++ )
3157cdf0e10cSrcweir 				{
3158cdf0e10cSrcweir 					aSelRestore.push(pSelected);
3159cdf0e10cSrcweir 					pSelected = pView->NextSelected( pSelected );
3160cdf0e10cSrcweir 				}
3161cdf0e10cSrcweir 				pView->SelectAll( sal_False );
3162cdf0e10cSrcweir 			}
3163cdf0e10cSrcweir 			else
3164cdf0e10cSrcweir 			{	// deselect all
3165cdf0e10cSrcweir 				pView->SelectAll( sal_False );
3166cdf0e10cSrcweir 			}
3167cdf0e10cSrcweir 
3168cdf0e10cSrcweir 
3169cdf0e10cSrcweir 		}
3170cdf0e10cSrcweir 		else
3171cdf0e10cSrcweir 		{	// key event (or at least no mouse event)
3172cdf0e10cSrcweir 			sal_Int32	nSelectionCount = pView->GetSelectionCount();
3173cdf0e10cSrcweir 
3174cdf0e10cSrcweir 			if( nSelectionCount )
3175cdf0e10cSrcweir 			{	// now allways take first visible as base for positioning the menu
3176cdf0e10cSrcweir 				SvLBoxEntry*	pSelected = pView->FirstSelected();
3177cdf0e10cSrcweir 				while( pSelected )
3178cdf0e10cSrcweir 				{
3179cdf0e10cSrcweir 					if( IsEntryInView( pSelected ) )
3180cdf0e10cSrcweir 						break;
3181cdf0e10cSrcweir 
3182cdf0e10cSrcweir 					pSelected = pView->NextSelected( pSelected );
3183cdf0e10cSrcweir 				}
3184cdf0e10cSrcweir 
3185cdf0e10cSrcweir 				if( !pSelected )
3186cdf0e10cSrcweir 				{
3187cdf0e10cSrcweir 					// no one was visible
3188cdf0e10cSrcweir 					pSelected = pView->FirstSelected();
3189cdf0e10cSrcweir 					pView->MakeVisible( pSelected );
3190cdf0e10cSrcweir 				}
3191cdf0e10cSrcweir 
3192cdf0e10cSrcweir 				aPopupPos = pView->GetFocusRect( pSelected, pView->GetEntryPosition( pSelected ).Y() ).Center();
3193cdf0e10cSrcweir 			}
3194cdf0e10cSrcweir 			else
3195cdf0e10cSrcweir 				aPopupPos = Point( 0, 0 );
3196cdf0e10cSrcweir 		}
3197cdf0e10cSrcweir 
3198cdf0e10cSrcweir 		PopupMenu*	pPopup = pView->CreateContextMenu();
3199cdf0e10cSrcweir 
3200cdf0e10cSrcweir 		if( pPopup )
3201cdf0e10cSrcweir 		{
3202cdf0e10cSrcweir 			// do action for selected entry in popup menu
3203cdf0e10cSrcweir             sal_uInt16 nMenuAction = pPopup->Execute( pView, aPopupPos );
3204cdf0e10cSrcweir             if ( nMenuAction )
3205cdf0e10cSrcweir 			    pView->ExcecuteContextMenuAction( nMenuAction );
3206cdf0e10cSrcweir             lcl_DeleteSubPopups(pPopup);
3207cdf0e10cSrcweir             delete pPopup;
3208cdf0e10cSrcweir 		}
3209cdf0e10cSrcweir 		//added by BerryJia for fixing Bug102739 2002-9-9 17:00(Beijing Time)
3210cdf0e10cSrcweir 		if( bClickedIsFreePlace )
3211cdf0e10cSrcweir 		{
3212cdf0e10cSrcweir 			while(!aSelRestore.empty())
3213cdf0e10cSrcweir 			{
3214cdf0e10cSrcweir 				SvLBoxEntry* pEntry = aSelRestore.top();
3215cdf0e10cSrcweir 				//#i19717# the entry is maybe already deleted
3216cdf0e10cSrcweir 				bool bFound = false;
3217cdf0e10cSrcweir 				for(sal_uLong nEntry = 0; nEntry < pView->GetEntryCount(); nEntry++)
3218cdf0e10cSrcweir 					if(pEntry == pView->GetEntry(nEntry))
3219cdf0e10cSrcweir 					{
3220cdf0e10cSrcweir 						bFound = true;
3221cdf0e10cSrcweir 						break;
3222cdf0e10cSrcweir 					}
3223cdf0e10cSrcweir 				if(bFound)
3224cdf0e10cSrcweir 					SetCurEntry( pEntry );
3225cdf0e10cSrcweir 				aSelRestore.pop();
3226cdf0e10cSrcweir 			}
3227cdf0e10cSrcweir 		}
3228cdf0e10cSrcweir 	}
3229cdf0e10cSrcweir #ifndef NOCOMMAND
3230cdf0e10cSrcweir 	else
3231cdf0e10cSrcweir 	{
3232cdf0e10cSrcweir 		const Point& rPos = rCEvt.GetMousePosPixel();
3233cdf0e10cSrcweir 		if( rPos.X() < aOutputSize.Width() && rPos.Y() < aOutputSize.Height() )
3234cdf0e10cSrcweir 			aSelEng.Command( rCEvt );
3235cdf0e10cSrcweir 	}
3236cdf0e10cSrcweir #endif
3237cdf0e10cSrcweir }
3238cdf0e10cSrcweir 
3239cdf0e10cSrcweir void SvImpLBox::BeginScroll()
3240cdf0e10cSrcweir {
3241cdf0e10cSrcweir 	if( !(nFlags & F_IN_SCROLLING))
3242cdf0e10cSrcweir 	{
3243cdf0e10cSrcweir 		pView->NotifyBeginScroll();
3244cdf0e10cSrcweir 		nFlags |= F_IN_SCROLLING;
3245cdf0e10cSrcweir 	}
3246cdf0e10cSrcweir }
3247cdf0e10cSrcweir 
3248cdf0e10cSrcweir void SvImpLBox::EndScroll()
3249cdf0e10cSrcweir {
3250cdf0e10cSrcweir 	if( nFlags & F_IN_SCROLLING)
3251cdf0e10cSrcweir 	{
3252cdf0e10cSrcweir 		pView->NotifyEndScroll();
3253cdf0e10cSrcweir 		nFlags &= (~F_IN_SCROLLING);
3254cdf0e10cSrcweir 	}
3255cdf0e10cSrcweir }
3256cdf0e10cSrcweir 
3257cdf0e10cSrcweir 
3258cdf0e10cSrcweir Rectangle SvImpLBox::GetVisibleArea() const
3259cdf0e10cSrcweir {
3260cdf0e10cSrcweir 	Point aPos( pView->GetMapMode().GetOrigin() );
3261cdf0e10cSrcweir 	aPos.X() *= -1;
3262cdf0e10cSrcweir 	Rectangle aRect( aPos, aOutputSize );
3263cdf0e10cSrcweir 	return aRect;
3264cdf0e10cSrcweir }
3265cdf0e10cSrcweir 
3266cdf0e10cSrcweir void SvImpLBox::Invalidate()
3267cdf0e10cSrcweir {
3268cdf0e10cSrcweir 	pView->SetClipRegion();
3269cdf0e10cSrcweir }
3270cdf0e10cSrcweir 
3271cdf0e10cSrcweir void SvImpLBox::SetCurEntry( SvLBoxEntry* pEntry )
3272cdf0e10cSrcweir {
3273cdf0e10cSrcweir 	if  (  ( aSelEng.GetSelectionMode() != SINGLE_SELECTION )
3274cdf0e10cSrcweir         && ( aSelEng.GetSelectionMode() != NO_SELECTION )
3275cdf0e10cSrcweir         )
3276cdf0e10cSrcweir 		SelAllDestrAnch( sal_False, sal_True, sal_False );
3277cdf0e10cSrcweir     if ( pEntry )
3278cdf0e10cSrcweir 	    MakeVisible( pEntry );
3279cdf0e10cSrcweir 	SetCursor( pEntry );
3280cdf0e10cSrcweir     if ( pEntry && ( aSelEng.GetSelectionMode() != NO_SELECTION ) )
3281cdf0e10cSrcweir 		pView->Select( pEntry, sal_True );
3282cdf0e10cSrcweir }
3283cdf0e10cSrcweir 
3284cdf0e10cSrcweir IMPL_LINK( SvImpLBox, EditTimerCall, Timer *, EMPTYARG )
3285cdf0e10cSrcweir {
3286cdf0e10cSrcweir 	if( pView->IsInplaceEditingEnabled() )
3287cdf0e10cSrcweir 	{
3288cdf0e10cSrcweir 		sal_Bool bIsMouseTriggered = aEditClickPos.X() >= 0;
3289cdf0e10cSrcweir 		if ( bIsMouseTriggered )
3290cdf0e10cSrcweir 		{
3291cdf0e10cSrcweir 			Point aCurrentMousePos = pView->GetPointerPosPixel();
3292cdf0e10cSrcweir 			if	(	( abs( aCurrentMousePos.X() - aEditClickPos.X() ) > 5 )
3293cdf0e10cSrcweir 				||	( abs( aCurrentMousePos.Y() - aEditClickPos.Y() ) > 5 )
3294cdf0e10cSrcweir 				)
3295cdf0e10cSrcweir 			{
3296cdf0e10cSrcweir 				return 0L;
3297cdf0e10cSrcweir 			}
3298cdf0e10cSrcweir 		}
3299cdf0e10cSrcweir 
3300cdf0e10cSrcweir 		SvLBoxEntry* pEntry = GetCurEntry();
3301cdf0e10cSrcweir 		if( pEntry )
3302cdf0e10cSrcweir 		{
3303cdf0e10cSrcweir 			ShowCursor( sal_False );
3304cdf0e10cSrcweir 			pView->ImplEditEntry( pEntry );
3305cdf0e10cSrcweir 			ShowCursor( sal_True );
3306cdf0e10cSrcweir 		}
3307cdf0e10cSrcweir 	}
3308cdf0e10cSrcweir 	return 0;
3309cdf0e10cSrcweir }
3310cdf0e10cSrcweir 
3311cdf0e10cSrcweir sal_Bool SvImpLBox::RequestHelp( const HelpEvent& rHEvt )
3312cdf0e10cSrcweir {
3313cdf0e10cSrcweir 	if( rHEvt.GetMode() & HELPMODE_QUICK )
3314cdf0e10cSrcweir 	{
3315cdf0e10cSrcweir 		Point aPos( pView->ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
3316cdf0e10cSrcweir 		if( !GetVisibleArea().IsInside( aPos ))
3317cdf0e10cSrcweir 			return sal_False;
3318cdf0e10cSrcweir 
3319cdf0e10cSrcweir 		SvLBoxEntry* pEntry = GetEntry( aPos );
3320cdf0e10cSrcweir 		if( pEntry )
3321cdf0e10cSrcweir 		{
3322cdf0e10cSrcweir 			// Rechteck des Textes berechnen
3323cdf0e10cSrcweir 			SvLBoxTab* pTab;
3324cdf0e10cSrcweir 			SvLBoxString* pItem = (SvLBoxString*)(pView->GetItem( pEntry, aPos.X(), &pTab ));
3325cdf0e10cSrcweir 			if( !pItem || pItem->IsA() != SV_ITEM_ID_LBOXSTRING )
3326cdf0e10cSrcweir 				return sal_False;
3327cdf0e10cSrcweir 
3328cdf0e10cSrcweir 			aPos = GetEntryPosition( pEntry );
3329cdf0e10cSrcweir 			aPos.X() = pView->GetTabPos( pEntry, pTab ); //pTab->GetPos();
3330cdf0e10cSrcweir 			Size aSize( pItem->GetSize( pView, pEntry ) );
3331cdf0e10cSrcweir 			SvLBoxTab* pNextTab = NextTab( pTab );
3332cdf0e10cSrcweir 			sal_Bool bItemClipped = sal_False;
3333cdf0e10cSrcweir 			// wurde das Item von seinem rechten Nachbarn abgeschnitten?
3334cdf0e10cSrcweir 			if( pNextTab && pView->GetTabPos(pEntry,pNextTab) < aPos.X()+aSize.Width() )
3335cdf0e10cSrcweir 			{
3336cdf0e10cSrcweir 				aSize.Width() = pNextTab->GetPos() - pTab->GetPos();
3337cdf0e10cSrcweir 				bItemClipped = sal_True;
3338cdf0e10cSrcweir 			}
3339cdf0e10cSrcweir 			Rectangle aItemRect( aPos, aSize );
3340cdf0e10cSrcweir 
3341cdf0e10cSrcweir 			Rectangle aViewRect( GetVisibleArea() );
3342cdf0e10cSrcweir 
3343cdf0e10cSrcweir 			if( bItemClipped || !aViewRect.IsInside( aItemRect ) )
3344cdf0e10cSrcweir 			{
3345cdf0e10cSrcweir 				// rechten Item-Rand am View-Rand clippen
3346cdf0e10cSrcweir 				//if( aItemRect.Right() > aViewRect.Right() )
3347cdf0e10cSrcweir 				//	aItemRect.Right() = aViewRect.Right();
3348cdf0e10cSrcweir 
3349cdf0e10cSrcweir 				Point aPt = pView->OutputToScreenPixel( aItemRect.TopLeft() );
3350cdf0e10cSrcweir 				aItemRect.Left()   = aPt.X();
3351cdf0e10cSrcweir 				aItemRect.Top()    = aPt.Y();
3352cdf0e10cSrcweir 				aPt = pView->OutputToScreenPixel( aItemRect.BottomRight() );
3353cdf0e10cSrcweir 				aItemRect.Right()  = aPt.X();
3354cdf0e10cSrcweir 				aItemRect.Bottom() = aPt.Y();
3355cdf0e10cSrcweir 
3356cdf0e10cSrcweir 				Help::ShowQuickHelp( pView, aItemRect,
3357cdf0e10cSrcweir 									 pItem->GetText(), QUICKHELP_LEFT | QUICKHELP_VCENTER );
3358cdf0e10cSrcweir 				return sal_True;
3359cdf0e10cSrcweir 			}
3360cdf0e10cSrcweir 		}
3361cdf0e10cSrcweir 	}
3362cdf0e10cSrcweir 	return sal_False;
3363cdf0e10cSrcweir }
3364cdf0e10cSrcweir 
3365cdf0e10cSrcweir SvLBoxTab* SvImpLBox::NextTab( SvLBoxTab* pTab )
3366cdf0e10cSrcweir {
3367cdf0e10cSrcweir 	sal_uInt16 nTabCount = pView->TabCount();
3368cdf0e10cSrcweir 	if( nTabCount <= 1 )
3369cdf0e10cSrcweir 		return 0;
3370cdf0e10cSrcweir 	for( sal_uInt16 nTab=0; nTab < (nTabCount-1); nTab++)
3371cdf0e10cSrcweir 	{
3372cdf0e10cSrcweir 		if( pView->aTabs[nTab]==pTab )
3373cdf0e10cSrcweir 			return (SvLBoxTab*)(pView->aTabs[nTab+1]);
3374cdf0e10cSrcweir 	}
3375cdf0e10cSrcweir 	return 0;
3376cdf0e10cSrcweir }
3377cdf0e10cSrcweir 
3378cdf0e10cSrcweir void SvImpLBox::EndSelection()
3379cdf0e10cSrcweir {
3380cdf0e10cSrcweir 	DestroyAnchor();
3381cdf0e10cSrcweir 	nFlags &=  ~F_START_EDITTIMER;
3382cdf0e10cSrcweir }
3383cdf0e10cSrcweir 
3384cdf0e10cSrcweir void SvImpLBox::RepaintScrollBars()
3385cdf0e10cSrcweir {
3386cdf0e10cSrcweir }
3387cdf0e10cSrcweir 
3388cdf0e10cSrcweir void SvImpLBox::SetUpdateMode( sal_Bool bMode )
3389cdf0e10cSrcweir {
3390cdf0e10cSrcweir 	if( bUpdateMode != bMode )
3391cdf0e10cSrcweir 	{
3392cdf0e10cSrcweir 		bUpdateMode = bMode;
3393cdf0e10cSrcweir 		if( bUpdateMode )
3394cdf0e10cSrcweir 			UpdateAll( sal_False );
3395cdf0e10cSrcweir 	}
3396cdf0e10cSrcweir }
3397cdf0e10cSrcweir 
3398cdf0e10cSrcweir void SvImpLBox::SetUpdateModeFast( sal_Bool bMode )
3399cdf0e10cSrcweir {
3400cdf0e10cSrcweir 	if( bUpdateMode != bMode )
3401cdf0e10cSrcweir 	{
3402cdf0e10cSrcweir 		bUpdateMode = bMode;
3403cdf0e10cSrcweir 		if( bUpdateMode )
3404cdf0e10cSrcweir 			UpdateAll( sal_False, sal_False );
3405cdf0e10cSrcweir 	}
3406cdf0e10cSrcweir }
3407cdf0e10cSrcweir 
3408cdf0e10cSrcweir 
3409cdf0e10cSrcweir sal_Bool SvImpLBox::SetMostRight( SvLBoxEntry* pEntry )
3410cdf0e10cSrcweir {
3411cdf0e10cSrcweir 	if( pView->nTreeFlags & TREEFLAG_RECALCTABS )
3412cdf0e10cSrcweir 	{
3413cdf0e10cSrcweir 		nFlags |= F_IGNORE_CHANGED_TABS;
3414cdf0e10cSrcweir 		pView->SetTabs();
3415cdf0e10cSrcweir 		nFlags &= ~F_IGNORE_CHANGED_TABS;
3416cdf0e10cSrcweir 	}
3417cdf0e10cSrcweir 
3418cdf0e10cSrcweir 	sal_uInt16 nLastTab = pView->aTabs.Count() - 1;
3419cdf0e10cSrcweir 	sal_uInt16 nLastItem = pEntry->ItemCount() - 1;
3420cdf0e10cSrcweir 	if( nLastTab != USHRT_MAX && nLastItem != USHRT_MAX )
3421cdf0e10cSrcweir 	{
3422cdf0e10cSrcweir 		if( nLastItem < nLastTab )
3423cdf0e10cSrcweir 			nLastTab = nLastItem;
3424cdf0e10cSrcweir 
3425cdf0e10cSrcweir 		SvLBoxTab* pTab = (SvLBoxTab*)pView->aTabs[ nLastTab ];
3426cdf0e10cSrcweir 		SvLBoxItem* pItem = pEntry->GetItem( nLastTab );
3427cdf0e10cSrcweir 
3428cdf0e10cSrcweir 		long nTabPos = pView->GetTabPos( pEntry, pTab );
3429cdf0e10cSrcweir 
3430cdf0e10cSrcweir 		long nMaxRight = GetOutputSize().Width();
3431cdf0e10cSrcweir 		Point aPos( pView->GetMapMode().GetOrigin() );
3432cdf0e10cSrcweir 		aPos.X() *= -1; // Umrechnung Dokumentkoord.
3433cdf0e10cSrcweir 		nMaxRight = nMaxRight + aPos.X() - 1;
3434cdf0e10cSrcweir 
3435cdf0e10cSrcweir 		long nNextTab = nTabPos < nMaxRight ? nMaxRight : nMaxRight + 50;
3436cdf0e10cSrcweir 		long nTabWidth = nNextTab - nTabPos + 1;
3437cdf0e10cSrcweir 		long nItemSize = pItem->GetSize(pView,pEntry).Width();
3438cdf0e10cSrcweir 		long nOffset = pTab->CalcOffset( nItemSize, nTabWidth );
3439cdf0e10cSrcweir 
3440cdf0e10cSrcweir 		long nRight = nTabPos + nOffset + nItemSize;
3441cdf0e10cSrcweir 		if( nRight > nMostRight )
3442cdf0e10cSrcweir 		{
3443cdf0e10cSrcweir 			nMostRight = nRight;
3444cdf0e10cSrcweir 			pMostRightEntry = pEntry;
3445cdf0e10cSrcweir 			return sal_True;
3446cdf0e10cSrcweir 		}
3447cdf0e10cSrcweir 	}
3448cdf0e10cSrcweir 	return sal_False;
3449cdf0e10cSrcweir }
3450cdf0e10cSrcweir 
3451cdf0e10cSrcweir void SvImpLBox::FindMostRight( SvLBoxEntry* pEntryToIgnore )
3452cdf0e10cSrcweir {
3453cdf0e10cSrcweir 	nMostRight = -1;
3454cdf0e10cSrcweir 	pMostRightEntry = 0;
3455cdf0e10cSrcweir 	if( !pView->GetModel() )
3456cdf0e10cSrcweir 		return;
3457cdf0e10cSrcweir 
3458cdf0e10cSrcweir 	SvLBoxEntry* pEntry = (SvLBoxEntry*)pView->FirstVisible();
3459cdf0e10cSrcweir 	while( pEntry )
3460cdf0e10cSrcweir 	{
3461cdf0e10cSrcweir 		if( pEntry != pEntryToIgnore )
3462cdf0e10cSrcweir 			SetMostRight( pEntry );
3463cdf0e10cSrcweir 		pEntry = (SvLBoxEntry*)pView->NextVisible( pEntry );
3464cdf0e10cSrcweir 	}
3465cdf0e10cSrcweir }
3466cdf0e10cSrcweir 
3467cdf0e10cSrcweir void SvImpLBox::FindMostRight( SvLBoxEntry* pParent, SvLBoxEntry* pEntryToIgnore )
3468cdf0e10cSrcweir {
3469cdf0e10cSrcweir 	if( !pParent )
3470cdf0e10cSrcweir 		FindMostRight( pEntryToIgnore );
3471cdf0e10cSrcweir 	else
3472cdf0e10cSrcweir 		FindMostRight_Impl( pParent, pEntryToIgnore  );
3473cdf0e10cSrcweir }
3474cdf0e10cSrcweir 
3475cdf0e10cSrcweir void SvImpLBox::FindMostRight_Impl( SvLBoxEntry* pParent, SvLBoxEntry* pEntryToIgnore )
3476cdf0e10cSrcweir {
3477cdf0e10cSrcweir 	SvTreeEntryList* pList = pTree->GetChildList( pParent );
3478cdf0e10cSrcweir 
3479cdf0e10cSrcweir 	if( !pList )
3480cdf0e10cSrcweir 		return;
3481cdf0e10cSrcweir 
3482cdf0e10cSrcweir 	sal_uLong nCount = pList->Count();
3483cdf0e10cSrcweir 	for( sal_uLong nCur = 0; nCur < nCount; nCur++ )
3484cdf0e10cSrcweir 	{
3485cdf0e10cSrcweir 		SvLBoxEntry* pChild = (SvLBoxEntry*)pList->GetObject( nCur );
3486cdf0e10cSrcweir 		if( pChild != pEntryToIgnore )
3487cdf0e10cSrcweir 		{
3488cdf0e10cSrcweir 			SetMostRight( pChild );
3489cdf0e10cSrcweir 			if( pChild->HasChilds() && pView->IsExpanded( pChild ))
3490cdf0e10cSrcweir 				FindMostRight_Impl( pChild, pEntryToIgnore );
3491cdf0e10cSrcweir 		}
3492cdf0e10cSrcweir 	}
3493cdf0e10cSrcweir }
3494cdf0e10cSrcweir 
3495cdf0e10cSrcweir void SvImpLBox::NotifyTabsChanged()
3496cdf0e10cSrcweir {
3497cdf0e10cSrcweir 	if( GetUpdateMode() && !(nFlags & F_IGNORE_CHANGED_TABS ) &&
3498cdf0e10cSrcweir 		nCurUserEvent == 0xffffffff )
3499cdf0e10cSrcweir 	{
3500cdf0e10cSrcweir 		nCurUserEvent = Application::PostUserEvent(LINK(this,SvImpLBox,MyUserEvent),(void*)0);
3501cdf0e10cSrcweir 	}
3502cdf0e10cSrcweir }
3503cdf0e10cSrcweir 
3504cdf0e10cSrcweir IMPL_LINK(SvImpLBox,MyUserEvent,void*, pArg )
3505cdf0e10cSrcweir {
3506cdf0e10cSrcweir 	nCurUserEvent = 0xffffffff;
3507cdf0e10cSrcweir 	if( !pArg )
3508cdf0e10cSrcweir 	{
3509cdf0e10cSrcweir 		pView->Invalidate();
3510cdf0e10cSrcweir 		pView->Update();
3511cdf0e10cSrcweir 	}
3512cdf0e10cSrcweir 	else
3513cdf0e10cSrcweir 	{
3514cdf0e10cSrcweir 		FindMostRight( 0 );
3515cdf0e10cSrcweir 		ShowVerSBar();
3516cdf0e10cSrcweir 		pView->Invalidate( GetVisibleArea() );
3517cdf0e10cSrcweir 	}
3518cdf0e10cSrcweir 	return 0;
3519cdf0e10cSrcweir }
3520cdf0e10cSrcweir 
3521cdf0e10cSrcweir 
3522cdf0e10cSrcweir void SvImpLBox::StopUserEvent()
3523cdf0e10cSrcweir {
3524cdf0e10cSrcweir 	if( nCurUserEvent != 0xffffffff )
3525cdf0e10cSrcweir 	{
3526cdf0e10cSrcweir 		Application::RemoveUserEvent( nCurUserEvent );
3527cdf0e10cSrcweir 		nCurUserEvent = 0xffffffff;
3528cdf0e10cSrcweir 	}
3529cdf0e10cSrcweir }
3530cdf0e10cSrcweir 
3531cdf0e10cSrcweir void SvImpLBox::ShowFocusRect( const SvLBoxEntry* pEntry )
3532cdf0e10cSrcweir {
3533cdf0e10cSrcweir 	if( pEntry )
3534cdf0e10cSrcweir 	{
3535cdf0e10cSrcweir 		long nY = GetEntryLine( (SvLBoxEntry*)pEntry );
3536cdf0e10cSrcweir 		Rectangle aRect = pView->GetFocusRect( (SvLBoxEntry*)pEntry, nY );
3537cdf0e10cSrcweir 		Region aOldClip( pView->GetClipRegion());
3538cdf0e10cSrcweir 		Region aClipRegion( GetClipRegionRect() );
3539cdf0e10cSrcweir 		pView->SetClipRegion( aClipRegion );
3540cdf0e10cSrcweir 		pView->ShowFocus( aRect );
3541cdf0e10cSrcweir 		pView->SetClipRegion( aOldClip );
3542cdf0e10cSrcweir 
3543cdf0e10cSrcweir 	}
3544cdf0e10cSrcweir 	else
3545cdf0e10cSrcweir 	{
3546cdf0e10cSrcweir 		pView->HideFocus();
3547cdf0e10cSrcweir 	}
3548cdf0e10cSrcweir }
3549cdf0e10cSrcweir 
3550cdf0e10cSrcweir void SvImpLBox::SetTabBar( TabBar* _pTabBar )
3551cdf0e10cSrcweir {
3552cdf0e10cSrcweir 	pTabBar = _pTabBar;
3553cdf0e10cSrcweir }
3554cdf0e10cSrcweir 
3555cdf0e10cSrcweir void SvImpLBox::CancelPendingEdit()
3556cdf0e10cSrcweir {
3557cdf0e10cSrcweir 	if( aEditTimer.IsActive() )
3558cdf0e10cSrcweir 		aEditTimer.Stop();
3559cdf0e10cSrcweir 	nFlags &= ~F_START_EDITTIMER;
3560cdf0e10cSrcweir }
3561cdf0e10cSrcweir 
3562cdf0e10cSrcweir // -----------------------------------------------------------------------
3563cdf0e10cSrcweir void SvImpLBox::implInitDefaultNodeImages()
3564cdf0e10cSrcweir {
3565cdf0e10cSrcweir 	if ( s_pDefCollapsed )
3566cdf0e10cSrcweir 		// assume that all or nothing is initialized
3567cdf0e10cSrcweir 		return;
3568cdf0e10cSrcweir 
3569cdf0e10cSrcweir 	s_pDefCollapsed = new Image( SvtResId( RID_IMG_TREENODE_COLLAPSED ) );
3570cdf0e10cSrcweir 	s_pDefCollapsedHC = new Image( SvtResId( RID_IMG_TREENODE_COLLAPSED_HC ) );
3571cdf0e10cSrcweir 	s_pDefExpanded = new Image( SvtResId( RID_IMG_TREENODE_EXPANDED ) );
3572cdf0e10cSrcweir 	s_pDefExpandedHC = new Image( SvtResId( RID_IMG_TREENODE_EXPANDED_HC ) );
3573cdf0e10cSrcweir }
3574cdf0e10cSrcweir 
3575cdf0e10cSrcweir // -----------------------------------------------------------------------
3576cdf0e10cSrcweir const Image& SvImpLBox::GetDefaultExpandedNodeImage( BmpColorMode _eMode )
3577cdf0e10cSrcweir {
3578cdf0e10cSrcweir 	implInitDefaultNodeImages();
3579cdf0e10cSrcweir 	return ( BMP_COLOR_NORMAL == _eMode ) ? *s_pDefExpanded : *s_pDefExpandedHC;
3580cdf0e10cSrcweir }
3581cdf0e10cSrcweir 
3582cdf0e10cSrcweir // -----------------------------------------------------------------------
3583cdf0e10cSrcweir const Image& SvImpLBox::GetDefaultCollapsedNodeImage( BmpColorMode _eMode )
3584cdf0e10cSrcweir {
3585cdf0e10cSrcweir 	implInitDefaultNodeImages();
3586cdf0e10cSrcweir 	return ( BMP_COLOR_NORMAL == _eMode ) ? *s_pDefCollapsed : *s_pDefCollapsedHC;
3587cdf0e10cSrcweir }
3588cdf0e10cSrcweir 
3589cdf0e10cSrcweir // -----------------------------------------------------------------------
3590cdf0e10cSrcweir void SvImpLBox::CallEventListeners( sal_uLong nEvent, void* pData )
3591cdf0e10cSrcweir {
3592cdf0e10cSrcweir 	if ( pView )
3593cdf0e10cSrcweir 		pView->CallImplEventListeners( nEvent, pData);
3594cdf0e10cSrcweir }
3595cdf0e10cSrcweir 
3596cdf0e10cSrcweir // -----------------------------------------------------------------------
3597cdf0e10cSrcweir 
3598cdf0e10cSrcweir bool SvImpLBox::SetCurrentTabPos( sal_uInt16 _nNewPos )
3599cdf0e10cSrcweir {
3600cdf0e10cSrcweir 	bool bRet = false;
3601cdf0e10cSrcweir 
3602cdf0e10cSrcweir 	if ( pView && _nNewPos < ( pView->TabCount() - 2 ) )
3603cdf0e10cSrcweir 	{
3604cdf0e10cSrcweir 		nCurTabPos = _nNewPos;
3605cdf0e10cSrcweir 		ShowCursor( sal_True );
3606cdf0e10cSrcweir 		bRet = true;
3607cdf0e10cSrcweir 	}
3608cdf0e10cSrcweir 
3609cdf0e10cSrcweir 	return bRet;
3610cdf0e10cSrcweir }
3611cdf0e10cSrcweir 
3612cdf0e10cSrcweir // -----------------------------------------------------------------------
3613cdf0e10cSrcweir 
3614cdf0e10cSrcweir bool SvImpLBox::IsSelectable( const SvLBoxEntry* pEntry )
3615cdf0e10cSrcweir {
3616cdf0e10cSrcweir 	if( pEntry )
3617cdf0e10cSrcweir 	{
3618cdf0e10cSrcweir 		SvViewDataEntry* pViewDataNewCur = pView->GetViewDataEntry(const_cast<SvLBoxEntry*>(pEntry));
3619cdf0e10cSrcweir 		return (pViewDataNewCur == 0) || pViewDataNewCur->IsSelectable();
3620cdf0e10cSrcweir 	}
3621cdf0e10cSrcweir 	else
3622cdf0e10cSrcweir 	{
3623cdf0e10cSrcweir 		return false;
3624cdf0e10cSrcweir 	}
3625cdf0e10cSrcweir }
3626cdf0e10cSrcweir 
3627