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