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