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