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