1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svtools.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #define _SVTREEBX_CXX 32*cdf0e10cSrcweir #include <vcl/svapp.hxx> 33*cdf0e10cSrcweir #ifndef GCC 34*cdf0e10cSrcweir #endif 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir class TabBar; 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir // #102891# ----------------------- 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <svtools/svlbox.hxx> 41*cdf0e10cSrcweir #include <svtools/svlbitm.hxx> 42*cdf0e10cSrcweir #include <svtools/svtreebx.hxx> 43*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 44*cdf0e10cSrcweir #include <svimpbox.hxx> 45*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 46*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 47*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir /* 53*cdf0e10cSrcweir Bugs/ToDo 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir - Berechnung Rectangle beim Inplace-Editing (Bug bei manchen Fonts) 56*cdf0e10cSrcweir - SetSpaceBetweenEntries: Offset wird in SetEntryHeight nicht 57*cdf0e10cSrcweir beruecksichtigt 58*cdf0e10cSrcweir */ 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir #define TREEFLAG_FIXEDHEIGHT 0x0010 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir DBG_NAME(SvTreeListBox) 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir #define SV_LBOX_DEFAULT_INDENT_PIXEL 20 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir SvTreeListBox::SvTreeListBox( Window* pParent, WinBits nWinStyle ) 68*cdf0e10cSrcweir : SvLBox( pParent, nWinStyle ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir DBG_CTOR(SvTreeListBox,0); 71*cdf0e10cSrcweir InitTreeView(); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir SetSublistOpenWithLeftRight(); 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir SvTreeListBox::SvTreeListBox( Window* pParent , const ResId& rResId ) 77*cdf0e10cSrcweir : SvLBox( pParent,rResId ) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir DBG_CTOR(SvTreeListBox,0); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir InitTreeView(); 82*cdf0e10cSrcweir Resize(); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir SetSublistOpenWithLeftRight(); 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir void SvTreeListBox::InitTreeView() 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 90*cdf0e10cSrcweir pCheckButtonData = NULL; 91*cdf0e10cSrcweir pEdEntry = NULL; 92*cdf0e10cSrcweir pEdItem = NULL; 93*cdf0e10cSrcweir nEntryHeight = 0; 94*cdf0e10cSrcweir pEdCtrl = NULL; 95*cdf0e10cSrcweir nFirstSelTab = 0; 96*cdf0e10cSrcweir nLastSelTab = 0; 97*cdf0e10cSrcweir nFocusWidth = -1; 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir Link* pLink = new Link( LINK(this,SvTreeListBox, DefaultCompare) ); 100*cdf0e10cSrcweir pLBoxImpl->m_pLink = pLink; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir nTreeFlags = TREEFLAG_RECALCTABS; 103*cdf0e10cSrcweir nIndent = SV_LBOX_DEFAULT_INDENT_PIXEL; 104*cdf0e10cSrcweir nEntryHeightOffs = SV_ENTRYHEIGHTOFFS_PIXEL; 105*cdf0e10cSrcweir pImp = new SvImpLBox( this, GetModel(), GetStyle() ); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir aContextBmpMode = SVLISTENTRYFLAG_EXPANDED; 108*cdf0e10cSrcweir nContextBmpWidthMax = 0; 109*cdf0e10cSrcweir SetFont( GetFont() ); 110*cdf0e10cSrcweir SetSpaceBetweenEntries( 0 ); 111*cdf0e10cSrcweir SetLineColor(); 112*cdf0e10cSrcweir InitSettings( sal_True, sal_True, sal_True ); 113*cdf0e10cSrcweir ImplInitStyle(); 114*cdf0e10cSrcweir SetTabs(); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir SvTreeListBox::~SvTreeListBox() 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir DBG_DTOR(SvTreeListBox,0); 121*cdf0e10cSrcweir pImp->CallEventListeners( VCLEVENT_OBJECT_DYING ); 122*cdf0e10cSrcweir delete pImp; 123*cdf0e10cSrcweir delete pLBoxImpl->m_pLink; 124*cdf0e10cSrcweir ClearTabList(); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir void SvTreeListBox::SetExtendedWinBits( ExtendedWinBits _nBits ) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir pImp->SetExtendedWindowBits( _nBits ); 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir ExtendedWinBits SvTreeListBox::GetExtendedWinBits() const 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir return pImp->GetExtendedWindowBits(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir void SvTreeListBox::SetModel( SvLBoxTreeList* pNewModel ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 140*cdf0e10cSrcweir pImp->SetModel( pNewModel ); 141*cdf0e10cSrcweir SvLBox::SetModel( pNewModel ); 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir void SvTreeListBox::DisconnectFromModel() 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 147*cdf0e10cSrcweir SvLBox::DisconnectFromModel(); 148*cdf0e10cSrcweir pImp->SetModel( GetModel() ); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir sal_uInt16 SvTreeListBox::IsA() 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 155*cdf0e10cSrcweir return SV_LISTBOX_ID_TREEBOX; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir void SvTreeListBox::SetSublistOpenWithReturn( sal_Bool b ) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir pImp->bSubLstOpRet = b; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir sal_Bool SvTreeListBox::IsSublistOpenWithReturn() const 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir return pImp->bSubLstOpRet; 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir void SvTreeListBox::SetSublistOpenWithLeftRight( sal_Bool b ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir pImp->bSubLstOpLR = b; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir sal_Bool SvTreeListBox::IsSublistOpenWithLeftRight() const 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir return pImp->bSubLstOpLR; 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir void SvTreeListBox::Resize() 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 181*cdf0e10cSrcweir if( IsEditingActive() ) 182*cdf0e10cSrcweir EndEditing( sal_True ); 183*cdf0e10cSrcweir SvLBox::Resize(); 184*cdf0e10cSrcweir pImp->Resize(); 185*cdf0e10cSrcweir nFocusWidth = -1; 186*cdf0e10cSrcweir pImp->ShowCursor( sal_False ); 187*cdf0e10cSrcweir pImp->ShowCursor( sal_True ); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir /* Faelle: 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir A) Entries haben Bitmaps 193*cdf0e10cSrcweir 0. Keine Buttons 194*cdf0e10cSrcweir 1. Node-Buttons (optional auch an Root-Items) 195*cdf0e10cSrcweir 2. Node-Buttons (optional auch an Root-Items) + CheckButton 196*cdf0e10cSrcweir 3. CheckButton 197*cdf0e10cSrcweir B) Entries haben keine Bitmaps (->ueber WindowBits wg. D&D !!!!!!) 198*cdf0e10cSrcweir 0. Keine Buttons 199*cdf0e10cSrcweir 1. Node-Buttons (optional auch an Root-Items) 200*cdf0e10cSrcweir 2. Node-Buttons (optional auch an Root-Items) + CheckButton 201*cdf0e10cSrcweir 3. CheckButton 202*cdf0e10cSrcweir */ 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir #define NO_BUTTONS 0 205*cdf0e10cSrcweir #define NODE_BUTTONS 1 206*cdf0e10cSrcweir #define NODE_AND_CHECK_BUTTONS 2 207*cdf0e10cSrcweir #define CHECK_BUTTONS 3 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir #define TABFLAGS_TEXT (SV_LBOXTAB_DYNAMIC | \ 210*cdf0e10cSrcweir SV_LBOXTAB_ADJUST_LEFT | \ 211*cdf0e10cSrcweir SV_LBOXTAB_EDITABLE | \ 212*cdf0e10cSrcweir SV_LBOXTAB_SHOW_SELECTION) 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir #define TABFLAGS_CONTEXTBMP (SV_LBOXTAB_DYNAMIC | SV_LBOXTAB_ADJUST_CENTER) 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir #define TABFLAGS_CHECKBTN (SV_LBOXTAB_DYNAMIC | \ 217*cdf0e10cSrcweir SV_LBOXTAB_ADJUST_CENTER | \ 218*cdf0e10cSrcweir SV_LBOXTAB_PUSHABLE) 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir #define TAB_STARTPOS 2 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir // bei Aenderungen GetTextOffset beruecksichtigen 223*cdf0e10cSrcweir void SvTreeListBox::SetTabs() 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 226*cdf0e10cSrcweir if( IsEditingActive() ) 227*cdf0e10cSrcweir EndEditing( sal_True ); 228*cdf0e10cSrcweir nTreeFlags &= (~TREEFLAG_RECALCTABS); 229*cdf0e10cSrcweir nFocusWidth = -1; 230*cdf0e10cSrcweir const WinBits nStyle( GetStyle() ); 231*cdf0e10cSrcweir sal_Bool bHasButtons = (nStyle & WB_HASBUTTONS)!=0; 232*cdf0e10cSrcweir sal_Bool bHasButtonsAtRoot = (nStyle & (WB_HASLINESATROOT | 233*cdf0e10cSrcweir WB_HASBUTTONSATROOT))!=0; 234*cdf0e10cSrcweir long nStartPos = TAB_STARTPOS; 235*cdf0e10cSrcweir long nNodeWidthPixel = GetExpandedNodeBmp().GetSizePixel().Width(); 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir long nCheckWidth = 0; 238*cdf0e10cSrcweir if( nTreeFlags & TREEFLAG_CHKBTN ) 239*cdf0e10cSrcweir nCheckWidth = pCheckButtonData->aBmps[0].GetSizePixel().Width(); 240*cdf0e10cSrcweir long nCheckWidthDIV2 = nCheckWidth / 2; 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir long nContextWidth = nContextBmpWidthMax; 243*cdf0e10cSrcweir long nContextWidthDIV2 = nContextWidth / 2; 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir ClearTabList(); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir int nCase = NO_BUTTONS; 248*cdf0e10cSrcweir if( !(nTreeFlags & TREEFLAG_CHKBTN) ) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir if( bHasButtons ) 251*cdf0e10cSrcweir nCase = NODE_BUTTONS; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir else 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir if( bHasButtons ) 256*cdf0e10cSrcweir nCase = NODE_AND_CHECK_BUTTONS; 257*cdf0e10cSrcweir else 258*cdf0e10cSrcweir nCase = CHECK_BUTTONS; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir switch( nCase ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir case NO_BUTTONS : 264*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // wg. Zentrierung 265*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_CONTEXTBMP ); 266*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp 267*cdf0e10cSrcweir // Abstand setzen nur wenn Bitmaps da 268*cdf0e10cSrcweir if( nContextBmpWidthMax ) 269*cdf0e10cSrcweir nStartPos += 5; // Abstand Context-Bmp - Text 270*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_TEXT ); 271*cdf0e10cSrcweir break; 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir case NODE_BUTTONS : 274*cdf0e10cSrcweir if( bHasButtonsAtRoot ) 275*cdf0e10cSrcweir nStartPos += ( nIndent + (nNodeWidthPixel/2) ); 276*cdf0e10cSrcweir else 277*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; 278*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_CONTEXTBMP ); 279*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp 280*cdf0e10cSrcweir // Abstand setzen nur wenn Bitmaps da 281*cdf0e10cSrcweir if( nContextBmpWidthMax ) 282*cdf0e10cSrcweir nStartPos += 5; // Abstand Context-Bmp - Text 283*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_TEXT ); 284*cdf0e10cSrcweir break; 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir case NODE_AND_CHECK_BUTTONS : 287*cdf0e10cSrcweir if( bHasButtonsAtRoot ) 288*cdf0e10cSrcweir nStartPos += ( nIndent + nNodeWidthPixel ); 289*cdf0e10cSrcweir else 290*cdf0e10cSrcweir nStartPos += nCheckWidthDIV2; 291*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_CHECKBTN ); 292*cdf0e10cSrcweir nStartPos += nCheckWidthDIV2; // rechter Rand des CheckButtons 293*cdf0e10cSrcweir nStartPos += 3; // Abstand CheckButton Context-Bmp 294*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // Mitte der Context-Bmp 295*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_CONTEXTBMP ); 296*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp 297*cdf0e10cSrcweir // Abstand setzen nur wenn Bitmaps da 298*cdf0e10cSrcweir if( nContextBmpWidthMax ) 299*cdf0e10cSrcweir nStartPos += 5; // Abstand Context-Bmp - Text 300*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_TEXT ); 301*cdf0e10cSrcweir break; 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir case CHECK_BUTTONS : 304*cdf0e10cSrcweir nStartPos += nCheckWidthDIV2; 305*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_CHECKBTN ); 306*cdf0e10cSrcweir nStartPos += nCheckWidthDIV2; // rechter Rand CheckButton 307*cdf0e10cSrcweir nStartPos += 3; // Abstand CheckButton Context-Bmp 308*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // Mitte der Context-Bmp 309*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_CONTEXTBMP ); 310*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp 311*cdf0e10cSrcweir // Abstand setzen nur wenn Bitmaps da 312*cdf0e10cSrcweir if( nContextBmpWidthMax ) 313*cdf0e10cSrcweir nStartPos += 5; // Abstand Context-Bmp - Text 314*cdf0e10cSrcweir AddTab( nStartPos, TABFLAGS_TEXT ); 315*cdf0e10cSrcweir break; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir pImp->NotifyTabsChanged(); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir void SvTreeListBox::InitEntry( SvLBoxEntry* pEntry, 321*cdf0e10cSrcweir const XubString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp, 322*cdf0e10cSrcweir SvLBoxButtonKind eButtonKind) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 325*cdf0e10cSrcweir SvLBoxButton* pButton; 326*cdf0e10cSrcweir SvLBoxString* pString; 327*cdf0e10cSrcweir SvLBoxContextBmp* pContextBmp; 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir if( nTreeFlags & TREEFLAG_CHKBTN ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir pButton= new SvLBoxButton( pEntry,eButtonKind,0,pCheckButtonData ); 332*cdf0e10cSrcweir pEntry->AddItem( pButton ); 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir pContextBmp= new SvLBoxContextBmp( pEntry,0, aCollEntryBmp,aExpEntryBmp, 336*cdf0e10cSrcweir aContextBmpMode ); 337*cdf0e10cSrcweir pEntry->AddItem( pContextBmp ); 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir pString = new SvLBoxString( pEntry, 0, aStr ); 340*cdf0e10cSrcweir pEntry->AddItem( pString ); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir String SvTreeListBox::GetEntryText(SvLBoxEntry* pEntry) const 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 346*cdf0e10cSrcweir DBG_ASSERT( pEntry, "SvTreeListBox::GetEntryText(): no entry" ); 347*cdf0e10cSrcweir SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 348*cdf0e10cSrcweir DBG_ASSERT( pEntry, "SvTreeListBox::GetEntryText(): item not found" ); 349*cdf0e10cSrcweir return pItem->GetText(); 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir String SvTreeListBox::SearchEntryText( SvLBoxEntry* pEntry ) const 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 355*cdf0e10cSrcweir DBG_ASSERT( pEntry, "SvTreeListBox::SearchEntryText(): no entry" ); 356*cdf0e10cSrcweir String sRet; 357*cdf0e10cSrcweir sal_uInt16 nCount = pEntry->ItemCount(); 358*cdf0e10cSrcweir sal_uInt16 nCur = 0; 359*cdf0e10cSrcweir SvLBoxItem* pItem; 360*cdf0e10cSrcweir while( nCur < nCount ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir pItem = pEntry->GetItem( nCur ); 363*cdf0e10cSrcweir if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING && 364*cdf0e10cSrcweir static_cast<SvLBoxString*>( pItem )->GetText().Len() > 0 ) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir sRet = static_cast<SvLBoxString*>( pItem )->GetText(); 367*cdf0e10cSrcweir break; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir nCur++; 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir return sRet; 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir const Image& SvTreeListBox::GetExpandedEntryBmp(SvLBoxEntry* pEntry, BmpColorMode _eMode) const 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 377*cdf0e10cSrcweir DBG_ASSERT(pEntry,"Entry?"); 378*cdf0e10cSrcweir SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); 379*cdf0e10cSrcweir DBG_ASSERT(pItem,"GetContextBmp:Item not found"); 380*cdf0e10cSrcweir return pItem->GetBitmap2( _eMode ); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir const Image& SvTreeListBox::GetCollapsedEntryBmp( SvLBoxEntry* pEntry, BmpColorMode _eMode ) const 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 386*cdf0e10cSrcweir DBG_ASSERT(pEntry,"Entry?"); 387*cdf0e10cSrcweir SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); 388*cdf0e10cSrcweir DBG_ASSERT(pItem,"GetContextBmp:Item not found"); 389*cdf0e10cSrcweir return pItem->GetBitmap1( _eMode ); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir IMPL_LINK_INLINE_START( SvTreeListBox, CheckButtonClick, SvLBoxButtonData *, pData ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 395*cdf0e10cSrcweir pHdlEntry = pData->GetActEntry(); 396*cdf0e10cSrcweir CheckButtonHdl(); 397*cdf0e10cSrcweir return 0; 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir IMPL_LINK_INLINE_END( SvTreeListBox, CheckButtonClick, SvLBoxButtonData *, pData ) 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::InsertEntry( const XubString& aText,SvLBoxEntry* pParent, 402*cdf0e10cSrcweir sal_Bool bChildsOnDemand, sal_uLong nPos, void* pUser, 403*cdf0e10cSrcweir SvLBoxButtonKind eButtonKind ) 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 406*cdf0e10cSrcweir nTreeFlags |= TREEFLAG_MANINS; 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir const Image& rDefExpBmp = pImp->GetDefaultEntryExpBmp( ); 409*cdf0e10cSrcweir const Image& rDefColBmp = pImp->GetDefaultEntryColBmp( ); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir aCurInsertedExpBmp = rDefExpBmp; 412*cdf0e10cSrcweir aCurInsertedColBmp = rDefColBmp; 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir SvLBoxEntry* pEntry = CreateEntry(); 415*cdf0e10cSrcweir pEntry->SetUserData( pUser ); 416*cdf0e10cSrcweir InitEntry( pEntry, aText, rDefColBmp, rDefExpBmp, eButtonKind ); 417*cdf0e10cSrcweir pEntry->EnableChildsOnDemand( bChildsOnDemand ); 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir // Add the HC versions of the default images 420*cdf0e10cSrcweir SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) ); 421*cdf0e10cSrcweir if( pBmpItem ) 422*cdf0e10cSrcweir { 423*cdf0e10cSrcweir pBmpItem->SetBitmap1( pImp->GetDefaultEntryColBmp( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST ); 424*cdf0e10cSrcweir pBmpItem->SetBitmap2( pImp->GetDefaultEntryExpBmp( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST ); 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir if( !pParent ) 428*cdf0e10cSrcweir SvLBox::Insert( pEntry, nPos ); 429*cdf0e10cSrcweir else 430*cdf0e10cSrcweir SvLBox::Insert( pEntry, pParent, nPos ); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir aPrevInsertedExpBmp = rDefExpBmp; 433*cdf0e10cSrcweir aPrevInsertedColBmp = rDefColBmp; 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir nTreeFlags &= (~TREEFLAG_MANINS); 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir return pEntry; 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::InsertEntry( const XubString& aText, 441*cdf0e10cSrcweir const Image& aExpEntryBmp, const Image& aCollEntryBmp, 442*cdf0e10cSrcweir SvLBoxEntry* pParent, sal_Bool bChildsOnDemand, sal_uLong nPos, void* pUser, 443*cdf0e10cSrcweir SvLBoxButtonKind eButtonKind ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 446*cdf0e10cSrcweir nTreeFlags |= TREEFLAG_MANINS; 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir aCurInsertedExpBmp = aExpEntryBmp; 449*cdf0e10cSrcweir aCurInsertedColBmp = aCollEntryBmp; 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir SvLBoxEntry* pEntry = CreateEntry(); 452*cdf0e10cSrcweir pEntry->SetUserData( pUser ); 453*cdf0e10cSrcweir InitEntry( pEntry, aText, aCollEntryBmp, aExpEntryBmp, eButtonKind ); 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir pEntry->EnableChildsOnDemand( bChildsOnDemand ); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir if( !pParent ) 458*cdf0e10cSrcweir SvLBox::Insert( pEntry, nPos ); 459*cdf0e10cSrcweir else 460*cdf0e10cSrcweir SvLBox::Insert( pEntry, pParent, nPos ); 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir aPrevInsertedExpBmp = aExpEntryBmp; 463*cdf0e10cSrcweir aPrevInsertedColBmp = aCollEntryBmp; 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir nTreeFlags &= (~TREEFLAG_MANINS); 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir return pEntry; 468*cdf0e10cSrcweir } 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir void SvTreeListBox::SetEntryText( SvLBoxEntry* pEntry, const XubString& aStr) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 473*cdf0e10cSrcweir SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 474*cdf0e10cSrcweir DBG_ASSERT(pItem,"SetText:Item not found"); 475*cdf0e10cSrcweir pItem->SetText( pEntry, aStr ); 476*cdf0e10cSrcweir pItem->InitViewData( this, pEntry, 0 ); 477*cdf0e10cSrcweir GetModel()->InvalidateEntry( pEntry ); 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir void SvTreeListBox::SetExpandedEntryBmp( SvLBoxEntry* pEntry, const Image& aBmp, BmpColorMode _eMode ) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 483*cdf0e10cSrcweir SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir DBG_ASSERT(pItem,"SetExpBmp:Item not found"); 486*cdf0e10cSrcweir pItem->SetBitmap2( aBmp, _eMode ); 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir GetModel()->InvalidateEntry( pEntry ); 489*cdf0e10cSrcweir SetEntryHeight( pEntry ); 490*cdf0e10cSrcweir Size aSize = aBmp.GetSizePixel(); 491*cdf0e10cSrcweir // #97680# --------------- 492*cdf0e10cSrcweir short nWidth = pImp->UpdateContextBmpWidthVector( pEntry, (short)aSize.Width() ); 493*cdf0e10cSrcweir if( nWidth > nContextBmpWidthMax ) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir nContextBmpWidthMax = nWidth; 496*cdf0e10cSrcweir SetTabs(); 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir } 499*cdf0e10cSrcweir 500*cdf0e10cSrcweir void SvTreeListBox::SetCollapsedEntryBmp(SvLBoxEntry* pEntry,const Image& aBmp, BmpColorMode _eMode ) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 503*cdf0e10cSrcweir SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir DBG_ASSERT(pItem,"SetExpBmp:Item not found"); 506*cdf0e10cSrcweir pItem->SetBitmap1( aBmp, _eMode ); 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir GetModel()->InvalidateEntry( pEntry ); 509*cdf0e10cSrcweir SetEntryHeight( pEntry ); 510*cdf0e10cSrcweir Size aSize = aBmp.GetSizePixel(); 511*cdf0e10cSrcweir // #97680# ----------- 512*cdf0e10cSrcweir short nWidth = pImp->UpdateContextBmpWidthVector( pEntry, (short)aSize.Width() ); 513*cdf0e10cSrcweir if( nWidth > nContextBmpWidthMax ) 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir nContextBmpWidthMax = nWidth; 516*cdf0e10cSrcweir SetTabs(); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir void SvTreeListBox::ImpEntryInserted( SvLBoxEntry* pEntry ) 521*cdf0e10cSrcweir { 522*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir SvLBoxEntry* pParent = (SvLBoxEntry*)pModel->GetParent( pEntry ); 525*cdf0e10cSrcweir if( pParent ) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir sal_uInt16 nFlags = pParent->GetFlags(); 528*cdf0e10cSrcweir nFlags &= ~SV_ENTRYFLAG_NO_NODEBMP; 529*cdf0e10cSrcweir pParent->SetFlags( nFlags ); 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir if(!((nTreeFlags & TREEFLAG_MANINS) && 533*cdf0e10cSrcweir (aPrevInsertedExpBmp == aCurInsertedExpBmp) && 534*cdf0e10cSrcweir (aPrevInsertedColBmp == aCurInsertedColBmp) )) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir Size aSize = GetCollapsedEntryBmp( pEntry ).GetSizePixel(); 537*cdf0e10cSrcweir if( aSize.Width() > nContextBmpWidthMax ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir nContextBmpWidthMax = (short)aSize.Width(); 540*cdf0e10cSrcweir nTreeFlags |= TREEFLAG_RECALCTABS; 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir aSize = GetExpandedEntryBmp( pEntry ).GetSizePixel(); 543*cdf0e10cSrcweir if( aSize.Width() > nContextBmpWidthMax ) 544*cdf0e10cSrcweir { 545*cdf0e10cSrcweir nContextBmpWidthMax = (short)aSize.Width(); 546*cdf0e10cSrcweir nTreeFlags |= TREEFLAG_RECALCTABS; 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir } 549*cdf0e10cSrcweir SetEntryHeight( (SvLBoxEntry*)pEntry ); 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir void SvTreeListBox::SetCheckButtonState( SvLBoxEntry* pEntry, SvButtonState eState) 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 557*cdf0e10cSrcweir if( nTreeFlags & TREEFLAG_CHKBTN ) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON)); 560*cdf0e10cSrcweir if(!(pItem && pItem->CheckModification())) 561*cdf0e10cSrcweir return ; 562*cdf0e10cSrcweir switch( eState ) 563*cdf0e10cSrcweir { 564*cdf0e10cSrcweir case SV_BUTTON_CHECKED: 565*cdf0e10cSrcweir pItem->SetStateChecked(); 566*cdf0e10cSrcweir break; 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir case SV_BUTTON_UNCHECKED: 569*cdf0e10cSrcweir pItem->SetStateUnchecked(); 570*cdf0e10cSrcweir break; 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir case SV_BUTTON_TRISTATE: 573*cdf0e10cSrcweir pItem->SetStateTristate(); 574*cdf0e10cSrcweir break; 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir InvalidateEntry( pEntry ); 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir SvButtonState SvTreeListBox::GetCheckButtonState( SvLBoxEntry* pEntry ) const 581*cdf0e10cSrcweir { 582*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 583*cdf0e10cSrcweir SvButtonState eState = SV_BUTTON_UNCHECKED; 584*cdf0e10cSrcweir if( nTreeFlags & TREEFLAG_CHKBTN ) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON)); 587*cdf0e10cSrcweir if(!pItem) 588*cdf0e10cSrcweir return SV_BUTTON_TRISTATE; 589*cdf0e10cSrcweir sal_uInt16 nButtonFlags = pItem->GetButtonFlags(); 590*cdf0e10cSrcweir eState = pCheckButtonData->ConvertToButtonState( nButtonFlags ); 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir return eState; 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir void SvTreeListBox::CheckButtonHdl() 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 598*cdf0e10cSrcweir aCheckButtonHdl.Call( this ); 599*cdf0e10cSrcweir if ( pCheckButtonData ) 600*cdf0e10cSrcweir pImp->CallEventListeners( VCLEVENT_CHECKBOX_TOGGLE, (void*)pCheckButtonData->GetActEntry() ); 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir // ********************************************************************* 604*cdf0e10cSrcweir // ********************************************************************* 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir // 607*cdf0e10cSrcweir // TODO: Momentan werden die Daten so geklont, dass sie dem 608*cdf0e10cSrcweir // Standard-TreeView-Format entsprechen. Hier sollte eigentlich 609*cdf0e10cSrcweir // das Model als Referenz dienen. Dies fuehrt dazu, dass 610*cdf0e10cSrcweir // SvLBoxEntry::Clone _nicht_ gerufen wird, sondern nur dessen 611*cdf0e10cSrcweir // Basisklasse SvListEntry 612*cdf0e10cSrcweir // 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::CloneEntry( SvLBoxEntry* pSource ) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 617*cdf0e10cSrcweir XubString aStr; 618*cdf0e10cSrcweir Image aCollEntryBmp; 619*cdf0e10cSrcweir Image aExpEntryBmp; 620*cdf0e10cSrcweir SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox; 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir SvLBoxString* pStringItem = (SvLBoxString*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXSTRING)); 623*cdf0e10cSrcweir if( pStringItem ) 624*cdf0e10cSrcweir aStr = pStringItem->GetText(); 625*cdf0e10cSrcweir SvLBoxContextBmp* pBmpItem = (SvLBoxContextBmp*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)); 626*cdf0e10cSrcweir if( pBmpItem ) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir aCollEntryBmp = pBmpItem->GetBitmap1( BMP_COLOR_NORMAL ); 629*cdf0e10cSrcweir aExpEntryBmp = pBmpItem->GetBitmap2( BMP_COLOR_NORMAL ); 630*cdf0e10cSrcweir } 631*cdf0e10cSrcweir SvLBoxButton* pButtonItem = (SvLBoxButton*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXBUTTON)); 632*cdf0e10cSrcweir if( pButtonItem ) 633*cdf0e10cSrcweir eButtonKind = pButtonItem->GetKind(); 634*cdf0e10cSrcweir SvLBoxEntry* pClone = CreateEntry(); 635*cdf0e10cSrcweir InitEntry( pClone, aStr, aCollEntryBmp, aExpEntryBmp, eButtonKind ); 636*cdf0e10cSrcweir pClone->SvListEntry::Clone( pSource ); 637*cdf0e10cSrcweir pClone->EnableChildsOnDemand( pSource->HasChildsOnDemand() ); 638*cdf0e10cSrcweir pClone->SetUserData( pSource->GetUserData() ); 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir if ( pBmpItem ) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir SvLBoxContextBmp* pCloneBitmap = static_cast< SvLBoxContextBmp* >( pClone->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) ); 643*cdf0e10cSrcweir if ( pCloneBitmap ) 644*cdf0e10cSrcweir { 645*cdf0e10cSrcweir pCloneBitmap->SetBitmap1( pBmpItem->GetBitmap1( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST ); 646*cdf0e10cSrcweir pCloneBitmap->SetBitmap2( pBmpItem->GetBitmap2( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST ); 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir } 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir return pClone; 651*cdf0e10cSrcweir } 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir // ********************************************************************* 654*cdf0e10cSrcweir // ********************************************************************* 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir void SvTreeListBox::ShowExpandBitmapOnCursor( sal_Bool bYes ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 660*cdf0e10cSrcweir if( bYes ) 661*cdf0e10cSrcweir aContextBmpMode = SVLISTENTRYFLAG_FOCUSED; 662*cdf0e10cSrcweir else 663*cdf0e10cSrcweir aContextBmpMode = SVLISTENTRYFLAG_EXPANDED; 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir void SvTreeListBox::SetIndent( short nNewIndent ) 667*cdf0e10cSrcweir { 668*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 669*cdf0e10cSrcweir nIndent = nNewIndent; 670*cdf0e10cSrcweir SetTabs(); 671*cdf0e10cSrcweir if( IsUpdateMode() ) 672*cdf0e10cSrcweir Invalidate(); 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir const Image& SvTreeListBox::GetDefaultExpandedEntryBmp( BmpColorMode _eMode ) const 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir return pImp->GetDefaultEntryExpBmp( _eMode ); 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir const Image& SvTreeListBox::GetDefaultCollapsedEntryBmp( BmpColorMode _eMode ) const 681*cdf0e10cSrcweir { 682*cdf0e10cSrcweir return pImp->GetDefaultEntryColBmp( _eMode ); 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir void SvTreeListBox::SetDefaultExpandedEntryBmp( const Image& aBmp, BmpColorMode _eMode ) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 688*cdf0e10cSrcweir Size aSize = aBmp.GetSizePixel(); 689*cdf0e10cSrcweir if( aSize.Width() > nContextBmpWidthMax ) 690*cdf0e10cSrcweir nContextBmpWidthMax = (short)aSize.Width(); 691*cdf0e10cSrcweir SetTabs(); 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir pImp->SetDefaultEntryExpBmp( aBmp, _eMode ); 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir void SvTreeListBox::SetDefaultCollapsedEntryBmp( const Image& aBmp, BmpColorMode _eMode ) 697*cdf0e10cSrcweir { 698*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 699*cdf0e10cSrcweir Size aSize = aBmp.GetSizePixel(); 700*cdf0e10cSrcweir if( aSize.Width() > nContextBmpWidthMax ) 701*cdf0e10cSrcweir nContextBmpWidthMax = (short)aSize.Width(); 702*cdf0e10cSrcweir SetTabs(); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir pImp->SetDefaultEntryColBmp( aBmp, _eMode ); 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir void SvTreeListBox::EnableCheckButton( SvLBoxButtonData* pData ) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 710*cdf0e10cSrcweir DBG_ASSERT(!GetEntryCount(),"EnableCheckButton: Entry count != 0"); 711*cdf0e10cSrcweir if( !pData ) 712*cdf0e10cSrcweir nTreeFlags &= (~TREEFLAG_CHKBTN); 713*cdf0e10cSrcweir else 714*cdf0e10cSrcweir { 715*cdf0e10cSrcweir SetCheckButtonData( pData ); 716*cdf0e10cSrcweir nTreeFlags |= TREEFLAG_CHKBTN; 717*cdf0e10cSrcweir pData->SetLink( LINK(this, SvTreeListBox, CheckButtonClick)); 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir SetTabs(); 721*cdf0e10cSrcweir if( IsUpdateMode() ) 722*cdf0e10cSrcweir Invalidate(); 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir void SvTreeListBox::SetCheckButtonData( SvLBoxButtonData* pData ) 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 728*cdf0e10cSrcweir if ( pData ) 729*cdf0e10cSrcweir pCheckButtonData = pData; 730*cdf0e10cSrcweir } 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir const Image& SvTreeListBox::GetDefaultExpandedNodeImage( BmpColorMode _eMode ) 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir return SvImpLBox::GetDefaultExpandedNodeImage( _eMode ); 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir 737*cdf0e10cSrcweir const Image& SvTreeListBox::GetDefaultCollapsedNodeImage( BmpColorMode _eMode ) 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir return SvImpLBox::GetDefaultCollapsedNodeImage( _eMode ); 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir void SvTreeListBox::SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp, BmpColorMode _eMode ) 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 745*cdf0e10cSrcweir SetExpandedNodeBmp( rExpandedNodeBmp, _eMode ); 746*cdf0e10cSrcweir SetCollapsedNodeBmp( rCollapsedNodeBmp, _eMode ); 747*cdf0e10cSrcweir SetTabs(); 748*cdf0e10cSrcweir } 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir void SvTreeListBox::SetDontKnowNodeBitmap( const Image& rDontKnowBmp, BmpColorMode _eMode ) 751*cdf0e10cSrcweir { 752*cdf0e10cSrcweir pImp->SetDontKnowNodeBmp( rDontKnowBmp, _eMode ); 753*cdf0e10cSrcweir } 754*cdf0e10cSrcweir 755*cdf0e10cSrcweir sal_Bool SvTreeListBox::EditingEntry( SvLBoxEntry*, Selection& ) 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 758*cdf0e10cSrcweir return sal_True; 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir sal_Bool SvTreeListBox::EditedEntry( SvLBoxEntry* /*pEntry*/,const XubString& /*rNewText*/) 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 764*cdf0e10cSrcweir return sal_True; 765*cdf0e10cSrcweir } 766*cdf0e10cSrcweir 767*cdf0e10cSrcweir void SvTreeListBox::EnableInplaceEditing( sal_Bool bOn ) 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 770*cdf0e10cSrcweir SvLBox::EnableInplaceEditing( bOn ); 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir void SvTreeListBox::KeyInput( const KeyEvent& rKEvt ) 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 776*cdf0e10cSrcweir // unter OS/2 bekommen wir auch beim Editieren Key-Up/Down 777*cdf0e10cSrcweir if( IsEditingActive() ) 778*cdf0e10cSrcweir return; 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir nImpFlags |= SVLBOX_IS_TRAVELSELECT; 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir #ifdef OVDEBUG 783*cdf0e10cSrcweir sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); 784*cdf0e10cSrcweir switch ( nCode ) 785*cdf0e10cSrcweir { 786*cdf0e10cSrcweir case KEY_F1: 787*cdf0e10cSrcweir { 788*cdf0e10cSrcweir SvLBoxEntry* pEntry = First(); 789*cdf0e10cSrcweir pEntry = NextVisible( pEntry ); 790*cdf0e10cSrcweir SetEntryText( pEntry, "SetEntryText" ); 791*cdf0e10cSrcweir Sound::Beep(); 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir break; 794*cdf0e10cSrcweir } 795*cdf0e10cSrcweir #endif 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir if( !pImp->KeyInput( rKEvt ) ) 798*cdf0e10cSrcweir SvLBox::KeyInput( rKEvt ); 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir nImpFlags &= ~SVLBOX_IS_TRAVELSELECT; 801*cdf0e10cSrcweir } 802*cdf0e10cSrcweir 803*cdf0e10cSrcweir void SvTreeListBox::RequestingChilds( SvLBoxEntry* pParent ) 804*cdf0e10cSrcweir { 805*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 806*cdf0e10cSrcweir if( !pParent->HasChilds() ) 807*cdf0e10cSrcweir InsertEntry( String::CreateFromAscii("<dummy>"), pParent, sal_False, LIST_APPEND ); 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir void SvTreeListBox::GetFocus() 811*cdf0e10cSrcweir { 812*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 813*cdf0e10cSrcweir pImp->GetFocus(); 814*cdf0e10cSrcweir SvLBox::GetFocus(); 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir SvLBoxEntry* pEntry = FirstSelected(); 817*cdf0e10cSrcweir if ( pEntry ) 818*cdf0e10cSrcweir pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry ); 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir void SvTreeListBox::LoseFocus() 823*cdf0e10cSrcweir { 824*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 825*cdf0e10cSrcweir pImp->LoseFocus(); 826*cdf0e10cSrcweir SvLBox::LoseFocus(); 827*cdf0e10cSrcweir } 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir void SvTreeListBox::ModelHasCleared() 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 832*cdf0e10cSrcweir pImp->pCursor = 0; //sonst Absturz beim Inplace-Editieren im GetFocus 833*cdf0e10cSrcweir delete pEdCtrl; 834*cdf0e10cSrcweir pEdCtrl = NULL; 835*cdf0e10cSrcweir pImp->Clear(); 836*cdf0e10cSrcweir nFocusWidth = -1; 837*cdf0e10cSrcweir 838*cdf0e10cSrcweir nContextBmpWidthMax = 0; 839*cdf0e10cSrcweir SetDefaultExpandedEntryBmp( GetDefaultExpandedEntryBmp() ); 840*cdf0e10cSrcweir SetDefaultCollapsedEntryBmp( GetDefaultCollapsedEntryBmp() ); 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir if( !(nTreeFlags & TREEFLAG_FIXEDHEIGHT )) 843*cdf0e10cSrcweir nEntryHeight = 0; 844*cdf0e10cSrcweir AdjustEntryHeight( GetFont() ); 845*cdf0e10cSrcweir AdjustEntryHeight( GetDefaultExpandedEntryBmp() ); 846*cdf0e10cSrcweir AdjustEntryHeight( GetDefaultCollapsedEntryBmp() ); 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir SvLBox::ModelHasCleared(); 849*cdf0e10cSrcweir // if( IsUpdateMode() ) 850*cdf0e10cSrcweir // Invalidate(); 851*cdf0e10cSrcweir } 852*cdf0e10cSrcweir 853*cdf0e10cSrcweir void SvTreeListBox::ShowTargetEmphasis( SvLBoxEntry* pEntry, sal_Bool /* bShow */ ) 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 856*cdf0e10cSrcweir pImp->PaintDDCursor( pEntry ); 857*cdf0e10cSrcweir } 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir void SvTreeListBox::ScrollOutputArea( short nDeltaEntries ) 860*cdf0e10cSrcweir { 861*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 862*cdf0e10cSrcweir if( !nDeltaEntries || !pImp->aVerSBar.IsVisible() ) 863*cdf0e10cSrcweir return; 864*cdf0e10cSrcweir 865*cdf0e10cSrcweir long nThumb = pImp->aVerSBar.GetThumbPos(); 866*cdf0e10cSrcweir long nMax = pImp->aVerSBar.GetRange().Max(); 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir NotifyBeginScroll(); 869*cdf0e10cSrcweir if( nDeltaEntries < 0 ) 870*cdf0e10cSrcweir { 871*cdf0e10cSrcweir // das Fenster nach oben verschieben 872*cdf0e10cSrcweir nDeltaEntries *= -1; 873*cdf0e10cSrcweir long nVis = pImp->aVerSBar.GetVisibleSize(); 874*cdf0e10cSrcweir long nTemp = nThumb + nVis; 875*cdf0e10cSrcweir if( nDeltaEntries > (nMax - nTemp) ) 876*cdf0e10cSrcweir nDeltaEntries = (short)(nMax - nTemp); 877*cdf0e10cSrcweir pImp->PageDown( (sal_uInt16)nDeltaEntries ); 878*cdf0e10cSrcweir } 879*cdf0e10cSrcweir else 880*cdf0e10cSrcweir { 881*cdf0e10cSrcweir if( nDeltaEntries > nThumb ) 882*cdf0e10cSrcweir nDeltaEntries = (short)nThumb; 883*cdf0e10cSrcweir pImp->PageUp( (sal_uInt16)nDeltaEntries ); 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir pImp->SyncVerThumb(); 886*cdf0e10cSrcweir NotifyEndScroll(); 887*cdf0e10cSrcweir } 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir void SvTreeListBox::SetSelectionMode( SelectionMode eSelectMode ) 890*cdf0e10cSrcweir { 891*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 892*cdf0e10cSrcweir SvLBox::SetSelectionMode( eSelectMode ); 893*cdf0e10cSrcweir pImp->SetSelectionMode( eSelectMode ); 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir void SvTreeListBox::SetDragDropMode( DragDropMode nDDMode ) 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 899*cdf0e10cSrcweir SvLBox::SetDragDropMode( nDDMode ); 900*cdf0e10cSrcweir pImp->SetDragDropMode( nDDMode ); 901*cdf0e10cSrcweir } 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir short SvTreeListBox::GetHeightOffset(const Image& rBmp, Size& aSizeLogic ) 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 906*cdf0e10cSrcweir short nOffset = 0; 907*cdf0e10cSrcweir aSizeLogic = rBmp.GetSizePixel(); 908*cdf0e10cSrcweir if( GetEntryHeight() > aSizeLogic.Height() ) 909*cdf0e10cSrcweir nOffset = ( GetEntryHeight() - (short)aSizeLogic.Height()) / 2; 910*cdf0e10cSrcweir return nOffset; 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir short SvTreeListBox::GetHeightOffset(const Font& /* rFont */, Size& aSizeLogic ) 914*cdf0e10cSrcweir { 915*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 916*cdf0e10cSrcweir short nOffset = 0; 917*cdf0e10cSrcweir aSizeLogic = Size(GetTextWidth('X'), GetTextHeight()); 918*cdf0e10cSrcweir if( GetEntryHeight() > aSizeLogic.Height() ) 919*cdf0e10cSrcweir nOffset = ( GetEntryHeight() - (short)aSizeLogic.Height()) / 2; 920*cdf0e10cSrcweir return nOffset; 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir void SvTreeListBox::SetEntryHeight( SvLBoxEntry* pEntry ) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 926*cdf0e10cSrcweir short nHeight, nHeightMax=0; 927*cdf0e10cSrcweir sal_uInt16 nCount = pEntry->ItemCount(); 928*cdf0e10cSrcweir sal_uInt16 nCur = 0; 929*cdf0e10cSrcweir SvViewDataEntry* pViewData = GetViewDataEntry( pEntry ); 930*cdf0e10cSrcweir while( nCur < nCount ) 931*cdf0e10cSrcweir { 932*cdf0e10cSrcweir SvLBoxItem* pItem = pEntry->GetItem( nCur ); 933*cdf0e10cSrcweir nHeight = (short)(pItem->GetSize( pViewData, nCur ).Height()); 934*cdf0e10cSrcweir if( nHeight > nHeightMax ) 935*cdf0e10cSrcweir nHeightMax = nHeight; 936*cdf0e10cSrcweir nCur++; 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir if( nHeightMax > nEntryHeight ) 940*cdf0e10cSrcweir { 941*cdf0e10cSrcweir nEntryHeight = nHeightMax; 942*cdf0e10cSrcweir SvLBox::SetFont( GetFont() ); 943*cdf0e10cSrcweir pImp->SetEntryHeight( nHeightMax ); 944*cdf0e10cSrcweir } 945*cdf0e10cSrcweir } 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir void SvTreeListBox::SetEntryHeight( short nHeight, sal_Bool bAlways ) 948*cdf0e10cSrcweir { 949*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 950*cdf0e10cSrcweir 951*cdf0e10cSrcweir if( bAlways || nHeight > nEntryHeight ) 952*cdf0e10cSrcweir { 953*cdf0e10cSrcweir nEntryHeight = nHeight; 954*cdf0e10cSrcweir if( nEntryHeight ) 955*cdf0e10cSrcweir nTreeFlags |= TREEFLAG_FIXEDHEIGHT; 956*cdf0e10cSrcweir else 957*cdf0e10cSrcweir nTreeFlags &= ~TREEFLAG_FIXEDHEIGHT; 958*cdf0e10cSrcweir SvLBox::SetFont( GetFont() ); 959*cdf0e10cSrcweir pImp->SetEntryHeight( nHeight ); 960*cdf0e10cSrcweir } 961*cdf0e10cSrcweir } 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir void SvTreeListBox::AdjustEntryHeight( const Image& rBmp ) 965*cdf0e10cSrcweir { 966*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 967*cdf0e10cSrcweir Size aSize; 968*cdf0e10cSrcweir GetHeightOffset( rBmp, aSize ); 969*cdf0e10cSrcweir if( aSize.Height() > nEntryHeight ) 970*cdf0e10cSrcweir { 971*cdf0e10cSrcweir nEntryHeight = (short)aSize.Height() + nEntryHeightOffs; 972*cdf0e10cSrcweir pImp->SetEntryHeight( nEntryHeight ); 973*cdf0e10cSrcweir } 974*cdf0e10cSrcweir } 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir void SvTreeListBox::AdjustEntryHeight( const Font& rFont ) 977*cdf0e10cSrcweir { 978*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 979*cdf0e10cSrcweir Size aSize; 980*cdf0e10cSrcweir GetHeightOffset( rFont, aSize ); 981*cdf0e10cSrcweir if( aSize.Height() > nEntryHeight ) 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir nEntryHeight = (short)aSize.Height() + nEntryHeightOffs; 984*cdf0e10cSrcweir pImp->SetEntryHeight( nEntryHeight ); 985*cdf0e10cSrcweir } 986*cdf0e10cSrcweir } 987*cdf0e10cSrcweir 988*cdf0e10cSrcweir sal_Bool SvTreeListBox::Expand( SvLBoxEntry* pParent ) 989*cdf0e10cSrcweir { 990*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 991*cdf0e10cSrcweir pHdlEntry = pParent; 992*cdf0e10cSrcweir sal_Bool bExpanded = sal_False; 993*cdf0e10cSrcweir sal_uInt16 nFlags; 994*cdf0e10cSrcweir 995*cdf0e10cSrcweir if( pParent->HasChildsOnDemand() ) 996*cdf0e10cSrcweir RequestingChilds( pParent ); 997*cdf0e10cSrcweir if( pParent->HasChilds() ) 998*cdf0e10cSrcweir { 999*cdf0e10cSrcweir nImpFlags |= SVLBOX_IS_EXPANDING; 1000*cdf0e10cSrcweir if( ExpandingHdl() ) 1001*cdf0e10cSrcweir { 1002*cdf0e10cSrcweir bExpanded = sal_True; 1003*cdf0e10cSrcweir SvListView::Expand( pParent ); 1004*cdf0e10cSrcweir pImp->EntryExpanded( pParent ); 1005*cdf0e10cSrcweir pHdlEntry = pParent; 1006*cdf0e10cSrcweir ExpandedHdl(); 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir nFlags = pParent->GetFlags(); 1009*cdf0e10cSrcweir nFlags &= ~SV_ENTRYFLAG_NO_NODEBMP; 1010*cdf0e10cSrcweir nFlags |= SV_ENTRYFLAG_HAD_CHILDREN; 1011*cdf0e10cSrcweir pParent->SetFlags( nFlags ); 1012*cdf0e10cSrcweir } 1013*cdf0e10cSrcweir else 1014*cdf0e10cSrcweir { 1015*cdf0e10cSrcweir nFlags = pParent->GetFlags(); 1016*cdf0e10cSrcweir nFlags |= SV_ENTRYFLAG_NO_NODEBMP; 1017*cdf0e10cSrcweir pParent->SetFlags( nFlags ); 1018*cdf0e10cSrcweir GetModel()->InvalidateEntry( pParent ); // neu zeichnen 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir // --> OD 2009-04-01 #i92103# 1022*cdf0e10cSrcweir if ( bExpanded ) 1023*cdf0e10cSrcweir { 1024*cdf0e10cSrcweir pImp->CallEventListeners( VCLEVENT_ITEM_EXPANDED, pParent ); 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir // <-- 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir return bExpanded; 1029*cdf0e10cSrcweir } 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir sal_Bool SvTreeListBox::Collapse( SvLBoxEntry* pParent ) 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1034*cdf0e10cSrcweir nImpFlags &= ~SVLBOX_IS_EXPANDING; 1035*cdf0e10cSrcweir pHdlEntry = pParent; 1036*cdf0e10cSrcweir sal_Bool bCollapsed = sal_False; 1037*cdf0e10cSrcweir 1038*cdf0e10cSrcweir if( ExpandingHdl() ) 1039*cdf0e10cSrcweir { 1040*cdf0e10cSrcweir bCollapsed = sal_True; 1041*cdf0e10cSrcweir pImp->CollapsingEntry( pParent ); 1042*cdf0e10cSrcweir SvListView::Collapse( pParent ); 1043*cdf0e10cSrcweir pImp->EntryCollapsed( pParent ); 1044*cdf0e10cSrcweir pHdlEntry = pParent; 1045*cdf0e10cSrcweir ExpandedHdl(); 1046*cdf0e10cSrcweir } 1047*cdf0e10cSrcweir 1048*cdf0e10cSrcweir // --> OD 2009-04-01 #i92103# 1049*cdf0e10cSrcweir if ( bCollapsed ) 1050*cdf0e10cSrcweir { 1051*cdf0e10cSrcweir pImp->CallEventListeners( VCLEVENT_ITEM_COLLAPSED, pParent ); 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir // <-- 1054*cdf0e10cSrcweir 1055*cdf0e10cSrcweir return bCollapsed; 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir sal_Bool SvTreeListBox::Select( SvLBoxEntry* pEntry, sal_Bool bSelect ) 1059*cdf0e10cSrcweir { 1060*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1061*cdf0e10cSrcweir DBG_ASSERT(pEntry,"Select: Null-Ptr"); 1062*cdf0e10cSrcweir sal_Bool bRetVal = SvListView::Select( pEntry, bSelect ); 1063*cdf0e10cSrcweir DBG_ASSERT(IsSelected(pEntry)==bSelect,"Select failed"); 1064*cdf0e10cSrcweir if( bRetVal ) 1065*cdf0e10cSrcweir { 1066*cdf0e10cSrcweir pImp->EntrySelected( pEntry, bSelect ); 1067*cdf0e10cSrcweir pHdlEntry = pEntry; 1068*cdf0e10cSrcweir if( bSelect ) 1069*cdf0e10cSrcweir { 1070*cdf0e10cSrcweir SelectHdl(); 1071*cdf0e10cSrcweir pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry ); 1072*cdf0e10cSrcweir } 1073*cdf0e10cSrcweir else 1074*cdf0e10cSrcweir DeselectHdl(); 1075*cdf0e10cSrcweir } 1076*cdf0e10cSrcweir return bRetVal; 1077*cdf0e10cSrcweir } 1078*cdf0e10cSrcweir 1079*cdf0e10cSrcweir sal_uLong SvTreeListBox::SelectChilds( SvLBoxEntry* pParent, sal_Bool bSelect ) 1080*cdf0e10cSrcweir { 1081*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1082*cdf0e10cSrcweir pImp->DestroyAnchor(); 1083*cdf0e10cSrcweir sal_uLong nRet = 0; 1084*cdf0e10cSrcweir if( !pParent->HasChilds() ) 1085*cdf0e10cSrcweir return 0; 1086*cdf0e10cSrcweir sal_uInt16 nRefDepth = pModel->GetDepth( pParent ); 1087*cdf0e10cSrcweir SvLBoxEntry* pChild = FirstChild( pParent ); 1088*cdf0e10cSrcweir do { 1089*cdf0e10cSrcweir nRet++; 1090*cdf0e10cSrcweir Select( pChild, bSelect ); 1091*cdf0e10cSrcweir pChild = Next( pChild ); 1092*cdf0e10cSrcweir } while( pChild && pModel->GetDepth( pChild ) > nRefDepth ); 1093*cdf0e10cSrcweir return nRet; 1094*cdf0e10cSrcweir } 1095*cdf0e10cSrcweir 1096*cdf0e10cSrcweir void SvTreeListBox::SelectAll( sal_Bool bSelect, sal_Bool ) 1097*cdf0e10cSrcweir { 1098*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1099*cdf0e10cSrcweir pImp->SelAllDestrAnch( 1100*cdf0e10cSrcweir bSelect, 1101*cdf0e10cSrcweir sal_True, // Anker loeschen, 1102*cdf0e10cSrcweir sal_True ); // auch bei SINGLE_SELECTION den Cursor deselektieren 1103*cdf0e10cSrcweir } 1104*cdf0e10cSrcweir 1105*cdf0e10cSrcweir void SvTreeListBox::ModelHasInsertedTree( SvListEntry* pEntry ) 1106*cdf0e10cSrcweir { 1107*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1108*cdf0e10cSrcweir sal_uInt16 nRefDepth = pModel->GetDepth( (SvLBoxEntry*)pEntry ); 1109*cdf0e10cSrcweir SvLBoxEntry* pTmp = (SvLBoxEntry*)pEntry; 1110*cdf0e10cSrcweir do 1111*cdf0e10cSrcweir { 1112*cdf0e10cSrcweir ImpEntryInserted( pTmp ); 1113*cdf0e10cSrcweir pTmp = Next( pTmp ); 1114*cdf0e10cSrcweir } while( pTmp && nRefDepth < pModel->GetDepth( pTmp ) ); 1115*cdf0e10cSrcweir pImp->TreeInserted( (SvLBoxEntry*)pEntry ); 1116*cdf0e10cSrcweir } 1117*cdf0e10cSrcweir 1118*cdf0e10cSrcweir void SvTreeListBox::ModelHasInserted( SvListEntry* pEntry ) 1119*cdf0e10cSrcweir { 1120*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1121*cdf0e10cSrcweir ImpEntryInserted( (SvLBoxEntry*)pEntry ); 1122*cdf0e10cSrcweir pImp->EntryInserted( (SvLBoxEntry*)pEntry ); 1123*cdf0e10cSrcweir } 1124*cdf0e10cSrcweir 1125*cdf0e10cSrcweir void SvTreeListBox::ModelIsMoving(SvListEntry* pSource, 1126*cdf0e10cSrcweir SvListEntry* /* pTargetParent */, 1127*cdf0e10cSrcweir sal_uLong /* nChildPos */ ) 1128*cdf0e10cSrcweir { 1129*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1130*cdf0e10cSrcweir pImp->MovingEntry( (SvLBoxEntry*)pSource ); 1131*cdf0e10cSrcweir } 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir void SvTreeListBox::ModelHasMoved( SvListEntry* pSource ) 1134*cdf0e10cSrcweir { 1135*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1136*cdf0e10cSrcweir pImp->EntryMoved( (SvLBoxEntry*)pSource ); 1137*cdf0e10cSrcweir } 1138*cdf0e10cSrcweir 1139*cdf0e10cSrcweir void SvTreeListBox::ModelIsRemoving( SvListEntry* pEntry ) 1140*cdf0e10cSrcweir { 1141*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1142*cdf0e10cSrcweir if(pEdEntry == pEntry) 1143*cdf0e10cSrcweir pEdEntry = NULL; 1144*cdf0e10cSrcweir 1145*cdf0e10cSrcweir pImp->RemovingEntry( (SvLBoxEntry*)pEntry ); 1146*cdf0e10cSrcweir NotifyRemoving( (SvLBoxEntry*)pEntry ); 1147*cdf0e10cSrcweir } 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir void SvTreeListBox::ModelHasRemoved( SvListEntry* pEntry ) 1150*cdf0e10cSrcweir { 1151*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1152*cdf0e10cSrcweir if ( pEntry == pHdlEntry) 1153*cdf0e10cSrcweir pHdlEntry = NULL; 1154*cdf0e10cSrcweir pImp->EntryRemoved(); 1155*cdf0e10cSrcweir } 1156*cdf0e10cSrcweir 1157*cdf0e10cSrcweir void SvTreeListBox::SetCollapsedNodeBmp( const Image& rBmp, BmpColorMode _eMode ) 1158*cdf0e10cSrcweir { 1159*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1160*cdf0e10cSrcweir AdjustEntryHeight( rBmp ); 1161*cdf0e10cSrcweir pImp->SetCollapsedNodeBmp( rBmp, _eMode ); 1162*cdf0e10cSrcweir } 1163*cdf0e10cSrcweir 1164*cdf0e10cSrcweir void SvTreeListBox::SetExpandedNodeBmp( const Image& rBmp, BmpColorMode _eMode ) 1165*cdf0e10cSrcweir { 1166*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1167*cdf0e10cSrcweir AdjustEntryHeight( rBmp ); 1168*cdf0e10cSrcweir pImp->SetExpandedNodeBmp( rBmp, _eMode ); 1169*cdf0e10cSrcweir } 1170*cdf0e10cSrcweir 1171*cdf0e10cSrcweir 1172*cdf0e10cSrcweir void SvTreeListBox::SetFont( const Font& rFont ) 1173*cdf0e10cSrcweir { 1174*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1175*cdf0e10cSrcweir Font aTempFont( rFont ); 1176*cdf0e10cSrcweir aTempFont.SetTransparent( sal_True ); 1177*cdf0e10cSrcweir Control::SetFont( aTempFont ); 1178*cdf0e10cSrcweir AdjustEntryHeight( aTempFont ); 1179*cdf0e10cSrcweir // immer Invalidieren, sonst fallen wir 1180*cdf0e10cSrcweir // bei SetEntryHeight auf die Nase 1181*cdf0e10cSrcweir RecalcViewData(); 1182*cdf0e10cSrcweir } 1183*cdf0e10cSrcweir 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir void SvTreeListBox::Paint( const Rectangle& rRect ) 1186*cdf0e10cSrcweir { 1187*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1188*cdf0e10cSrcweir SvLBox::Paint( rRect ); 1189*cdf0e10cSrcweir if( nTreeFlags & TREEFLAG_RECALCTABS ) 1190*cdf0e10cSrcweir SetTabs(); 1191*cdf0e10cSrcweir pImp->Paint( rRect ); 1192*cdf0e10cSrcweir } 1193*cdf0e10cSrcweir 1194*cdf0e10cSrcweir void SvTreeListBox::MouseButtonDown( const MouseEvent& rMEvt ) 1195*cdf0e10cSrcweir { 1196*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1197*cdf0e10cSrcweir pImp->MouseButtonDown( rMEvt ); 1198*cdf0e10cSrcweir } 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir void SvTreeListBox::MouseButtonUp( const MouseEvent& rMEvt ) 1201*cdf0e10cSrcweir { 1202*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1203*cdf0e10cSrcweir pImp->MouseButtonUp( rMEvt ); 1204*cdf0e10cSrcweir } 1205*cdf0e10cSrcweir 1206*cdf0e10cSrcweir void SvTreeListBox::MouseMove( const MouseEvent& rMEvt ) 1207*cdf0e10cSrcweir { 1208*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1209*cdf0e10cSrcweir pImp->MouseMove( rMEvt ); 1210*cdf0e10cSrcweir } 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir 1213*cdf0e10cSrcweir void SvTreeListBox::SetUpdateMode( sal_Bool bUpdate ) 1214*cdf0e10cSrcweir { 1215*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1216*cdf0e10cSrcweir pImp->SetUpdateMode( bUpdate ); 1217*cdf0e10cSrcweir } 1218*cdf0e10cSrcweir 1219*cdf0e10cSrcweir void SvTreeListBox::SetUpdateModeFast( sal_Bool bUpdate ) 1220*cdf0e10cSrcweir { 1221*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1222*cdf0e10cSrcweir pImp->SetUpdateModeFast( bUpdate ); 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir 1225*cdf0e10cSrcweir void SvTreeListBox::SetSpaceBetweenEntries( short nOffsLogic ) 1226*cdf0e10cSrcweir { 1227*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1228*cdf0e10cSrcweir if( nOffsLogic != nEntryHeightOffs ) 1229*cdf0e10cSrcweir { 1230*cdf0e10cSrcweir nEntryHeight = nEntryHeight - nEntryHeightOffs; 1231*cdf0e10cSrcweir nEntryHeightOffs = (short)nOffsLogic; 1232*cdf0e10cSrcweir nEntryHeight = nEntryHeight + nOffsLogic; 1233*cdf0e10cSrcweir AdjustEntryHeight( GetFont() ); 1234*cdf0e10cSrcweir RecalcViewData(); 1235*cdf0e10cSrcweir pImp->SetEntryHeight( nEntryHeight ); 1236*cdf0e10cSrcweir } 1237*cdf0e10cSrcweir } 1238*cdf0e10cSrcweir 1239*cdf0e10cSrcweir void SvTreeListBox::SetCursor( SvLBoxEntry* pEntry, sal_Bool bForceNoSelect ) 1240*cdf0e10cSrcweir { 1241*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1242*cdf0e10cSrcweir pImp->SetCursor(pEntry, bForceNoSelect); 1243*cdf0e10cSrcweir } 1244*cdf0e10cSrcweir 1245*cdf0e10cSrcweir void SvTreeListBox::SetCurEntry( SvLBoxEntry* pEntry ) 1246*cdf0e10cSrcweir { 1247*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1248*cdf0e10cSrcweir pImp->SetCurEntry( pEntry ); 1249*cdf0e10cSrcweir } 1250*cdf0e10cSrcweir 1251*cdf0e10cSrcweir Image SvTreeListBox::GetCollapsedNodeBmp( BmpColorMode _eMode ) const 1252*cdf0e10cSrcweir { 1253*cdf0e10cSrcweir return pImp->GetCollapsedNodeBmp( _eMode ); 1254*cdf0e10cSrcweir } 1255*cdf0e10cSrcweir 1256*cdf0e10cSrcweir Image SvTreeListBox::GetExpandedNodeBmp( BmpColorMode _eMode ) const 1257*cdf0e10cSrcweir { 1258*cdf0e10cSrcweir return pImp->GetExpandedNodeBmp( _eMode ); 1259*cdf0e10cSrcweir } 1260*cdf0e10cSrcweir 1261*cdf0e10cSrcweir Point SvTreeListBox::GetEntryPosition( SvLBoxEntry* pEntry ) const 1262*cdf0e10cSrcweir { 1263*cdf0e10cSrcweir return pImp->GetEntryPosition( pEntry ); 1264*cdf0e10cSrcweir } 1265*cdf0e10cSrcweir 1266*cdf0e10cSrcweir void SvTreeListBox::ShowEntry( SvLBoxEntry* pEntry ) 1267*cdf0e10cSrcweir { 1268*cdf0e10cSrcweir MakeVisible( pEntry ); 1269*cdf0e10cSrcweir } 1270*cdf0e10cSrcweir 1271*cdf0e10cSrcweir void SvTreeListBox::MakeVisible( SvLBoxEntry* pEntry ) 1272*cdf0e10cSrcweir { 1273*cdf0e10cSrcweir pImp->MakeVisible(pEntry); 1274*cdf0e10cSrcweir } 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir void SvTreeListBox::MakeVisible( SvLBoxEntry* pEntry, sal_Bool bMoveToTop ) 1277*cdf0e10cSrcweir { 1278*cdf0e10cSrcweir pImp->MakeVisible( pEntry, bMoveToTop ); 1279*cdf0e10cSrcweir } 1280*cdf0e10cSrcweir 1281*cdf0e10cSrcweir void SvTreeListBox::ModelHasEntryInvalidated( SvListEntry* pEntry ) 1282*cdf0e10cSrcweir { 1283*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1284*cdf0e10cSrcweir // die einzelnen Items des Entries reinitialisieren 1285*cdf0e10cSrcweir SvLBox::ModelHasEntryInvalidated( pEntry ); 1286*cdf0e10cSrcweir // repainten 1287*cdf0e10cSrcweir pImp->InvalidateEntry( (SvLBoxEntry*)pEntry ); 1288*cdf0e10cSrcweir } 1289*cdf0e10cSrcweir 1290*cdf0e10cSrcweir void SvTreeListBox::EditItemText( SvLBoxEntry* pEntry, SvLBoxString* pItem, 1291*cdf0e10cSrcweir const Selection& rSelection ) 1292*cdf0e10cSrcweir { 1293*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1294*cdf0e10cSrcweir DBG_ASSERT(pEntry&&pItem,"EditItemText: Bad params"); 1295*cdf0e10cSrcweir if( IsSelected( pEntry )) 1296*cdf0e10cSrcweir { 1297*cdf0e10cSrcweir pImp->ShowCursor( sal_False ); 1298*cdf0e10cSrcweir SvListView::Select( pEntry, sal_False ); 1299*cdf0e10cSrcweir PaintEntry( pEntry ); 1300*cdf0e10cSrcweir SvListView::Select( pEntry, sal_True ); 1301*cdf0e10cSrcweir pImp->ShowCursor( sal_True ); 1302*cdf0e10cSrcweir } 1303*cdf0e10cSrcweir pEdEntry = pEntry; 1304*cdf0e10cSrcweir pEdItem = pItem; 1305*cdf0e10cSrcweir SvLBoxTab* pTab = GetTab( pEntry, pItem ); 1306*cdf0e10cSrcweir DBG_ASSERT(pTab,"EditItemText:Tab not found"); 1307*cdf0e10cSrcweir 1308*cdf0e10cSrcweir Size aItemSize( pItem->GetSize(this, pEntry) ); 1309*cdf0e10cSrcweir Point aPos = GetEntryPosition( pEntry ); 1310*cdf0e10cSrcweir aPos.Y() += ( nEntryHeight - aItemSize.Height() ) / 2; 1311*cdf0e10cSrcweir aPos.X() = GetTabPos( pEntry, pTab ); 1312*cdf0e10cSrcweir long nOutputWidth = pImp->GetOutputSize().Width(); 1313*cdf0e10cSrcweir Size aSize( nOutputWidth - aPos.X(), aItemSize.Height() ); 1314*cdf0e10cSrcweir sal_uInt16 nPos = aTabs.GetPos( pTab ); 1315*cdf0e10cSrcweir if( nPos+1 < aTabs.Count() ) 1316*cdf0e10cSrcweir { 1317*cdf0e10cSrcweir SvLBoxTab* pRightTab = (SvLBoxTab*)aTabs.GetObject( nPos + 1 ); 1318*cdf0e10cSrcweir long nRight = GetTabPos( pEntry, pRightTab ); 1319*cdf0e10cSrcweir if( nRight <= nOutputWidth ) 1320*cdf0e10cSrcweir aSize.Width() = nRight - aPos.X(); 1321*cdf0e10cSrcweir } 1322*cdf0e10cSrcweir Point aOrigin( GetMapMode().GetOrigin() ); 1323*cdf0e10cSrcweir aPos += aOrigin; // in Win-Koord umrechnen 1324*cdf0e10cSrcweir aSize.Width() -= aOrigin.X(); 1325*cdf0e10cSrcweir Rectangle aRect( aPos, aSize ); 1326*cdf0e10cSrcweir #ifdef OS2 1327*cdf0e10cSrcweir // Platz lassen fuer WB_BORDER 1328*cdf0e10cSrcweir aRect.Left() -= 2; 1329*cdf0e10cSrcweir aRect.Top() -= 3; 1330*cdf0e10cSrcweir aRect.Bottom() += 3; 1331*cdf0e10cSrcweir #endif 1332*cdf0e10cSrcweir EditText( pItem->GetText(), aRect, rSelection ); 1333*cdf0e10cSrcweir } 1334*cdf0e10cSrcweir 1335*cdf0e10cSrcweir void SvTreeListBox::CancelEditing() 1336*cdf0e10cSrcweir { 1337*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1338*cdf0e10cSrcweir SvLBox::CancelTextEditing(); 1339*cdf0e10cSrcweir } 1340*cdf0e10cSrcweir 1341*cdf0e10cSrcweir void SvTreeListBox::EditEntry( SvLBoxEntry* pEntry ) 1342*cdf0e10cSrcweir { 1343*cdf0e10cSrcweir pImp->aEditClickPos = Point( -1, -1 ); 1344*cdf0e10cSrcweir ImplEditEntry( pEntry ); 1345*cdf0e10cSrcweir } 1346*cdf0e10cSrcweir 1347*cdf0e10cSrcweir void SvTreeListBox::ImplEditEntry( SvLBoxEntry* pEntry ) 1348*cdf0e10cSrcweir { 1349*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1350*cdf0e10cSrcweir if( IsEditingActive() ) 1351*cdf0e10cSrcweir EndEditing(); 1352*cdf0e10cSrcweir if( !pEntry ) 1353*cdf0e10cSrcweir pEntry = GetCurEntry(); 1354*cdf0e10cSrcweir if( pEntry ) 1355*cdf0e10cSrcweir { 1356*cdf0e10cSrcweir long nClickX = pImp->aEditClickPos.X(); 1357*cdf0e10cSrcweir bool bIsMouseTriggered = nClickX >= 0; 1358*cdf0e10cSrcweir 1359*cdf0e10cSrcweir SvLBoxString* pItem = NULL; 1360*cdf0e10cSrcweir sal_uInt16 nCount = pEntry->ItemCount(); 1361*cdf0e10cSrcweir for( sal_uInt16 i = 0 ; i < nCount ; i++ ) 1362*cdf0e10cSrcweir { 1363*cdf0e10cSrcweir SvLBoxItem* pTmpItem = pEntry->GetItem( i ); 1364*cdf0e10cSrcweir if( pTmpItem->IsA() != SV_ITEM_ID_LBOXSTRING ) 1365*cdf0e10cSrcweir continue; 1366*cdf0e10cSrcweir 1367*cdf0e10cSrcweir SvLBoxTab* pTab = GetTab( pEntry, pTmpItem ); 1368*cdf0e10cSrcweir long nTabPos = pTab->GetPos(); 1369*cdf0e10cSrcweir long nNextTabPos = -1; 1370*cdf0e10cSrcweir if( i < nCount - 1 ) 1371*cdf0e10cSrcweir { 1372*cdf0e10cSrcweir SvLBoxItem* pNextItem = pEntry->GetItem( i + 1 ); 1373*cdf0e10cSrcweir SvLBoxTab* pNextTab = GetTab( pEntry, pNextItem ); 1374*cdf0e10cSrcweir nNextTabPos = pNextTab->GetPos(); 1375*cdf0e10cSrcweir } 1376*cdf0e10cSrcweir 1377*cdf0e10cSrcweir if( pTab && pTab->IsEditable() ) 1378*cdf0e10cSrcweir { 1379*cdf0e10cSrcweir if( !bIsMouseTriggered || (nClickX > nTabPos && (nNextTabPos == -1 || nClickX < nNextTabPos ) ) ) 1380*cdf0e10cSrcweir { 1381*cdf0e10cSrcweir pItem = static_cast<SvLBoxString*>( pTmpItem ); 1382*cdf0e10cSrcweir break; 1383*cdf0e10cSrcweir } 1384*cdf0e10cSrcweir } 1385*cdf0e10cSrcweir } 1386*cdf0e10cSrcweir 1387*cdf0e10cSrcweir Selection aSel( SELECTION_MIN, SELECTION_MAX ); 1388*cdf0e10cSrcweir if( pItem && EditingEntry( pEntry, aSel ) ) 1389*cdf0e10cSrcweir { 1390*cdf0e10cSrcweir SelectAll( sal_False ); 1391*cdf0e10cSrcweir MakeVisible( pEntry ); 1392*cdf0e10cSrcweir EditItemText( pEntry, pItem, aSel ); 1393*cdf0e10cSrcweir } 1394*cdf0e10cSrcweir } 1395*cdf0e10cSrcweir } 1396*cdf0e10cSrcweir 1397*cdf0e10cSrcweir sal_Bool SvTreeListBox::AreChildrenTransient() const 1398*cdf0e10cSrcweir { 1399*cdf0e10cSrcweir return pImp->AreChildrenTransient(); 1400*cdf0e10cSrcweir } 1401*cdf0e10cSrcweir 1402*cdf0e10cSrcweir void SvTreeListBox::SetChildrenNotTransient() 1403*cdf0e10cSrcweir { 1404*cdf0e10cSrcweir pImp->SetChildrenNotTransient(); 1405*cdf0e10cSrcweir } 1406*cdf0e10cSrcweir 1407*cdf0e10cSrcweir void SvTreeListBox::EditedText( const XubString& rStr ) 1408*cdf0e10cSrcweir 1409*cdf0e10cSrcweir { 1410*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1411*cdf0e10cSrcweir if(pEdEntry) // we have to check if this entry is null that means that it is removed while editing 1412*cdf0e10cSrcweir { 1413*cdf0e10cSrcweir Point aPos = GetEntryPosition( pEdEntry ); 1414*cdf0e10cSrcweir if( EditedEntry( pEdEntry, rStr ) ) 1415*cdf0e10cSrcweir { 1416*cdf0e10cSrcweir ((SvLBoxString*)pEdItem)->SetText( pEdEntry, rStr ); 1417*cdf0e10cSrcweir pModel->InvalidateEntry( pEdEntry ); 1418*cdf0e10cSrcweir } 1419*cdf0e10cSrcweir //if( GetSelectionMode() == SINGLE_SELECTION ) 1420*cdf0e10cSrcweir //{ 1421*cdf0e10cSrcweir if( GetSelectionCount() == 0 ) 1422*cdf0e10cSrcweir Select( pEdEntry ); 1423*cdf0e10cSrcweir if( GetSelectionMode() == MULTIPLE_SELECTION && !GetCurEntry() ) 1424*cdf0e10cSrcweir SetCurEntry( pEdEntry ); 1425*cdf0e10cSrcweir //} 1426*cdf0e10cSrcweir } 1427*cdf0e10cSrcweir } 1428*cdf0e10cSrcweir 1429*cdf0e10cSrcweir void SvTreeListBox::EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem, 1430*cdf0e10cSrcweir const Point& ) 1431*cdf0e10cSrcweir { 1432*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1433*cdf0e10cSrcweir if( IsEditingActive() ) 1434*cdf0e10cSrcweir EndEditing(); 1435*cdf0e10cSrcweir if( pItem->IsA() == SV_ITEM_ID_LBOXSTRING ) 1436*cdf0e10cSrcweir { 1437*cdf0e10cSrcweir Selection aSel( SELECTION_MIN, SELECTION_MAX ); 1438*cdf0e10cSrcweir if( EditingEntry( pEntry, aSel ) ) 1439*cdf0e10cSrcweir { 1440*cdf0e10cSrcweir SelectAll( sal_False ); 1441*cdf0e10cSrcweir EditItemText( pEntry, (SvLBoxString*)pItem, aSel ); 1442*cdf0e10cSrcweir } 1443*cdf0e10cSrcweir } 1444*cdf0e10cSrcweir } 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir 1447*cdf0e10cSrcweir 1448*cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetDropTarget( const Point& rPos ) 1449*cdf0e10cSrcweir { 1450*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1451*cdf0e10cSrcweir // Scrollen 1452*cdf0e10cSrcweir if( rPos.Y() < 12 ) 1453*cdf0e10cSrcweir { 1454*cdf0e10cSrcweir SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, sal_False ); 1455*cdf0e10cSrcweir ScrollOutputArea( +1 ); 1456*cdf0e10cSrcweir } 1457*cdf0e10cSrcweir else 1458*cdf0e10cSrcweir { 1459*cdf0e10cSrcweir Size aSize( pImp->GetOutputSize() ); 1460*cdf0e10cSrcweir if( rPos.Y() > aSize.Height() - 12 ) 1461*cdf0e10cSrcweir { 1462*cdf0e10cSrcweir SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, sal_False ); 1463*cdf0e10cSrcweir ScrollOutputArea( -1 ); 1464*cdf0e10cSrcweir } 1465*cdf0e10cSrcweir } 1466*cdf0e10cSrcweir 1467*cdf0e10cSrcweir SvLBoxEntry* pTarget = pImp->GetEntry( rPos ); 1468*cdf0e10cSrcweir // bei Droppen in leere Flaeche -> den letzten Eintrag nehmen 1469*cdf0e10cSrcweir if( !pTarget ) 1470*cdf0e10cSrcweir return (SvLBoxEntry*)LastVisible(); 1471*cdf0e10cSrcweir else if( (GetDragDropMode() & SV_DRAGDROP_ENABLE_TOP) && 1472*cdf0e10cSrcweir pTarget == First() && rPos.Y() < 6 ) 1473*cdf0e10cSrcweir return 0; 1474*cdf0e10cSrcweir 1475*cdf0e10cSrcweir return pTarget; 1476*cdf0e10cSrcweir } 1477*cdf0e10cSrcweir 1478*cdf0e10cSrcweir 1479*cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetEntry( const Point& rPos, sal_Bool bHit ) const 1480*cdf0e10cSrcweir { 1481*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1482*cdf0e10cSrcweir SvLBoxEntry* pEntry = pImp->GetEntry( rPos ); 1483*cdf0e10cSrcweir if( pEntry && bHit ) 1484*cdf0e10cSrcweir { 1485*cdf0e10cSrcweir long nLine = pImp->GetEntryLine( pEntry ); 1486*cdf0e10cSrcweir if( !(pImp->EntryReallyHit( pEntry, rPos, nLine)) ) 1487*cdf0e10cSrcweir return 0; 1488*cdf0e10cSrcweir } 1489*cdf0e10cSrcweir return pEntry; 1490*cdf0e10cSrcweir } 1491*cdf0e10cSrcweir 1492*cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetCurEntry() const 1493*cdf0e10cSrcweir { 1494*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1495*cdf0e10cSrcweir return pImp->GetCurEntry(); 1496*cdf0e10cSrcweir } 1497*cdf0e10cSrcweir 1498*cdf0e10cSrcweir void SvTreeListBox::ImplInitStyle() 1499*cdf0e10cSrcweir { 1500*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir const WinBits nWindowStyle = GetStyle(); 1503*cdf0e10cSrcweir 1504*cdf0e10cSrcweir nTreeFlags |= TREEFLAG_RECALCTABS; 1505*cdf0e10cSrcweir if( nWindowStyle & WB_SORT ) 1506*cdf0e10cSrcweir { 1507*cdf0e10cSrcweir GetModel()->SetSortMode( SortAscending ); 1508*cdf0e10cSrcweir GetModel()->SetCompareHdl( LINK(this,SvTreeListBox,DefaultCompare)); 1509*cdf0e10cSrcweir } 1510*cdf0e10cSrcweir else 1511*cdf0e10cSrcweir { 1512*cdf0e10cSrcweir GetModel()->SetSortMode( SortNone ); 1513*cdf0e10cSrcweir GetModel()->SetCompareHdl( Link() ); 1514*cdf0e10cSrcweir } 1515*cdf0e10cSrcweir #ifdef OS2 1516*cdf0e10cSrcweir nWindowStyle |= WB_VSCROLL; 1517*cdf0e10cSrcweir #endif 1518*cdf0e10cSrcweir pImp->SetStyle( nWindowStyle ); 1519*cdf0e10cSrcweir pImp->Resize(); 1520*cdf0e10cSrcweir Invalidate(); 1521*cdf0e10cSrcweir } 1522*cdf0e10cSrcweir 1523*cdf0e10cSrcweir void SvTreeListBox::PaintEntry( SvLBoxEntry* pEntry ) 1524*cdf0e10cSrcweir { 1525*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1526*cdf0e10cSrcweir DBG_ASSERT(pEntry,"PaintEntry:No Entry"); 1527*cdf0e10cSrcweir if( pEntry ) 1528*cdf0e10cSrcweir pImp->PaintEntry( pEntry ); 1529*cdf0e10cSrcweir } 1530*cdf0e10cSrcweir 1531*cdf0e10cSrcweir void SvTreeListBox::InvalidateEntry( SvLBoxEntry* pEntry ) 1532*cdf0e10cSrcweir { 1533*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1534*cdf0e10cSrcweir DBG_ASSERT(pEntry,"InvalidateEntry:No Entry"); 1535*cdf0e10cSrcweir if( pEntry ) 1536*cdf0e10cSrcweir { 1537*cdf0e10cSrcweir GetModel()->InvalidateEntry( pEntry ); 1538*cdf0e10cSrcweir // pImp->InvalidateEntry( pEntry ); 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir } 1541*cdf0e10cSrcweir 1542*cdf0e10cSrcweir 1543*cdf0e10cSrcweir long SvTreeListBox::PaintEntry(SvLBoxEntry* pEntry,long nLine,sal_uInt16 nTabFlags) 1544*cdf0e10cSrcweir { 1545*cdf0e10cSrcweir return PaintEntry1(pEntry,nLine,nTabFlags); 1546*cdf0e10cSrcweir } 1547*cdf0e10cSrcweir 1548*cdf0e10cSrcweir #define SV_TAB_BORDER 8 1549*cdf0e10cSrcweir 1550*cdf0e10cSrcweir long SvTreeListBox::PaintEntry1(SvLBoxEntry* pEntry,long nLine,sal_uInt16 nTabFlags, 1551*cdf0e10cSrcweir sal_Bool bHasClipRegion ) 1552*cdf0e10cSrcweir { 1553*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1554*cdf0e10cSrcweir 1555*cdf0e10cSrcweir Rectangle aRect; // multi purpose 1556*cdf0e10cSrcweir 1557*cdf0e10cSrcweir sal_Bool bHorSBar = pImp->HasHorScrollBar(); 1558*cdf0e10cSrcweir PreparePaint( pEntry ); 1559*cdf0e10cSrcweir 1560*cdf0e10cSrcweir // #97680# ------------------ 1561*cdf0e10cSrcweir pImp->UpdateContextBmpWidthMax( pEntry ); 1562*cdf0e10cSrcweir 1563*cdf0e10cSrcweir if( nTreeFlags & TREEFLAG_RECALCTABS ) 1564*cdf0e10cSrcweir SetTabs(); 1565*cdf0e10cSrcweir 1566*cdf0e10cSrcweir short nTempEntryHeight = GetEntryHeight(); 1567*cdf0e10cSrcweir long nWidth = pImp->GetOutputSize().Width(); 1568*cdf0e10cSrcweir 1569*cdf0e10cSrcweir // wurde innerhalb des PreparePaints die horizontale ScrollBar 1570*cdf0e10cSrcweir // angeschaltet? Wenn ja, muss die ClipRegion neu gesetzt werden 1571*cdf0e10cSrcweir if( !bHorSBar && pImp->HasHorScrollBar() ) 1572*cdf0e10cSrcweir SetClipRegion( Region(pImp->GetClipRegionRect()) ); 1573*cdf0e10cSrcweir 1574*cdf0e10cSrcweir Point aEntryPos( GetMapMode().GetOrigin() ); 1575*cdf0e10cSrcweir aEntryPos.X() *= -1; // Umrechnung Dokumentkoord. 1576*cdf0e10cSrcweir long nMaxRight = nWidth + aEntryPos.X() - 1; 1577*cdf0e10cSrcweir 1578*cdf0e10cSrcweir Color aBackupTextColor( GetTextColor() ); 1579*cdf0e10cSrcweir Font aBackupFont( GetFont() ); 1580*cdf0e10cSrcweir Color aBackupColor = GetFillColor(); 1581*cdf0e10cSrcweir 1582*cdf0e10cSrcweir bool bCurFontIsSel = false; 1583*cdf0e10cSrcweir sal_Bool bInUse = pEntry->HasInUseEmphasis(); 1584*cdf0e10cSrcweir // wenn eine ClipRegion von aussen gesetzt wird, dann 1585*cdf0e10cSrcweir // diese nicht zuruecksetzen 1586*cdf0e10cSrcweir const WinBits nWindowStyle = GetStyle(); 1587*cdf0e10cSrcweir const sal_Bool bResetClipRegion = !bHasClipRegion; 1588*cdf0e10cSrcweir const sal_Bool bHideSelection = ((nWindowStyle & WB_HIDESELECTION) && !HasFocus())!=0; 1589*cdf0e10cSrcweir const StyleSettings& rSettings = GetSettings().GetStyleSettings(); 1590*cdf0e10cSrcweir 1591*cdf0e10cSrcweir Font aHighlightFont( GetFont() ); 1592*cdf0e10cSrcweir const Color aHighlightTextColor( rSettings.GetHighlightTextColor() ); 1593*cdf0e10cSrcweir aHighlightFont.SetColor( aHighlightTextColor ); 1594*cdf0e10cSrcweir 1595*cdf0e10cSrcweir Size aRectSize( 0, nTempEntryHeight ); 1596*cdf0e10cSrcweir 1597*cdf0e10cSrcweir if( !bHasClipRegion && nWindowStyle & WB_HSCROLL ) 1598*cdf0e10cSrcweir { 1599*cdf0e10cSrcweir SetClipRegion( Region(pImp->GetClipRegionRect()) ); 1600*cdf0e10cSrcweir bHasClipRegion = sal_True; 1601*cdf0e10cSrcweir } 1602*cdf0e10cSrcweir 1603*cdf0e10cSrcweir SvViewDataEntry* pViewDataEntry = GetViewDataEntry( pEntry ); 1604*cdf0e10cSrcweir 1605*cdf0e10cSrcweir sal_uInt16 nTabCount = aTabs.Count(); 1606*cdf0e10cSrcweir sal_uInt16 nItemCount = pEntry->ItemCount(); 1607*cdf0e10cSrcweir sal_uInt16 nCurTab = 0; 1608*cdf0e10cSrcweir sal_uInt16 nCurItem = 0; 1609*cdf0e10cSrcweir 1610*cdf0e10cSrcweir while( nCurTab < nTabCount && nCurItem < nItemCount ) 1611*cdf0e10cSrcweir { 1612*cdf0e10cSrcweir SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( nCurTab ); 1613*cdf0e10cSrcweir sal_uInt16 nNextTab = nCurTab + 1; 1614*cdf0e10cSrcweir SvLBoxTab* pNextTab = nNextTab < nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextTab) : 0; 1615*cdf0e10cSrcweir SvLBoxItem* pItem = nCurItem < nItemCount ? pEntry->GetItem(nCurItem) : 0; 1616*cdf0e10cSrcweir 1617*cdf0e10cSrcweir sal_uInt16 nFlags = pTab->nFlags; 1618*cdf0e10cSrcweir Size aSize( pItem->GetSize( pViewDataEntry, nCurItem )); 1619*cdf0e10cSrcweir long nTabPos = GetTabPos( pEntry, pTab ); 1620*cdf0e10cSrcweir 1621*cdf0e10cSrcweir long nNextTabPos; 1622*cdf0e10cSrcweir if( pNextTab ) 1623*cdf0e10cSrcweir nNextTabPos = GetTabPos( pEntry, pNextTab ); 1624*cdf0e10cSrcweir else 1625*cdf0e10cSrcweir { 1626*cdf0e10cSrcweir nNextTabPos = nMaxRight; 1627*cdf0e10cSrcweir if( nTabPos > nMaxRight ) 1628*cdf0e10cSrcweir nNextTabPos += 50; 1629*cdf0e10cSrcweir } 1630*cdf0e10cSrcweir 1631*cdf0e10cSrcweir long nX; 1632*cdf0e10cSrcweir if( pTab->nFlags & SV_LBOXTAB_ADJUST_RIGHT ) 1633*cdf0e10cSrcweir //verhindern, das rechter Rand von der Tabtrennung abgeschnitten wird 1634*cdf0e10cSrcweir nX = nTabPos + pTab->CalcOffset(aSize.Width(), (nNextTabPos-SV_TAB_BORDER-1) -nTabPos); 1635*cdf0e10cSrcweir else 1636*cdf0e10cSrcweir nX = nTabPos + pTab->CalcOffset(aSize.Width(), nNextTabPos-nTabPos); 1637*cdf0e10cSrcweir 1638*cdf0e10cSrcweir if( nFlags & nTabFlags ) 1639*cdf0e10cSrcweir { 1640*cdf0e10cSrcweir if( !bHasClipRegion && nX + aSize.Width() >= nMaxRight ) 1641*cdf0e10cSrcweir { 1642*cdf0e10cSrcweir SetClipRegion( Region(pImp->GetClipRegionRect()) ); 1643*cdf0e10cSrcweir bHasClipRegion = sal_True; 1644*cdf0e10cSrcweir } 1645*cdf0e10cSrcweir aEntryPos.X() = nX; 1646*cdf0e10cSrcweir aEntryPos.Y() = nLine; 1647*cdf0e10cSrcweir 1648*cdf0e10cSrcweir // Hintergrund-Muster & Farbe bestimmen 1649*cdf0e10cSrcweir 1650*cdf0e10cSrcweir Wallpaper aWallpaper = GetBackground(); 1651*cdf0e10cSrcweir 1652*cdf0e10cSrcweir int bSelTab = nFlags & SV_LBOXTAB_SHOW_SELECTION; 1653*cdf0e10cSrcweir sal_uInt16 nItemType = pItem->IsA(); 1654*cdf0e10cSrcweir 1655*cdf0e10cSrcweir if ( pViewDataEntry->IsSelected() && bSelTab && !pViewDataEntry->IsCursored() ) 1656*cdf0e10cSrcweir { 1657*cdf0e10cSrcweir Color aNewWallColor = rSettings.GetHighlightColor(); 1658*cdf0e10cSrcweir if ( !bInUse || nItemType != SV_ITEM_ID_LBOXCONTEXTBMP ) 1659*cdf0e10cSrcweir { 1660*cdf0e10cSrcweir // if the face color is bright then the deactive color is also bright 1661*cdf0e10cSrcweir // -> so you can't see any deactive selection 1662*cdf0e10cSrcweir if ( bHideSelection && !rSettings.GetFaceColor().IsBright() && 1663*cdf0e10cSrcweir aWallpaper.GetColor().IsBright() != rSettings.GetDeactiveColor().IsBright() ) 1664*cdf0e10cSrcweir aNewWallColor = rSettings.GetDeactiveColor(); 1665*cdf0e10cSrcweir // set font color to highlight 1666*cdf0e10cSrcweir if ( !bCurFontIsSel ) 1667*cdf0e10cSrcweir { 1668*cdf0e10cSrcweir SetTextColor( aHighlightTextColor ); 1669*cdf0e10cSrcweir SetFont( aHighlightFont ); 1670*cdf0e10cSrcweir bCurFontIsSel = true; 1671*cdf0e10cSrcweir } 1672*cdf0e10cSrcweir } 1673*cdf0e10cSrcweir aWallpaper.SetColor( aNewWallColor ); 1674*cdf0e10cSrcweir } 1675*cdf0e10cSrcweir else // keine Selektion 1676*cdf0e10cSrcweir { 1677*cdf0e10cSrcweir if( bInUse && nItemType == SV_ITEM_ID_LBOXCONTEXTBMP ) 1678*cdf0e10cSrcweir aWallpaper.SetColor( rSettings.GetFieldColor() ); 1679*cdf0e10cSrcweir else if( bCurFontIsSel ) 1680*cdf0e10cSrcweir { 1681*cdf0e10cSrcweir bCurFontIsSel = false; 1682*cdf0e10cSrcweir SetTextColor( aBackupTextColor ); 1683*cdf0e10cSrcweir SetFont( aBackupFont ); 1684*cdf0e10cSrcweir } 1685*cdf0e10cSrcweir } 1686*cdf0e10cSrcweir 1687*cdf0e10cSrcweir // Hintergrund zeichnen 1688*cdf0e10cSrcweir if( !(nTreeFlags & TREEFLAG_USESEL)) 1689*cdf0e10cSrcweir { 1690*cdf0e10cSrcweir // nur den Bereich zeichnen, den das Item einnimmt 1691*cdf0e10cSrcweir aRectSize.Width() = aSize.Width(); 1692*cdf0e10cSrcweir aRect.SetPos( aEntryPos ); 1693*cdf0e10cSrcweir aRect.SetSize( aRectSize ); 1694*cdf0e10cSrcweir } 1695*cdf0e10cSrcweir else 1696*cdf0e10cSrcweir { 1697*cdf0e10cSrcweir // vom aktuellen bis zum naechsten Tab zeichnen 1698*cdf0e10cSrcweir if( nCurTab != 0 ) 1699*cdf0e10cSrcweir aRect.Left() = nTabPos; 1700*cdf0e10cSrcweir else 1701*cdf0e10cSrcweir // beim nullten Tab immer ab Spalte 0 zeichnen 1702*cdf0e10cSrcweir // (sonst Probleme bei Tabs mit Zentrierung) 1703*cdf0e10cSrcweir aRect.Left() = 0; 1704*cdf0e10cSrcweir aRect.Top() = nLine; 1705*cdf0e10cSrcweir aRect.Bottom() = nLine + nTempEntryHeight - 1; 1706*cdf0e10cSrcweir if( pNextTab ) 1707*cdf0e10cSrcweir { 1708*cdf0e10cSrcweir long nRight; 1709*cdf0e10cSrcweir nRight = GetTabPos(pEntry,pNextTab)-1; 1710*cdf0e10cSrcweir if( nRight > nMaxRight ) 1711*cdf0e10cSrcweir nRight = nMaxRight; 1712*cdf0e10cSrcweir aRect.Right() = nRight; 1713*cdf0e10cSrcweir } 1714*cdf0e10cSrcweir else 1715*cdf0e10cSrcweir aRect.Right() = nMaxRight; 1716*cdf0e10cSrcweir } 1717*cdf0e10cSrcweir // bei anwenderdefinierter Selektion, die bei einer Tabposition 1718*cdf0e10cSrcweir // groesser 0 beginnt den Hintergrund des 0.ten Items nicht 1719*cdf0e10cSrcweir // fuellen, da sonst z.B. TablistBoxen mit Linien nicht 1720*cdf0e10cSrcweir // realisiert werden koennen. 1721*cdf0e10cSrcweir if( !(nCurTab==0 && (nTreeFlags & TREEFLAG_USESEL) && nFirstSelTab) ) 1722*cdf0e10cSrcweir { 1723*cdf0e10cSrcweir SetFillColor( aWallpaper.GetColor() ); 1724*cdf0e10cSrcweir // Bei kleinen hor. Resizes tritt dieser Fall auf 1725*cdf0e10cSrcweir if( aRect.Left() < aRect.Right() ) 1726*cdf0e10cSrcweir DrawRect( aRect ); 1727*cdf0e10cSrcweir } 1728*cdf0e10cSrcweir // Item zeichnen 1729*cdf0e10cSrcweir // vertikal zentrieren 1730*cdf0e10cSrcweir aEntryPos.Y() += ( nTempEntryHeight - aSize.Height() ) / 2; 1731*cdf0e10cSrcweir pItem->Paint( aEntryPos, *this, pViewDataEntry->GetFlags(), pEntry ); 1732*cdf0e10cSrcweir 1733*cdf0e10cSrcweir // Trennungslinie zwischen Tabs 1734*cdf0e10cSrcweir if( pNextTab && pItem->IsA() == SV_ITEM_ID_LBOXSTRING && 1735*cdf0e10cSrcweir // nicht am rechten Fensterrand! 1736*cdf0e10cSrcweir aRect.Right() < nMaxRight ) 1737*cdf0e10cSrcweir { 1738*cdf0e10cSrcweir aRect.Left() = aRect.Right() - SV_TAB_BORDER; 1739*cdf0e10cSrcweir DrawRect( aRect ); 1740*cdf0e10cSrcweir } 1741*cdf0e10cSrcweir 1742*cdf0e10cSrcweir SetFillColor( aBackupColor ); 1743*cdf0e10cSrcweir } 1744*cdf0e10cSrcweir nCurItem++; 1745*cdf0e10cSrcweir nCurTab++; 1746*cdf0e10cSrcweir } 1747*cdf0e10cSrcweir if( pViewDataEntry->IsCursored() && !HasFocus() ) 1748*cdf0e10cSrcweir { 1749*cdf0e10cSrcweir // Cursor-Emphasis 1750*cdf0e10cSrcweir SetFillColor(); 1751*cdf0e10cSrcweir Color aOldLineColor = GetLineColor(); 1752*cdf0e10cSrcweir SetLineColor( Color( COL_BLACK ) ); 1753*cdf0e10cSrcweir aRect = GetFocusRect( pEntry, nLine ); 1754*cdf0e10cSrcweir aRect.Top()++; 1755*cdf0e10cSrcweir aRect.Bottom()--; 1756*cdf0e10cSrcweir DrawRect( aRect ); 1757*cdf0e10cSrcweir SetLineColor( aOldLineColor ); 1758*cdf0e10cSrcweir SetFillColor( aBackupColor ); 1759*cdf0e10cSrcweir } 1760*cdf0e10cSrcweir 1761*cdf0e10cSrcweir if( bCurFontIsSel ) 1762*cdf0e10cSrcweir { 1763*cdf0e10cSrcweir SetTextColor( aBackupTextColor ); 1764*cdf0e10cSrcweir SetFont( aBackupFont ); 1765*cdf0e10cSrcweir } 1766*cdf0e10cSrcweir 1767*cdf0e10cSrcweir sal_uInt16 nFirstDynTabPos; 1768*cdf0e10cSrcweir SvLBoxTab* pFirstDynamicTab = GetFirstDynamicTab( nFirstDynTabPos ); 1769*cdf0e10cSrcweir long nDynTabPos = GetTabPos( pEntry, pFirstDynamicTab ); 1770*cdf0e10cSrcweir nDynTabPos += pImp->nNodeBmpTabDistance; 1771*cdf0e10cSrcweir nDynTabPos += pImp->nNodeBmpWidth / 2; 1772*cdf0e10cSrcweir nDynTabPos += 4; // 4 Pixel Reserve, damit die Node-Bitmap 1773*cdf0e10cSrcweir // nicht zu nah am naechsten Tab steht 1774*cdf0e10cSrcweir 1775*cdf0e10cSrcweir if( (!(pEntry->GetFlags() & SV_ENTRYFLAG_NO_NODEBMP)) && 1776*cdf0e10cSrcweir (nWindowStyle & WB_HASBUTTONS) && pFirstDynamicTab && 1777*cdf0e10cSrcweir ( pEntry->HasChilds() || pEntry->HasChildsOnDemand() ) ) 1778*cdf0e10cSrcweir { 1779*cdf0e10cSrcweir // ersten festen Tab suchen, und pruefen ob die Node-Bitmap 1780*cdf0e10cSrcweir // in ihn hineinragt 1781*cdf0e10cSrcweir sal_uInt16 nNextTab = nFirstDynTabPos; 1782*cdf0e10cSrcweir SvLBoxTab* pNextTab; 1783*cdf0e10cSrcweir do 1784*cdf0e10cSrcweir { 1785*cdf0e10cSrcweir nNextTab++; 1786*cdf0e10cSrcweir pNextTab = nNextTab < nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextTab) : 0; 1787*cdf0e10cSrcweir } while( pNextTab && pNextTab->IsDynamic() ); 1788*cdf0e10cSrcweir 1789*cdf0e10cSrcweir if( !pNextTab || (GetTabPos( pEntry, pNextTab ) > nDynTabPos) ) 1790*cdf0e10cSrcweir { 1791*cdf0e10cSrcweir if((nWindowStyle & WB_HASBUTTONSATROOT) || pModel->GetDepth(pEntry) > 0) 1792*cdf0e10cSrcweir { 1793*cdf0e10cSrcweir Point aPos( GetTabPos(pEntry,pFirstDynamicTab), nLine ); 1794*cdf0e10cSrcweir aPos.X() += pImp->nNodeBmpTabDistance; 1795*cdf0e10cSrcweir 1796*cdf0e10cSrcweir const Image* pImg = 0; 1797*cdf0e10cSrcweir BmpColorMode eBitmapMode = BMP_COLOR_NORMAL; 1798*cdf0e10cSrcweir if ( GetSettings().GetStyleSettings().GetHighContrastMode() ) 1799*cdf0e10cSrcweir eBitmapMode = BMP_COLOR_HIGHCONTRAST; 1800*cdf0e10cSrcweir 1801*cdf0e10cSrcweir if( IsExpanded(pEntry) ) 1802*cdf0e10cSrcweir pImg = &pImp->GetExpandedNodeBmp( eBitmapMode ); 1803*cdf0e10cSrcweir else 1804*cdf0e10cSrcweir { 1805*cdf0e10cSrcweir if( (!pEntry->HasChilds()) && pEntry->HasChildsOnDemand() && 1806*cdf0e10cSrcweir (!(pEntry->GetFlags() & SV_ENTRYFLAG_HAD_CHILDREN)) && 1807*cdf0e10cSrcweir pImp->GetDontKnowNodeBmp().GetSizePixel().Width() ) 1808*cdf0e10cSrcweir pImg = &pImp->GetDontKnowNodeBmp( eBitmapMode ); 1809*cdf0e10cSrcweir else 1810*cdf0e10cSrcweir pImg = &pImp->GetCollapsedNodeBmp( eBitmapMode ); 1811*cdf0e10cSrcweir } 1812*cdf0e10cSrcweir aPos.Y() += (nTempEntryHeight - pImg->GetSizePixel().Height()) / 2; 1813*cdf0e10cSrcweir 1814*cdf0e10cSrcweir sal_uInt16 nStyle = 0; 1815*cdf0e10cSrcweir if ( !IsEnabled() ) 1816*cdf0e10cSrcweir nStyle |= IMAGE_DRAW_DISABLE; 1817*cdf0e10cSrcweir 1818*cdf0e10cSrcweir //native 1819*cdf0e10cSrcweir sal_Bool bNativeOK = sal_False; 1820*cdf0e10cSrcweir if ( IsNativeControlSupported( CTRL_LISTNODE, PART_ENTIRE_CONTROL) ) 1821*cdf0e10cSrcweir { 1822*cdf0e10cSrcweir ImplControlValue aControlValue; 1823*cdf0e10cSrcweir Rectangle aCtrlRegion( aPos, pImg->GetSizePixel() ); 1824*cdf0e10cSrcweir ControlState nState = 0; 1825*cdf0e10cSrcweir 1826*cdf0e10cSrcweir if ( IsEnabled() ) nState |= CTRL_STATE_ENABLED; 1827*cdf0e10cSrcweir 1828*cdf0e10cSrcweir if ( IsExpanded(pEntry) ) 1829*cdf0e10cSrcweir aControlValue.setTristateVal( BUTTONVALUE_ON );//expanded node 1830*cdf0e10cSrcweir else 1831*cdf0e10cSrcweir { 1832*cdf0e10cSrcweir if( (!pEntry->HasChilds()) && pEntry->HasChildsOnDemand() && 1833*cdf0e10cSrcweir (!(pEntry->GetFlags() & SV_ENTRYFLAG_HAD_CHILDREN)) && 1834*cdf0e10cSrcweir pImp->GetDontKnowNodeBmp().GetSizePixel().Width() ) 1835*cdf0e10cSrcweir aControlValue.setTristateVal( BUTTONVALUE_DONTKNOW );//dont know 1836*cdf0e10cSrcweir else 1837*cdf0e10cSrcweir aControlValue.setTristateVal( BUTTONVALUE_OFF );//collapsed node 1838*cdf0e10cSrcweir } 1839*cdf0e10cSrcweir 1840*cdf0e10cSrcweir bNativeOK = DrawNativeControl( CTRL_LISTNODE, PART_ENTIRE_CONTROL, 1841*cdf0e10cSrcweir aCtrlRegion, nState, aControlValue, rtl::OUString() ); 1842*cdf0e10cSrcweir } 1843*cdf0e10cSrcweir 1844*cdf0e10cSrcweir if( !bNativeOK) { 1845*cdf0e10cSrcweir //non native 1846*cdf0e10cSrcweir DrawImage( aPos, *pImg ,nStyle); 1847*cdf0e10cSrcweir } 1848*cdf0e10cSrcweir } 1849*cdf0e10cSrcweir } 1850*cdf0e10cSrcweir } 1851*cdf0e10cSrcweir 1852*cdf0e10cSrcweir 1853*cdf0e10cSrcweir if( bHasClipRegion && bResetClipRegion ) 1854*cdf0e10cSrcweir SetClipRegion(); 1855*cdf0e10cSrcweir return 0; // nRowLen; 1856*cdf0e10cSrcweir } 1857*cdf0e10cSrcweir 1858*cdf0e10cSrcweir void SvTreeListBox::PreparePaint( SvLBoxEntry* ) 1859*cdf0e10cSrcweir { 1860*cdf0e10cSrcweir } 1861*cdf0e10cSrcweir 1862*cdf0e10cSrcweir Rectangle SvTreeListBox::GetFocusRect( SvLBoxEntry* pEntry, long nLine ) 1863*cdf0e10cSrcweir { 1864*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1865*cdf0e10cSrcweir Size aSize; 1866*cdf0e10cSrcweir Rectangle aRect; 1867*cdf0e10cSrcweir aRect.Top() = nLine; 1868*cdf0e10cSrcweir aSize.Height() = GetEntryHeight(); 1869*cdf0e10cSrcweir 1870*cdf0e10cSrcweir long nRealWidth = pImp->GetOutputSize().Width(); 1871*cdf0e10cSrcweir nRealWidth -= GetMapMode().GetOrigin().X(); 1872*cdf0e10cSrcweir 1873*cdf0e10cSrcweir sal_uInt16 nCurTab; 1874*cdf0e10cSrcweir SvLBoxTab* pTab = GetFirstTab( SV_LBOXTAB_SHOW_SELECTION, nCurTab ); 1875*cdf0e10cSrcweir long nTabPos = 0; 1876*cdf0e10cSrcweir if( pTab ) 1877*cdf0e10cSrcweir nTabPos = GetTabPos( pEntry, pTab ); 1878*cdf0e10cSrcweir long nNextTabPos; 1879*cdf0e10cSrcweir if( pTab && nCurTab < aTabs.Count() - 1 ) 1880*cdf0e10cSrcweir { 1881*cdf0e10cSrcweir SvLBoxTab* pNextTab = (SvLBoxTab*)aTabs.GetObject( nCurTab + 1 ); 1882*cdf0e10cSrcweir nNextTabPos = GetTabPos( pEntry, pNextTab ); 1883*cdf0e10cSrcweir } 1884*cdf0e10cSrcweir else 1885*cdf0e10cSrcweir { 1886*cdf0e10cSrcweir nNextTabPos = nRealWidth; 1887*cdf0e10cSrcweir if( nTabPos > nRealWidth ) 1888*cdf0e10cSrcweir nNextTabPos += 50; 1889*cdf0e10cSrcweir } 1890*cdf0e10cSrcweir 1891*cdf0e10cSrcweir sal_Bool bUserSelection = (sal_Bool)( nTreeFlags & TREEFLAG_USESEL ) != 0; 1892*cdf0e10cSrcweir if( !bUserSelection ) 1893*cdf0e10cSrcweir { 1894*cdf0e10cSrcweir if( pTab && nCurTab < pEntry->ItemCount() ) 1895*cdf0e10cSrcweir { 1896*cdf0e10cSrcweir SvLBoxItem* pItem = pEntry->GetItem( nCurTab ); 1897*cdf0e10cSrcweir aSize.Width() = pItem->GetSize( this, pEntry ).Width(); 1898*cdf0e10cSrcweir if( !aSize.Width() ) 1899*cdf0e10cSrcweir aSize.Width() = 15; 1900*cdf0e10cSrcweir long nX = nTabPos; //GetTabPos( pEntry, pTab ); 1901*cdf0e10cSrcweir // Ausrichtung 1902*cdf0e10cSrcweir nX += pTab->CalcOffset( aSize.Width(), nNextTabPos - nTabPos ); 1903*cdf0e10cSrcweir aRect.Left() = nX; 1904*cdf0e10cSrcweir // damit erster & letzter Buchstabe nicht angeknabbert werden 1905*cdf0e10cSrcweir aRect.SetSize( aSize ); 1906*cdf0e10cSrcweir if( aRect.Left() > 0 ) 1907*cdf0e10cSrcweir aRect.Left()--; 1908*cdf0e10cSrcweir aRect.Right()++; 1909*cdf0e10cSrcweir } 1910*cdf0e10cSrcweir } 1911*cdf0e10cSrcweir else 1912*cdf0e10cSrcweir { 1913*cdf0e10cSrcweir // wenn erster SelTab != 0, dann muessen wir auch rechnen 1914*cdf0e10cSrcweir if( nFocusWidth == -1 || nFirstSelTab ) 1915*cdf0e10cSrcweir { 1916*cdf0e10cSrcweir sal_uInt16 nLastTab; 1917*cdf0e10cSrcweir SvLBoxTab* pLastTab = GetLastTab(SV_LBOXTAB_SHOW_SELECTION,nLastTab); 1918*cdf0e10cSrcweir nLastTab++; 1919*cdf0e10cSrcweir if( nLastTab < aTabs.Count() ) // gibts noch einen ? 1920*cdf0e10cSrcweir pLastTab = (SvLBoxTab*)aTabs.GetObject( nLastTab ); 1921*cdf0e10cSrcweir else 1922*cdf0e10cSrcweir pLastTab = 0; // ueber gesamte Breite selektieren 1923*cdf0e10cSrcweir aSize.Width() = pLastTab ? pLastTab->GetPos() : 0x0fffffff; 1924*cdf0e10cSrcweir nFocusWidth = (short)aSize.Width(); 1925*cdf0e10cSrcweir if( pTab ) 1926*cdf0e10cSrcweir nFocusWidth = nFocusWidth - (short)nTabPos; //pTab->GetPos(); 1927*cdf0e10cSrcweir } 1928*cdf0e10cSrcweir else 1929*cdf0e10cSrcweir { 1930*cdf0e10cSrcweir aSize.Width() = nFocusWidth; 1931*cdf0e10cSrcweir if( pTab ) 1932*cdf0e10cSrcweir { 1933*cdf0e10cSrcweir if( nCurTab ) 1934*cdf0e10cSrcweir aSize.Width() += nTabPos; 1935*cdf0e10cSrcweir else 1936*cdf0e10cSrcweir aSize.Width() += pTab->GetPos(); // Tab0 immer ab ganz links 1937*cdf0e10cSrcweir } 1938*cdf0e10cSrcweir } 1939*cdf0e10cSrcweir // wenn Sel. beim nullten Tab anfaengt, dann ab Spalte 0 sel. zeichnen 1940*cdf0e10cSrcweir if( nCurTab != 0 ) 1941*cdf0e10cSrcweir { 1942*cdf0e10cSrcweir aRect.Left() = nTabPos; 1943*cdf0e10cSrcweir aSize.Width() -= nTabPos; 1944*cdf0e10cSrcweir } 1945*cdf0e10cSrcweir aRect.SetSize( aSize ); 1946*cdf0e10cSrcweir } 1947*cdf0e10cSrcweir // rechten Rand anpassen wg. Clipping 1948*cdf0e10cSrcweir if( aRect.Right() >= nRealWidth ) 1949*cdf0e10cSrcweir { 1950*cdf0e10cSrcweir aRect.Right() = nRealWidth-1; 1951*cdf0e10cSrcweir nFocusWidth = (short)aRect.GetWidth(); 1952*cdf0e10cSrcweir } 1953*cdf0e10cSrcweir return aRect; 1954*cdf0e10cSrcweir } 1955*cdf0e10cSrcweir 1956*cdf0e10cSrcweir 1957*cdf0e10cSrcweir long SvTreeListBox::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab) 1958*cdf0e10cSrcweir { 1959*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1960*cdf0e10cSrcweir DBG_ASSERT(pTab,"No Tab"); 1961*cdf0e10cSrcweir long nPos = pTab->GetPos(); 1962*cdf0e10cSrcweir if( pTab->IsDynamic() ) 1963*cdf0e10cSrcweir { 1964*cdf0e10cSrcweir sal_uInt16 nDepth = pModel->GetDepth( pEntry ); 1965*cdf0e10cSrcweir nDepth = nDepth * (sal_uInt16)nIndent; 1966*cdf0e10cSrcweir nPos += (long)nDepth; 1967*cdf0e10cSrcweir } 1968*cdf0e10cSrcweir return nPos; 1969*cdf0e10cSrcweir } 1970*cdf0e10cSrcweir 1971*cdf0e10cSrcweir SvLBoxItem* SvTreeListBox::GetItem_Impl( SvLBoxEntry* pEntry, long nX, 1972*cdf0e10cSrcweir SvLBoxTab** ppTab, sal_uInt16 nEmptyWidth ) 1973*cdf0e10cSrcweir { 1974*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 1975*cdf0e10cSrcweir SvLBoxItem* pItemClicked = 0; 1976*cdf0e10cSrcweir sal_uInt16 nTabCount = aTabs.Count(); 1977*cdf0e10cSrcweir sal_uInt16 nItemCount = pEntry->ItemCount(); 1978*cdf0e10cSrcweir SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0); 1979*cdf0e10cSrcweir SvLBoxItem* pItem = pEntry->GetItem(0); 1980*cdf0e10cSrcweir sal_uInt16 nNextItem = 1; 1981*cdf0e10cSrcweir nX -= GetMapMode().GetOrigin().X(); 1982*cdf0e10cSrcweir long nRealWidth = pImp->GetOutputSize().Width(); 1983*cdf0e10cSrcweir nRealWidth -= GetMapMode().GetOrigin().X(); 1984*cdf0e10cSrcweir 1985*cdf0e10cSrcweir while( 1 ) 1986*cdf0e10cSrcweir { 1987*cdf0e10cSrcweir SvLBoxTab* pNextTab=nNextItem<nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextItem) : 0; 1988*cdf0e10cSrcweir long nStart = GetTabPos( pEntry, pTab ); 1989*cdf0e10cSrcweir 1990*cdf0e10cSrcweir long nNextTabPos; 1991*cdf0e10cSrcweir if( pNextTab ) 1992*cdf0e10cSrcweir nNextTabPos = GetTabPos( pEntry, pNextTab ); 1993*cdf0e10cSrcweir else 1994*cdf0e10cSrcweir { 1995*cdf0e10cSrcweir nNextTabPos = nRealWidth; 1996*cdf0e10cSrcweir if( nStart > nRealWidth ) 1997*cdf0e10cSrcweir nNextTabPos += 50; 1998*cdf0e10cSrcweir } 1999*cdf0e10cSrcweir 2000*cdf0e10cSrcweir Size aItemSize( pItem->GetSize(this, pEntry)); 2001*cdf0e10cSrcweir nStart += pTab->CalcOffset( aItemSize.Width(), nNextTabPos - nStart ); 2002*cdf0e10cSrcweir long nLen = aItemSize.Width(); 2003*cdf0e10cSrcweir if( pNextTab ) 2004*cdf0e10cSrcweir { 2005*cdf0e10cSrcweir long nTabWidth = GetTabPos( pEntry, pNextTab ) - nStart; 2006*cdf0e10cSrcweir if( nTabWidth < nLen ) 2007*cdf0e10cSrcweir nLen = nTabWidth; 2008*cdf0e10cSrcweir } 2009*cdf0e10cSrcweir 2010*cdf0e10cSrcweir if( !nLen ) 2011*cdf0e10cSrcweir nLen = nEmptyWidth; 2012*cdf0e10cSrcweir 2013*cdf0e10cSrcweir if( nX >= nStart && nX < (nStart+nLen ) ) 2014*cdf0e10cSrcweir { 2015*cdf0e10cSrcweir pItemClicked = pItem; 2016*cdf0e10cSrcweir if( ppTab ) 2017*cdf0e10cSrcweir { 2018*cdf0e10cSrcweir *ppTab = pTab; 2019*cdf0e10cSrcweir break; 2020*cdf0e10cSrcweir } 2021*cdf0e10cSrcweir } 2022*cdf0e10cSrcweir if( nNextItem >= nItemCount || nNextItem >= nTabCount) 2023*cdf0e10cSrcweir break; 2024*cdf0e10cSrcweir pTab = (SvLBoxTab*)aTabs.GetObject( nNextItem ); 2025*cdf0e10cSrcweir pItem = pEntry->GetItem( nNextItem ); 2026*cdf0e10cSrcweir nNextItem++; 2027*cdf0e10cSrcweir } 2028*cdf0e10cSrcweir return pItemClicked; 2029*cdf0e10cSrcweir } 2030*cdf0e10cSrcweir 2031*cdf0e10cSrcweir SvLBoxItem* SvTreeListBox::GetItem(SvLBoxEntry* pEntry,long nX,SvLBoxTab** ppTab) 2032*cdf0e10cSrcweir { 2033*cdf0e10cSrcweir return GetItem_Impl( pEntry, nX, ppTab, 0 ); 2034*cdf0e10cSrcweir } 2035*cdf0e10cSrcweir 2036*cdf0e10cSrcweir SvLBoxItem* SvTreeListBox::GetItem(SvLBoxEntry* pEntry,long nX ) 2037*cdf0e10cSrcweir { 2038*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2039*cdf0e10cSrcweir SvLBoxTab* pDummyTab; 2040*cdf0e10cSrcweir return GetItem_Impl( pEntry, nX, &pDummyTab, 0 ); 2041*cdf0e10cSrcweir } 2042*cdf0e10cSrcweir 2043*cdf0e10cSrcweir SvLBoxItem* SvTreeListBox::GetFirstDynamicItem( SvLBoxEntry* pEntry ) 2044*cdf0e10cSrcweir { 2045*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2046*cdf0e10cSrcweir 2047*cdf0e10cSrcweir SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0); 2048*cdf0e10cSrcweir SvLBoxItem* pItem = pEntry->GetItem(0); 2049*cdf0e10cSrcweir sal_uInt16 nTabCount = aTabs.Count(); 2050*cdf0e10cSrcweir 2051*cdf0e10cSrcweir sal_uInt16 nNext = 1; 2052*cdf0e10cSrcweir while ( !pTab->IsDynamic() && nNext < nTabCount ) 2053*cdf0e10cSrcweir { 2054*cdf0e10cSrcweir pItem = pEntry->GetItem( nNext ); 2055*cdf0e10cSrcweir pTab = (SvLBoxTab*)aTabs.GetObject( nNext ); 2056*cdf0e10cSrcweir nNext++; 2057*cdf0e10cSrcweir } 2058*cdf0e10cSrcweir return pItem; 2059*cdf0e10cSrcweir } 2060*cdf0e10cSrcweir 2061*cdf0e10cSrcweir void SvTreeListBox::AddTab(long nTabPos,sal_uInt16 nFlags,void* pUserData ) 2062*cdf0e10cSrcweir { 2063*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2064*cdf0e10cSrcweir nFocusWidth = -1; 2065*cdf0e10cSrcweir SvLBoxTab* pTab = new SvLBoxTab( nTabPos, nFlags ); 2066*cdf0e10cSrcweir pTab->SetUserData( pUserData ); 2067*cdf0e10cSrcweir aTabs.Insert( pTab, aTabs.Count() ); 2068*cdf0e10cSrcweir if( nTreeFlags & TREEFLAG_USESEL ) 2069*cdf0e10cSrcweir { 2070*cdf0e10cSrcweir sal_uInt16 nPos = aTabs.Count() - 1; 2071*cdf0e10cSrcweir if( nPos >= nFirstSelTab && nPos <= nLastSelTab ) 2072*cdf0e10cSrcweir pTab->nFlags |= SV_LBOXTAB_SHOW_SELECTION; 2073*cdf0e10cSrcweir else 2074*cdf0e10cSrcweir // String-Items werden normalerweise immer selektiert 2075*cdf0e10cSrcweir // deshalb explizit ausschalten 2076*cdf0e10cSrcweir pTab->nFlags &= ~SV_LBOXTAB_SHOW_SELECTION; 2077*cdf0e10cSrcweir } 2078*cdf0e10cSrcweir } 2079*cdf0e10cSrcweir 2080*cdf0e10cSrcweir 2081*cdf0e10cSrcweir 2082*cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetFirstDynamicTab( sal_uInt16& rPos ) const 2083*cdf0e10cSrcweir { 2084*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2085*cdf0e10cSrcweir sal_uInt16 nCurTab = 0; 2086*cdf0e10cSrcweir sal_uInt16 nTabCount = aTabs.Count(); 2087*cdf0e10cSrcweir while( nCurTab < nTabCount ) 2088*cdf0e10cSrcweir { 2089*cdf0e10cSrcweir SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(nCurTab); 2090*cdf0e10cSrcweir if( pTab->nFlags & SV_LBOXTAB_DYNAMIC ) 2091*cdf0e10cSrcweir { 2092*cdf0e10cSrcweir rPos = nCurTab; 2093*cdf0e10cSrcweir return pTab; 2094*cdf0e10cSrcweir } 2095*cdf0e10cSrcweir nCurTab++; 2096*cdf0e10cSrcweir } 2097*cdf0e10cSrcweir return 0; 2098*cdf0e10cSrcweir } 2099*cdf0e10cSrcweir 2100*cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetFirstDynamicTab() const 2101*cdf0e10cSrcweir { 2102*cdf0e10cSrcweir sal_uInt16 nDummy; 2103*cdf0e10cSrcweir return GetFirstDynamicTab( nDummy ); 2104*cdf0e10cSrcweir } 2105*cdf0e10cSrcweir 2106*cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetTab( SvLBoxEntry* pEntry, SvLBoxItem* pItem) const 2107*cdf0e10cSrcweir { 2108*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2109*cdf0e10cSrcweir sal_uInt16 nPos = pEntry->GetPos( pItem ); 2110*cdf0e10cSrcweir return (SvLBoxTab*)aTabs.GetObject( nPos ); 2111*cdf0e10cSrcweir } 2112*cdf0e10cSrcweir 2113*cdf0e10cSrcweir void SvTreeListBox::ClearTabList() 2114*cdf0e10cSrcweir { 2115*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2116*cdf0e10cSrcweir sal_uInt16 nTabCount = aTabs.Count(); 2117*cdf0e10cSrcweir while( nTabCount ) 2118*cdf0e10cSrcweir { 2119*cdf0e10cSrcweir nTabCount--; 2120*cdf0e10cSrcweir SvLBoxTab* pDelTab = (SvLBoxTab*)aTabs.GetObject( nTabCount ); 2121*cdf0e10cSrcweir delete pDelTab; 2122*cdf0e10cSrcweir } 2123*cdf0e10cSrcweir aTabs.Remove(0,aTabs.Count()); 2124*cdf0e10cSrcweir } 2125*cdf0e10cSrcweir 2126*cdf0e10cSrcweir 2127*cdf0e10cSrcweir Size SvTreeListBox::GetOutputSizePixel() const 2128*cdf0e10cSrcweir { 2129*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2130*cdf0e10cSrcweir Size aSize = pImp->GetOutputSize(); 2131*cdf0e10cSrcweir return aSize; 2132*cdf0e10cSrcweir } 2133*cdf0e10cSrcweir 2134*cdf0e10cSrcweir void SvTreeListBox::NotifyBeginScroll() 2135*cdf0e10cSrcweir { 2136*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2137*cdf0e10cSrcweir } 2138*cdf0e10cSrcweir 2139*cdf0e10cSrcweir void SvTreeListBox::NotifyEndScroll() 2140*cdf0e10cSrcweir { 2141*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2142*cdf0e10cSrcweir } 2143*cdf0e10cSrcweir 2144*cdf0e10cSrcweir void SvTreeListBox::NotifyScrolling( long ) 2145*cdf0e10cSrcweir { 2146*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2147*cdf0e10cSrcweir } 2148*cdf0e10cSrcweir 2149*cdf0e10cSrcweir void SvTreeListBox::NotifyScrolled() 2150*cdf0e10cSrcweir { 2151*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2152*cdf0e10cSrcweir aScrolledHdl.Call( this ); 2153*cdf0e10cSrcweir } 2154*cdf0e10cSrcweir 2155*cdf0e10cSrcweir void SvTreeListBox::NotifyInvalidating() 2156*cdf0e10cSrcweir { 2157*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2158*cdf0e10cSrcweir } 2159*cdf0e10cSrcweir 2160*cdf0e10cSrcweir void SvTreeListBox::Invalidate( sal_uInt16 nInvalidateFlags ) 2161*cdf0e10cSrcweir { 2162*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2163*cdf0e10cSrcweir if( nFocusWidth == -1 ) 2164*cdf0e10cSrcweir // damit Control nicht nach dem Paint ein falsches FocusRect anzeigt 2165*cdf0e10cSrcweir pImp->RecalcFocusRect(); 2166*cdf0e10cSrcweir NotifyInvalidating(); 2167*cdf0e10cSrcweir SvLBox::Invalidate( nInvalidateFlags ); 2168*cdf0e10cSrcweir pImp->Invalidate(); 2169*cdf0e10cSrcweir } 2170*cdf0e10cSrcweir 2171*cdf0e10cSrcweir void SvTreeListBox::Invalidate( const Rectangle& rRect, sal_uInt16 nInvalidateFlags ) 2172*cdf0e10cSrcweir { 2173*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2174*cdf0e10cSrcweir if( nFocusWidth == -1 ) 2175*cdf0e10cSrcweir // damit Control nicht nach dem Paint ein falsches FocusRect anzeigt 2176*cdf0e10cSrcweir pImp->RecalcFocusRect(); 2177*cdf0e10cSrcweir NotifyInvalidating(); 2178*cdf0e10cSrcweir SvLBox::Invalidate( rRect, nInvalidateFlags ); 2179*cdf0e10cSrcweir } 2180*cdf0e10cSrcweir 2181*cdf0e10cSrcweir 2182*cdf0e10cSrcweir void SvTreeListBox::SetHighlightRange( sal_uInt16 nStart, sal_uInt16 nEnd) 2183*cdf0e10cSrcweir { 2184*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2185*cdf0e10cSrcweir 2186*cdf0e10cSrcweir sal_uInt16 nTemp; 2187*cdf0e10cSrcweir nTreeFlags |= TREEFLAG_USESEL; 2188*cdf0e10cSrcweir if( nStart > nEnd ) 2189*cdf0e10cSrcweir { 2190*cdf0e10cSrcweir nTemp = nStart; 2191*cdf0e10cSrcweir nStart = nEnd; 2192*cdf0e10cSrcweir nEnd = nTemp; 2193*cdf0e10cSrcweir } 2194*cdf0e10cSrcweir // alle Tabs markieren, die im Bereich liegen 2195*cdf0e10cSrcweir nTreeFlags |= TREEFLAG_RECALCTABS; 2196*cdf0e10cSrcweir nFirstSelTab = nStart; 2197*cdf0e10cSrcweir nLastSelTab = nEnd; 2198*cdf0e10cSrcweir pImp->RecalcFocusRect(); 2199*cdf0e10cSrcweir } 2200*cdf0e10cSrcweir 2201*cdf0e10cSrcweir void SvTreeListBox::RemoveHighlightRange() 2202*cdf0e10cSrcweir { 2203*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2204*cdf0e10cSrcweir nTreeFlags &= (~TREEFLAG_USESEL); 2205*cdf0e10cSrcweir if( IsUpdateMode() ) 2206*cdf0e10cSrcweir Invalidate(); 2207*cdf0e10cSrcweir } 2208*cdf0e10cSrcweir 2209*cdf0e10cSrcweir sal_uLong SvTreeListBox::GetAscInsertionPos(SvLBoxEntry*,SvLBoxEntry*) 2210*cdf0e10cSrcweir { 2211*cdf0e10cSrcweir return LIST_APPEND; 2212*cdf0e10cSrcweir } 2213*cdf0e10cSrcweir 2214*cdf0e10cSrcweir sal_uLong SvTreeListBox::GetDescInsertionPos(SvLBoxEntry*,SvLBoxEntry*) 2215*cdf0e10cSrcweir { 2216*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2217*cdf0e10cSrcweir return LIST_APPEND; 2218*cdf0e10cSrcweir } 2219*cdf0e10cSrcweir 2220*cdf0e10cSrcweir Region SvTreeListBox::GetDragRegion() const 2221*cdf0e10cSrcweir { 2222*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2223*cdf0e10cSrcweir Rectangle aRect; 2224*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetCurEntry(); 2225*cdf0e10cSrcweir if( pEntry ) 2226*cdf0e10cSrcweir { 2227*cdf0e10cSrcweir Point aPos = GetEntryPosition( pEntry ); 2228*cdf0e10cSrcweir aRect = ((SvTreeListBox*)this)->GetFocusRect( pEntry, aPos.Y() ); 2229*cdf0e10cSrcweir } 2230*cdf0e10cSrcweir Region aRegion( aRect ); 2231*cdf0e10cSrcweir return aRegion; 2232*cdf0e10cSrcweir } 2233*cdf0e10cSrcweir 2234*cdf0e10cSrcweir 2235*cdf0e10cSrcweir void SvTreeListBox::Command( const CommandEvent& rCEvt ) 2236*cdf0e10cSrcweir { 2237*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2238*cdf0e10cSrcweir // FIXME gnumake2 resync to DEV300_m84 2239*cdf0e10cSrcweir pImp->Command( rCEvt ); 2240*cdf0e10cSrcweir } 2241*cdf0e10cSrcweir 2242*cdf0e10cSrcweir 2243*cdf0e10cSrcweir void SvTreeListBox::RemoveParentKeepChilds( SvLBoxEntry* pParent ) 2244*cdf0e10cSrcweir { 2245*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2246*cdf0e10cSrcweir DBG_ASSERT(pParent,"RemoveParentKeepChilds:No Parent"); 2247*cdf0e10cSrcweir SvLBoxEntry* pNewParent = GetParent( pParent ); 2248*cdf0e10cSrcweir if( pParent->HasChilds()) 2249*cdf0e10cSrcweir { 2250*cdf0e10cSrcweir SvLBoxEntry* pChild = FirstChild( pParent ); 2251*cdf0e10cSrcweir while( pChild ) 2252*cdf0e10cSrcweir { 2253*cdf0e10cSrcweir pModel->Move( pChild, pNewParent, LIST_APPEND ); 2254*cdf0e10cSrcweir pChild = FirstChild( pParent ); 2255*cdf0e10cSrcweir } 2256*cdf0e10cSrcweir } 2257*cdf0e10cSrcweir pModel->Remove( pParent ); 2258*cdf0e10cSrcweir } 2259*cdf0e10cSrcweir 2260*cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rPos ) 2261*cdf0e10cSrcweir { 2262*cdf0e10cSrcweir sal_uInt16 nTabCount = aTabs.Count(); 2263*cdf0e10cSrcweir for( sal_uInt16 nPos = 0; nPos < nTabCount; nPos++ ) 2264*cdf0e10cSrcweir { 2265*cdf0e10cSrcweir SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( nPos ); 2266*cdf0e10cSrcweir if( (pTab->nFlags & nFlagMask) ) 2267*cdf0e10cSrcweir { 2268*cdf0e10cSrcweir rPos = nPos; 2269*cdf0e10cSrcweir return pTab; 2270*cdf0e10cSrcweir } 2271*cdf0e10cSrcweir } 2272*cdf0e10cSrcweir rPos = 0xffff; 2273*cdf0e10cSrcweir return 0; 2274*cdf0e10cSrcweir } 2275*cdf0e10cSrcweir 2276*cdf0e10cSrcweir SvLBoxTab* SvTreeListBox::GetLastTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos ) 2277*cdf0e10cSrcweir { 2278*cdf0e10cSrcweir short nTabCount = (short)aTabs.Count(); 2279*cdf0e10cSrcweir if( nTabCount ) 2280*cdf0e10cSrcweir { 2281*cdf0e10cSrcweir for( short nPos = nTabCount-1; nPos >= 0; nPos-- ) 2282*cdf0e10cSrcweir { 2283*cdf0e10cSrcweir SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( (sal_uInt16)nPos ); 2284*cdf0e10cSrcweir if( (pTab->nFlags & nFlagMask) ) 2285*cdf0e10cSrcweir { 2286*cdf0e10cSrcweir rTabPos = (sal_uInt16)nPos; 2287*cdf0e10cSrcweir return pTab; 2288*cdf0e10cSrcweir } 2289*cdf0e10cSrcweir } 2290*cdf0e10cSrcweir } 2291*cdf0e10cSrcweir rTabPos = 0xffff; 2292*cdf0e10cSrcweir return 0; 2293*cdf0e10cSrcweir } 2294*cdf0e10cSrcweir 2295*cdf0e10cSrcweir void SvTreeListBox::SetAddMode( sal_Bool bAdd ) 2296*cdf0e10cSrcweir { 2297*cdf0e10cSrcweir pImp->SetAddMode( bAdd ); 2298*cdf0e10cSrcweir } 2299*cdf0e10cSrcweir 2300*cdf0e10cSrcweir sal_Bool SvTreeListBox::IsAddMode() const 2301*cdf0e10cSrcweir { 2302*cdf0e10cSrcweir return pImp->IsAddMode(); 2303*cdf0e10cSrcweir } 2304*cdf0e10cSrcweir 2305*cdf0e10cSrcweir void SvTreeListBox::RequestHelp( const HelpEvent& rHEvt ) 2306*cdf0e10cSrcweir { 2307*cdf0e10cSrcweir if( !pImp->RequestHelp( rHEvt ) ) 2308*cdf0e10cSrcweir SvLBox::RequestHelp( rHEvt ); 2309*cdf0e10cSrcweir } 2310*cdf0e10cSrcweir 2311*cdf0e10cSrcweir void SvTreeListBox::CursorMoved( SvLBoxEntry* ) 2312*cdf0e10cSrcweir { 2313*cdf0e10cSrcweir } 2314*cdf0e10cSrcweir 2315*cdf0e10cSrcweir IMPL_LINK( SvTreeListBox, DefaultCompare, SvSortData*, pData ) 2316*cdf0e10cSrcweir { 2317*cdf0e10cSrcweir SvLBoxEntry* pLeft = (SvLBoxEntry*)(pData->pLeft ); 2318*cdf0e10cSrcweir SvLBoxEntry* pRight = (SvLBoxEntry*)(pData->pRight ); 2319*cdf0e10cSrcweir String aLeft( ((SvLBoxString*)(pLeft->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText()); 2320*cdf0e10cSrcweir String aRight( ((SvLBoxString*)(pRight->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText()); 2321*cdf0e10cSrcweir // #102891# ---------------- 2322*cdf0e10cSrcweir pImp->UpdateIntlWrapper(); 2323*cdf0e10cSrcweir return pImp->pIntlWrapper->getCaseCollator()->compareString( aLeft, aRight ); 2324*cdf0e10cSrcweir } 2325*cdf0e10cSrcweir 2326*cdf0e10cSrcweir void SvTreeListBox::ModelNotification( sal_uInt16 nActionId, SvListEntry* pEntry1, 2327*cdf0e10cSrcweir SvListEntry* pEntry2, sal_uLong nPos ) 2328*cdf0e10cSrcweir { 2329*cdf0e10cSrcweir if( nActionId == LISTACTION_CLEARING ) 2330*cdf0e10cSrcweir CancelTextEditing(); 2331*cdf0e10cSrcweir 2332*cdf0e10cSrcweir SvLBox::ModelNotification( nActionId, pEntry1, pEntry2, nPos ); 2333*cdf0e10cSrcweir switch( nActionId ) 2334*cdf0e10cSrcweir { 2335*cdf0e10cSrcweir case LISTACTION_INSERTED: 2336*cdf0e10cSrcweir { 2337*cdf0e10cSrcweir SvLBoxEntry* pEntry( dynamic_cast< SvLBoxEntry* >( pEntry1 ) ); 2338*cdf0e10cSrcweir ENSURE_OR_BREAK( pEntry, "SvTreeListBox::ModelNotification: invalid entry!" ); 2339*cdf0e10cSrcweir SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) ); 2340*cdf0e10cSrcweir if ( !pBmpItem ) 2341*cdf0e10cSrcweir break; 2342*cdf0e10cSrcweir const Image& rBitmap1( pBmpItem->GetBitmap1() ); 2343*cdf0e10cSrcweir const Image& rBitmap2( pBmpItem->GetBitmap2() ); 2344*cdf0e10cSrcweir short nMaxWidth = short( Max( rBitmap1.GetSizePixel().Width(), rBitmap2.GetSizePixel().Width() ) ); 2345*cdf0e10cSrcweir nMaxWidth = pImp->UpdateContextBmpWidthVector( pEntry, nMaxWidth ); 2346*cdf0e10cSrcweir if( nMaxWidth > nContextBmpWidthMax ) 2347*cdf0e10cSrcweir { 2348*cdf0e10cSrcweir nContextBmpWidthMax = nMaxWidth; 2349*cdf0e10cSrcweir SetTabs(); 2350*cdf0e10cSrcweir } 2351*cdf0e10cSrcweir } 2352*cdf0e10cSrcweir break; 2353*cdf0e10cSrcweir 2354*cdf0e10cSrcweir case LISTACTION_RESORTING: 2355*cdf0e10cSrcweir SetUpdateMode( sal_False ); 2356*cdf0e10cSrcweir break; 2357*cdf0e10cSrcweir 2358*cdf0e10cSrcweir case LISTACTION_RESORTED: 2359*cdf0e10cSrcweir // nach Sortierung den ersten Eintrag anzeigen, dabei die 2360*cdf0e10cSrcweir // Selektion erhalten. 2361*cdf0e10cSrcweir MakeVisible( (SvLBoxEntry*)pModel->First(), sal_True ); 2362*cdf0e10cSrcweir SetUpdateMode( sal_True ); 2363*cdf0e10cSrcweir break; 2364*cdf0e10cSrcweir 2365*cdf0e10cSrcweir case LISTACTION_CLEARED: 2366*cdf0e10cSrcweir if( IsUpdateMode() ) 2367*cdf0e10cSrcweir Update(); 2368*cdf0e10cSrcweir break; 2369*cdf0e10cSrcweir } 2370*cdf0e10cSrcweir } 2371*cdf0e10cSrcweir 2372*cdf0e10cSrcweir // bei Aenderungen SetTabs beruecksichtigen 2373*cdf0e10cSrcweir long SvTreeListBox::GetTextOffset() const 2374*cdf0e10cSrcweir { 2375*cdf0e10cSrcweir DBG_CHKTHIS(SvTreeListBox,0); 2376*cdf0e10cSrcweir const WinBits nWindowStyle = GetStyle(); 2377*cdf0e10cSrcweir sal_Bool bHasButtons = (nWindowStyle & WB_HASBUTTONS)!=0; 2378*cdf0e10cSrcweir sal_Bool bHasButtonsAtRoot = (nWindowStyle & (WB_HASLINESATROOT | 2379*cdf0e10cSrcweir WB_HASBUTTONSATROOT))!=0; 2380*cdf0e10cSrcweir long nStartPos = TAB_STARTPOS; 2381*cdf0e10cSrcweir long nNodeWidthPixel = GetExpandedNodeBmp().GetSizePixel().Width(); 2382*cdf0e10cSrcweir 2383*cdf0e10cSrcweir long nCheckWidth = 0; 2384*cdf0e10cSrcweir if( nTreeFlags & TREEFLAG_CHKBTN ) 2385*cdf0e10cSrcweir nCheckWidth = pCheckButtonData->aBmps[0].GetSizePixel().Width(); 2386*cdf0e10cSrcweir long nCheckWidthDIV2 = nCheckWidth / 2; 2387*cdf0e10cSrcweir 2388*cdf0e10cSrcweir long nContextWidth = nContextBmpWidthMax; 2389*cdf0e10cSrcweir long nContextWidthDIV2 = nContextWidth / 2; 2390*cdf0e10cSrcweir 2391*cdf0e10cSrcweir int nCase = NO_BUTTONS; 2392*cdf0e10cSrcweir if( !(nTreeFlags & TREEFLAG_CHKBTN) ) 2393*cdf0e10cSrcweir { 2394*cdf0e10cSrcweir if( bHasButtons ) 2395*cdf0e10cSrcweir nCase = NODE_BUTTONS; 2396*cdf0e10cSrcweir } 2397*cdf0e10cSrcweir else 2398*cdf0e10cSrcweir { 2399*cdf0e10cSrcweir if( bHasButtons ) 2400*cdf0e10cSrcweir nCase = NODE_AND_CHECK_BUTTONS; 2401*cdf0e10cSrcweir else 2402*cdf0e10cSrcweir nCase = CHECK_BUTTONS; 2403*cdf0e10cSrcweir } 2404*cdf0e10cSrcweir 2405*cdf0e10cSrcweir switch( nCase ) 2406*cdf0e10cSrcweir { 2407*cdf0e10cSrcweir case NO_BUTTONS : 2408*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // wg. Zentrierung 2409*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp 2410*cdf0e10cSrcweir if( nContextBmpWidthMax ) 2411*cdf0e10cSrcweir nStartPos += 5; // Abstand Context-Bmp - Text 2412*cdf0e10cSrcweir break; 2413*cdf0e10cSrcweir 2414*cdf0e10cSrcweir case NODE_BUTTONS : 2415*cdf0e10cSrcweir if( bHasButtonsAtRoot ) 2416*cdf0e10cSrcweir nStartPos += ( nIndent + (nNodeWidthPixel/2) ); 2417*cdf0e10cSrcweir else 2418*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; 2419*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp 2420*cdf0e10cSrcweir if( nContextBmpWidthMax ) 2421*cdf0e10cSrcweir nStartPos += 5; // Abstand Context-Bmp - Text 2422*cdf0e10cSrcweir break; 2423*cdf0e10cSrcweir 2424*cdf0e10cSrcweir case NODE_AND_CHECK_BUTTONS : 2425*cdf0e10cSrcweir if( bHasButtonsAtRoot ) 2426*cdf0e10cSrcweir nStartPos += ( nIndent + nNodeWidthPixel ); 2427*cdf0e10cSrcweir else 2428*cdf0e10cSrcweir nStartPos += nCheckWidthDIV2; 2429*cdf0e10cSrcweir nStartPos += nCheckWidthDIV2; // rechter Rand des CheckButtons 2430*cdf0e10cSrcweir nStartPos += 3; // Abstand CheckButton Context-Bmp 2431*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // Mitte der Context-Bmp 2432*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp 2433*cdf0e10cSrcweir // Abstand setzen nur wenn Bitmaps da 2434*cdf0e10cSrcweir if( nContextBmpWidthMax ) 2435*cdf0e10cSrcweir nStartPos += 5; // Abstand Context-Bmp - Text 2436*cdf0e10cSrcweir break; 2437*cdf0e10cSrcweir 2438*cdf0e10cSrcweir case CHECK_BUTTONS : 2439*cdf0e10cSrcweir nStartPos += nCheckWidthDIV2; 2440*cdf0e10cSrcweir nStartPos += nCheckWidthDIV2; // rechter Rand CheckButton 2441*cdf0e10cSrcweir nStartPos += 3; // Abstand CheckButton Context-Bmp 2442*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // Mitte der Context-Bmp 2443*cdf0e10cSrcweir nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp 2444*cdf0e10cSrcweir if( nContextBmpWidthMax ) 2445*cdf0e10cSrcweir nStartPos += 5; // Abstand Context-Bmp - Text 2446*cdf0e10cSrcweir break; 2447*cdf0e10cSrcweir } 2448*cdf0e10cSrcweir return nStartPos; 2449*cdf0e10cSrcweir } 2450*cdf0e10cSrcweir 2451*cdf0e10cSrcweir void SvTreeListBox::EndSelection() 2452*cdf0e10cSrcweir { 2453*cdf0e10cSrcweir pImp->EndSelection(); 2454*cdf0e10cSrcweir } 2455*cdf0e10cSrcweir 2456*cdf0e10cSrcweir sal_Bool SvTreeListBox::IsNodeButton( const Point& rPos ) const 2457*cdf0e10cSrcweir { 2458*cdf0e10cSrcweir SvLBoxEntry* pEntry = GetEntry( rPos ); 2459*cdf0e10cSrcweir if( pEntry ) 2460*cdf0e10cSrcweir return pImp->IsNodeButton( rPos, pEntry ); 2461*cdf0e10cSrcweir return sal_False; 2462*cdf0e10cSrcweir } 2463*cdf0e10cSrcweir 2464*cdf0e10cSrcweir void SvTreeListBox::RepaintScrollBars() const 2465*cdf0e10cSrcweir { 2466*cdf0e10cSrcweir ((SvTreeListBox*)this)->pImp->RepaintScrollBars(); 2467*cdf0e10cSrcweir } 2468*cdf0e10cSrcweir 2469*cdf0e10cSrcweir ScrollBar *SvTreeListBox::GetVScroll() 2470*cdf0e10cSrcweir { 2471*cdf0e10cSrcweir return &((SvTreeListBox*)this)->pImp->aVerSBar; 2472*cdf0e10cSrcweir } 2473*cdf0e10cSrcweir 2474*cdf0e10cSrcweir ScrollBar *SvTreeListBox::GetHScroll() 2475*cdf0e10cSrcweir { 2476*cdf0e10cSrcweir return &((SvTreeListBox*)this)->pImp->aHorSBar; 2477*cdf0e10cSrcweir } 2478*cdf0e10cSrcweir 2479*cdf0e10cSrcweir void SvTreeListBox::EnableAsyncDrag( sal_Bool b ) 2480*cdf0e10cSrcweir { 2481*cdf0e10cSrcweir pImp->EnableAsyncDrag( b ); 2482*cdf0e10cSrcweir } 2483*cdf0e10cSrcweir 2484*cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetFirstEntryInView() const 2485*cdf0e10cSrcweir { 2486*cdf0e10cSrcweir Point aPos; 2487*cdf0e10cSrcweir return GetEntry( aPos ); 2488*cdf0e10cSrcweir } 2489*cdf0e10cSrcweir 2490*cdf0e10cSrcweir SvLBoxEntry* SvTreeListBox::GetNextEntryInView(SvLBoxEntry* pEntry ) const 2491*cdf0e10cSrcweir { 2492*cdf0e10cSrcweir SvLBoxEntry* pNext = (SvLBoxEntry*)NextVisible( pEntry ); 2493*cdf0e10cSrcweir if( pNext ) 2494*cdf0e10cSrcweir { 2495*cdf0e10cSrcweir Point aPos( GetEntryPosition(pNext) ); 2496*cdf0e10cSrcweir const Size& rSize = pImp->GetOutputSize(); 2497*cdf0e10cSrcweir if( aPos.Y() < 0 || aPos.Y() >= rSize.Height() ) 2498*cdf0e10cSrcweir return 0; 2499*cdf0e10cSrcweir } 2500*cdf0e10cSrcweir return pNext; 2501*cdf0e10cSrcweir } 2502*cdf0e10cSrcweir 2503*cdf0e10cSrcweir void SvTreeListBox::ShowFocusRect( const SvLBoxEntry* pEntry ) 2504*cdf0e10cSrcweir { 2505*cdf0e10cSrcweir pImp->ShowFocusRect( pEntry ); 2506*cdf0e10cSrcweir } 2507*cdf0e10cSrcweir 2508*cdf0e10cSrcweir void SvTreeListBox::SetTabBar( TabBar* pTabBar ) 2509*cdf0e10cSrcweir { 2510*cdf0e10cSrcweir pImp->SetTabBar( pTabBar ); 2511*cdf0e10cSrcweir } 2512*cdf0e10cSrcweir 2513*cdf0e10cSrcweir void SvTreeListBox::DataChanged( const DataChangedEvent& rDCEvt ) 2514*cdf0e10cSrcweir { 2515*cdf0e10cSrcweir if( (rDCEvt.GetType()==DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 2516*cdf0e10cSrcweir { 2517*cdf0e10cSrcweir nEntryHeight = 0; // _together_ with sal_True of 1. par (bFont) of InitSettings() a zero-height 2518*cdf0e10cSrcweir // forces complete recalc of heights! 2519*cdf0e10cSrcweir InitSettings( sal_True, sal_True, sal_True ); 2520*cdf0e10cSrcweir Invalidate(); 2521*cdf0e10cSrcweir } 2522*cdf0e10cSrcweir else 2523*cdf0e10cSrcweir Control::DataChanged( rDCEvt ); 2524*cdf0e10cSrcweir } 2525*cdf0e10cSrcweir 2526*cdf0e10cSrcweir void SvTreeListBox::StateChanged( StateChangedType i_nStateChange ) 2527*cdf0e10cSrcweir { 2528*cdf0e10cSrcweir SvLBox::StateChanged( i_nStateChange ); 2529*cdf0e10cSrcweir if ( i_nStateChange == STATE_CHANGE_STYLE ) 2530*cdf0e10cSrcweir ImplInitStyle(); 2531*cdf0e10cSrcweir } 2532*cdf0e10cSrcweir 2533*cdf0e10cSrcweir void SvTreeListBox::InitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground) 2534*cdf0e10cSrcweir { 2535*cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 2536*cdf0e10cSrcweir if( bFont ) 2537*cdf0e10cSrcweir { 2538*cdf0e10cSrcweir Font aFont; 2539*cdf0e10cSrcweir aFont = rStyleSettings.GetFieldFont(); 2540*cdf0e10cSrcweir aFont.SetColor( rStyleSettings.GetWindowTextColor() ); 2541*cdf0e10cSrcweir SetPointFont( aFont ); 2542*cdf0e10cSrcweir AdjustEntryHeight( aFont ); 2543*cdf0e10cSrcweir RecalcViewData(); 2544*cdf0e10cSrcweir } 2545*cdf0e10cSrcweir 2546*cdf0e10cSrcweir if( bForeground || bFont ) 2547*cdf0e10cSrcweir { 2548*cdf0e10cSrcweir SetTextColor( rStyleSettings.GetFieldTextColor() ); 2549*cdf0e10cSrcweir SetTextFillColor(); 2550*cdf0e10cSrcweir } 2551*cdf0e10cSrcweir 2552*cdf0e10cSrcweir if( bBackground ) 2553*cdf0e10cSrcweir SetBackground( rStyleSettings.GetFieldColor() ); 2554*cdf0e10cSrcweir 2555*cdf0e10cSrcweir // always try to re-create default-SvLBoxButtonData 2556*cdf0e10cSrcweir if( pCheckButtonData && pCheckButtonData->HasDefaultImages() ) 2557*cdf0e10cSrcweir pCheckButtonData->SetDefaultImages( this ); 2558*cdf0e10cSrcweir } 2559*cdf0e10cSrcweir 2560*cdf0e10cSrcweir sal_Bool SvTreeListBox::IsCellFocusEnabled() const 2561*cdf0e10cSrcweir { 2562*cdf0e10cSrcweir return pImp->IsCellFocusEnabled(); 2563*cdf0e10cSrcweir } 2564*cdf0e10cSrcweir 2565*cdf0e10cSrcweir bool SvTreeListBox::SetCurrentTabPos( sal_uInt16 _nNewPos ) 2566*cdf0e10cSrcweir { 2567*cdf0e10cSrcweir return pImp->SetCurrentTabPos( _nNewPos ); 2568*cdf0e10cSrcweir } 2569*cdf0e10cSrcweir 2570*cdf0e10cSrcweir sal_uInt16 SvTreeListBox::GetCurrentTabPos() const 2571*cdf0e10cSrcweir { 2572*cdf0e10cSrcweir return pImp->GetCurrentTabPos(); 2573*cdf0e10cSrcweir } 2574*cdf0e10cSrcweir 2575*cdf0e10cSrcweir void SvTreeListBox::InitStartEntry() 2576*cdf0e10cSrcweir { 2577*cdf0e10cSrcweir if( !pImp->pStartEntry ) 2578*cdf0e10cSrcweir pImp->pStartEntry = GetModel()->First(); 2579*cdf0e10cSrcweir } 2580*cdf0e10cSrcweir 2581*cdf0e10cSrcweir void SvTreeListBox::CancelPendingEdit() 2582*cdf0e10cSrcweir { 2583*cdf0e10cSrcweir if( pImp ) 2584*cdf0e10cSrcweir pImp->CancelPendingEdit(); 2585*cdf0e10cSrcweir } 2586*cdf0e10cSrcweir 2587*cdf0e10cSrcweir PopupMenu* SvTreeListBox::CreateContextMenu( void ) 2588*cdf0e10cSrcweir { 2589*cdf0e10cSrcweir return NULL; 2590*cdf0e10cSrcweir } 2591*cdf0e10cSrcweir 2592*cdf0e10cSrcweir void SvTreeListBox::ExcecuteContextMenuAction( sal_uInt16 ) 2593*cdf0e10cSrcweir { 2594*cdf0e10cSrcweir DBG_WARNING( "SvTreeListBox::ExcecuteContextMenuAction(): now there's happening nothing!" ); 2595*cdf0e10cSrcweir } 2596*cdf0e10cSrcweir 2597*cdf0e10cSrcweir void SvTreeListBox::EnableContextMenuHandling( void ) 2598*cdf0e10cSrcweir { 2599*cdf0e10cSrcweir DBG_ASSERT( pImp, "-SvTreeListBox::EnableContextMenuHandling(): No implementation!" ); 2600*cdf0e10cSrcweir 2601*cdf0e10cSrcweir pImp->bContextMenuHandling = sal_True; 2602*cdf0e10cSrcweir } 2603*cdf0e10cSrcweir 2604*cdf0e10cSrcweir void SvTreeListBox::EnableContextMenuHandling( sal_Bool b ) 2605*cdf0e10cSrcweir { 2606*cdf0e10cSrcweir DBG_ASSERT( pImp, "-SvTreeListBox::EnableContextMenuHandling(): No implementation!" ); 2607*cdf0e10cSrcweir 2608*cdf0e10cSrcweir pImp->bContextMenuHandling = b; 2609*cdf0e10cSrcweir } 2610*cdf0e10cSrcweir 2611*cdf0e10cSrcweir sal_Bool SvTreeListBox::IsContextMenuHandlingEnabled( void ) const 2612*cdf0e10cSrcweir { 2613*cdf0e10cSrcweir DBG_ASSERT( pImp, "-SvTreeListBox::IsContextMenuHandlingEnabled(): No implementation!" ); 2614*cdf0e10cSrcweir 2615*cdf0e10cSrcweir return pImp->bContextMenuHandling; 2616*cdf0e10cSrcweir } 2617*cdf0e10cSrcweir 2618*cdf0e10cSrcweir void SvTreeListBox::EnableList( bool _bEnable ) 2619*cdf0e10cSrcweir { 2620*cdf0e10cSrcweir // call base class method 2621*cdf0e10cSrcweir Window::Enable( _bEnable != false ); 2622*cdf0e10cSrcweir // then paint immediately 2623*cdf0e10cSrcweir Paint( Rectangle( Point(), GetSizePixel() ) ); 2624*cdf0e10cSrcweir } 2625*cdf0e10cSrcweir 2626*cdf0e10cSrcweir ::com::sun::star::uno::Reference< XAccessible > SvTreeListBox::CreateAccessible() 2627*cdf0e10cSrcweir { 2628*cdf0e10cSrcweir Window* pParent = GetAccessibleParentWindow(); 2629*cdf0e10cSrcweir DBG_ASSERT( pParent, "SvTreeListBox::CreateAccessible - accessible parent not found" ); 2630*cdf0e10cSrcweir 2631*cdf0e10cSrcweir ::com::sun::star::uno::Reference< XAccessible > xAccessible; 2632*cdf0e10cSrcweir if ( pParent ) 2633*cdf0e10cSrcweir { 2634*cdf0e10cSrcweir ::com::sun::star::uno::Reference< XAccessible > xAccParent = pParent->GetAccessible(); 2635*cdf0e10cSrcweir if ( xAccParent.is() ) 2636*cdf0e10cSrcweir { 2637*cdf0e10cSrcweir // need to be done here to get the vclxwindow later on in the accessbile 2638*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xTemp(GetComponentInterface()); 2639*cdf0e10cSrcweir xAccessible = pImp->m_aFactoryAccess.getFactory().createAccessibleTreeListBox( *this, xAccParent ); 2640*cdf0e10cSrcweir } 2641*cdf0e10cSrcweir } 2642*cdf0e10cSrcweir return xAccessible; 2643*cdf0e10cSrcweir } 2644*cdf0e10cSrcweir 2645*cdf0e10cSrcweir void SvTreeListBox::FillAccessibleEntryStateSet( SvLBoxEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const 2646*cdf0e10cSrcweir { 2647*cdf0e10cSrcweir DBG_ASSERT( pEntry, "SvTreeListBox::FillAccessibleEntryStateSet: invalid entry" ); 2648*cdf0e10cSrcweir 2649*cdf0e10cSrcweir if ( pEntry->HasChildsOnDemand() || pEntry->HasChilds() ) 2650*cdf0e10cSrcweir { 2651*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::EXPANDABLE ); 2652*cdf0e10cSrcweir if ( IsExpanded( pEntry ) ) 2653*cdf0e10cSrcweir rStateSet.AddState( (sal_Int16)AccessibleStateType::EXPANDED ); 2654*cdf0e10cSrcweir } 2655*cdf0e10cSrcweir 2656*cdf0e10cSrcweir if ( GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED ) 2657*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::CHECKED ); 2658*cdf0e10cSrcweir if ( IsEntryVisible( pEntry ) ) 2659*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VISIBLE ); 2660*cdf0e10cSrcweir if ( IsSelected( pEntry ) ) 2661*cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::SELECTED ); 2662*cdf0e10cSrcweir } 2663*cdf0e10cSrcweir 2664*cdf0e10cSrcweir Rectangle SvTreeListBox::GetBoundingRect( SvLBoxEntry* pEntry ) 2665*cdf0e10cSrcweir { 2666*cdf0e10cSrcweir Point aPos = GetEntryPosition( pEntry ); 2667*cdf0e10cSrcweir Rectangle aRect = GetFocusRect( pEntry, aPos.Y() ); 2668*cdf0e10cSrcweir return aRect; 2669*cdf0e10cSrcweir } 2670*cdf0e10cSrcweir 2671*cdf0e10cSrcweir void SvTreeListBox::EnableCellFocus() 2672*cdf0e10cSrcweir { 2673*cdf0e10cSrcweir pImp->EnableCellFocus(); 2674*cdf0e10cSrcweir } 2675*cdf0e10cSrcweir 2676*cdf0e10cSrcweir void SvTreeListBox::CallImplEventListeners(sal_uLong nEvent, void* pData) 2677*cdf0e10cSrcweir { 2678*cdf0e10cSrcweir CallEventListeners(nEvent, pData); 2679*cdf0e10cSrcweir } 2680*cdf0e10cSrcweir 2681*cdf0e10cSrcweir void SvTreeListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet ) const 2682*cdf0e10cSrcweir { 2683*cdf0e10cSrcweir SvLBox::FillAccessibleStateSet( rStateSet ); 2684*cdf0e10cSrcweir } 2685