Update ooo320-m1
[ooovba.git] / svtools / source / contnr / svtreebx.cxx
blob1bfde383fab84cae07be9e8a27de52c8525d08ea
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svtreebx.cxx,v $
10 * $Revision: 1.56 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #define _SVTREEBX_CXX
35 #include <vcl/svapp.hxx>
36 #ifndef GCC
37 #endif
39 class TabBar;
41 // #102891# -----------------------
43 #include <svtools/svlbox.hxx>
44 #include <svtools/svlbitm.hxx>
45 #include <svtools/svtreebx.hxx>
46 #include <svimpbox.hxx>
47 #include <unotools/accessiblestatesethelper.hxx>
48 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
49 #include <com/sun/star/awt/XWindowPeer.hpp>
52 using namespace ::com::sun::star::accessibility;
55 Bugs/ToDo
57 - Berechnung Rectangle beim Inplace-Editing (Bug bei manchen Fonts)
58 - SetSpaceBetweenEntries: Offset wird in SetEntryHeight nicht
59 beruecksichtigt
62 #define TREEFLAG_FIXEDHEIGHT 0x0010
65 DBG_NAME(SvTreeListBox)
67 #define SV_LBOX_DEFAULT_INDENT_PIXEL 20
69 SvTreeListBox::SvTreeListBox( Window* pParent, WinBits nWinStyle )
70 : SvLBox(pParent,nWinStyle )
72 DBG_CTOR(SvTreeListBox,0);
73 InitTreeView( nWinStyle );
75 SetSublistOpenWithLeftRight();
78 SvTreeListBox::SvTreeListBox( Window* pParent , const ResId& rResId )
79 : SvLBox( pParent,rResId )
81 DBG_CTOR(SvTreeListBox,0);
83 InitTreeView( 0 );
84 Resize();
86 SetSublistOpenWithLeftRight();
89 void SvTreeListBox::InitTreeView( WinBits nWinStyle )
91 DBG_CHKTHIS(SvTreeListBox,0);
92 pCheckButtonData = NULL;
93 pEdEntry = NULL;
94 pEdItem = NULL;
95 nEntryHeight = 0;
96 pEdCtrl = NULL;
97 nFirstSelTab = 0;
98 nLastSelTab = 0;
99 nFocusWidth = -1;
101 Link* pLink = new Link( LINK(this,SvTreeListBox, DefaultCompare) );
102 pLBoxImpl->m_pLink = pLink;
104 nTreeFlags = TREEFLAG_RECALCTABS;
105 nIndent = SV_LBOX_DEFAULT_INDENT_PIXEL;
106 nEntryHeightOffs = SV_ENTRYHEIGHTOFFS_PIXEL;
107 pImp = new SvImpLBox( this, GetModel(), nWinStyle );
109 aContextBmpMode = SVLISTENTRYFLAG_EXPANDED;
110 nContextBmpWidthMax = 0;
111 SetFont( GetFont() );
112 SetSpaceBetweenEntries( 0 );
113 SetLineColor();
114 InitSettings( TRUE, TRUE, TRUE );
115 SetWindowBits( nWinStyle );
116 SetTabs();
120 SvTreeListBox::~SvTreeListBox()
122 DBG_DTOR(SvTreeListBox,0);
123 pImp->CallEventListeners( VCLEVENT_OBJECT_DYING );
124 delete pImp;
125 delete pLBoxImpl->m_pLink;
126 ClearTabList();
129 void SvTreeListBox::SetExtendedWinBits( ExtendedWinBits _nBits )
131 pImp->SetExtendedWindowBits( _nBits );
134 ExtendedWinBits SvTreeListBox::GetExtendedWinBits() const
136 return pImp->GetExtendedWindowBits();
139 void SvTreeListBox::SetModel( SvLBoxTreeList* pNewModel )
141 DBG_CHKTHIS(SvTreeListBox,0);
142 pImp->SetModel( pNewModel );
143 SvLBox::SetModel( pNewModel );
146 void SvTreeListBox::DisconnectFromModel()
148 DBG_CHKTHIS(SvTreeListBox,0);
149 SvLBox::DisconnectFromModel();
150 pImp->SetModel( GetModel() );
154 USHORT SvTreeListBox::IsA()
156 DBG_CHKTHIS(SvTreeListBox,0);
157 return SV_LISTBOX_ID_TREEBOX;
160 void SvTreeListBox::SetSublistOpenWithReturn( BOOL b )
162 pImp->bSubLstOpRet = b;
165 BOOL SvTreeListBox::IsSublistOpenWithReturn() const
167 return pImp->bSubLstOpRet;
170 void SvTreeListBox::SetSublistOpenWithLeftRight( BOOL b )
172 pImp->bSubLstOpLR = b;
175 BOOL SvTreeListBox::IsSublistOpenWithLeftRight() const
177 return pImp->bSubLstOpLR;
180 void SvTreeListBox::Resize()
182 DBG_CHKTHIS(SvTreeListBox,0);
183 if( IsEditingActive() )
184 EndEditing( TRUE );
185 SvLBox::Resize();
186 pImp->Resize();
187 nFocusWidth = -1;
188 pImp->ShowCursor( FALSE );
189 pImp->ShowCursor( TRUE );
192 /* Faelle:
194 A) Entries haben Bitmaps
195 0. Keine Buttons
196 1. Node-Buttons (optional auch an Root-Items)
197 2. Node-Buttons (optional auch an Root-Items) + CheckButton
198 3. CheckButton
199 B) Entries haben keine Bitmaps (->ueber WindowBits wg. D&D !!!!!!)
200 0. Keine Buttons
201 1. Node-Buttons (optional auch an Root-Items)
202 2. Node-Buttons (optional auch an Root-Items) + CheckButton
203 3. CheckButton
206 #define NO_BUTTONS 0
207 #define NODE_BUTTONS 1
208 #define NODE_AND_CHECK_BUTTONS 2
209 #define CHECK_BUTTONS 3
211 #define TABFLAGS_TEXT (SV_LBOXTAB_DYNAMIC | \
212 SV_LBOXTAB_ADJUST_LEFT | \
213 SV_LBOXTAB_EDITABLE | \
214 SV_LBOXTAB_SHOW_SELECTION)
216 #define TABFLAGS_CONTEXTBMP (SV_LBOXTAB_DYNAMIC | SV_LBOXTAB_ADJUST_CENTER)
218 #define TABFLAGS_CHECKBTN (SV_LBOXTAB_DYNAMIC | \
219 SV_LBOXTAB_ADJUST_CENTER | \
220 SV_LBOXTAB_PUSHABLE)
222 #define TAB_STARTPOS 2
224 // bei Aenderungen GetTextOffset beruecksichtigen
225 void SvTreeListBox::SetTabs()
227 DBG_CHKTHIS(SvTreeListBox,0);
228 if( IsEditingActive() )
229 EndEditing( TRUE );
230 nTreeFlags &= (~TREEFLAG_RECALCTABS);
231 nFocusWidth = -1;
232 BOOL bHasButtons = (nWindowStyle & WB_HASBUTTONS)!=0;
233 BOOL bHasButtonsAtRoot = (nWindowStyle & (WB_HASLINESATROOT |
234 WB_HASBUTTONSATROOT))!=0;
235 long nStartPos = TAB_STARTPOS;
236 long nNodeWidthPixel = GetExpandedNodeBmp().GetSizePixel().Width();
238 long nCheckWidth = 0;
239 if( nTreeFlags & TREEFLAG_CHKBTN )
240 nCheckWidth = pCheckButtonData->aBmps[0].GetSizePixel().Width();
241 long nCheckWidthDIV2 = nCheckWidth / 2;
243 long nContextWidth = nContextBmpWidthMax;
244 long nContextWidthDIV2 = nContextWidth / 2;
246 ClearTabList();
248 int nCase = NO_BUTTONS;
249 if( !(nTreeFlags & TREEFLAG_CHKBTN) )
251 if( bHasButtons )
252 nCase = NODE_BUTTONS;
254 else
256 if( bHasButtons )
257 nCase = NODE_AND_CHECK_BUTTONS;
258 else
259 nCase = CHECK_BUTTONS;
262 switch( nCase )
264 case NO_BUTTONS :
265 nStartPos += nContextWidthDIV2; // wg. Zentrierung
266 AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
267 nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp
268 // Abstand setzen nur wenn Bitmaps da
269 if( nContextBmpWidthMax )
270 nStartPos += 5; // Abstand Context-Bmp - Text
271 AddTab( nStartPos, TABFLAGS_TEXT );
272 break;
274 case NODE_BUTTONS :
275 if( bHasButtonsAtRoot )
276 nStartPos += ( nIndent + (nNodeWidthPixel/2) );
277 else
278 nStartPos += nContextWidthDIV2;
279 AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
280 nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp
281 // Abstand setzen nur wenn Bitmaps da
282 if( nContextBmpWidthMax )
283 nStartPos += 5; // Abstand Context-Bmp - Text
284 AddTab( nStartPos, TABFLAGS_TEXT );
285 break;
287 case NODE_AND_CHECK_BUTTONS :
288 if( bHasButtonsAtRoot )
289 nStartPos += ( nIndent + nNodeWidthPixel );
290 else
291 nStartPos += nCheckWidthDIV2;
292 AddTab( nStartPos, TABFLAGS_CHECKBTN );
293 nStartPos += nCheckWidthDIV2; // rechter Rand des CheckButtons
294 nStartPos += 3; // Abstand CheckButton Context-Bmp
295 nStartPos += nContextWidthDIV2; // Mitte der Context-Bmp
296 AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
297 nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp
298 // Abstand setzen nur wenn Bitmaps da
299 if( nContextBmpWidthMax )
300 nStartPos += 5; // Abstand Context-Bmp - Text
301 AddTab( nStartPos, TABFLAGS_TEXT );
302 break;
304 case CHECK_BUTTONS :
305 nStartPos += nCheckWidthDIV2;
306 AddTab( nStartPos, TABFLAGS_CHECKBTN );
307 nStartPos += nCheckWidthDIV2; // rechter Rand CheckButton
308 nStartPos += 3; // Abstand CheckButton Context-Bmp
309 nStartPos += nContextWidthDIV2; // Mitte der Context-Bmp
310 AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
311 nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp
312 // Abstand setzen nur wenn Bitmaps da
313 if( nContextBmpWidthMax )
314 nStartPos += 5; // Abstand Context-Bmp - Text
315 AddTab( nStartPos, TABFLAGS_TEXT );
316 break;
318 pImp->NotifyTabsChanged();
321 void SvTreeListBox::InitEntry( SvLBoxEntry* pEntry,
322 const XubString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp,
323 SvLBoxButtonKind eButtonKind)
325 DBG_CHKTHIS(SvTreeListBox,0);
326 SvLBoxButton* pButton;
327 SvLBoxString* pString;
328 SvLBoxContextBmp* pContextBmp;
330 if( nTreeFlags & TREEFLAG_CHKBTN )
332 pButton= new SvLBoxButton( pEntry,eButtonKind,0,pCheckButtonData );
333 pEntry->AddItem( pButton );
336 pContextBmp= new SvLBoxContextBmp( pEntry,0, aCollEntryBmp,aExpEntryBmp,
337 aContextBmpMode );
338 pEntry->AddItem( pContextBmp );
340 pString = new SvLBoxString( pEntry, 0, aStr );
341 pEntry->AddItem( pString );
344 String SvTreeListBox::GetEntryText(SvLBoxEntry* pEntry) const
346 DBG_CHKTHIS(SvTreeListBox,0);
347 DBG_ASSERT( pEntry, "SvTreeListBox::GetEntryText(): no entry" );
348 SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
349 DBG_ASSERT( pEntry, "SvTreeListBox::GetEntryText(): item not found" );
350 return pItem->GetText();
353 String SvTreeListBox::SearchEntryText( SvLBoxEntry* pEntry ) const
355 DBG_CHKTHIS(SvTreeListBox,0);
356 DBG_ASSERT( pEntry, "SvTreeListBox::SearchEntryText(): no entry" );
357 String sRet;
358 USHORT nCount = pEntry->ItemCount();
359 USHORT nCur = 0;
360 SvLBoxItem* pItem;
361 while( nCur < nCount )
363 pItem = pEntry->GetItem( nCur );
364 if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING &&
365 static_cast<SvLBoxString*>( pItem )->GetText().Len() > 0 )
367 sRet = static_cast<SvLBoxString*>( pItem )->GetText();
368 break;
370 nCur++;
372 return sRet;
375 const Image& SvTreeListBox::GetExpandedEntryBmp(SvLBoxEntry* pEntry, BmpColorMode _eMode) const
377 DBG_CHKTHIS(SvTreeListBox,0);
378 DBG_ASSERT(pEntry,"Entry?");
379 SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
380 DBG_ASSERT(pItem,"GetContextBmp:Item not found");
381 return pItem->GetBitmap2( _eMode );
384 const Image& SvTreeListBox::GetCollapsedEntryBmp( SvLBoxEntry* pEntry, BmpColorMode _eMode ) const
386 DBG_CHKTHIS(SvTreeListBox,0);
387 DBG_ASSERT(pEntry,"Entry?");
388 SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
389 DBG_ASSERT(pItem,"GetContextBmp:Item not found");
390 return pItem->GetBitmap1( _eMode );
393 IMPL_LINK_INLINE_START( SvTreeListBox, CheckButtonClick, SvLBoxButtonData *, pData )
395 DBG_CHKTHIS(SvTreeListBox,0);
396 pHdlEntry = pData->GetActEntry();
397 CheckButtonHdl();
398 return 0;
400 IMPL_LINK_INLINE_END( SvTreeListBox, CheckButtonClick, SvLBoxButtonData *, pData )
402 SvLBoxEntry* SvTreeListBox::InsertEntry( const XubString& aText,SvLBoxEntry* pParent,
403 BOOL bChildsOnDemand, ULONG nPos, void* pUser,
404 SvLBoxButtonKind eButtonKind )
406 DBG_CHKTHIS(SvTreeListBox,0);
407 nTreeFlags |= TREEFLAG_MANINS;
409 const Image& rDefExpBmp = pImp->GetDefaultEntryExpBmp( );
410 const Image& rDefColBmp = pImp->GetDefaultEntryColBmp( );
412 aCurInsertedExpBmp = rDefExpBmp;
413 aCurInsertedColBmp = rDefColBmp;
415 SvLBoxEntry* pEntry = CreateEntry();
416 pEntry->SetUserData( pUser );
417 InitEntry( pEntry, aText, rDefColBmp, rDefExpBmp, eButtonKind );
418 pEntry->EnableChildsOnDemand( bChildsOnDemand );
420 // Add the HC versions of the default images
421 SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) );
422 if( pBmpItem )
424 pBmpItem->SetBitmap1( pImp->GetDefaultEntryColBmp( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
425 pBmpItem->SetBitmap2( pImp->GetDefaultEntryExpBmp( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
428 if( !pParent )
429 SvLBox::Insert( pEntry, nPos );
430 else
431 SvLBox::Insert( pEntry, pParent, nPos );
433 short nExpWidth = (short)rDefExpBmp.GetSizePixel().Width();
434 short nColWidth = (short)rDefColBmp.GetSizePixel().Width();
435 short nMax = Max(nExpWidth, nColWidth);
436 // #97680# ----------------
437 nMax = pImp->UpdateContextBmpWidthVector( pEntry, nMax );
438 if( nMax > nContextBmpWidthMax )
440 nContextBmpWidthMax = nMax;
441 SetTabs();
444 aPrevInsertedExpBmp = rDefExpBmp;
445 aPrevInsertedColBmp = rDefColBmp;
447 nTreeFlags &= (~TREEFLAG_MANINS);
449 return pEntry;
452 SvLBoxEntry* SvTreeListBox::InsertEntry( const XubString& aText,
453 const Image& aExpEntryBmp, const Image& aCollEntryBmp,
454 SvLBoxEntry* pParent, BOOL bChildsOnDemand, ULONG nPos, void* pUser,
455 SvLBoxButtonKind eButtonKind )
457 DBG_CHKTHIS(SvTreeListBox,0);
458 nTreeFlags |= TREEFLAG_MANINS;
460 aCurInsertedExpBmp = aExpEntryBmp;
461 aCurInsertedColBmp = aCollEntryBmp;
463 SvLBoxEntry* pEntry = CreateEntry();
464 pEntry->SetUserData( pUser );
465 InitEntry( pEntry, aText, aCollEntryBmp, aExpEntryBmp, eButtonKind );
467 pEntry->EnableChildsOnDemand( bChildsOnDemand );
469 if( !pParent )
470 SvLBox::Insert( pEntry, nPos );
471 else
472 SvLBox::Insert( pEntry, pParent, nPos );
474 short nExpWidth = (short)aExpEntryBmp.GetSizePixel().Width();
475 short nColWidth = (short)aCollEntryBmp.GetSizePixel().Width();
476 short nMax = Max(nExpWidth, nColWidth);
477 // #97680# ----------------
478 nMax = pImp->UpdateContextBmpWidthVector( pEntry, nMax );
479 if( nMax > nContextBmpWidthMax )
481 nContextBmpWidthMax = nMax;
482 SetTabs();
485 aPrevInsertedExpBmp = aExpEntryBmp;
486 aPrevInsertedColBmp = aCollEntryBmp;
488 nTreeFlags &= (~TREEFLAG_MANINS);
490 return pEntry;
493 void SvTreeListBox::SetEntryText( SvLBoxEntry* pEntry, const XubString& aStr)
495 DBG_CHKTHIS(SvTreeListBox,0);
496 SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
497 DBG_ASSERT(pItem,"SetText:Item not found");
498 pItem->SetText( pEntry, aStr );
499 pItem->InitViewData( this, pEntry, 0 );
500 GetModel()->InvalidateEntry( pEntry );
503 void SvTreeListBox::SetExpandedEntryBmp( SvLBoxEntry* pEntry, const Image& aBmp, BmpColorMode _eMode )
505 DBG_CHKTHIS(SvTreeListBox,0);
506 SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
508 DBG_ASSERT(pItem,"SetExpBmp:Item not found");
509 pItem->SetBitmap2( aBmp, _eMode );
511 GetModel()->InvalidateEntry( pEntry );
512 SetEntryHeight( pEntry );
513 Size aSize = aBmp.GetSizePixel();
514 // #97680# ---------------
515 short nWidth = pImp->UpdateContextBmpWidthVector( pEntry, (short)aSize.Width() );
516 if( nWidth > nContextBmpWidthMax )
518 nContextBmpWidthMax = nWidth;
519 SetTabs();
523 void SvTreeListBox::SetCollapsedEntryBmp(SvLBoxEntry* pEntry,const Image& aBmp, BmpColorMode _eMode )
525 DBG_CHKTHIS(SvTreeListBox,0);
526 SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
528 DBG_ASSERT(pItem,"SetExpBmp:Item not found");
529 pItem->SetBitmap1( aBmp, _eMode );
531 GetModel()->InvalidateEntry( pEntry );
532 SetEntryHeight( pEntry );
533 Size aSize = aBmp.GetSizePixel();
534 // #97680# -----------
535 short nWidth = pImp->UpdateContextBmpWidthVector( pEntry, (short)aSize.Width() );
536 if( nWidth > nContextBmpWidthMax )
538 nContextBmpWidthMax = nWidth;
539 SetTabs();
543 void SvTreeListBox::ImpEntryInserted( SvLBoxEntry* pEntry )
545 DBG_CHKTHIS(SvTreeListBox,0);
547 SvLBoxEntry* pParent = (SvLBoxEntry*)pModel->GetParent( pEntry );
548 if( pParent )
550 USHORT nFlags = pParent->GetFlags();
551 nFlags &= ~SV_ENTRYFLAG_NO_NODEBMP;
552 pParent->SetFlags( nFlags );
555 if(!((nTreeFlags & TREEFLAG_MANINS) &&
556 (aPrevInsertedExpBmp == aCurInsertedExpBmp) &&
557 (aPrevInsertedColBmp == aCurInsertedColBmp) ))
559 Size aSize = GetCollapsedEntryBmp( pEntry ).GetSizePixel();
560 if( aSize.Width() > nContextBmpWidthMax )
562 nContextBmpWidthMax = (short)aSize.Width();
563 nTreeFlags |= TREEFLAG_RECALCTABS;
565 aSize = GetExpandedEntryBmp( pEntry ).GetSizePixel();
566 if( aSize.Width() > nContextBmpWidthMax )
568 nContextBmpWidthMax = (short)aSize.Width();
569 nTreeFlags |= TREEFLAG_RECALCTABS;
572 SetEntryHeight( (SvLBoxEntry*)pEntry );
577 void SvTreeListBox::SetCheckButtonState( SvLBoxEntry* pEntry, SvButtonState eState)
579 DBG_CHKTHIS(SvTreeListBox,0);
580 if( nTreeFlags & TREEFLAG_CHKBTN )
582 SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
583 if(!(pItem && pItem->CheckModification()))
584 return ;
585 switch( eState )
587 case SV_BUTTON_CHECKED:
588 pItem->SetStateChecked();
589 break;
591 case SV_BUTTON_UNCHECKED:
592 pItem->SetStateUnchecked();
593 break;
595 case SV_BUTTON_TRISTATE:
596 pItem->SetStateTristate();
597 break;
599 InvalidateEntry( pEntry );
603 SvButtonState SvTreeListBox::GetCheckButtonState( SvLBoxEntry* pEntry ) const
605 DBG_CHKTHIS(SvTreeListBox,0);
606 SvButtonState eState = SV_BUTTON_UNCHECKED;
607 if( nTreeFlags & TREEFLAG_CHKBTN )
609 SvLBoxButton* pItem = (SvLBoxButton*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
610 if(!pItem)
611 return SV_BUTTON_TRISTATE;
612 USHORT nButtonFlags = pItem->GetButtonFlags();
613 eState = pCheckButtonData->ConvertToButtonState( nButtonFlags );
615 return eState;
618 void SvTreeListBox::CheckButtonHdl()
620 DBG_CHKTHIS(SvTreeListBox,0);
621 aCheckButtonHdl.Call( this );
622 if ( pCheckButtonData )
623 pImp->CallEventListeners( VCLEVENT_CHECKBOX_TOGGLE, (void*)pCheckButtonData->GetActEntry() );
626 // *********************************************************************
627 // *********************************************************************
630 // TODO: Momentan werden die Daten so geklont, dass sie dem
631 // Standard-TreeView-Format entsprechen. Hier sollte eigentlich
632 // das Model als Referenz dienen. Dies fuehrt dazu, dass
633 // SvLBoxEntry::Clone _nicht_ gerufen wird, sondern nur dessen
634 // Basisklasse SvListEntry
637 SvLBoxEntry* SvTreeListBox::CloneEntry( SvLBoxEntry* pSource )
639 DBG_CHKTHIS(SvTreeListBox,0);
640 XubString aStr;
641 Image aCollEntryBmp;
642 Image aExpEntryBmp;
643 SvLBoxButtonKind eButtonKind = SvLBoxButtonKind_enabledCheckbox;
645 SvLBoxString* pStringItem = (SvLBoxString*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
646 if( pStringItem )
647 aStr = pStringItem->GetText();
648 SvLBoxContextBmp* pBmpItem = (SvLBoxContextBmp*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
649 if( pBmpItem )
651 aCollEntryBmp = pBmpItem->GetBitmap1( BMP_COLOR_NORMAL );
652 aExpEntryBmp = pBmpItem->GetBitmap2( BMP_COLOR_NORMAL );
654 SvLBoxButton* pButtonItem = (SvLBoxButton*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXBUTTON));
655 if( pButtonItem )
656 eButtonKind = pButtonItem->GetKind();
657 SvLBoxEntry* pClone = CreateEntry();
658 InitEntry( pClone, aStr, aCollEntryBmp, aExpEntryBmp, eButtonKind );
659 pClone->SvListEntry::Clone( pSource );
660 pClone->EnableChildsOnDemand( pSource->HasChildsOnDemand() );
661 pClone->SetUserData( pSource->GetUserData() );
663 if ( pBmpItem )
665 SvLBoxContextBmp* pCloneBitmap = static_cast< SvLBoxContextBmp* >( pClone->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) );
666 if ( pCloneBitmap )
668 pCloneBitmap->SetBitmap1( pBmpItem->GetBitmap1( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
669 pCloneBitmap->SetBitmap2( pBmpItem->GetBitmap2( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
673 return pClone;
676 // *********************************************************************
677 // *********************************************************************
680 void SvTreeListBox::ShowExpandBitmapOnCursor( BOOL bYes )
682 DBG_CHKTHIS(SvTreeListBox,0);
683 if( bYes )
684 aContextBmpMode = SVLISTENTRYFLAG_FOCUSED;
685 else
686 aContextBmpMode = SVLISTENTRYFLAG_EXPANDED;
689 void SvTreeListBox::SetIndent( short nNewIndent )
691 DBG_CHKTHIS(SvTreeListBox,0);
692 nIndent = nNewIndent;
693 SetTabs();
694 if( IsUpdateMode() )
695 Invalidate();
698 const Image& SvTreeListBox::GetDefaultExpandedEntryBmp( BmpColorMode _eMode ) const
700 return pImp->GetDefaultEntryExpBmp( _eMode );
703 const Image& SvTreeListBox::GetDefaultCollapsedEntryBmp( BmpColorMode _eMode ) const
705 return pImp->GetDefaultEntryColBmp( _eMode );
708 void SvTreeListBox::SetDefaultExpandedEntryBmp( const Image& aBmp, BmpColorMode _eMode )
710 DBG_CHKTHIS(SvTreeListBox,0);
711 Size aSize = aBmp.GetSizePixel();
712 if( aSize.Width() > nContextBmpWidthMax )
713 nContextBmpWidthMax = (short)aSize.Width();
714 SetTabs();
716 pImp->SetDefaultEntryExpBmp( aBmp, _eMode );
719 void SvTreeListBox::SetDefaultCollapsedEntryBmp( const Image& aBmp, BmpColorMode _eMode )
721 DBG_CHKTHIS(SvTreeListBox,0);
722 Size aSize = aBmp.GetSizePixel();
723 if( aSize.Width() > nContextBmpWidthMax )
724 nContextBmpWidthMax = (short)aSize.Width();
725 SetTabs();
727 pImp->SetDefaultEntryColBmp( aBmp, _eMode );
730 void SvTreeListBox::EnableCheckButton( SvLBoxButtonData* pData )
732 DBG_CHKTHIS(SvTreeListBox,0);
733 DBG_ASSERT(!GetEntryCount(),"EnableCheckButton: Entry count != 0");
734 if( !pData )
735 nTreeFlags &= (~TREEFLAG_CHKBTN);
736 else
738 SetCheckButtonData( pData );
739 nTreeFlags |= TREEFLAG_CHKBTN;
740 pData->SetLink( LINK(this, SvTreeListBox, CheckButtonClick));
743 SetTabs();
744 if( IsUpdateMode() )
745 Invalidate();
748 void SvTreeListBox::SetCheckButtonData( SvLBoxButtonData* pData )
750 DBG_CHKTHIS(SvTreeListBox,0);
751 if ( pData )
752 pCheckButtonData = pData;
755 const Image& SvTreeListBox::GetDefaultExpandedNodeImage( BmpColorMode _eMode )
757 return SvImpLBox::GetDefaultExpandedNodeImage( _eMode );
760 const Image& SvTreeListBox::GetDefaultCollapsedNodeImage( BmpColorMode _eMode )
762 return SvImpLBox::GetDefaultCollapsedNodeImage( _eMode );
765 void SvTreeListBox::SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp, BmpColorMode _eMode )
767 DBG_CHKTHIS(SvTreeListBox,0);
768 SetExpandedNodeBmp( rExpandedNodeBmp, _eMode );
769 SetCollapsedNodeBmp( rCollapsedNodeBmp, _eMode );
770 SetTabs();
773 void SvTreeListBox::SetDontKnowNodeBitmap( const Image& rDontKnowBmp, BmpColorMode _eMode )
775 pImp->SetDontKnowNodeBmp( rDontKnowBmp, _eMode );
778 BOOL SvTreeListBox::EditingEntry( SvLBoxEntry*, Selection& )
780 DBG_CHKTHIS(SvTreeListBox,0);
781 return TRUE;
784 BOOL SvTreeListBox::EditedEntry( SvLBoxEntry* /*pEntry*/,const XubString& /*rNewText*/)
786 DBG_CHKTHIS(SvTreeListBox,0);
787 return TRUE;
790 void SvTreeListBox::EnableInplaceEditing( BOOL bOn )
792 DBG_CHKTHIS(SvTreeListBox,0);
793 SvLBox::EnableInplaceEditing( bOn );
796 void SvTreeListBox::KeyInput( const KeyEvent& rKEvt )
798 DBG_CHKTHIS(SvTreeListBox,0);
799 // unter OS/2 bekommen wir auch beim Editieren Key-Up/Down
800 if( IsEditingActive() )
801 return;
803 nImpFlags |= SVLBOX_IS_TRAVELSELECT;
805 #ifdef OVDEBUG
806 USHORT nCode = rKEvt.GetKeyCode().GetCode();
807 switch ( nCode )
809 case KEY_F1:
811 SvLBoxEntry* pEntry = First();
812 pEntry = NextVisible( pEntry );
813 SetEntryText( pEntry, "SetEntryText" );
814 Sound::Beep();
816 break;
818 #endif
820 if( !pImp->KeyInput( rKEvt ) )
821 SvLBox::KeyInput( rKEvt );
823 nImpFlags &= ~SVLBOX_IS_TRAVELSELECT;
826 void SvTreeListBox::RequestingChilds( SvLBoxEntry* pParent )
828 DBG_CHKTHIS(SvTreeListBox,0);
829 if( !pParent->HasChilds() )
830 InsertEntry( String::CreateFromAscii("<dummy>"), pParent, FALSE, LIST_APPEND );
833 void SvTreeListBox::GetFocus()
835 DBG_CHKTHIS(SvTreeListBox,0);
836 pImp->GetFocus();
837 SvLBox::GetFocus();
839 SvLBoxEntry* pEntry = FirstSelected();
840 if ( pEntry )
841 pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry );
845 void SvTreeListBox::LoseFocus()
847 DBG_CHKTHIS(SvTreeListBox,0);
848 pImp->LoseFocus();
849 SvLBox::LoseFocus();
852 void SvTreeListBox::ModelHasCleared()
854 DBG_CHKTHIS(SvTreeListBox,0);
855 pImp->pCursor = 0; //sonst Absturz beim Inplace-Editieren im GetFocus
856 delete pEdCtrl;
857 pEdCtrl = NULL;
858 pImp->Clear();
859 nFocusWidth = -1;
861 nContextBmpWidthMax = 0;
862 SetDefaultExpandedEntryBmp( GetDefaultExpandedEntryBmp() );
863 SetDefaultCollapsedEntryBmp( GetDefaultCollapsedEntryBmp() );
865 if( !(nTreeFlags & TREEFLAG_FIXEDHEIGHT ))
866 nEntryHeight = 0;
867 AdjustEntryHeight( GetFont() );
868 AdjustEntryHeight( GetDefaultExpandedEntryBmp() );
869 AdjustEntryHeight( GetDefaultCollapsedEntryBmp() );
871 SvLBox::ModelHasCleared();
872 // if( IsUpdateMode() )
873 // Invalidate();
876 void SvTreeListBox::ShowTargetEmphasis( SvLBoxEntry* pEntry, BOOL /* bShow */ )
878 DBG_CHKTHIS(SvTreeListBox,0);
879 pImp->PaintDDCursor( pEntry );
882 void SvTreeListBox::ScrollOutputArea( short nDeltaEntries )
884 DBG_CHKTHIS(SvTreeListBox,0);
885 if( !nDeltaEntries || !pImp->aVerSBar.IsVisible() )
886 return;
888 long nThumb = pImp->aVerSBar.GetThumbPos();
889 long nMax = pImp->aVerSBar.GetRange().Max();
891 NotifyBeginScroll();
892 if( nDeltaEntries < 0 )
894 // das Fenster nach oben verschieben
895 nDeltaEntries *= -1;
896 long nVis = pImp->aVerSBar.GetVisibleSize();
897 long nTemp = nThumb + nVis;
898 if( nDeltaEntries > (nMax - nTemp) )
899 nDeltaEntries = (short)(nMax - nTemp);
900 pImp->PageDown( (USHORT)nDeltaEntries );
902 else
904 if( nDeltaEntries > nThumb )
905 nDeltaEntries = (short)nThumb;
906 pImp->PageUp( (USHORT)nDeltaEntries );
908 pImp->SyncVerThumb();
909 NotifyEndScroll();
912 void SvTreeListBox::SetSelectionMode( SelectionMode eSelectMode )
914 DBG_CHKTHIS(SvTreeListBox,0);
915 SvLBox::SetSelectionMode( eSelectMode );
916 pImp->SetSelectionMode( eSelectMode );
919 void SvTreeListBox::SetDragDropMode( DragDropMode nDDMode )
921 DBG_CHKTHIS(SvTreeListBox,0);
922 SvLBox::SetDragDropMode( nDDMode );
923 pImp->SetDragDropMode( nDDMode );
926 short SvTreeListBox::GetHeightOffset(const Image& rBmp, Size& aSizeLogic )
928 DBG_CHKTHIS(SvTreeListBox,0);
929 short nOffset = 0;
930 aSizeLogic = rBmp.GetSizePixel();
931 if( GetEntryHeight() > aSizeLogic.Height() )
932 nOffset = ( GetEntryHeight() - (short)aSizeLogic.Height()) / 2;
933 return nOffset;
936 short SvTreeListBox::GetHeightOffset(const Font& /* rFont */, Size& aSizeLogic )
938 DBG_CHKTHIS(SvTreeListBox,0);
939 short nOffset = 0;
940 aSizeLogic = Size(GetTextWidth('X'), GetTextHeight());
941 if( GetEntryHeight() > aSizeLogic.Height() )
942 nOffset = ( GetEntryHeight() - (short)aSizeLogic.Height()) / 2;
943 return nOffset;
946 void SvTreeListBox::SetEntryHeight( SvLBoxEntry* pEntry )
948 DBG_CHKTHIS(SvTreeListBox,0);
949 short nHeight, nHeightMax=0;
950 USHORT nCount = pEntry->ItemCount();
951 USHORT nCur = 0;
952 SvViewDataEntry* pViewData = GetViewDataEntry( pEntry );
953 while( nCur < nCount )
955 SvLBoxItem* pItem = pEntry->GetItem( nCur );
956 nHeight = (short)(pItem->GetSize( pViewData, nCur ).Height());
957 if( nHeight > nHeightMax )
958 nHeightMax = nHeight;
959 nCur++;
962 if( nHeightMax > nEntryHeight )
964 nEntryHeight = nHeightMax;
965 SvLBox::SetFont( GetFont() );
966 pImp->SetEntryHeight( nHeightMax );
970 void SvTreeListBox::SetEntryHeight( short nHeight, BOOL bAlways )
972 DBG_CHKTHIS(SvTreeListBox,0);
974 if( bAlways || nHeight > nEntryHeight )
976 nEntryHeight = nHeight;
977 if( nEntryHeight )
978 nTreeFlags |= TREEFLAG_FIXEDHEIGHT;
979 else
980 nTreeFlags &= ~TREEFLAG_FIXEDHEIGHT;
981 SvLBox::SetFont( GetFont() );
982 pImp->SetEntryHeight( nHeight );
987 void SvTreeListBox::AdjustEntryHeight( const Image& rBmp )
989 DBG_CHKTHIS(SvTreeListBox,0);
990 Size aSize;
991 GetHeightOffset( rBmp, aSize );
992 if( aSize.Height() > nEntryHeight )
994 nEntryHeight = (short)aSize.Height() + nEntryHeightOffs;
995 pImp->SetEntryHeight( nEntryHeight );
999 void SvTreeListBox::AdjustEntryHeight( const Font& rFont )
1001 DBG_CHKTHIS(SvTreeListBox,0);
1002 Size aSize;
1003 GetHeightOffset( rFont, aSize );
1004 if( aSize.Height() > nEntryHeight )
1006 nEntryHeight = (short)aSize.Height() + nEntryHeightOffs;
1007 pImp->SetEntryHeight( nEntryHeight );
1011 BOOL SvTreeListBox::Expand( SvLBoxEntry* pParent )
1013 DBG_CHKTHIS(SvTreeListBox,0);
1014 pHdlEntry = pParent;
1015 BOOL bExpanded = FALSE;
1016 USHORT nFlags;
1018 if( pParent->HasChildsOnDemand() )
1019 RequestingChilds( pParent );
1020 if( pParent->HasChilds() )
1022 nImpFlags |= SVLBOX_IS_EXPANDING;
1023 if( ExpandingHdl() )
1025 bExpanded = TRUE;
1026 SvListView::Expand( pParent );
1027 pImp->EntryExpanded( pParent );
1028 pHdlEntry = pParent;
1029 ExpandedHdl();
1031 nFlags = pParent->GetFlags();
1032 nFlags &= ~SV_ENTRYFLAG_NO_NODEBMP;
1033 nFlags |= SV_ENTRYFLAG_HAD_CHILDREN;
1034 pParent->SetFlags( nFlags );
1036 else
1038 nFlags = pParent->GetFlags();
1039 nFlags |= SV_ENTRYFLAG_NO_NODEBMP;
1040 pParent->SetFlags( nFlags );
1041 GetModel()->InvalidateEntry( pParent ); // neu zeichnen
1044 // --> OD 2009-04-01 #i92103#
1045 if ( bExpanded )
1047 pImp->CallEventListeners( VCLEVENT_LISTBOX_ENTRY_EXPANDED, pParent );
1049 // <--
1051 return bExpanded;
1054 BOOL SvTreeListBox::Collapse( SvLBoxEntry* pParent )
1056 DBG_CHKTHIS(SvTreeListBox,0);
1057 nImpFlags &= ~SVLBOX_IS_EXPANDING;
1058 pHdlEntry = pParent;
1059 BOOL bCollapsed = FALSE;
1061 if( ExpandingHdl() )
1063 bCollapsed = TRUE;
1064 pImp->CollapsingEntry( pParent );
1065 SvListView::Collapse( pParent );
1066 pImp->EntryCollapsed( pParent );
1067 pHdlEntry = pParent;
1068 ExpandedHdl();
1071 // --> OD 2009-04-01 #i92103#
1072 if ( bCollapsed )
1074 pImp->CallEventListeners( VCLEVENT_LISTBOX_ENTRY_COLLAPSED, pParent );
1076 // <--
1078 return bCollapsed;
1081 BOOL SvTreeListBox::Select( SvLBoxEntry* pEntry, BOOL bSelect )
1083 DBG_CHKTHIS(SvTreeListBox,0);
1084 DBG_ASSERT(pEntry,"Select: Null-Ptr");
1085 BOOL bRetVal = SvListView::Select( pEntry, bSelect );
1086 DBG_ASSERT(IsSelected(pEntry)==bSelect,"Select failed");
1087 if( bRetVal )
1089 pImp->EntrySelected( pEntry, bSelect );
1090 pHdlEntry = pEntry;
1091 if( bSelect )
1093 SelectHdl();
1094 pImp->CallEventListeners( VCLEVENT_LISTBOX_SELECT, pEntry );
1096 else
1097 DeselectHdl();
1099 return bRetVal;
1102 ULONG SvTreeListBox::SelectChilds( SvLBoxEntry* pParent, BOOL bSelect )
1104 DBG_CHKTHIS(SvTreeListBox,0);
1105 pImp->DestroyAnchor();
1106 ULONG nRet = 0;
1107 if( !pParent->HasChilds() )
1108 return 0;
1109 USHORT nRefDepth = pModel->GetDepth( pParent );
1110 SvLBoxEntry* pChild = FirstChild( pParent );
1111 do {
1112 nRet++;
1113 Select( pChild, bSelect );
1114 pChild = Next( pChild );
1115 } while( pChild && pModel->GetDepth( pChild ) > nRefDepth );
1116 return nRet;
1119 void SvTreeListBox::SelectAll( BOOL bSelect, BOOL )
1121 DBG_CHKTHIS(SvTreeListBox,0);
1122 pImp->SelAllDestrAnch(
1123 bSelect,
1124 TRUE, // Anker loeschen,
1125 TRUE ); // auch bei SINGLE_SELECTION den Cursor deselektieren
1128 void SvTreeListBox::ModelHasInsertedTree( SvListEntry* pEntry )
1130 DBG_CHKTHIS(SvTreeListBox,0);
1131 USHORT nRefDepth = pModel->GetDepth( (SvLBoxEntry*)pEntry );
1132 SvLBoxEntry* pTmp = (SvLBoxEntry*)pEntry;
1135 ImpEntryInserted( pTmp );
1136 pTmp = Next( pTmp );
1137 } while( pTmp && nRefDepth < pModel->GetDepth( pTmp ) );
1138 pImp->TreeInserted( (SvLBoxEntry*)pEntry );
1141 void SvTreeListBox::ModelHasInserted( SvListEntry* pEntry )
1143 DBG_CHKTHIS(SvTreeListBox,0);
1144 ImpEntryInserted( (SvLBoxEntry*)pEntry );
1145 pImp->EntryInserted( (SvLBoxEntry*)pEntry );
1148 void SvTreeListBox::ModelIsMoving(SvListEntry* pSource,
1149 SvListEntry* /* pTargetParent */,
1150 ULONG /* nChildPos */ )
1152 DBG_CHKTHIS(SvTreeListBox,0);
1153 pImp->MovingEntry( (SvLBoxEntry*)pSource );
1156 void SvTreeListBox::ModelHasMoved( SvListEntry* pSource )
1158 DBG_CHKTHIS(SvTreeListBox,0);
1159 pImp->EntryMoved( (SvLBoxEntry*)pSource );
1162 void SvTreeListBox::ModelIsRemoving( SvListEntry* pEntry )
1164 DBG_CHKTHIS(SvTreeListBox,0);
1165 if(pEdEntry == pEntry)
1166 pEdEntry = NULL;
1168 pImp->RemovingEntry( (SvLBoxEntry*)pEntry );
1169 NotifyRemoving( (SvLBoxEntry*)pEntry );
1172 void SvTreeListBox::ModelHasRemoved( SvListEntry* /* pEntry */ )
1174 DBG_CHKTHIS(SvTreeListBox,0);
1175 pImp->EntryRemoved();
1178 void SvTreeListBox::SetCollapsedNodeBmp( const Image& rBmp, BmpColorMode _eMode )
1180 DBG_CHKTHIS(SvTreeListBox,0);
1181 AdjustEntryHeight( rBmp );
1182 pImp->SetCollapsedNodeBmp( rBmp, _eMode );
1185 void SvTreeListBox::SetExpandedNodeBmp( const Image& rBmp, BmpColorMode _eMode )
1187 DBG_CHKTHIS(SvTreeListBox,0);
1188 AdjustEntryHeight( rBmp );
1189 pImp->SetExpandedNodeBmp( rBmp, _eMode );
1193 void SvTreeListBox::SetFont( const Font& rFont )
1195 DBG_CHKTHIS(SvTreeListBox,0);
1196 Font aTempFont( rFont );
1197 aTempFont.SetTransparent( TRUE );
1198 Control::SetFont( aTempFont );
1199 AdjustEntryHeight( aTempFont );
1200 // immer Invalidieren, sonst fallen wir
1201 // bei SetEntryHeight auf die Nase
1202 RecalcViewData();
1206 void SvTreeListBox::Paint( const Rectangle& rRect )
1208 DBG_CHKTHIS(SvTreeListBox,0);
1209 SvLBox::Paint( rRect );
1210 if( nTreeFlags & TREEFLAG_RECALCTABS )
1211 SetTabs();
1212 pImp->Paint( rRect );
1215 void SvTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
1217 DBG_CHKTHIS(SvTreeListBox,0);
1218 pImp->MouseButtonDown( rMEvt );
1221 void SvTreeListBox::MouseButtonUp( const MouseEvent& rMEvt )
1223 DBG_CHKTHIS(SvTreeListBox,0);
1224 pImp->MouseButtonUp( rMEvt );
1227 void SvTreeListBox::MouseMove( const MouseEvent& rMEvt )
1229 DBG_CHKTHIS(SvTreeListBox,0);
1230 pImp->MouseMove( rMEvt );
1234 void SvTreeListBox::SetUpdateMode( BOOL bUpdate )
1236 DBG_CHKTHIS(SvTreeListBox,0);
1237 pImp->SetUpdateMode( bUpdate );
1240 void SvTreeListBox::SetUpdateModeFast( BOOL bUpdate )
1242 DBG_CHKTHIS(SvTreeListBox,0);
1243 pImp->SetUpdateModeFast( bUpdate );
1246 void SvTreeListBox::SetSpaceBetweenEntries( short nOffsLogic )
1248 DBG_CHKTHIS(SvTreeListBox,0);
1249 if( nOffsLogic != nEntryHeightOffs )
1251 nEntryHeight = nEntryHeight - nEntryHeightOffs;
1252 nEntryHeightOffs = (short)nOffsLogic;
1253 nEntryHeight = nEntryHeight + nOffsLogic;
1254 AdjustEntryHeight( GetFont() );
1255 RecalcViewData();
1256 pImp->SetEntryHeight( nEntryHeight );
1260 void SvTreeListBox::SetCursor( SvLBoxEntry* pEntry, BOOL bForceNoSelect )
1262 DBG_CHKTHIS(SvTreeListBox,0);
1263 pImp->SetCursor(pEntry, bForceNoSelect);
1266 void SvTreeListBox::SetCurEntry( SvLBoxEntry* pEntry )
1268 DBG_CHKTHIS(SvTreeListBox,0);
1269 pImp->SetCurEntry( pEntry );
1272 Image SvTreeListBox::GetCollapsedNodeBmp( BmpColorMode _eMode ) const
1274 return pImp->GetCollapsedNodeBmp( _eMode );
1277 Image SvTreeListBox::GetExpandedNodeBmp( BmpColorMode _eMode ) const
1279 return pImp->GetExpandedNodeBmp( _eMode );
1282 Point SvTreeListBox::GetEntryPosition( SvLBoxEntry* pEntry ) const
1284 return pImp->GetEntryPosition( pEntry );
1287 void SvTreeListBox::ShowEntry( SvLBoxEntry* pEntry )
1289 MakeVisible( pEntry );
1292 void SvTreeListBox::MakeVisible( SvLBoxEntry* pEntry )
1294 pImp->MakeVisible(pEntry);
1297 void SvTreeListBox::MakeVisible( SvLBoxEntry* pEntry, BOOL bMoveToTop )
1299 pImp->MakeVisible( pEntry, bMoveToTop );
1302 void SvTreeListBox::ModelHasEntryInvalidated( SvListEntry* pEntry )
1304 DBG_CHKTHIS(SvTreeListBox,0);
1305 // die einzelnen Items des Entries reinitialisieren
1306 SvLBox::ModelHasEntryInvalidated( pEntry );
1307 // repainten
1308 pImp->InvalidateEntry( (SvLBoxEntry*)pEntry );
1311 void SvTreeListBox::EditItemText( SvLBoxEntry* pEntry, SvLBoxString* pItem,
1312 const Selection& rSelection )
1314 DBG_CHKTHIS(SvTreeListBox,0);
1315 DBG_ASSERT(pEntry&&pItem,"EditItemText: Bad params");
1316 if( IsSelected( pEntry ))
1318 pImp->ShowCursor( FALSE );
1319 SvListView::Select( pEntry, FALSE );
1320 PaintEntry( pEntry );
1321 SvListView::Select( pEntry, TRUE );
1322 pImp->ShowCursor( TRUE );
1324 pEdEntry = pEntry;
1325 pEdItem = pItem;
1326 SvLBoxTab* pTab = GetTab( pEntry, pItem );
1327 DBG_ASSERT(pTab,"EditItemText:Tab not found");
1329 Size aItemSize( pItem->GetSize(this, pEntry) );
1330 Point aPos = GetEntryPosition( pEntry );
1331 aPos.Y() += ( nEntryHeight - aItemSize.Height() ) / 2;
1332 aPos.X() = GetTabPos( pEntry, pTab );
1333 long nOutputWidth = pImp->GetOutputSize().Width();
1334 Size aSize( nOutputWidth - aPos.X(), aItemSize.Height() );
1335 USHORT nPos = aTabs.GetPos( pTab );
1336 if( nPos+1 < aTabs.Count() )
1338 SvLBoxTab* pRightTab = (SvLBoxTab*)aTabs.GetObject( nPos + 1 );
1339 long nRight = GetTabPos( pEntry, pRightTab );
1340 if( nRight <= nOutputWidth )
1341 aSize.Width() = nRight - aPos.X();
1343 Point aOrigin( GetMapMode().GetOrigin() );
1344 aPos += aOrigin; // in Win-Koord umrechnen
1345 aSize.Width() -= aOrigin.X();
1346 Rectangle aRect( aPos, aSize );
1347 #ifdef OS2
1348 // Platz lassen fuer WB_BORDER
1349 aRect.Left() -= 2;
1350 aRect.Top() -= 3;
1351 aRect.Bottom() += 3;
1352 #endif
1353 EditText( pItem->GetText(), aRect, rSelection );
1356 void SvTreeListBox::CancelEditing()
1358 DBG_CHKTHIS(SvTreeListBox,0);
1359 SvLBox::CancelTextEditing();
1362 void SvTreeListBox::EditEntry( SvLBoxEntry* pEntry )
1364 pImp->aEditClickPos = Point( -1, -1 );
1365 ImplEditEntry( pEntry );
1368 void SvTreeListBox::ImplEditEntry( SvLBoxEntry* pEntry )
1370 DBG_CHKTHIS(SvTreeListBox,0);
1371 if( IsEditingActive() )
1372 EndEditing();
1373 if( !pEntry )
1374 pEntry = GetCurEntry();
1375 if( pEntry )
1377 long nClickX = pImp->aEditClickPos.X();
1378 bool bIsMouseTriggered = nClickX >= 0;
1380 SvLBoxString* pItem = NULL;
1381 USHORT nCount = pEntry->ItemCount();
1382 for( USHORT i = 0 ; i < nCount ; i++ )
1384 SvLBoxItem* pTmpItem = pEntry->GetItem( i );
1385 if( pTmpItem->IsA() != SV_ITEM_ID_LBOXSTRING )
1386 continue;
1388 SvLBoxTab* pTab = GetTab( pEntry, pTmpItem );
1389 long nTabPos = pTab->GetPos();
1390 long nNextTabPos = -1;
1391 if( i < nCount - 1 )
1393 SvLBoxItem* pNextItem = pEntry->GetItem( i + 1 );
1394 SvLBoxTab* pNextTab = GetTab( pEntry, pNextItem );
1395 nNextTabPos = pNextTab->GetPos();
1398 if( pTab && pTab->IsEditable() )
1400 if( !bIsMouseTriggered || (nClickX > nTabPos && (nNextTabPos == -1 || nClickX < nNextTabPos ) ) )
1402 pItem = static_cast<SvLBoxString*>( pTmpItem );
1403 break;
1408 Selection aSel( SELECTION_MIN, SELECTION_MAX );
1409 if( pItem && EditingEntry( pEntry, aSel ) )
1411 SelectAll( FALSE );
1412 MakeVisible( pEntry );
1413 EditItemText( pEntry, pItem, aSel );
1418 sal_Bool SvTreeListBox::AreChildrenTransient() const
1420 return pImp->AreChildrenTransient();
1423 void SvTreeListBox::SetChildrenNotTransient()
1425 pImp->SetChildrenNotTransient();
1428 void SvTreeListBox::EditedText( const XubString& rStr )
1431 DBG_CHKTHIS(SvTreeListBox,0);
1432 if(pEdEntry) // we have to check if this entry is null that means that it is removed while editing
1434 Point aPos = GetEntryPosition( pEdEntry );
1435 if( EditedEntry( pEdEntry, rStr ) )
1437 ((SvLBoxString*)pEdItem)->SetText( pEdEntry, rStr );
1438 pModel->InvalidateEntry( pEdEntry );
1440 //if( GetSelectionMode() == SINGLE_SELECTION )
1442 if( GetSelectionCount() == 0 )
1443 Select( pEdEntry );
1444 if( GetSelectionMode() == MULTIPLE_SELECTION && !GetCurEntry() )
1445 SetCurEntry( pEdEntry );
1450 void SvTreeListBox::EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
1451 const Point& )
1453 DBG_CHKTHIS(SvTreeListBox,0);
1454 if( IsEditingActive() )
1455 EndEditing();
1456 if( pItem->IsA() == SV_ITEM_ID_LBOXSTRING )
1458 Selection aSel( SELECTION_MIN, SELECTION_MAX );
1459 if( EditingEntry( pEntry, aSel ) )
1461 SelectAll( FALSE );
1462 EditItemText( pEntry, (SvLBoxString*)pItem, aSel );
1469 SvLBoxEntry* SvTreeListBox::GetDropTarget( const Point& rPos )
1471 DBG_CHKTHIS(SvTreeListBox,0);
1472 // Scrollen
1473 if( rPos.Y() < 12 )
1475 SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, FALSE );
1476 ScrollOutputArea( +1 );
1478 else
1480 Size aSize( pImp->GetOutputSize() );
1481 if( rPos.Y() > aSize.Height() - 12 )
1483 SvLBox::ImplShowTargetEmphasis( SvLBox::pTargetEntry, FALSE );
1484 ScrollOutputArea( -1 );
1488 SvLBoxEntry* pTarget = pImp->GetEntry( rPos );
1489 // bei Droppen in leere Flaeche -> den letzten Eintrag nehmen
1490 if( !pTarget )
1491 return (SvLBoxEntry*)LastVisible();
1492 else if( (GetDragDropMode() & SV_DRAGDROP_ENABLE_TOP) &&
1493 pTarget == First() && rPos.Y() < 6 )
1494 return 0;
1496 return pTarget;
1500 SvLBoxEntry* SvTreeListBox::GetEntry( const Point& rPos, BOOL bHit ) const
1502 DBG_CHKTHIS(SvTreeListBox,0);
1503 SvLBoxEntry* pEntry = pImp->GetEntry( rPos );
1504 if( pEntry && bHit )
1506 long nLine = pImp->GetEntryLine( pEntry );
1507 if( !(pImp->EntryReallyHit( pEntry, rPos, nLine)) )
1508 return 0;
1510 return pEntry;
1513 SvLBoxEntry* SvTreeListBox::GetCurEntry() const
1515 DBG_CHKTHIS(SvTreeListBox,0);
1516 return pImp->GetCurEntry();
1519 void SvTreeListBox::SetWindowBits( WinBits nWinStyle )
1521 DBG_CHKTHIS(SvTreeListBox,0);
1522 nWindowStyle = nWinStyle;
1523 nTreeFlags |= TREEFLAG_RECALCTABS;
1524 if( nWinStyle & WB_SORT )
1526 GetModel()->SetSortMode( SortAscending );
1527 GetModel()->SetCompareHdl( LINK(this,SvTreeListBox,DefaultCompare));
1529 else
1531 GetModel()->SetSortMode( SortNone );
1532 GetModel()->SetCompareHdl( Link() );
1534 #ifdef OS2
1535 nWinStyle |= WB_VSCROLL;
1536 #endif
1537 pImp->SetWindowBits( nWinStyle );
1538 pImp->Resize();
1539 Invalidate();
1542 void SvTreeListBox::PaintEntry( SvLBoxEntry* pEntry )
1544 DBG_CHKTHIS(SvTreeListBox,0);
1545 DBG_ASSERT(pEntry,"PaintEntry:No Entry");
1546 if( pEntry )
1547 pImp->PaintEntry( pEntry );
1550 void SvTreeListBox::InvalidateEntry( SvLBoxEntry* pEntry )
1552 DBG_CHKTHIS(SvTreeListBox,0);
1553 DBG_ASSERT(pEntry,"InvalidateEntry:No Entry");
1554 if( pEntry )
1556 GetModel()->InvalidateEntry( pEntry );
1557 // pImp->InvalidateEntry( pEntry );
1562 long SvTreeListBox::PaintEntry(SvLBoxEntry* pEntry,long nLine,USHORT nTabFlags)
1564 return PaintEntry1(pEntry,nLine,nTabFlags);
1567 #define SV_TAB_BORDER 8
1569 long SvTreeListBox::PaintEntry1(SvLBoxEntry* pEntry,long nLine,USHORT nTabFlags,
1570 BOOL bHasClipRegion )
1572 DBG_CHKTHIS(SvTreeListBox,0);
1574 Rectangle aRect; // multi purpose
1576 BOOL bHorSBar = pImp->HasHorScrollBar();
1577 PreparePaint( pEntry );
1579 // #97680# ------------------
1580 pImp->UpdateContextBmpWidthMax( pEntry );
1582 if( nTreeFlags & TREEFLAG_RECALCTABS )
1583 SetTabs();
1585 short nTempEntryHeight = GetEntryHeight();
1586 long nWidth = pImp->GetOutputSize().Width();
1588 // wurde innerhalb des PreparePaints die horizontale ScrollBar
1589 // angeschaltet? Wenn ja, muss die ClipRegion neu gesetzt werden
1590 if( !bHorSBar && pImp->HasHorScrollBar() )
1591 SetClipRegion( Region(pImp->GetClipRegionRect()) );
1593 Point aEntryPos( GetMapMode().GetOrigin() );
1594 aEntryPos.X() *= -1; // Umrechnung Dokumentkoord.
1595 long nMaxRight = nWidth + aEntryPos.X() - 1;
1597 Color aBackupTextColor( GetTextColor() );
1598 Font aBackupFont( GetFont() );
1599 Color aBackupColor = GetFillColor();
1601 bool bCurFontIsSel = false;
1602 BOOL bInUse = pEntry->HasInUseEmphasis();
1603 // wenn eine ClipRegion von aussen gesetzt wird, dann
1604 // diese nicht zuruecksetzen
1605 BOOL bResetClipRegion = !bHasClipRegion;
1606 BOOL bHideSelection = ((nWindowStyle & WB_HIDESELECTION) && !HasFocus())!=0;
1607 const StyleSettings& rSettings = GetSettings().GetStyleSettings();
1609 Font aHighlightFont( GetFont() );
1610 const Color aHighlightTextColor( rSettings.GetHighlightTextColor() );
1611 aHighlightFont.SetColor( aHighlightTextColor );
1613 Size aRectSize( 0, nTempEntryHeight );
1615 if( !bHasClipRegion && nWindowStyle & WB_HSCROLL )
1617 SetClipRegion( Region(pImp->GetClipRegionRect()) );
1618 bHasClipRegion = TRUE;
1621 SvViewDataEntry* pViewDataEntry = GetViewDataEntry( pEntry );
1623 USHORT nTabCount = aTabs.Count();
1624 USHORT nItemCount = pEntry->ItemCount();
1625 USHORT nCurTab = 0;
1626 USHORT nCurItem = 0;
1628 while( nCurTab < nTabCount && nCurItem < nItemCount )
1630 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( nCurTab );
1631 USHORT nNextTab = nCurTab + 1;
1632 SvLBoxTab* pNextTab = nNextTab < nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextTab) : 0;
1633 SvLBoxItem* pItem = nCurItem < nItemCount ? pEntry->GetItem(nCurItem) : 0;
1635 USHORT nFlags = pTab->nFlags;
1636 Size aSize( pItem->GetSize( pViewDataEntry, nCurItem ));
1637 long nTabPos = GetTabPos( pEntry, pTab );
1639 long nNextTabPos;
1640 if( pNextTab )
1641 nNextTabPos = GetTabPos( pEntry, pNextTab );
1642 else
1644 nNextTabPos = nMaxRight;
1645 if( nTabPos > nMaxRight )
1646 nNextTabPos += 50;
1649 long nX;
1650 if( pTab->nFlags & SV_LBOXTAB_ADJUST_RIGHT )
1651 //verhindern, das rechter Rand von der Tabtrennung abgeschnitten wird
1652 nX = nTabPos + pTab->CalcOffset(aSize.Width(), (nNextTabPos-SV_TAB_BORDER-1) -nTabPos);
1653 else
1654 nX = nTabPos + pTab->CalcOffset(aSize.Width(), nNextTabPos-nTabPos);
1656 if( nFlags & nTabFlags )
1658 if( !bHasClipRegion && nX + aSize.Width() >= nMaxRight )
1660 SetClipRegion( Region(pImp->GetClipRegionRect()) );
1661 bHasClipRegion = TRUE;
1663 aEntryPos.X() = nX;
1664 aEntryPos.Y() = nLine;
1666 // Hintergrund-Muster & Farbe bestimmen
1668 Wallpaper aWallpaper = GetBackground();
1670 int bSelTab = nFlags & SV_LBOXTAB_SHOW_SELECTION;
1671 USHORT nItemType = pItem->IsA();
1673 if ( pViewDataEntry->IsSelected() && bSelTab && !pViewDataEntry->IsCursored() )
1675 Color aNewWallColor = rSettings.GetHighlightColor();
1676 if ( !bInUse || nItemType != SV_ITEM_ID_LBOXCONTEXTBMP )
1678 // if the face color is bright then the deactive color is also bright
1679 // -> so you can't see any deactive selection
1680 if ( bHideSelection && !rSettings.GetFaceColor().IsBright() &&
1681 aWallpaper.GetColor().IsBright() != rSettings.GetDeactiveColor().IsBright() )
1682 aNewWallColor = rSettings.GetDeactiveColor();
1683 // set font color to highlight
1684 if ( !bCurFontIsSel )
1686 SetTextColor( aHighlightTextColor );
1687 SetFont( aHighlightFont );
1688 bCurFontIsSel = true;
1691 aWallpaper.SetColor( aNewWallColor );
1693 else // keine Selektion
1695 if( bInUse && nItemType == SV_ITEM_ID_LBOXCONTEXTBMP )
1696 aWallpaper.SetColor( rSettings.GetFieldColor() );
1697 else if( bCurFontIsSel )
1699 bCurFontIsSel = false;
1700 SetTextColor( aBackupTextColor );
1701 SetFont( aBackupFont );
1705 // Hintergrund zeichnen
1706 if( !(nTreeFlags & TREEFLAG_USESEL))
1708 // nur den Bereich zeichnen, den das Item einnimmt
1709 aRectSize.Width() = aSize.Width();
1710 aRect.SetPos( aEntryPos );
1711 aRect.SetSize( aRectSize );
1713 else
1715 // vom aktuellen bis zum naechsten Tab zeichnen
1716 if( nCurTab != 0 )
1717 aRect.Left() = nTabPos;
1718 else
1719 // beim nullten Tab immer ab Spalte 0 zeichnen
1720 // (sonst Probleme bei Tabs mit Zentrierung)
1721 aRect.Left() = 0;
1722 aRect.Top() = nLine;
1723 aRect.Bottom() = nLine + nTempEntryHeight - 1;
1724 if( pNextTab )
1726 long nRight;
1727 nRight = GetTabPos(pEntry,pNextTab)-1;
1728 if( nRight > nMaxRight )
1729 nRight = nMaxRight;
1730 aRect.Right() = nRight;
1732 else
1733 aRect.Right() = nMaxRight;
1735 // bei anwenderdefinierter Selektion, die bei einer Tabposition
1736 // groesser 0 beginnt den Hintergrund des 0.ten Items nicht
1737 // fuellen, da sonst z.B. TablistBoxen mit Linien nicht
1738 // realisiert werden koennen.
1739 if( !(nCurTab==0 && (nTreeFlags & TREEFLAG_USESEL) && nFirstSelTab) )
1741 SetFillColor( aWallpaper.GetColor() );
1742 // Bei kleinen hor. Resizes tritt dieser Fall auf
1743 if( aRect.Left() < aRect.Right() )
1744 DrawRect( aRect );
1746 // Item zeichnen
1747 // vertikal zentrieren
1748 aEntryPos.Y() += ( nTempEntryHeight - aSize.Height() ) / 2;
1749 pItem->Paint( aEntryPos, *this, pViewDataEntry->GetFlags(), pEntry );
1751 // Trennungslinie zwischen Tabs
1752 if( pNextTab && pItem->IsA() == SV_ITEM_ID_LBOXSTRING &&
1753 // nicht am rechten Fensterrand!
1754 aRect.Right() < nMaxRight )
1756 aRect.Left() = aRect.Right() - SV_TAB_BORDER;
1757 DrawRect( aRect );
1760 SetFillColor( aBackupColor );
1762 nCurItem++;
1763 nCurTab++;
1765 if( pViewDataEntry->IsCursored() && !HasFocus() )
1767 // Cursor-Emphasis
1768 SetFillColor();
1769 Color aOldLineColor = GetLineColor();
1770 SetLineColor( Color( COL_BLACK ) );
1771 aRect = GetFocusRect( pEntry, nLine );
1772 aRect.Top()++;
1773 aRect.Bottom()--;
1774 DrawRect( aRect );
1775 SetLineColor( aOldLineColor );
1776 SetFillColor( aBackupColor );
1779 if( bCurFontIsSel )
1781 SetTextColor( aBackupTextColor );
1782 SetFont( aBackupFont );
1785 USHORT nFirstDynTabPos;
1786 SvLBoxTab* pFirstDynamicTab = GetFirstDynamicTab( nFirstDynTabPos );
1787 long nDynTabPos = GetTabPos( pEntry, pFirstDynamicTab );
1788 nDynTabPos += pImp->nNodeBmpTabDistance;
1789 nDynTabPos += pImp->nNodeBmpWidth / 2;
1790 nDynTabPos += 4; // 4 Pixel Reserve, damit die Node-Bitmap
1791 // nicht zu nah am naechsten Tab steht
1793 if( (!(pEntry->GetFlags() & SV_ENTRYFLAG_NO_NODEBMP)) &&
1794 (nWindowStyle & WB_HASBUTTONS) && pFirstDynamicTab &&
1795 ( pEntry->HasChilds() || pEntry->HasChildsOnDemand() ) )
1797 // ersten festen Tab suchen, und pruefen ob die Node-Bitmap
1798 // in ihn hineinragt
1799 USHORT nNextTab = nFirstDynTabPos;
1800 SvLBoxTab* pNextTab;
1803 nNextTab++;
1804 pNextTab = nNextTab < nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextTab) : 0;
1805 } while( pNextTab && pNextTab->IsDynamic() );
1807 if( !pNextTab || (GetTabPos( pEntry, pNextTab ) > nDynTabPos) )
1809 if((nWindowStyle & WB_HASBUTTONSATROOT) || pModel->GetDepth(pEntry) > 0)
1811 Point aPos( GetTabPos(pEntry,pFirstDynamicTab), nLine );
1812 aPos.X() += pImp->nNodeBmpTabDistance;
1814 const Image* pImg = 0;
1815 BmpColorMode eBitmapMode = BMP_COLOR_NORMAL;
1816 if ( GetDisplayBackground().GetColor().IsDark() )
1817 eBitmapMode = BMP_COLOR_HIGHCONTRAST;
1819 if( IsExpanded(pEntry) )
1820 pImg = &pImp->GetExpandedNodeBmp( eBitmapMode );
1821 else
1823 if( (!pEntry->HasChilds()) && pEntry->HasChildsOnDemand() &&
1824 (!(pEntry->GetFlags() & SV_ENTRYFLAG_HAD_CHILDREN)) &&
1825 pImp->GetDontKnowNodeBmp().GetSizePixel().Width() )
1826 pImg = &pImp->GetDontKnowNodeBmp( eBitmapMode );
1827 else
1828 pImg = &pImp->GetCollapsedNodeBmp( eBitmapMode );
1830 aPos.Y() += (nTempEntryHeight - pImg->GetSizePixel().Height()) / 2;
1832 USHORT nStyle = 0;
1833 if ( !IsEnabled() )
1834 nStyle |= IMAGE_DRAW_DISABLE;
1836 //native
1837 BOOL bNativeOK = FALSE;
1838 if ( IsNativeControlSupported( CTRL_LISTNODE, PART_ENTIRE_CONTROL) )
1840 ImplControlValue aControlValue;
1841 Region aCtrlRegion( Rectangle(aPos, pImg->GetSizePixel() ) );
1842 ControlState nState = 0;
1844 if ( IsEnabled() ) nState |= CTRL_STATE_ENABLED;
1846 if ( IsExpanded(pEntry) )
1847 aControlValue.setTristateVal( BUTTONVALUE_ON );//expanded node
1848 else
1850 if( (!pEntry->HasChilds()) && pEntry->HasChildsOnDemand() &&
1851 (!(pEntry->GetFlags() & SV_ENTRYFLAG_HAD_CHILDREN)) &&
1852 pImp->GetDontKnowNodeBmp().GetSizePixel().Width() )
1853 aControlValue.setTristateVal( BUTTONVALUE_DONTKNOW );//dont know
1854 else
1855 aControlValue.setTristateVal( BUTTONVALUE_OFF );//collapsed node
1858 bNativeOK = DrawNativeControl( CTRL_LISTNODE, PART_ENTIRE_CONTROL,
1859 aCtrlRegion, nState, aControlValue, rtl::OUString() );
1862 if( !bNativeOK) {
1863 //non native
1864 DrawImage( aPos, *pImg ,nStyle);
1871 if( bHasClipRegion && bResetClipRegion )
1872 SetClipRegion();
1873 return 0; // nRowLen;
1876 void SvTreeListBox::PreparePaint( SvLBoxEntry* )
1880 Rectangle SvTreeListBox::GetFocusRect( SvLBoxEntry* pEntry, long nLine )
1882 DBG_CHKTHIS(SvTreeListBox,0);
1883 Size aSize;
1884 Rectangle aRect;
1885 aRect.Top() = nLine;
1886 aSize.Height() = GetEntryHeight();
1888 long nRealWidth = pImp->GetOutputSize().Width();
1889 nRealWidth -= GetMapMode().GetOrigin().X();
1891 USHORT nCurTab;
1892 SvLBoxTab* pTab = GetFirstTab( SV_LBOXTAB_SHOW_SELECTION, nCurTab );
1893 long nTabPos = 0;
1894 if( pTab )
1895 nTabPos = GetTabPos( pEntry, pTab );
1896 long nNextTabPos;
1897 if( pTab && nCurTab < aTabs.Count() - 1 )
1899 SvLBoxTab* pNextTab = (SvLBoxTab*)aTabs.GetObject( nCurTab + 1 );
1900 nNextTabPos = GetTabPos( pEntry, pNextTab );
1902 else
1904 nNextTabPos = nRealWidth;
1905 if( nTabPos > nRealWidth )
1906 nNextTabPos += 50;
1909 BOOL bUserSelection = (BOOL)( nTreeFlags & TREEFLAG_USESEL ) != 0;
1910 if( !bUserSelection )
1912 if( pTab && nCurTab < pEntry->ItemCount() )
1914 SvLBoxItem* pItem = pEntry->GetItem( nCurTab );
1915 aSize.Width() = pItem->GetSize( this, pEntry ).Width();
1916 if( !aSize.Width() )
1917 aSize.Width() = 15;
1918 long nX = nTabPos; //GetTabPos( pEntry, pTab );
1919 // Ausrichtung
1920 nX += pTab->CalcOffset( aSize.Width(), nNextTabPos - nTabPos );
1921 aRect.Left() = nX;
1922 // damit erster & letzter Buchstabe nicht angeknabbert werden
1923 aRect.SetSize( aSize );
1924 if( aRect.Left() > 0 )
1925 aRect.Left()--;
1926 aRect.Right()++;
1929 else
1931 // wenn erster SelTab != 0, dann muessen wir auch rechnen
1932 if( nFocusWidth == -1 || nFirstSelTab )
1934 USHORT nLastTab;
1935 SvLBoxTab* pLastTab = GetLastTab(SV_LBOXTAB_SHOW_SELECTION,nLastTab);
1936 nLastTab++;
1937 if( nLastTab < aTabs.Count() ) // gibts noch einen ?
1938 pLastTab = (SvLBoxTab*)aTabs.GetObject( nLastTab );
1939 else
1940 pLastTab = 0; // ueber gesamte Breite selektieren
1941 aSize.Width() = pLastTab ? pLastTab->GetPos() : 0x0fffffff;
1942 nFocusWidth = (short)aSize.Width();
1943 if( pTab )
1944 nFocusWidth = nFocusWidth - (short)nTabPos; //pTab->GetPos();
1946 else
1948 aSize.Width() = nFocusWidth;
1949 if( pTab )
1951 if( nCurTab )
1952 aSize.Width() += nTabPos;
1953 else
1954 aSize.Width() += pTab->GetPos(); // Tab0 immer ab ganz links
1957 // wenn Sel. beim nullten Tab anfaengt, dann ab Spalte 0 sel. zeichnen
1958 if( nCurTab != 0 )
1960 aRect.Left() = nTabPos;
1961 aSize.Width() -= nTabPos;
1963 aRect.SetSize( aSize );
1965 // rechten Rand anpassen wg. Clipping
1966 if( aRect.Right() >= nRealWidth )
1968 aRect.Right() = nRealWidth-1;
1969 nFocusWidth = (short)aRect.GetWidth();
1971 return aRect;
1975 long SvTreeListBox::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab)
1977 DBG_CHKTHIS(SvTreeListBox,0);
1978 DBG_ASSERT(pTab,"No Tab");
1979 long nPos = pTab->GetPos();
1980 if( pTab->IsDynamic() )
1982 USHORT nDepth = pModel->GetDepth( pEntry );
1983 nDepth = nDepth * (USHORT)nIndent;
1984 nPos += (long)nDepth;
1986 return nPos;
1989 SvLBoxItem* SvTreeListBox::GetItem_Impl( SvLBoxEntry* pEntry, long nX,
1990 SvLBoxTab** ppTab, USHORT nEmptyWidth )
1992 DBG_CHKTHIS(SvTreeListBox,0);
1993 SvLBoxItem* pItemClicked = 0;
1994 USHORT nTabCount = aTabs.Count();
1995 USHORT nItemCount = pEntry->ItemCount();
1996 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0);
1997 SvLBoxItem* pItem = pEntry->GetItem(0);
1998 USHORT nNextItem = 1;
1999 nX -= GetMapMode().GetOrigin().X();
2000 long nRealWidth = pImp->GetOutputSize().Width();
2001 nRealWidth -= GetMapMode().GetOrigin().X();
2003 while( 1 )
2005 SvLBoxTab* pNextTab=nNextItem<nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextItem) : 0;
2006 long nStart = GetTabPos( pEntry, pTab );
2008 long nNextTabPos;
2009 if( pNextTab )
2010 nNextTabPos = GetTabPos( pEntry, pNextTab );
2011 else
2013 nNextTabPos = nRealWidth;
2014 if( nStart > nRealWidth )
2015 nNextTabPos += 50;
2018 Size aItemSize( pItem->GetSize(this, pEntry));
2019 nStart += pTab->CalcOffset( aItemSize.Width(), nNextTabPos - nStart );
2020 long nLen = aItemSize.Width();
2021 if( pNextTab )
2023 long nTabWidth = GetTabPos( pEntry, pNextTab ) - nStart;
2024 if( nTabWidth < nLen )
2025 nLen = nTabWidth;
2028 if( !nLen )
2029 nLen = nEmptyWidth;
2031 if( nX >= nStart && nX < (nStart+nLen ) )
2033 pItemClicked = pItem;
2034 if( ppTab )
2036 *ppTab = pTab;
2037 break;
2040 if( nNextItem >= nItemCount || nNextItem >= nTabCount)
2041 break;
2042 pTab = (SvLBoxTab*)aTabs.GetObject( nNextItem );
2043 pItem = pEntry->GetItem( nNextItem );
2044 nNextItem++;
2046 return pItemClicked;
2049 SvLBoxItem* SvTreeListBox::GetItem(SvLBoxEntry* pEntry,long nX,SvLBoxTab** ppTab)
2051 return GetItem_Impl( pEntry, nX, ppTab, 0 );
2054 SvLBoxItem* SvTreeListBox::GetItem(SvLBoxEntry* pEntry,long nX )
2056 DBG_CHKTHIS(SvTreeListBox,0);
2057 SvLBoxTab* pDummyTab;
2058 return GetItem_Impl( pEntry, nX, &pDummyTab, 0 );
2061 SvLBoxItem* SvTreeListBox::GetFirstDynamicItem( SvLBoxEntry* pEntry )
2063 DBG_CHKTHIS(SvTreeListBox,0);
2065 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0);
2066 SvLBoxItem* pItem = pEntry->GetItem(0);
2067 USHORT nTabCount = aTabs.Count();
2069 USHORT nNext = 1;
2070 while ( !pTab->IsDynamic() && nNext < nTabCount )
2072 pItem = pEntry->GetItem( nNext );
2073 pTab = (SvLBoxTab*)aTabs.GetObject( nNext );
2074 nNext++;
2076 return pItem;
2079 void SvTreeListBox::AddTab(long nTabPos,USHORT nFlags,void* pUserData )
2081 DBG_CHKTHIS(SvTreeListBox,0);
2082 nFocusWidth = -1;
2083 SvLBoxTab* pTab = new SvLBoxTab( nTabPos, nFlags );
2084 pTab->SetUserData( pUserData );
2085 aTabs.Insert( pTab, aTabs.Count() );
2086 if( nTreeFlags & TREEFLAG_USESEL )
2088 USHORT nPos = aTabs.Count() - 1;
2089 if( nPos >= nFirstSelTab && nPos <= nLastSelTab )
2090 pTab->nFlags |= SV_LBOXTAB_SHOW_SELECTION;
2091 else
2092 // String-Items werden normalerweise immer selektiert
2093 // deshalb explizit ausschalten
2094 pTab->nFlags &= ~SV_LBOXTAB_SHOW_SELECTION;
2100 SvLBoxTab* SvTreeListBox::GetFirstDynamicTab( USHORT& rPos ) const
2102 DBG_CHKTHIS(SvTreeListBox,0);
2103 USHORT nCurTab = 0;
2104 USHORT nTabCount = aTabs.Count();
2105 while( nCurTab < nTabCount )
2107 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(nCurTab);
2108 if( pTab->nFlags & SV_LBOXTAB_DYNAMIC )
2110 rPos = nCurTab;
2111 return pTab;
2113 nCurTab++;
2115 return 0;
2118 SvLBoxTab* SvTreeListBox::GetFirstDynamicTab() const
2120 USHORT nDummy;
2121 return GetFirstDynamicTab( nDummy );
2124 SvLBoxTab* SvTreeListBox::GetTab( SvLBoxEntry* pEntry, SvLBoxItem* pItem) const
2126 DBG_CHKTHIS(SvTreeListBox,0);
2127 USHORT nPos = pEntry->GetPos( pItem );
2128 return (SvLBoxTab*)aTabs.GetObject( nPos );
2131 void SvTreeListBox::ClearTabList()
2133 DBG_CHKTHIS(SvTreeListBox,0);
2134 USHORT nTabCount = aTabs.Count();
2135 while( nTabCount )
2137 nTabCount--;
2138 SvLBoxTab* pDelTab = (SvLBoxTab*)aTabs.GetObject( nTabCount );
2139 delete pDelTab;
2141 aTabs.Remove(0,aTabs.Count());
2145 Size SvTreeListBox::GetOutputSizePixel() const
2147 DBG_CHKTHIS(SvTreeListBox,0);
2148 Size aSize = pImp->GetOutputSize();
2149 return aSize;
2152 void SvTreeListBox::NotifyBeginScroll()
2154 DBG_CHKTHIS(SvTreeListBox,0);
2157 void SvTreeListBox::NotifyEndScroll()
2159 DBG_CHKTHIS(SvTreeListBox,0);
2162 void SvTreeListBox::NotifyScrolling( long )
2164 DBG_CHKTHIS(SvTreeListBox,0);
2167 void SvTreeListBox::NotifyScrolled()
2169 DBG_CHKTHIS(SvTreeListBox,0);
2170 aScrolledHdl.Call( this );
2173 void SvTreeListBox::NotifyInvalidating()
2175 DBG_CHKTHIS(SvTreeListBox,0);
2178 void SvTreeListBox::Invalidate( USHORT nInvalidateFlags )
2180 DBG_CHKTHIS(SvTreeListBox,0);
2181 if( nFocusWidth == -1 )
2182 // damit Control nicht nach dem Paint ein falsches FocusRect anzeigt
2183 pImp->RecalcFocusRect();
2184 NotifyInvalidating();
2185 SvLBox::Invalidate( nInvalidateFlags );
2186 pImp->Invalidate();
2189 void SvTreeListBox::Invalidate( const Rectangle& rRect, USHORT nInvalidateFlags )
2191 DBG_CHKTHIS(SvTreeListBox,0);
2192 if( nFocusWidth == -1 )
2193 // damit Control nicht nach dem Paint ein falsches FocusRect anzeigt
2194 pImp->RecalcFocusRect();
2195 NotifyInvalidating();
2196 SvLBox::Invalidate( rRect, nInvalidateFlags );
2200 void SvTreeListBox::SetHighlightRange( USHORT nStart, USHORT nEnd)
2202 DBG_CHKTHIS(SvTreeListBox,0);
2204 USHORT nTemp;
2205 nTreeFlags |= TREEFLAG_USESEL;
2206 if( nStart > nEnd )
2208 nTemp = nStart;
2209 nStart = nEnd;
2210 nEnd = nTemp;
2212 // alle Tabs markieren, die im Bereich liegen
2213 nTreeFlags |= TREEFLAG_RECALCTABS;
2214 nFirstSelTab = nStart;
2215 nLastSelTab = nEnd;
2216 pImp->RecalcFocusRect();
2219 void SvTreeListBox::RemoveHighlightRange()
2221 DBG_CHKTHIS(SvTreeListBox,0);
2222 nTreeFlags &= (~TREEFLAG_USESEL);
2223 if( IsUpdateMode() )
2224 Invalidate();
2227 ULONG SvTreeListBox::GetAscInsertionPos(SvLBoxEntry*,SvLBoxEntry*)
2229 return LIST_APPEND;
2232 ULONG SvTreeListBox::GetDescInsertionPos(SvLBoxEntry*,SvLBoxEntry*)
2234 DBG_CHKTHIS(SvTreeListBox,0);
2235 return LIST_APPEND;
2238 Region SvTreeListBox::GetDragRegion() const
2240 DBG_CHKTHIS(SvTreeListBox,0);
2241 Rectangle aRect;
2242 SvLBoxEntry* pEntry = GetCurEntry();
2243 if( pEntry )
2245 Point aPos = GetEntryPosition( pEntry );
2246 aRect = ((SvTreeListBox*)this)->GetFocusRect( pEntry, aPos.Y() );
2248 Region aRegion( aRect );
2249 return aRegion;
2253 void SvTreeListBox::Command( const CommandEvent& rCEvt )
2255 DBG_CHKTHIS(SvTreeListBox,0);
2256 pImp->Command( rCEvt );
2260 void SvTreeListBox::RemoveParentKeepChilds( SvLBoxEntry* pParent )
2262 DBG_CHKTHIS(SvTreeListBox,0);
2263 DBG_ASSERT(pParent,"RemoveParentKeepChilds:No Parent");
2264 SvLBoxEntry* pNewParent = GetParent( pParent );
2265 if( pParent->HasChilds())
2267 SvLBoxEntry* pChild = FirstChild( pParent );
2268 while( pChild )
2270 pModel->Move( pChild, pNewParent, LIST_APPEND );
2271 pChild = FirstChild( pParent );
2274 pModel->Remove( pParent );
2277 SvLBoxTab* SvTreeListBox::GetFirstTab( USHORT nFlagMask, USHORT& rPos )
2279 USHORT nTabCount = aTabs.Count();
2280 for( USHORT nPos = 0; nPos < nTabCount; nPos++ )
2282 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( nPos );
2283 if( (pTab->nFlags & nFlagMask) )
2285 rPos = nPos;
2286 return pTab;
2289 rPos = 0xffff;
2290 return 0;
2293 SvLBoxTab* SvTreeListBox::GetLastTab( USHORT nFlagMask, USHORT& rTabPos )
2295 short nTabCount = (short)aTabs.Count();
2296 if( nTabCount )
2298 for( short nPos = nTabCount-1; nPos >= 0; nPos-- )
2300 SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( (USHORT)nPos );
2301 if( (pTab->nFlags & nFlagMask) )
2303 rTabPos = (USHORT)nPos;
2304 return pTab;
2308 rTabPos = 0xffff;
2309 return 0;
2312 void SvTreeListBox::SetAddMode( BOOL bAdd )
2314 pImp->SetAddMode( bAdd );
2317 BOOL SvTreeListBox::IsAddMode() const
2319 return pImp->IsAddMode();
2322 void SvTreeListBox::RequestHelp( const HelpEvent& rHEvt )
2324 if( !pImp->RequestHelp( rHEvt ) )
2325 SvLBox::RequestHelp( rHEvt );
2328 void SvTreeListBox::CursorMoved( SvLBoxEntry* )
2332 IMPL_LINK( SvTreeListBox, DefaultCompare, SvSortData*, pData )
2334 SvLBoxEntry* pLeft = (SvLBoxEntry*)(pData->pLeft );
2335 SvLBoxEntry* pRight = (SvLBoxEntry*)(pData->pRight );
2336 String aLeft( ((SvLBoxString*)(pLeft->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText());
2337 String aRight( ((SvLBoxString*)(pRight->GetFirstItem(SV_ITEM_ID_LBOXSTRING)))->GetText());
2338 // #102891# ----------------
2339 pImp->UpdateIntlWrapper();
2340 return pImp->pIntlWrapper->getCaseCollator()->compareString( aLeft, aRight );
2343 void SvTreeListBox::ModelNotification( USHORT nActionId, SvListEntry* pEntry1,
2344 SvListEntry* pEntry2, ULONG nPos )
2346 if( nActionId == LISTACTION_CLEARING )
2347 CancelTextEditing();
2349 SvLBox::ModelNotification( nActionId, pEntry1, pEntry2, nPos );
2350 switch( nActionId )
2352 case LISTACTION_RESORTING:
2353 SetUpdateMode( FALSE );
2354 break;
2356 case LISTACTION_RESORTED:
2357 // nach Sortierung den ersten Eintrag anzeigen, dabei die
2358 // Selektion erhalten.
2359 MakeVisible( (SvLBoxEntry*)pModel->First(), TRUE );
2360 SetUpdateMode( TRUE );
2361 break;
2363 case LISTACTION_CLEARED:
2364 if( IsUpdateMode() )
2365 Update();
2366 break;
2370 // bei Aenderungen SetTabs beruecksichtigen
2371 long SvTreeListBox::GetTextOffset() const
2373 DBG_CHKTHIS(SvTreeListBox,0);
2374 BOOL bHasButtons = (nWindowStyle & WB_HASBUTTONS)!=0;
2375 BOOL bHasButtonsAtRoot = (nWindowStyle & (WB_HASLINESATROOT |
2376 WB_HASBUTTONSATROOT))!=0;
2377 long nStartPos = TAB_STARTPOS;
2378 long nNodeWidthPixel = GetExpandedNodeBmp().GetSizePixel().Width();
2380 long nCheckWidth = 0;
2381 if( nTreeFlags & TREEFLAG_CHKBTN )
2382 nCheckWidth = pCheckButtonData->aBmps[0].GetSizePixel().Width();
2383 long nCheckWidthDIV2 = nCheckWidth / 2;
2385 long nContextWidth = nContextBmpWidthMax;
2386 long nContextWidthDIV2 = nContextWidth / 2;
2388 int nCase = NO_BUTTONS;
2389 if( !(nTreeFlags & TREEFLAG_CHKBTN) )
2391 if( bHasButtons )
2392 nCase = NODE_BUTTONS;
2394 else
2396 if( bHasButtons )
2397 nCase = NODE_AND_CHECK_BUTTONS;
2398 else
2399 nCase = CHECK_BUTTONS;
2402 switch( nCase )
2404 case NO_BUTTONS :
2405 nStartPos += nContextWidthDIV2; // wg. Zentrierung
2406 nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp
2407 if( nContextBmpWidthMax )
2408 nStartPos += 5; // Abstand Context-Bmp - Text
2409 break;
2411 case NODE_BUTTONS :
2412 if( bHasButtonsAtRoot )
2413 nStartPos += ( nIndent + (nNodeWidthPixel/2) );
2414 else
2415 nStartPos += nContextWidthDIV2;
2416 nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp
2417 if( nContextBmpWidthMax )
2418 nStartPos += 5; // Abstand Context-Bmp - Text
2419 break;
2421 case NODE_AND_CHECK_BUTTONS :
2422 if( bHasButtonsAtRoot )
2423 nStartPos += ( nIndent + nNodeWidthPixel );
2424 else
2425 nStartPos += nCheckWidthDIV2;
2426 nStartPos += nCheckWidthDIV2; // rechter Rand des CheckButtons
2427 nStartPos += 3; // Abstand CheckButton Context-Bmp
2428 nStartPos += nContextWidthDIV2; // Mitte der Context-Bmp
2429 nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp
2430 // Abstand setzen nur wenn Bitmaps da
2431 if( nContextBmpWidthMax )
2432 nStartPos += 5; // Abstand Context-Bmp - Text
2433 break;
2435 case CHECK_BUTTONS :
2436 nStartPos += nCheckWidthDIV2;
2437 nStartPos += nCheckWidthDIV2; // rechter Rand CheckButton
2438 nStartPos += 3; // Abstand CheckButton Context-Bmp
2439 nStartPos += nContextWidthDIV2; // Mitte der Context-Bmp
2440 nStartPos += nContextWidthDIV2; // rechter Rand der Context-Bmp
2441 if( nContextBmpWidthMax )
2442 nStartPos += 5; // Abstand Context-Bmp - Text
2443 break;
2445 return nStartPos;
2448 void SvTreeListBox::EndSelection()
2450 pImp->EndSelection();
2453 BOOL SvTreeListBox::IsNodeButton( const Point& rPos ) const
2455 SvLBoxEntry* pEntry = GetEntry( rPos );
2456 if( pEntry )
2457 return pImp->IsNodeButton( rPos, pEntry );
2458 return FALSE;
2461 void SvTreeListBox::RepaintScrollBars() const
2463 ((SvTreeListBox*)this)->pImp->RepaintScrollBars();
2466 ScrollBar *SvTreeListBox::GetVScroll()
2468 return &((SvTreeListBox*)this)->pImp->aVerSBar;
2471 ScrollBar *SvTreeListBox::GetHScroll()
2473 return &((SvTreeListBox*)this)->pImp->aHorSBar;
2476 void SvTreeListBox::EnableAsyncDrag( BOOL b )
2478 pImp->EnableAsyncDrag( b );
2481 SvLBoxEntry* SvTreeListBox::GetFirstEntryInView() const
2483 Point aPos;
2484 return GetEntry( aPos );
2487 SvLBoxEntry* SvTreeListBox::GetNextEntryInView(SvLBoxEntry* pEntry ) const
2489 SvLBoxEntry* pNext = (SvLBoxEntry*)NextVisible( pEntry );
2490 if( pNext )
2492 Point aPos( GetEntryPosition(pNext) );
2493 const Size& rSize = pImp->GetOutputSize();
2494 if( aPos.Y() < 0 || aPos.Y() >= rSize.Height() )
2495 return 0;
2497 return pNext;
2500 void SvTreeListBox::ShowFocusRect( const SvLBoxEntry* pEntry )
2502 pImp->ShowFocusRect( pEntry );
2505 void SvTreeListBox::SetTabBar( TabBar* pTabBar )
2507 pImp->SetTabBar( pTabBar );
2510 void SvTreeListBox::DataChanged( const DataChangedEvent& rDCEvt )
2512 if( (rDCEvt.GetType()==DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
2514 nEntryHeight = 0; // _together_ with TRUE of 1. par (bFont) of InitSettings() a zero-height
2515 // forces complete recalc of heights!
2516 InitSettings( TRUE, TRUE, TRUE );
2517 Invalidate();
2519 else
2520 Control::DataChanged( rDCEvt );
2523 void SvTreeListBox::InitSettings(BOOL bFont,BOOL bForeground,BOOL bBackground)
2525 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
2526 if( bFont )
2528 Font aFont;
2529 aFont = rStyleSettings.GetFieldFont();
2530 aFont.SetColor( rStyleSettings.GetWindowTextColor() );
2531 SetPointFont( aFont );
2532 AdjustEntryHeight( aFont );
2533 RecalcViewData();
2536 if( bForeground || bFont )
2538 SetTextColor( rStyleSettings.GetFieldTextColor() );
2539 SetTextFillColor();
2542 if( bBackground )
2543 SetBackground( rStyleSettings.GetFieldColor() );
2545 // always try to re-create default-SvLBoxButtonData
2546 if( pCheckButtonData && pCheckButtonData->HasDefaultImages() )
2547 pCheckButtonData->SetDefaultImages( this );
2550 BOOL SvTreeListBox::IsCellFocusEnabled() const
2552 return pImp->IsCellFocusEnabled();
2555 bool SvTreeListBox::SetCurrentTabPos( USHORT _nNewPos )
2557 return pImp->SetCurrentTabPos( _nNewPos );
2560 USHORT SvTreeListBox::GetCurrentTabPos() const
2562 return pImp->GetCurrentTabPos();
2565 void SvTreeListBox::InitStartEntry()
2567 if( !pImp->pStartEntry )
2568 pImp->pStartEntry = GetModel()->First();
2571 void SvTreeListBox::CancelPendingEdit()
2573 if( pImp )
2574 pImp->CancelPendingEdit();
2577 PopupMenu* SvTreeListBox::CreateContextMenu( void )
2579 return NULL;
2582 void SvTreeListBox::ExcecuteContextMenuAction( USHORT )
2584 DBG_WARNING( "SvTreeListBox::ExcecuteContextMenuAction(): now there's happening nothing!" );
2587 void SvTreeListBox::EnableContextMenuHandling( void )
2589 DBG_ASSERT( pImp, "-SvTreeListBox::EnableContextMenuHandling(): No implementation!" );
2591 pImp->bContextMenuHandling = TRUE;
2594 void SvTreeListBox::EnableContextMenuHandling( BOOL b )
2596 DBG_ASSERT( pImp, "-SvTreeListBox::EnableContextMenuHandling(): No implementation!" );
2598 pImp->bContextMenuHandling = b;
2601 BOOL SvTreeListBox::IsContextMenuHandlingEnabled( void ) const
2603 DBG_ASSERT( pImp, "-SvTreeListBox::IsContextMenuHandlingEnabled(): No implementation!" );
2605 return pImp->bContextMenuHandling;
2608 void SvTreeListBox::EnableList( bool _bEnable )
2610 // call base class method
2611 Window::Enable( _bEnable != false );
2612 // then paint immediately
2613 Paint( Rectangle( Point(), GetSizePixel() ) );
2616 ::com::sun::star::uno::Reference< XAccessible > SvTreeListBox::CreateAccessible()
2618 Window* pParent = GetAccessibleParentWindow();
2619 DBG_ASSERT( pParent, "SvTreeListBox::CreateAccessible - accessible parent not found" );
2621 ::com::sun::star::uno::Reference< XAccessible > xAccessible;
2622 if ( pParent )
2624 ::com::sun::star::uno::Reference< XAccessible > xAccParent = pParent->GetAccessible();
2625 if ( xAccParent.is() )
2627 // need to be done here to get the vclxwindow later on in the accessbile
2628 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > xTemp(GetComponentInterface());
2629 xAccessible = pImp->m_aFactoryAccess.getFactory().createAccessibleTreeListBox( *this, xAccParent );
2632 return xAccessible;
2635 void SvTreeListBox::FillAccessibleEntryStateSet( SvLBoxEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const
2637 DBG_ASSERT( pEntry, "SvTreeListBox::FillAccessibleEntryStateSet: invalid entry" );
2639 if ( pEntry->HasChildsOnDemand() || pEntry->HasChilds() )
2641 rStateSet.AddState( AccessibleStateType::EXPANDABLE );
2642 if ( IsExpanded( pEntry ) )
2643 rStateSet.AddState( (sal_Int16)AccessibleStateType::EXPANDED );
2646 if ( GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED )
2647 rStateSet.AddState( AccessibleStateType::CHECKED );
2648 if ( IsEntryVisible( pEntry ) )
2649 rStateSet.AddState( AccessibleStateType::VISIBLE );
2650 if ( IsSelected( pEntry ) )
2651 rStateSet.AddState( AccessibleStateType::SELECTED );
2654 Rectangle SvTreeListBox::GetBoundingRect( SvLBoxEntry* pEntry )
2656 Point aPos = GetEntryPosition( pEntry );
2657 Rectangle aRect = GetFocusRect( pEntry, aPos.Y() );
2658 return aRect;
2661 void SvTreeListBox::EnableCellFocus()
2663 pImp->EnableCellFocus();
2666 void SvTreeListBox::CallImplEventListeners(ULONG nEvent, void* pData)
2668 CallEventListeners(nEvent, pData);
2671 void SvTreeListBox::FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet ) const
2673 SvLBox::FillAccessibleStateSet( rStateSet );