LibreOffice Module vcl (master)  1
treelistbox.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 /*
21  TODO:
22  - delete anchor in SelectionEngine when selecting manually
23  - SelectAll( false ) => only repaint the deselected entries
24 */
25 
28 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
29 #include <vcl/svapp.hxx>
30 #include <vcl/accel.hxx>
31 #include <vcl/builder.hxx>
32 #include <vcl/toolkit/edit.hxx>
33 #include <vcl/settings.hxx>
34 #include <vcl/commandevent.hxx>
35 #include <vcl/uitest/uiobject.hxx>
36 #include <sot/formats.hxx>
38 #include <rtl/instance.hxx>
39 #include <comphelper/string.hxx>
40 #include <sal/log.hxx>
41 #include <tools/debug.hxx>
42 
43 #include <vcl/toolkit/svlbitm.hxx>
46 #include <svimpbox.hxx>
47 
48 #include <set>
49 #include <string.h>
50 #include <vector>
51 
52 using namespace css::accessibility;
53 
54 // Drag&Drop
57 
58 #define SVLBOX_ACC_RETURN 1
59 #define SVLBOX_ACC_ESCAPE 2
60 
62 {
64  Accelerator aAccReturn;
65  Accelerator aAccEscape;
68  bool bCanceled;
70 
71  void CallCallBackHdl_Impl();
72  DECL_LINK( Timeout_Impl, Timer *, void );
73  DECL_LINK( ReturnHdl_Impl, Accelerator&, void );
74  DECL_LINK( EscapeHdl_Impl, Accelerator&, void );
75 
76 public:
77  SvInplaceEdit2( vcl::Window* pParent, const Point& rPos, const Size& rSize,
78  const OUString& rData, const Link<SvInplaceEdit2&,void>& rNotifyEditEnd,
79  const Selection& );
80  ~SvInplaceEdit2();
81  bool KeyInput( const KeyEvent& rKEvt );
82  void LoseFocus();
83  bool EditingCanceled() const { return bCanceled; }
84  OUString GetText() const;
85  OUString const & GetSavedValue() const;
86  void StopEditing( bool bCancel );
87  void Hide();
88 };
89 
90 // ***************************************************************
91 
92 namespace {
93 
94 class MyEdit_Impl : public Edit
95 {
97 public:
98  MyEdit_Impl( vcl::Window* pParent, SvInplaceEdit2* pOwner );
99  virtual ~MyEdit_Impl() override { disposeOnce(); }
100  virtual void dispose() override { pOwner = nullptr; Edit::dispose(); }
101  virtual void KeyInput( const KeyEvent& rKEvt ) override;
102  virtual void LoseFocus() override;
103 };
104 
105 }
106 
107 MyEdit_Impl::MyEdit_Impl( vcl::Window* pParent, SvInplaceEdit2* _pOwner ) :
108 
109  Edit( pParent, WB_LEFT ),
110 
111  pOwner( _pOwner )
112 
113 {
114 }
115 
116 void MyEdit_Impl::KeyInput( const KeyEvent& rKEvt )
117 {
118  if( !pOwner->KeyInput( rKEvt ))
119  Edit::KeyInput( rKEvt );
120 }
121 
122 void MyEdit_Impl::LoseFocus()
123 {
124  if (pOwner)
125  pOwner->LoseFocus();
126 }
127 
129 (
130  vcl::Window* pParent, const Point& rPos,
131  const Size& rSize,
132  const OUString& rData,
133  const Link<SvInplaceEdit2&,void>& rNotifyEditEnd,
134  const Selection& rSelection
135 ) :
136 
137  aCallBackHdl ( rNotifyEditEnd ),
138  bCanceled ( false ),
139  bAlreadyInCallBack ( false )
140 
141 {
142 
143  pEdit = VclPtr<MyEdit_Impl>::Create( pParent, this );
144 
145  vcl::Font aFont( pParent->GetFont() );
146  aFont.SetTransparent( false );
147  Color aColor( pParent->GetBackground().GetColor() );
148  aFont.SetFillColor(aColor );
149  pEdit->SetFont( aFont );
150  pEdit->SetBackground( pParent->GetBackground() );
151  pEdit->SetPosPixel( rPos );
152  pEdit->SetSizePixel( rSize );
153  pEdit->SetText( rData );
154  pEdit->SetSelection( rSelection );
155  pEdit->SaveValue();
156 
157  aAccReturn.InsertItem( SVLBOX_ACC_RETURN, vcl::KeyCode(KEY_RETURN) );
158  aAccEscape.InsertItem( SVLBOX_ACC_ESCAPE, vcl::KeyCode(KEY_ESCAPE) );
159 
160  aAccReturn.SetActivateHdl( LINK( this, SvInplaceEdit2, ReturnHdl_Impl) );
161  aAccEscape.SetActivateHdl( LINK( this, SvInplaceEdit2, EscapeHdl_Impl) );
162  Application::InsertAccel( &aAccReturn );
163  Application::InsertAccel( &aAccEscape );
164 
165  pEdit->Show();
166  pEdit->GrabFocus();
167 }
168 
170 {
171  if( !bAlreadyInCallBack )
172  {
175  }
177 }
178 
179 OUString const & SvInplaceEdit2::GetSavedValue() const
180 {
181  return pEdit->GetSavedValue();
182 }
183 
185 {
186  pEdit->Hide();
187 }
188 
189 
190 IMPL_LINK_NOARG(SvInplaceEdit2, ReturnHdl_Impl, Accelerator&, void)
191 {
192  bCanceled = false;
193  CallCallBackHdl_Impl();
194 }
195 
196 IMPL_LINK_NOARG(SvInplaceEdit2, EscapeHdl_Impl, Accelerator&, void)
197 {
198  bCanceled = true;
199  CallCallBackHdl_Impl();
200 }
201 
202 bool SvInplaceEdit2::KeyInput( const KeyEvent& rKEvt )
203 {
204  vcl::KeyCode aCode = rKEvt.GetKeyCode();
205  sal_uInt16 nCode = aCode.GetCode();
206 
207  switch ( nCode )
208  {
209  case KEY_ESCAPE:
210  bCanceled = true;
212  return true;
213 
214  case KEY_RETURN:
215  bCanceled = false;
217  return true;
218  }
219  return false;
220 }
221 
222 void SvInplaceEdit2::StopEditing( bool bCancel )
223 {
224  if ( !bAlreadyInCallBack )
225  {
226  bCanceled = bCancel;
228  }
229 }
230 
232 {
233  if ( !bAlreadyInCallBack
235  )
236  {
237  bCanceled = false;
239  aIdle.SetInvokeHandler(LINK(this,SvInplaceEdit2,Timeout_Impl));
240  aIdle.SetDebugName( "svtools::SvInplaceEdit2 aIdle" );
241  aIdle.Start();
242  }
243 }
244 
245 IMPL_LINK_NOARG(SvInplaceEdit2, Timeout_Impl, Timer *, void)
246 {
247  CallCallBackHdl_Impl();
248 }
249 
251 {
252  aIdle.Stop();
253  if ( !bAlreadyInCallBack )
254  {
255  bAlreadyInCallBack = true;
258  pEdit->Hide();
259  aCallBackHdl.Call( *this );
260  }
261 }
262 
263 OUString SvInplaceEdit2::GetText() const
264 {
265  return pEdit->GetText();
266 }
267 
268 // ***************************************************************
269 // class SvLBoxTab
270 // ***************************************************************
271 
272 
274 {
275  nPos = 0;
277 }
278 
280 {
281  nPos = nPosition;
282  nFlags = nTabFlags;
283 }
284 
286 {
287  nPos = rTab.nPos;
288  nFlags = rTab.nFlags;
289 }
290 
292 {
293 }
294 
295 
297 {
298  tools::Long nOffset = 0;
300  {
301  nOffset = nTabWidth - nItemWidth;
302  if( nOffset < 0 )
303  nOffset = 0;
304  }
306  {
308  {
309  // correct implementation of centering
310  nOffset = ( nTabWidth - nItemWidth ) / 2;
311  if( nOffset < 0 )
312  nOffset = 0;
313  }
314  else
315  {
316  // historically grown, wrong calculation of tabs which is needed by
317  // Abo-Tabbox, Tools/Options/Customize etc.
318  nItemWidth++;
319  nOffset = -( nItemWidth / 2 );
320  }
321  }
322  return nOffset;
323 }
324 
325 // ***************************************************************
326 // class SvLBoxItem
327 // ***************************************************************
328 
329 
331  : mbDisabled(false)
332 {
333 }
334 
336 {
337 }
338 
339 int SvLBoxItem::GetWidth(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const
340 {
341  const SvViewDataItem* pViewData = pView->GetViewDataItem( pEntry, this );
342  int nWidth = pViewData->mnWidth;
343  if (nWidth == -1)
344  {
345  nWidth = CalcWidth(pView);
346  const_cast<SvViewDataItem*>(pViewData)->mnWidth = nWidth;
347  }
348  return nWidth;
349 }
350 
351 int SvLBoxItem::GetHeight(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const
352 {
353  const SvViewDataItem* pViewData = pView->GetViewDataItem( pEntry, this );
354  return pViewData->mnHeight;
355 }
356 
357 int SvLBoxItem::GetWidth(const SvTreeListBox* pView, const SvViewDataEntry* pData, sal_uInt16 nItemPos)
358 {
359  const SvViewDataItem& rIData = pData->GetItem(nItemPos);
360  int nWidth = rIData.mnWidth;
361  if (nWidth == -1)
362  {
363  nWidth = CalcWidth(pView);
364  const_cast<SvViewDataItem&>(rIData).mnWidth = nWidth;
365  }
366  return nWidth;
367 }
368 
369 int SvLBoxItem::GetHeight(const SvViewDataEntry* pData, sal_uInt16 nItemPos)
370 {
371  const SvViewDataItem& rIData = pData->GetItem(nItemPos);
372  return rIData.mnHeight;
373 }
374 
375 int SvLBoxItem::CalcWidth(const SvTreeListBox* /*pView*/) const
376 {
377  return 0;
378 }
379 
381 {
383 
385 
386  explicit SvTreeListBoxImpl(SvTreeListBox& _rBox) :
387  m_bDoingQuickSelection(false),
388  m_aQuickSelectionEngine(_rBox) {}
389 };
390 
392  Control(pParent, nWinStyle | WB_CLIPCHILDREN),
393  DropTargetHelper(this),
394  DragSourceHelper(this),
395  mpImpl(new SvTreeListBoxImpl(*this)),
396  mbContextBmpExpanded(false),
397  mbAlternatingRowColors(false),
398  mbUpdateAlternatingRows(false),
399  mbQuickSearch(false),
400  mbActivateOnSingleClick(false),
401  mbHoverSelection(false),
402  mnClicksToToggle(0), //at default clicking on a row won't toggle its default checkbox
403  eSelMode(SelectionMode::NONE),
404  nMinWidthInChars(0),
405  mnDragAction(DND_ACTION_COPYMOVE | DND_ACTION_LINK),
406  mbCenterAndClipText(false)
407 {
409  pTargetEntry = nullptr;
411  pModel->SetCloneLink( LINK(this, SvTreeListBox, CloneHdl_Impl ));
412  pHdlEntry = nullptr;
415  SetType(WindowType::TREELISTBOX);
416 
417  InitTreeView();
418  pImpl->SetModel( pModel.get() );
419 
421 }
422 
424 {
425  if (pModel)
426  pModel->Clear(); // Model calls SvTreeListBox::ModelHasCleared()
427 }
428 
430 {
431  return CloneEntry(pEntry);
432 }
433 
434 sal_uInt32 SvTreeListBox::Insert( SvTreeListEntry* pEntry, SvTreeListEntry* pParent, sal_uInt32 nPos )
435 {
436  sal_uInt32 nInsPos = pModel->Insert( pEntry, pParent, nPos );
437  pEntry->SetBackColor( GetBackground().GetColor() );
439  return nInsPos;
440 }
441 
442 sal_uInt32 SvTreeListBox::Insert( SvTreeListEntry* pEntry,sal_uInt32 nRootPos )
443 {
444  sal_uInt32 nInsPos = pModel->Insert( pEntry, nRootPos );
445  pEntry->SetBackColor( GetBackground().GetColor() );
447  return nInsPos;
448 }
449 
451 {
452  return !aExpandingHdl.IsSet() || aExpandingHdl.Call( this );
453 }
454 
456 {
457  aExpandedHdl.Call( this );
458 }
459 
461 {
462  aSelectHdl.Call( this );
463 }
464 
466 {
467  aDeselectHdl.Call( this );
468 }
469 
471 {
472  return !aDoubleClickHdl.IsSet() || aDoubleClickHdl.Call(this);
473 }
474 
476 {
477  if ( pSource != this )
478  return false; // no drop
479 
481  return false; // D&D locked within list
482 
483  if( DND_ACTION_MOVE == nAction )
484  {
485  if ( !(nDragDropMode & DragDropMode::CTRL_MOVE) )
486  return false; // no local move
487  }
488  else
489  return false; // no local copy
490 
491  return true;
492 }
493 
494 
495 /*
496  NotifyMoving/Copying
497  ====================
498 
499  default behavior:
500 
501  1. target doesn't have children
502  - entry becomes sibling of target. entry comes after target
503  (->Window: below the target)
504  2. target is an expanded parent
505  - entry inserted at the beginning of the target childlist
506  3. target is a collapsed parent
507  - entry is inserted at the end of the target childlist
508 */
510  SvTreeListEntry* pTarget, // D&D dropping position in GetModel()
511  const SvTreeListEntry* pEntry, // entry that we want to move, from
512  // GetSourceListBox()->GetModel()
513  SvTreeListEntry*& rpNewParent, // new target parent
514  sal_uInt32& rNewChildPos) // position in childlist of target parent
515 {
516  DBG_ASSERT(pEntry,"NotifyMoving:SourceEntry?");
517  if( !pTarget )
518  {
519  rpNewParent = nullptr;
520  rNewChildPos = 0;
521  return TRISTATE_TRUE;
522  }
523  if ( !pTarget->HasChildren() && !pTarget->HasChildrenOnDemand() )
524  {
525  // case 1
526  rpNewParent = GetParent( pTarget );
527  rNewChildPos = SvTreeList::GetRelPos( pTarget ) + 1;
528  rNewChildPos += nCurEntrySelPos;
529  nCurEntrySelPos++;
530  }
531  else
532  {
533  // cases 2 & 3
534  rpNewParent = pTarget;
535  if( IsExpanded(pTarget))
536  rNewChildPos = 0;
537  else
538  rNewChildPos = TREELIST_APPEND;
539  }
540  return TRISTATE_TRUE;
541 }
542 
544  SvTreeListEntry* pTarget, // D&D dropping position in GetModel()
545  const SvTreeListEntry* pEntry, // entry that we want to move, from
546  // GetSourceListBox()->GetModel()
547  SvTreeListEntry*& rpNewParent, // new target parent
548  sal_uInt32& rNewChildPos) // position in childlist of target parent
549 {
550  return NotifyMoving(pTarget,pEntry,rpNewParent,rNewChildPos);
551 }
552 
554 {
555  return pModel->FirstChild(pParent);
556 }
557 
558 // return: all entries copied
560 {
561  nCurEntrySelPos = 0; // selection counter for NotifyMoving/Copying
562  bool bSuccess = true;
563  std::vector<SvTreeListEntry*> aList;
564  bool bClone = ( pSource->GetModel() != GetModel() );
565  Link<SvTreeListEntry*,SvTreeListEntry*> aCloneLink( pModel->GetCloneLink() );
566  pModel->SetCloneLink( LINK(this, SvTreeListBox, CloneHdl_Impl ));
567 
568  // cache selection to simplify iterating over the selection when doing a D&D
569  // exchange within the same listbox
570  SvTreeListEntry* pSourceEntry = pSource->FirstSelected();
571  while ( pSourceEntry )
572  {
573  // children are copied automatically
574  pSource->SelectChildren( pSourceEntry, false );
575  aList.push_back( pSourceEntry );
576  pSourceEntry = pSource->NextSelected( pSourceEntry );
577  }
578 
579  for (auto const& elem : aList)
580  {
581  pSourceEntry = elem;
582  SvTreeListEntry* pNewParent = nullptr;
583  sal_uInt32 nInsertionPos = TREELIST_APPEND;
584  TriState nOk = NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos);
585  if ( nOk )
586  {
587  if ( bClone )
588  {
589  sal_uInt32 nCloneCount = 0;
590  pSourceEntry = pModel->Clone(pSourceEntry, nCloneCount);
591  pModel->InsertTree(pSourceEntry, pNewParent, nInsertionPos);
592  }
593  else
594  {
595  sal_uInt32 nListPos = pModel->Copy(pSourceEntry, pNewParent, nInsertionPos);
596  pSourceEntry = GetEntry( pNewParent, nListPos );
597  }
598  }
599  else
600  bSuccess = false;
601 
602  if (nOk == TRISTATE_INDET) // HACK: make visible moved entry
603  MakeVisible( pSourceEntry );
604  }
605  pModel->SetCloneLink( aCloneLink );
606  return bSuccess;
607 }
608 
609 // return: all entries were moved
610 bool SvTreeListBox::MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback )
611 {
612  nCurEntrySelPos = 0; // selection counter for NotifyMoving/Copying
613  bool bSuccess = true;
614  std::vector<SvTreeListEntry*> aList;
615  bool bClone = ( pSource->GetModel() != GetModel() );
616  Link<SvTreeListEntry*,SvTreeListEntry*> aCloneLink( pModel->GetCloneLink() );
617  if ( bClone )
618  pModel->SetCloneLink( LINK(this, SvTreeListBox, CloneHdl_Impl ));
619 
620  SvTreeListEntry* pSourceEntry = pSource->FirstSelected();
621  while ( pSourceEntry )
622  {
623  // children are automatically moved
624  pSource->SelectChildren( pSourceEntry, false );
625  aList.push_back( pSourceEntry );
626  pSourceEntry = pSource->NextSelected( pSourceEntry );
627  }
628 
629  for (auto const& elem : aList)
630  {
631  pSourceEntry = elem;
632  SvTreeListEntry* pNewParent = nullptr;
633  sal_uInt32 nInsertionPos = TREELIST_APPEND;
634  TriState nOk = NotifyMoving(pTarget,pSourceEntry,pNewParent,nInsertionPos);
635  TriState nCopyOk = nOk;
636  if ( !nOk && bAllowCopyFallback )
637  {
638  nInsertionPos = TREELIST_APPEND;
639  nCopyOk = NotifyCopying(pTarget,pSourceEntry,pNewParent,nInsertionPos);
640  }
641 
642  if ( nOk || nCopyOk )
643  {
644  if ( bClone )
645  {
646  sal_uInt32 nCloneCount = 0;
647  pSourceEntry = pModel->Clone(pSourceEntry, nCloneCount);
648  pModel->InsertTree(pSourceEntry, pNewParent, nInsertionPos);
649  }
650  else
651  {
652  if ( nOk )
653  pModel->Move(pSourceEntry, pNewParent, nInsertionPos);
654  else
655  pModel->Copy(pSourceEntry, pNewParent, nInsertionPos);
656  }
657  }
658  else
659  bSuccess = false;
660 
661  if (nOk == TRISTATE_INDET) // HACK: make moved entry visible
662  MakeVisible( pSourceEntry );
663  }
664  pModel->SetCloneLink( aCloneLink );
665  return bSuccess;
666 }
667 
669 {
670  std::vector<const SvTreeListEntry*> aList;
671  // cache selection, as the implementation deselects everything on the first
672  // remove
673  SvTreeListEntry* pEntry = FirstSelected();
674  while ( pEntry )
675  {
676  aList.push_back( pEntry );
677  if ( pEntry->HasChildren() )
678  // remove deletes all children automatically
679  SelectChildren(pEntry, false);
680  pEntry = NextSelected( pEntry );
681  }
682 
683  for (auto const& elem : aList)
684  pModel->Remove(elem);
685 }
686 
688 {
689  pModel->Remove(pEntry);
690 }
691 
693 {
694  SvTreeListEntry* pEntry = First();
695  while( pEntry )
696  {
697  sal_uInt16 nCount = pEntry->ItemCount();
698  sal_uInt16 nCurPos = 0;
699  while ( nCurPos < nCount )
700  {
701  SvLBoxItem& rItem = pEntry->GetItem( nCurPos );
702  rItem.InitViewData( this, pEntry );
703  nCurPos++;
704  }
705  pEntry = Next( pEntry );
706  }
707 }
708 
710 {
711  if ( bShow && (nImpFlags & SvTreeListBoxFlags::TARGEMPH_VIS) )
712  return;
713  if ( !bShow && !(nImpFlags & SvTreeListBoxFlags::TARGEMPH_VIS) )
714  return;
715  pImpl->PaintDDCursor( pEntry, bShow);
716  if( bShow )
718  else
720 }
721 
723 {
724  if ( !mpImpl->m_bDoingQuickSelection )
725  mpImpl->m_aQuickSelectionEngine.Reset();
726 }
727 
728 SvTreeListEntry* SvTreeListBox::GetEntry( SvTreeListEntry* pParent, sal_uInt32 nPos ) const
729 {
730  return pModel->GetEntry(pParent, nPos);
731 }
732 
733 SvTreeListEntry* SvTreeListBox::GetEntry( sal_uInt32 nRootPos ) const
734 {
735  return pModel->GetEntry(nRootPos);
736 }
737 
738 SvTreeListEntry* SvTreeListBox::GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const
739 {
740 
741  SvTreeListEntry* pEntry = nullptr;
742  SvTreeListEntry* pParent = nullptr;
743  for (auto const& elem : _rPath)
744  {
745  pEntry = GetEntry( pParent, elem );
746  if ( !pEntry )
747  break;
748  pParent = pEntry;
749  }
750 
751  return pEntry;
752 }
753 
754 void SvTreeListBox::FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const
755 {
756 
757  if ( !pEntry )
758  return;
759 
760  SvTreeListEntry* pParentEntry = GetParent( pEntry );
761  while ( true )
762  {
763  sal_uInt32 i, nCount = GetLevelChildCount( pParentEntry );
764  for ( i = 0; i < nCount; ++i )
765  {
766  SvTreeListEntry* pTemp = GetEntry( pParentEntry, i );
767  DBG_ASSERT( pEntry, "invalid entry" );
768  if ( pEntry == pTemp )
769  {
770  _rPath.push_front( static_cast<sal_Int32>(i) );
771  break;
772  }
773  }
774 
775  if ( pParentEntry )
776  {
777  pEntry = pParentEntry;
778  pParentEntry = GetParent( pParentEntry );
779  }
780  else
781  break;
782  }
783 }
784 
786 {
787  return pModel->GetParent(pEntry);
788 }
789 
790 sal_uInt32 SvTreeListBox::GetChildCount( SvTreeListEntry const * pParent ) const
791 {
792  return pModel->GetChildCount(pParent);
793 }
794 
796 {
797 
798  //if _pParent is 0, then pEntry is the first child of the root.
799  SvTreeListEntry* pEntry = FirstChild( _pParent );
800 
801  if( !pEntry )//there is only root, root don't have children
802  return 0;
803 
804  if( !_pParent )//root and children of root
805  return pEntry->pParent->m_Children.size();
806 
807  return _pParent->m_Children.size();
808 }
809 
811 {
812  return const_cast<SvViewDataEntry*>(SvListView::GetViewData(pEntry));
813 }
814 
816 {
817  return const_cast<SvViewDataItem*>(static_cast<const SvTreeListBox*>(this)->GetViewDataItem(pEntry, pItem));
818 }
819 
821 {
822  const SvViewDataEntry* pEntryData = SvListView::GetViewData(pEntry);
823  assert(pEntryData && "Entry not in View");
824  sal_uInt16 nItemPos = pEntry->GetPos(pItem);
825  return &pEntryData->GetItem(nItemPos);
826 }
827 
829 {
830  SvTreeListEntry* pInhEntry = pEntry;
831  SvViewDataEntry* pEntryData = pData;
832 
833  pEntryData->Init(pInhEntry->ItemCount());
834  sal_uInt16 nCount = pInhEntry->ItemCount();
835  sal_uInt16 nCurPos = 0;
836  while( nCurPos < nCount )
837  {
838  SvLBoxItem& rItem = pInhEntry->GetItem( nCurPos );
839  SvViewDataItem& rItemData = pEntryData->GetItem(nCurPos);
840  rItem.InitViewData( this, pInhEntry, &rItemData );
841  nCurPos++;
842  }
843 }
844 
846 {
847  sal_uInt16 nRefDepth;
848  SvTreeListEntry* pTemp;
849 
850  SvTreeListEntry* pSelEntry = FirstSelected();
851  while( pSelEntry )
852  {
853  if ( !bEnable )
854  {
856  nRefDepth = pModel->GetDepth( pSelEntry );
857  pTemp = Next( pSelEntry );
858  while( pTemp && pModel->GetDepth( pTemp ) > nRefDepth )
859  {
861  pTemp = Next( pTemp );
862  }
863  }
864  else
865  {
867  nRefDepth = pModel->GetDepth( pSelEntry );
868  pTemp = Next( pSelEntry );
869  while( pTemp && pModel->GetDepth( pTemp ) > nRefDepth )
870  {
872  pTemp = Next( pTemp );
873  }
874  }
875  pSelEntry = NextSelected( pSelEntry );
876  }
877 }
878 
879 // ******************************************************************
880 // InplaceEditing
881 // ******************************************************************
882 
883 void SvTreeListBox::EditText( const OUString& rStr, const tools::Rectangle& rRect,
884  const Selection& rSel )
885 {
886  pEdCtrl.reset();
889  HideFocus();
890  pEdCtrl.reset( new SvInplaceEdit2(
891  this, rRect.TopLeft(), rRect.GetSize(), rStr,
892  LINK( this, SvTreeListBox, TextEditEndedHdl_Impl ),
893  rSel ) );
894 }
895 
896 IMPL_LINK_NOARG(SvTreeListBox, TextEditEndedHdl_Impl, SvInplaceEdit2&, void)
897 {
898  if ( nImpFlags & SvTreeListBoxFlags::EDTEND_CALLED ) // avoid nesting
899  return;
901  OUString aStr;
902  if ( !pEdCtrl->EditingCanceled() )
903  aStr = pEdCtrl->GetText();
904  else
905  aStr = pEdCtrl->GetSavedValue();
906  EditedText( aStr );
907  // Hide may only be called after the new text was put into the entry, so
908  // that we don't call the selection handler in the GetFocus of the listbox
909  // with the old entry text.
910  pEdCtrl->Hide();
911  nImpFlags &= ~SvTreeListBoxFlags::IN_EDT;
912  GrabFocus();
913 }
914 
916 {
917  if ( pEdCtrl )
918  pEdCtrl->StopEditing( true );
920 }
921 
922 void SvTreeListBox::EndEditing( bool bCancel )
923 {
924  if( pEdCtrl )
925  pEdCtrl->StopEditing( bCancel );
927 }
928 
930 {
931  // always accept the current entry if there is one
932  SvTreeListEntry* pEntry( GetCurEntry() );
933  if (pEntry)
934  {
935  _out_entryText = GetEntryText(pEntry);
936  return pEntry;
937  }
938 
939  pEntry = FirstSelected();
940  if ( !pEntry )
941  pEntry = First();
942 
943  if ( pEntry )
944  _out_entryText = GetEntryText( pEntry );
945 
946  return pEntry;
947 }
948 
949 vcl::StringEntryIdentifier SvTreeListBox::NextEntry(vcl::StringEntryIdentifier _pCurrentSearchEntry, OUString& _out_entryText) const
950 {
951  SvTreeListEntry* pEntry = const_cast< SvTreeListEntry* >( static_cast< const SvTreeListEntry* >( _pCurrentSearchEntry ) );
952 
953  if ( ( ( GetChildCount( pEntry ) > 0 )
954  || ( pEntry->HasChildrenOnDemand() )
955  )
956  && !IsExpanded( pEntry )
957  )
958  {
959  SvTreeListEntry* pNextSiblingEntry = pEntry->NextSibling();
960  if ( !pNextSiblingEntry )
961  pEntry = Next( pEntry );
962  else
963  pEntry = pNextSiblingEntry;
964  }
965  else
966  {
967  pEntry = Next( pEntry );
968  }
969 
970  if ( !pEntry )
971  pEntry = First();
972 
973  if ( pEntry )
974  _out_entryText = GetEntryText( pEntry );
975 
976  return pEntry;
977 }
978 
980 {
981  SvTreeListEntry* pEntry = const_cast< SvTreeListEntry* >( static_cast< const SvTreeListEntry* >( _pEntry ) );
982  DBG_ASSERT( pEntry, "SvTreeListBox::SelectSearchEntry: invalid entry!" );
983  if ( !pEntry )
984  return;
985 
986  SelectAll( false );
987  SetCurEntry( pEntry );
988  Select( pEntry );
989 }
990 
992 {
993  if ( _rKEvt.GetKeyCode().IsMod1() )
994  return false;
995 
996  if (mbQuickSearch)
997  {
998  mpImpl->m_bDoingQuickSelection = true;
999  const bool bHandled = mpImpl->m_aQuickSelectionEngine.HandleKeyEvent( _rKEvt );
1000  mpImpl->m_bDoingQuickSelection = false;
1001  if ( bHandled )
1002  return true;
1003  }
1004 
1005  return false;
1006 }
1007 
1008 
1009 //JP 28.3.2001: new Drag & Drop API
1011 {
1012  sal_Int8 nRet = DND_ACTION_NONE;
1013 
1014  if (rEvt.mbLeaving || !CheckDragAndDropMode(g_pDDSource, rEvt.mnAction))
1015  {
1017  }
1018  else if( nDragDropMode == DragDropMode::NONE )
1019  {
1020  SAL_WARN( "svtools.contnr", "SvTreeListBox::QueryDrop(): no target" );
1021  }
1022  else
1023  {
1024  SvTreeListEntry* pEntry = GetDropTarget( rEvt.maPosPixel );
1025  if( !IsDropFormatSupported( SotClipboardFormatId::TREELISTBOX ) )
1026  {
1027  SAL_WARN( "svtools.contnr", "SvTreeListBox::QueryDrop(): no format" );
1028  }
1029  else
1030  {
1031  DBG_ASSERT(g_pDDSource, "SvTreeListBox::QueryDrop(): SourceBox == 0");
1032  if (!( pEntry && g_pDDSource->GetModel() == GetModel()
1033  && DND_ACTION_MOVE == rEvt.mnAction
1034  && (pEntry->nEntryFlags & SvTLEntryFlags::DISABLE_DROP)))
1035  {
1036  nRet = rEvt.mnAction;
1037  }
1038  }
1039 
1040  // **** draw emphasis ****
1041  if( DND_ACTION_NONE == nRet )
1043  else if( pEntry != pTargetEntry || !(nImpFlags & SvTreeListBoxFlags::TARGEMPH_VIS) )
1044  {
1046  pTargetEntry = pEntry;
1048  }
1049  }
1050  return nRet;
1051 }
1052 
1054 {
1055  assert(pSourceView);
1056  pSourceView->EnableSelectionAsDropTarget();
1057 
1059  g_pDDTarget = this;
1060 
1061  TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
1062 
1063  sal_Int8 nRet;
1064  if( aData.HasFormat( SotClipboardFormatId::TREELISTBOX ))
1065  nRet = rEvt.mnAction;
1066  else
1067  nRet = DND_ACTION_NONE;
1068 
1069  if( DND_ACTION_NONE != nRet )
1070  {
1071  nRet = DND_ACTION_NONE;
1072 
1073  SvTreeListEntry* pTarget = pTargetEntry; // may be 0!
1074 
1075  if( DND_ACTION_COPY == rEvt.mnAction )
1076  {
1077  if (CopySelection(g_pDDSource, pTarget))
1078  nRet = rEvt.mnAction;
1079  }
1080  else if( DND_ACTION_MOVE == rEvt.mnAction )
1081  {
1082  if (MoveSelectionCopyFallbackPossible( g_pDDSource, pTarget, false ))
1083  nRet = rEvt.mnAction;
1084  }
1085  else if( DND_ACTION_COPYMOVE == rEvt.mnAction )
1086  {
1087  if (MoveSelectionCopyFallbackPossible(g_pDDSource, pTarget, true))
1088  nRet = rEvt.mnAction;
1089  }
1090  }
1091  return nRet;
1092 }
1093 
1095 {
1096  return ExecuteDrop( rEvt, g_pDDSource );
1097 }
1098 
1104 {
1105  g_pDDSource = this;
1106  g_pDDTarget = nullptr;
1107 }
1108 
1109 void SvTreeListBox::StartDrag( sal_Int8, const Point& rPosPixel )
1110 {
1111  Point aEventPos( rPosPixel );
1112  MouseEvent aMouseEvt( aEventPos, 1, MouseEventModifiers::SELECT, MOUSE_LEFT );
1113  MouseButtonUp( aMouseEvt );
1114 
1117  return;
1118 
1119  ReleaseMouse();
1120 
1121  SvTreeListEntry* pEntry = GetEntry( rPosPixel ); // GetDropTarget( rPos );
1122  if( !pEntry )
1123  {
1125  return;
1126  }
1127 
1129 
1130  if (!xContainer)
1131  {
1132  xContainer.set(new TransferDataContainer);
1133  // apparently some (unused) content is needed
1134  xContainer->CopyAnyData( SotClipboardFormatId::TREELISTBOX,
1135  "unused", SAL_N_ELEMENTS("unused") );
1136  }
1137 
1140  {
1143  return;
1144  }
1145 
1146  SetupDragOrigin();
1147 
1148  bool bOldUpdateMode = Control::IsUpdateMode();
1149  Control::SetUpdateMode( true );
1150  PaintImmediately();
1151  Control::SetUpdateMode( bOldUpdateMode );
1152 
1153  // Disallow using the selection and its children as drop targets.
1154  // Important: If the selection of the SourceListBox is changed in the
1155  // DropHandler, the entries have to be allowed as drop targets again:
1156  // (GetSourceListBox()->EnableSelectionAsDropTarget( true, true );)
1157  EnableSelectionAsDropTarget( false );
1158 
1159  xContainer->StartDrag(this, mnDragAction, GetDragFinishedHdl());
1160 }
1161 
1163 {
1164  m_xTransferHelper = rHelper;
1165  mnDragAction = eDNDConstants;
1166 }
1167 
1169 #ifndef UNX
1170 nAction
1171 #endif
1172 )
1173 {
1175 
1176 #ifndef UNX
1177  if ( (nAction == DND_ACTION_MOVE)
1178  && ( (g_pDDTarget && (g_pDDTarget->GetModel() != GetModel()))
1179  || !g_pDDTarget))
1180  {
1181  RemoveSelection();
1182  }
1183 #endif
1184 
1185  UnsetDropTarget();
1186  g_pDDSource = nullptr;
1187  g_pDDTarget = nullptr;
1189 }
1190 
1192 {
1193  if (pTargetEntry)
1194  {
1196  pTargetEntry = nullptr;
1197  }
1198 }
1199 
1201 {
1202  return DragDropMode(0xffff);
1203 }
1204 
1205 // Handler and methods for Drag - finished handler.
1206 // The with get GetDragFinishedHdl() get link can set on the
1207 // TransferDataContainer. This link is a callback for the DragFinished
1208 // call. AddBox method is called from the GetDragFinishedHdl() and the
1209 // remove is called in link callback and in the destructor. So it can't
1210 // called to a deleted object.
1211 
1212 namespace
1213 {
1214  // void* to avoid loplugin:vclwidgets, we don't need ownership here
1215  std::set<const void*> gSortLBoxes;
1216 }
1217 
1219 {
1220  gSortLBoxes.insert( &rB );
1221 }
1222 
1224 {
1225  gSortLBoxes.erase( &rB );
1226 }
1227 
1228 IMPL_LINK( SvTreeListBox, DragFinishHdl_Impl, sal_Int8, nAction, void )
1229 {
1230  auto &rSortLBoxes = gSortLBoxes;
1231  auto it = rSortLBoxes.find(this);
1232  if( it != rSortLBoxes.end() )
1233  {
1234  DragFinished( nAction );
1235  rSortLBoxes.erase( it );
1236  }
1237 }
1238 
1240 {
1241  AddBoxToDDList_Impl( *this );
1242  return LINK( const_cast<SvTreeListBox*>(this), SvTreeListBox, DragFinishHdl_Impl );
1243 }
1244 
1245 /*
1246  Bugs/TODO
1247 
1248  - calculate rectangle when editing in-place (bug with some fonts)
1249  - SetSpaceBetweenEntries: offset is not taken into account in SetEntryHeight
1250 */
1251 
1252 #define SV_LBOX_DEFAULT_INDENT_PIXEL 20
1253 
1255 {
1256  pCheckButtonData = nullptr;
1257  pEdEntry = nullptr;
1258  pEdItem = nullptr;
1259  nEntryHeight = 0;
1260  pEdCtrl = nullptr;
1261  nFirstSelTab = 0;
1262  nLastSelTab = 0;
1263  nFocusWidth = -1;
1264  mnCheckboxItemWidth = 0;
1265 
1269  pImpl.reset( new SvImpLBox( this, GetModel(), GetStyle() ) );
1270 
1271  mbContextBmpExpanded = true;
1272  nContextBmpWidthMax = 0;
1273 
1274  SetFont( GetFont() );
1276 
1278  SetLineColor();
1279  InitSettings();
1280  ImplInitStyle();
1281  SetTabs();
1282 }
1283 
1285 {
1286  assert(pEntry);
1287  OUStringBuffer sRet;
1288 
1289  sal_uInt16 nCount = pEntry->ItemCount();
1290  sal_uInt16 nCur = 0;
1291  while( nCur < nCount )
1292  {
1293  SvLBoxItem& rItem = pEntry->GetItem( nCur );
1294  if ( (rItem.GetType() == SvLBoxItemType::String) &&
1295  !static_cast<SvLBoxString&>( rItem ).GetText().isEmpty() )
1296  {
1297  sRet.append(static_cast<SvLBoxString&>( rItem ).GetText() + ",");
1298  }
1299  nCur++;
1300  }
1301 
1302  if (!sRet.isEmpty())
1303  sRet.remove(sRet.getLength() - 1, 1);
1304  return sRet.makeStringAndClear();
1305 }
1306 
1308 {
1309  disposeOnce();
1310 }
1311 
1313 {
1314  if (IsMouseCaptured())
1315  ReleaseMouse();
1316 
1317  if( pImpl )
1318  {
1319  pImpl->CallEventListeners( VclEventId::ObjectDying );
1320  pImpl.reset();
1321  }
1322  if( mpImpl )
1323  {
1324  ClearTabList();
1325 
1326  pEdCtrl.reset();
1327 
1329 
1331 
1332  if (this == g_pDDSource)
1333  g_pDDSource = nullptr;
1334  if (this == g_pDDTarget)
1335  g_pDDTarget = nullptr;
1336  mpImpl.reset();
1337  }
1338 
1341  Control::dispose();
1342 }
1343 
1345 {
1346  pImpl->SetNoAutoCurEntry( b );
1347 }
1348 
1350 {
1351  pImpl->m_bSubLstOpLR = true;
1352 }
1353 
1355 {
1356  if( IsEditingActive() )
1357  EndEditing( true );
1358 
1359  Control::Resize();
1360 
1361  pImpl->Resize();
1362  nFocusWidth = -1;
1363  pImpl->ShowCursor( false );
1364  pImpl->ShowCursor( true );
1365 }
1366 
1367 /* Cases:
1368 
1369  A) entries have bitmaps
1370  0. no buttons
1371  1. node buttons (can optionally also be on root items)
1372  2. node buttons (can optionally also be on root items) + CheckButton
1373  3. CheckButton
1374  B) entries don't have bitmaps (=>via WindowBits because of D&D!)
1375  0. no buttons
1376  1. node buttons (can optionally also be on root items)
1377  2. node buttons (can optionally also be on root items) + CheckButton
1378  3. CheckButton
1379 */
1380 
1381 #define NO_BUTTONS 0
1382 #define NODE_BUTTONS 1
1383 #define NODE_AND_CHECK_BUTTONS 2
1384 #define CHECK_BUTTONS 3
1385 
1386 #define TABFLAGS_TEXT (SvLBoxTabFlags::DYNAMIC | \
1387  SvLBoxTabFlags::ADJUST_LEFT | \
1388  SvLBoxTabFlags::EDITABLE | \
1389  SvLBoxTabFlags::SHOW_SELECTION)
1390 
1391 #define TABFLAGS_CONTEXTBMP (SvLBoxTabFlags::DYNAMIC | SvLBoxTabFlags::ADJUST_CENTER)
1392 
1393 #define TABFLAGS_CHECKBTN (SvLBoxTabFlags::DYNAMIC | \
1394  SvLBoxTabFlags::ADJUST_CENTER)
1395 
1396 #define TAB_STARTPOS 2
1397 
1398 // take care of GetTextOffset when doing changes
1400 {
1401  if( IsEditingActive() )
1402  EndEditing( true );
1404  nFocusWidth = -1;
1405  const WinBits nStyle( GetStyle() );
1406  bool bHasButtons = (nStyle & WB_HASBUTTONS)!=0;
1407  bool bHasButtonsAtRoot = (nStyle & (WB_HASLINESATROOT |
1408  WB_HASBUTTONSATROOT))!=0;
1409  tools::Long nStartPos = TAB_STARTPOS;
1410  tools::Long nNodeWidthPixel = GetExpandedNodeBmp().GetSizePixel().Width();
1411 
1412  // pCheckButtonData->Width() knows nothing about the native checkbox width,
1413  // so we have mnCheckboxItemWidth which becomes valid when something is added.
1414  tools::Long nCheckWidth = 0;
1416  nCheckWidth = mnCheckboxItemWidth;
1417  tools::Long nCheckWidthDIV2 = nCheckWidth / 2;
1418 
1419  tools::Long nContextWidth = nContextBmpWidthMax;
1420  tools::Long nContextWidthDIV2 = nContextWidth / 2;
1421 
1422  ClearTabList();
1423 
1424  int nCase = NO_BUTTONS;
1425  if( !(nTreeFlags & SvTreeFlags::CHKBTN) )
1426  {
1427  if( bHasButtons )
1428  nCase = NODE_BUTTONS;
1429  }
1430  else
1431  {
1432  if( bHasButtons )
1433  nCase = NODE_AND_CHECK_BUTTONS;
1434  else
1435  nCase = CHECK_BUTTONS;
1436  }
1437 
1438  switch( nCase )
1439  {
1440  case NO_BUTTONS :
1441  nStartPos += nContextWidthDIV2; // because of centering
1442  AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
1443  nStartPos += nContextWidthDIV2; // right edge of context bitmap
1444  // only set a distance if there are bitmaps
1445  if( nContextBmpWidthMax )
1446  nStartPos += 5; // distance context bitmap to text
1447  AddTab( nStartPos, TABFLAGS_TEXT );
1448  break;
1449 
1450  case NODE_BUTTONS :
1451  if( bHasButtonsAtRoot )
1452  nStartPos += ( nIndent + (nNodeWidthPixel/2) );
1453  else
1454  nStartPos += nContextWidthDIV2;
1455  AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
1456  nStartPos += nContextWidthDIV2; // right edge of context bitmap
1457  // only set a distance if there are bitmaps
1458  if( nContextBmpWidthMax )
1459  nStartPos += 5; // distance context bitmap to text
1460  AddTab( nStartPos, TABFLAGS_TEXT );
1461  break;
1462 
1463  case NODE_AND_CHECK_BUTTONS :
1464  if( bHasButtonsAtRoot )
1465  nStartPos += ( nIndent + nNodeWidthPixel );
1466  else
1467  nStartPos += nCheckWidthDIV2;
1468  AddTab( nStartPos, TABFLAGS_CHECKBTN );
1469  nStartPos += nCheckWidthDIV2; // right edge of CheckButton
1470  nStartPos += 3; // distance CheckButton to context bitmap
1471  nStartPos += nContextWidthDIV2; // center of context bitmap
1472  AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
1473  nStartPos += nContextWidthDIV2; // right edge of context bitmap
1474  // only set a distance if there are bitmaps
1475  if( nContextBmpWidthMax )
1476  nStartPos += 5; // distance context bitmap to text
1477  AddTab( nStartPos, TABFLAGS_TEXT );
1478  break;
1479 
1480  case CHECK_BUTTONS :
1481  nStartPos += nCheckWidthDIV2;
1482  AddTab( nStartPos, TABFLAGS_CHECKBTN );
1483  nStartPos += nCheckWidthDIV2; // right edge of CheckButton
1484  nStartPos += 3; // distance CheckButton to context bitmap
1485  nStartPos += nContextWidthDIV2; // center of context bitmap
1486  AddTab( nStartPos, TABFLAGS_CONTEXTBMP );
1487  nStartPos += nContextWidthDIV2; // right edge of context bitmap
1488  // only set a distance if there are bitmaps
1489  if( nContextBmpWidthMax )
1490  nStartPos += 5; // distance context bitmap to text
1491  AddTab( nStartPos, TABFLAGS_TEXT );
1492  break;
1493  }
1494  pImpl->NotifyTabsChanged();
1495 }
1496 
1498  const OUString& aStr, const Image& aCollEntryBmp, const Image& aExpEntryBmp)
1499 {
1501  {
1502  pEntry->AddItem(std::make_unique<SvLBoxButton>(pCheckButtonData));
1503  }
1504 
1505  pEntry->AddItem(std::make_unique<SvLBoxContextBmp>( aCollEntryBmp,aExpEntryBmp, mbContextBmpExpanded));
1506 
1507  pEntry->AddItem(std::make_unique<SvLBoxString>(aStr));
1508 }
1509 
1511 {
1512  assert(pEntry);
1513  SvLBoxString* pItem = static_cast<SvLBoxString*>(pEntry->GetFirstItem(SvLBoxItemType::String));
1514  assert(pItem);
1515  return pItem->GetText();
1516 }
1517 
1519 {
1520  assert(pEntry);
1521  const SvLBoxContextBmp* pItem = static_cast<const SvLBoxContextBmp*>(pEntry->GetFirstItem(SvLBoxItemType::ContextBmp));
1522  assert(pItem);
1523  return pItem->GetBitmap2( );
1524 }
1525 
1527 {
1528  assert(pEntry);
1529  const SvLBoxContextBmp* pItem = static_cast<const SvLBoxContextBmp*>(pEntry->GetFirstItem(SvLBoxItemType::ContextBmp));
1530  assert(pItem);
1531  return pItem->GetBitmap1( );
1532 }
1533 
1534 IMPL_LINK( SvTreeListBox, CheckButtonClick, SvLBoxButtonData *, pData, void )
1535 {
1536  pHdlEntry = pData->GetActEntry();
1537  CheckButtonHdl();
1538 }
1539 
1541  const OUString& rText,
1542  SvTreeListEntry* pParent,
1543  bool bChildrenOnDemand, sal_uInt32 nPos,
1544  void* pUser
1545 )
1546 {
1548 
1549  const Image& rDefExpBmp = pImpl->GetDefaultEntryExpBmp( );
1550  const Image& rDefColBmp = pImpl->GetDefaultEntryColBmp( );
1551 
1552  aCurInsertedExpBmp = rDefExpBmp;
1553  aCurInsertedColBmp = rDefColBmp;
1554 
1555  SvTreeListEntry* pEntry = new SvTreeListEntry;
1556  pEntry->SetUserData( pUser );
1557  InitEntry( pEntry, rText, rDefColBmp, rDefExpBmp );
1558  pEntry->EnableChildrenOnDemand( bChildrenOnDemand );
1559 
1560  if( !pParent )
1561  Insert( pEntry, nPos );
1562  else
1563  Insert( pEntry, pParent, nPos );
1564 
1565  aPrevInsertedExpBmp = rDefExpBmp;
1566  aPrevInsertedColBmp = rDefColBmp;
1567 
1569 
1570  return pEntry;
1571 }
1572 
1574  const Image& aExpEntryBmp, const Image& aCollEntryBmp,
1575  SvTreeListEntry* pParent, bool bChildrenOnDemand, sal_uInt32 nPos, void* pUser )
1576 {
1578 
1579  aCurInsertedExpBmp = aExpEntryBmp;
1580  aCurInsertedColBmp = aCollEntryBmp;
1581 
1582  SvTreeListEntry* pEntry = new SvTreeListEntry;
1583  pEntry->SetUserData( pUser );
1584  InitEntry( pEntry, rText, aCollEntryBmp, aExpEntryBmp );
1585 
1586  pEntry->EnableChildrenOnDemand( bChildrenOnDemand );
1587 
1588  if( !pParent )
1589  Insert( pEntry, nPos );
1590  else
1591  Insert( pEntry, pParent, nPos );
1592 
1593  aPrevInsertedExpBmp = aExpEntryBmp;
1594  aPrevInsertedColBmp = aCollEntryBmp;
1595 
1597 
1598  return pEntry;
1599 }
1600 
1601 void SvTreeListBox::SetEntryText(SvTreeListEntry* pEntry, const OUString& rStr)
1602 {
1603  SvLBoxString* pItem = static_cast<SvLBoxString*>(pEntry->GetFirstItem(SvLBoxItemType::String));
1604  assert(pItem);
1605  pItem->SetText(rStr);
1606  pItem->InitViewData( this, pEntry );
1607  GetModel()->InvalidateEntry( pEntry );
1608 }
1609 
1611 {
1613 
1614  assert(pItem);
1615  pItem->SetBitmap2( aBmp );
1616 
1617  ModelHasEntryInvalidated(pEntry);
1618  SetEntryHeight( pEntry );
1619  Size aSize = aBmp.GetSizePixel();
1620  short nWidth = pImpl->UpdateContextBmpWidthVector( pEntry, static_cast<short>(aSize.Width()) );
1621  if( nWidth > nContextBmpWidthMax )
1622  {
1623  nContextBmpWidthMax = nWidth;
1624  SetTabs();
1625  }
1626 }
1627 
1629 {
1631 
1632  assert(pItem);
1633  pItem->SetBitmap1( aBmp );
1634 
1635  ModelHasEntryInvalidated(pEntry);
1636  SetEntryHeight( pEntry );
1637  Size aSize = aBmp.GetSizePixel();
1638  short nWidth = pImpl->UpdateContextBmpWidthVector( pEntry, static_cast<short>(aSize.Width()) );
1639  if( nWidth > nContextBmpWidthMax )
1640  {
1641  nContextBmpWidthMax = nWidth;
1642  SetTabs();
1643  }
1644 }
1645 
1647 {
1648  SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button));
1649  if( pItem )
1650  {
1651  auto nWidth = pItem->GetWidth(this, pEntry);
1652  if( mnCheckboxItemWidth < nWidth )
1653  {
1654  mnCheckboxItemWidth = nWidth;
1656  }
1657  }
1658 }
1659 
1661 {
1662 
1663  SvTreeListEntry* pParent = pModel->GetParent( pEntry );
1664  if( pParent )
1665  {
1666  SvTLEntryFlags nFlags = pParent->GetFlags();
1667  nFlags &= ~SvTLEntryFlags::NO_NODEBMP;
1668  pParent->SetFlags( nFlags );
1669  }
1670 
1671  if(!((nTreeFlags & SvTreeFlags::MANINS) &&
1674  {
1675  Size aSize = GetCollapsedEntryBmp( pEntry ).GetSizePixel();
1676  if( aSize.Width() > nContextBmpWidthMax )
1677  {
1678  nContextBmpWidthMax = static_cast<short>(aSize.Width());
1680  }
1681  aSize = GetExpandedEntryBmp( pEntry ).GetSizePixel();
1682  if( aSize.Width() > nContextBmpWidthMax )
1683  {
1684  nContextBmpWidthMax = static_cast<short>(aSize.Width());
1686  }
1687  }
1688  SetEntryHeight( pEntry );
1689 
1690  if( !(nTreeFlags & SvTreeFlags::CHKBTN) )
1691  return;
1692 
1693  CheckBoxInserted(pEntry);
1694 }
1695 
1697 {
1698  if( !(nTreeFlags & SvTreeFlags::CHKBTN) )
1699  return;
1700 
1701  SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button));
1702  if(!pItem)
1703  return ;
1704  switch( eState )
1705  {
1707  pItem->SetStateChecked();
1708  break;
1709 
1711  pItem->SetStateUnchecked();
1712  break;
1713 
1715  pItem->SetStateTristate();
1716  break;
1717  }
1718  InvalidateEntry( pEntry );
1719 }
1720 
1722 {
1724  if( pEntry && ( nTreeFlags & SvTreeFlags::CHKBTN ) )
1725  {
1726  SvLBoxButton* pItem = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button));
1727  if(!pItem)
1728  return SvButtonState::Tristate;
1729  SvItemStateFlags nButtonFlags = pItem->GetButtonFlags();
1730  eState = SvLBoxButtonData::ConvertToButtonState( nButtonFlags );
1731  }
1732  return eState;
1733 }
1734 
1736 {
1737  if ( pCheckButtonData )
1738  pImpl->CallEventListeners( VclEventId::CheckboxToggle, static_cast<void*>(pCheckButtonData->GetActEntry()) );
1739 }
1740 
1741 
1742 // TODO: Currently all data is cloned so that they conform to the default tree
1743 // view format. Actually, the model should be used as a reference here. This
1744 // leads to us _not_ calling SvTreeListEntry::Clone, but only its base class
1745 // SvTreeListEntry.
1746 
1747 
1749 {
1750  OUString aStr;
1751  Image aCollEntryBmp;
1752  Image aExpEntryBmp;
1753 
1754  SvLBoxString* pStringItem = static_cast<SvLBoxString*>(pSource->GetFirstItem(SvLBoxItemType::String));
1755  if( pStringItem )
1756  aStr = pStringItem->GetText();
1757  SvLBoxContextBmp* pBmpItem = static_cast<SvLBoxContextBmp*>(pSource->GetFirstItem(SvLBoxItemType::ContextBmp));
1758  if( pBmpItem )
1759  {
1760  aCollEntryBmp = pBmpItem->GetBitmap1( );
1761  aExpEntryBmp = pBmpItem->GetBitmap2( );
1762  }
1763  SvTreeListEntry* pClone = new SvTreeListEntry;
1764  InitEntry( pClone, aStr, aCollEntryBmp, aExpEntryBmp );
1765  pClone->SvTreeListEntry::Clone( pSource );
1766  pClone->EnableChildrenOnDemand( pSource->HasChildrenOnDemand() );
1767  pClone->SetUserData( pSource->GetUserData() );
1768 
1769  return pClone;
1770 }
1771 
1773 {
1774  return pImpl->GetDefaultEntryExpBmp( );
1775 }
1776 
1778 {
1779  return pImpl->GetDefaultEntryColBmp( );
1780 }
1781 
1783 {
1784  Size aSize = aBmp.GetSizePixel();
1785  if( aSize.Width() > nContextBmpWidthMax )
1786  nContextBmpWidthMax = static_cast<short>(aSize.Width());
1787  SetTabs();
1788 
1789  pImpl->SetDefaultEntryExpBmp( aBmp );
1790 }
1791 
1793 {
1794  Size aSize = aBmp.GetSizePixel();
1795  if( aSize.Width() > nContextBmpWidthMax )
1796  nContextBmpWidthMax = static_cast<short>(aSize.Width());
1797  SetTabs();
1798 
1799  pImpl->SetDefaultEntryColBmp( aBmp );
1800 }
1801 
1803 {
1804  if( !pData )
1806  else
1807  {
1808  SetCheckButtonData( pData );
1810  pData->SetLink( LINK(this, SvTreeListBox, CheckButtonClick));
1811  }
1812 
1813  SetTabs();
1814  if( IsUpdateMode() )
1815  Invalidate();
1816 }
1817 
1819 {
1820  if ( pData )
1821  pCheckButtonData = pData;
1822 }
1823 
1825 {
1827 }
1828 
1830 {
1832 }
1833 
1834 void SvTreeListBox::SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp )
1835 {
1836  SetExpandedNodeBmp( rExpandedNodeBmp );
1837  SetCollapsedNodeBmp( rCollapsedNodeBmp );
1838  SetTabs();
1839 }
1840 
1842 {
1843  return true;
1844 }
1845 
1846 bool SvTreeListBox::EditedEntry( SvTreeListEntry* /*pEntry*/,const OUString& /*rNewText*/)
1847 {
1848  return true;
1849 }
1850 
1852 {
1853  if (bOn)
1855  else
1857 }
1858 
1859 void SvTreeListBox::KeyInput( const KeyEvent& rKEvt )
1860 {
1861  // under OS/2, we get key up/down even while editing
1862  if( IsEditingActive() )
1863  return;
1864 
1865  if( !pImpl->KeyInput( rKEvt ) )
1866  {
1867  bool bHandled = HandleKeyInput( rKEvt );
1868  if ( !bHandled )
1869  Control::KeyInput( rKEvt );
1870  }
1871 }
1872 
1874 {
1875  if( !pParent->HasChildren() )
1876  InsertEntry( "<dummy>", pParent );
1877 }
1878 
1880 {
1881  //If there is no item in the tree, draw focus.
1882  if( !First())
1883  {
1884  Invalidate();
1885  }
1886  pImpl->GetFocus();
1888 
1889  SvTreeListEntry* pEntry = FirstSelected();
1890  if ( !pEntry )
1891  {
1892  pEntry = pImpl->GetCurEntry();
1893  }
1894  if (pImpl->m_pCursor)
1895  {
1896  if (pEntry != pImpl->m_pCursor)
1897  pEntry = pImpl->m_pCursor;
1898  }
1899  if ( pEntry )
1900  pImpl->CallEventListeners( VclEventId::ListboxTreeFocus, pEntry );
1901 
1902 }
1903 
1905 {
1906  // If there is no item in the tree, delete visual focus.
1907  if ( !First() )
1908  Invalidate();
1909  if ( pImpl )
1910  pImpl->LoseFocus();
1912 }
1913 
1915 {
1916  pImpl->m_pCursor = nullptr; // else we crash in GetFocus when editing in-place
1917  pTargetEntry = nullptr;
1918  pEdCtrl.reset();
1919  pImpl->Clear();
1920  nFocusWidth = -1;
1921 
1922  nContextBmpWidthMax = 0;
1925 
1927  nEntryHeight = 0;
1931 
1933 }
1934 
1935 bool SvTreeListBox::PosOverBody(const Point& rPos) const
1936 {
1937  if (rPos.X() < 0 || rPos.Y() < 0)
1938  return false;
1939  Size aSize(GetSizePixel());
1940  if (rPos.X() > aSize.Width() || rPos.Y() > aSize.Height())
1941  return false;
1942  if (pImpl->m_aVerSBar->IsVisible())
1943  {
1944  tools::Rectangle aRect(pImpl->m_aVerSBar->GetPosPixel(), pImpl->m_aVerSBar->GetSizePixel());
1945  if (aRect.IsInside(rPos))
1946  return false;
1947  }
1948  if (pImpl->m_aHorSBar->IsVisible())
1949  {
1950  tools::Rectangle aRect(pImpl->m_aHorSBar->GetPosPixel(), pImpl->m_aHorSBar->GetSizePixel());
1951  if (aRect.IsInside(rPos))
1952  return false;
1953  }
1954  return true;
1955 }
1956 
1957 void SvTreeListBox::ScrollOutputArea( short nDeltaEntries )
1958 {
1959  if( !nDeltaEntries || !pImpl->m_aVerSBar->IsVisible() )
1960  return;
1961 
1962  tools::Long nThumb = pImpl->m_aVerSBar->GetThumbPos();
1963  tools::Long nMax = pImpl->m_aVerSBar->GetRange().Max();
1964 
1965  if( nDeltaEntries < 0 )
1966  {
1967  // move window up
1968  nDeltaEntries *= -1;
1969  tools::Long nVis = pImpl->m_aVerSBar->GetVisibleSize();
1970  tools::Long nTemp = nThumb + nVis;
1971  if( nDeltaEntries > (nMax - nTemp) )
1972  nDeltaEntries = static_cast<short>(nMax - nTemp);
1973  pImpl->PageDown( static_cast<sal_uInt16>(nDeltaEntries) );
1974  }
1975  else
1976  {
1977  if( nDeltaEntries > nThumb )
1978  nDeltaEntries = static_cast<short>(nThumb);
1979  pImpl->PageUp( static_cast<sal_uInt16>(nDeltaEntries) );
1980  }
1981  pImpl->SyncVerThumb();
1982 }
1983 
1985 {
1986  pImpl->ScrollToAbsPos( nPos );
1987 }
1988 
1990 {
1991  eSelMode = eSelectMode;
1992  pImpl->SetSelectionMode( eSelectMode );
1993 }
1994 
1996 {
1997  nDragDropMode = nDDMode;
1998  pImpl->SetDragDropMode( nDDMode );
1999 }
2000 
2002 {
2003  short nHeightMax=0;
2004  sal_uInt16 nCount = pEntry->ItemCount();
2005  sal_uInt16 nCur = 0;
2006  SvViewDataEntry* pViewData = GetViewDataEntry( pEntry );
2007  while( nCur < nCount )
2008  {
2009  auto nHeight = SvLBoxItem::GetHeight(pViewData, nCur);
2010  if( nHeight > nHeightMax )
2011  nHeightMax = nHeight;
2012  nCur++;
2013  }
2014 
2015  if( nHeightMax > nEntryHeight )
2016  {
2017  nEntryHeight = nHeightMax;
2019  pImpl->SetEntryHeight();
2020  }
2021 }
2022 
2023 void SvTreeListBox::SetEntryHeight( short nHeight )
2024 {
2025  if( nHeight > nEntryHeight )
2026  {
2027  nEntryHeight = nHeight;
2028  if( nEntryHeight )
2030  else
2033  pImpl->SetEntryHeight();
2034  }
2035 }
2036 
2037 void SvTreeListBox::SetEntryWidth( short nWidth )
2038 {
2039  nEntryWidth = nWidth;
2040 }
2041 
2043 {
2044  const Size aSize( rBmp.GetSizePixel() );
2045  if( aSize.Height() > nEntryHeight )
2046  {
2047  nEntryHeight = static_cast<short>(aSize.Height()) + nEntryHeightOffs;
2048  pImpl->SetEntryHeight();
2049  }
2050 }
2051 
2053 {
2054  Size aSize( GetTextWidth(OUString('X')), GetTextHeight() );
2055  if( aSize.Height() > nEntryHeight )
2056  {
2057  nEntryHeight = static_cast<short>(aSize.Height()) + nEntryHeightOffs;
2058  pImpl->SetEntryHeight();
2059  }
2060 }
2061 
2063 {
2064  pHdlEntry = pParent;
2065  bool bExpanded = false;
2066  SvTLEntryFlags nFlags;
2067 
2068  if( pParent->HasChildrenOnDemand() )
2069  RequestingChildren( pParent );
2070  bool bExpandAllowed = pParent->HasChildren() && ExpandingHdl();
2071  // double check if the expander callback ended up removing all children
2072  if (pParent->HasChildren())
2073  {
2074  if (bExpandAllowed)
2075  {
2076  bExpanded = true;
2077  ExpandListEntry( pParent );
2078  pImpl->EntryExpanded( pParent );
2079  pHdlEntry = pParent;
2080  ExpandedHdl();
2082  }
2083  nFlags = pParent->GetFlags();
2084  nFlags &= ~SvTLEntryFlags::NO_NODEBMP;
2085  nFlags |= SvTLEntryFlags::HAD_CHILDREN;
2086  pParent->SetFlags( nFlags );
2087  }
2088  else
2089  {
2090  nFlags = pParent->GetFlags();
2091  nFlags |= SvTLEntryFlags::NO_NODEBMP;
2092  pParent->SetFlags( nFlags );
2093  GetModel()->InvalidateEntry( pParent ); // repaint
2094  }
2095 
2096  // #i92103#
2097  if ( bExpanded )
2098  {
2099  pImpl->CallEventListeners( VclEventId::ItemExpanded, pParent );
2100  }
2101 
2102  return bExpanded;
2103 }
2104 
2106 {
2107  pHdlEntry = pParent;
2108  bool bCollapsed = false;
2109 
2110  if( ExpandingHdl() )
2111  {
2112  bCollapsed = true;
2113  pImpl->CollapsingEntry( pParent );
2114  CollapseListEntry( pParent );
2115  pImpl->EntryCollapsed( pParent );
2116  pHdlEntry = pParent;
2117  ExpandedHdl();
2119  }
2120 
2121  // #i92103#
2122  if ( bCollapsed )
2123  {
2124  pImpl->CallEventListeners( VclEventId::ItemCollapsed, pParent );
2125  }
2126 
2127  return bCollapsed;
2128 }
2129 
2130 bool SvTreeListBox::Select( SvTreeListEntry* pEntry, bool bSelect )
2131 {
2132  DBG_ASSERT(pEntry,"Select: Null-Ptr");
2133  bool bRetVal = SelectListEntry( pEntry, bSelect );
2134  DBG_ASSERT(IsSelected(pEntry)==bSelect,"Select failed");
2135  if( bRetVal )
2136  {
2137  pImpl->EntrySelected( pEntry, bSelect );
2138  pHdlEntry = pEntry;
2139  if( bSelect )
2140  {
2141  SelectHdl();
2143  }
2144  else
2145  DeselectHdl();
2146  }
2147  return bRetVal;
2148 }
2149 
2150 sal_uInt32 SvTreeListBox::SelectChildren( SvTreeListEntry* pParent, bool bSelect )
2151 {
2152  pImpl->DestroyAnchor();
2153  sal_uInt32 nRet = 0;
2154  if( !pParent->HasChildren() )
2155  return 0;
2156  sal_uInt16 nRefDepth = pModel->GetDepth( pParent );
2157  SvTreeListEntry* pChild = FirstChild( pParent );
2158  do {
2159  nRet++;
2160  Select( pChild, bSelect );
2161  pChild = Next( pChild );
2162  } while( pChild && pModel->GetDepth( pChild ) > nRefDepth );
2163  return nRet;
2164 }
2165 
2166 void SvTreeListBox::SelectAll( bool bSelect )
2167 {
2168  pImpl->SelAllDestrAnch(
2169  bSelect,
2170  true, // delete anchor,
2171  true ); // even when using SelectionMode::Single, deselect the cursor
2172 }
2173 
2175 {
2176  sal_uInt16 nRefDepth = pModel->GetDepth( pEntry );
2177  SvTreeListEntry* pTmp = pEntry;
2178  do
2179  {
2180  ImpEntryInserted( pTmp );
2181  pTmp = Next( pTmp );
2182  } while( pTmp && nRefDepth < pModel->GetDepth( pTmp ) );
2183  pImpl->TreeInserted( pEntry );
2184 }
2185 
2187 {
2188  ImpEntryInserted( pEntry );
2189  pImpl->EntryInserted( pEntry );
2190 }
2191 
2193 {
2194  pImpl->MovingEntry( pSource );
2195 }
2196 
2198 {
2199  pImpl->EntryMoved( pSource );
2200 }
2201 
2203 {
2204  if(pEdEntry == pEntry)
2205  pEdEntry = nullptr;
2206 
2207  pImpl->RemovingEntry( pEntry );
2208 }
2209 
2211 {
2212  if (pEntry == pHdlEntry)
2213  pHdlEntry = nullptr;
2214 
2215  if (pEntry == pTargetEntry)
2216  pTargetEntry = nullptr;
2217 
2218  pImpl->EntryRemoved();
2219 }
2220 
2222 {
2223  AdjustEntryHeight( rBmp );
2224  pImpl->SetCollapsedNodeBmp( rBmp );
2225 }
2226 
2228 {
2229  AdjustEntryHeight( rBmp );
2230  pImpl->SetExpandedNodeBmp( rBmp );
2231 }
2232 
2233 
2234 void SvTreeListBox::SetFont( const vcl::Font& rFont )
2235 {
2236  vcl::Font aTempFont( rFont );
2237  vcl::Font aOrigFont( GetFont() );
2238  aTempFont.SetTransparent( true );
2239  if (aTempFont == aOrigFont)
2240  return;
2241  Control::SetFont( aTempFont );
2242 
2243  aTempFont.SetColor(aOrigFont.GetColor());
2244  aTempFont.SetFillColor(aOrigFont.GetFillColor());
2245  aTempFont.SetTransparent(aOrigFont.IsTransparent());
2246 
2247  if (aTempFont == aOrigFont)
2248  return;
2249 
2251 }
2252 
2254 {
2256  // always invalidate, else things go wrong in SetEntryHeight
2257  RecalcViewData();
2258 }
2259 
2260 void SvTreeListBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
2261 {
2262  Control::Paint(rRenderContext, rRect);
2264  SetTabs();
2265  pImpl->Paint(rRenderContext, rRect);
2266 
2267  //Add visual focus draw
2268  if (First())
2269  return;
2270 
2271  if (HasFocus())
2272  {
2273  tools::Long nHeight = rRenderContext.GetTextHeight();
2274  tools::Rectangle aRect(Point(0, 0), Size(GetSizePixel().Width(), nHeight));
2275  ShowFocus(aRect);
2276  }
2277  else
2278  {
2279  HideFocus();
2280  }
2281 }
2282 
2284 {
2285  pImpl->m_pCursorOld = pImpl->m_pCursor;
2286  pImpl->MouseButtonDown( rMEvt );
2287 }
2288 
2290 {
2291  // tdf#116675 clicking on an entry should toggle its checkbox
2292  if (rMEvt.IsLeft() && (nTreeFlags & SvTreeFlags::CHKBTN) && mnClicksToToggle > 0)
2293  {
2294  const Point aPnt = rMEvt.GetPosPixel();
2295  SvTreeListEntry* pEntry = GetEntry(aPnt);
2296  if (pEntry && pEntry->m_Items.size() > 0 && (mnClicksToToggle == 1 || pEntry == pImpl->m_pCursorOld))
2297  {
2298  SvLBoxItem* pItem = GetItem(pEntry, aPnt.X());
2299  // if the checkbox button was clicked, that will be toggled later, do not toggle here
2300  // anyway users probably don't want to toggle the checkbox by clickink on another button
2301  if (!pItem || pItem->GetType() != SvLBoxItemType::Button)
2302  {
2303  SvLBoxButton* pItemCheckBox
2304  = static_cast<SvLBoxButton*>(pEntry->GetFirstItem(SvLBoxItemType::Button));
2305  if (pItemCheckBox && GetItemPos(pEntry, 0).first < aPnt.X() - GetMapMode().GetOrigin().X())
2306  {
2307  pItemCheckBox->ClickHdl(pEntry);
2308  InvalidateEntry(pEntry);
2309  }
2310  }
2311  }
2312  }
2313 
2314  pImpl->MouseButtonUp( rMEvt );
2315 }
2316 
2318 {
2319  pImpl->MouseMove( rMEvt );
2320 }
2321 
2322 void SvTreeListBox::SetUpdateMode( bool bUpdate )
2323 {
2324  pImpl->SetUpdateMode( bUpdate );
2325  mbUpdateAlternatingRows = bUpdate;
2327 }
2328 
2330 {
2331  if( nOffsLogic != nEntryHeightOffs )
2332  {
2334  nEntryHeightOffs = nOffsLogic;
2335  nEntryHeight = nEntryHeight + nOffsLogic;
2337  pImpl->SetEntryHeight();
2338  }
2339 }
2340 
2342 {
2343  pImpl->SetCurEntry( pEntry );
2344 }
2345 
2347 {
2348  return pImpl->GetExpandedNodeBmp( );
2349 }
2350 
2352 {
2353  return pImpl->GetEntryPosition( pEntry );
2354 }
2355 
2357 {
2358  pImpl->MakeVisible(pEntry);
2359 }
2360 
2361 void SvTreeListBox::MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop )
2362 {
2363  pImpl->MakeVisible( pEntry, bMoveToTop );
2364 }
2365 
2367 {
2368 
2369  // reinitialize the separate items of the entries
2370  sal_uInt16 nCount = pEntry->ItemCount();
2371  for( sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++ )
2372  {
2373  SvLBoxItem& rItem = pEntry->GetItem( nIdx );
2374  rItem.InitViewData( this, pEntry );
2375  }
2376 
2377  // repaint
2378  pImpl->InvalidateEntry( pEntry );
2379 }
2380 
2381 void SvTreeListBox::EditItemText(SvTreeListEntry* pEntry, SvLBoxString* pItem, const Selection& rSelection)
2382 {
2383  assert(pEntry && pItem);
2384  if( IsSelected( pEntry ))
2385  {
2386  pImpl->ShowCursor( false );
2387  SelectListEntry( pEntry, false );
2388  pImpl->InvalidateEntry(pEntry);
2389  SelectListEntry( pEntry, true );
2390  pImpl->ShowCursor( true );
2391  }
2392  pEdEntry = pEntry;
2393  pEdItem = pItem;
2394  SvLBoxTab* pTab = GetTab( pEntry, pItem );
2395  DBG_ASSERT(pTab,"EditItemText:Tab not found");
2396 
2397  auto nItemHeight( pItem->GetHeight(this, pEntry) );
2398  Point aPos = GetEntryPosition( pEntry );
2399  aPos.AdjustY(( nEntryHeight - nItemHeight ) / 2 );
2400  aPos.setX( GetTabPos( pEntry, pTab ) );
2401  tools::Long nOutputWidth = pImpl->GetOutputSize().Width();
2402  Size aSize( nOutputWidth - aPos.X(), nItemHeight );
2403  sal_uInt16 nPos = std::find_if( aTabs.begin(), aTabs.end(),
2404  [pTab](const std::unique_ptr<SvLBoxTab>& p) { return p.get() == pTab; })
2405  - aTabs.begin();
2406  if( nPos+1 < static_cast<sal_uInt16>(aTabs.size()) )
2407  {
2408  SvLBoxTab* pRightTab = aTabs[ nPos + 1 ].get();
2409  tools::Long nRight = GetTabPos( pEntry, pRightTab );
2410  if( nRight <= nOutputWidth )
2411  aSize.setWidth( nRight - aPos.X() );
2412  }
2413  Point aOrigin( GetMapMode().GetOrigin() );
2414  aPos += aOrigin; // convert to win coordinates
2415  aSize.AdjustWidth( -(aOrigin.X()) );
2416  tools::Rectangle aRect( aPos, aSize );
2417  EditText( pItem->GetText(), aRect, rSelection );
2418 }
2419 
2421 {
2422  pImpl->m_aEditClickPos = Point( -1, -1 );
2423  ImplEditEntry( pEntry );
2424 }
2425 
2427 {
2428  if( IsEditingActive() )
2429  EndEditing();
2430  if( !pEntry )
2431  pEntry = GetCurEntry();
2432  if( !pEntry )
2433  return;
2434 
2435  tools::Long nClickX = pImpl->m_aEditClickPos.X();
2436  bool bIsMouseTriggered = nClickX >= 0;
2437 
2438  SvLBoxString* pItem = nullptr;
2439  sal_uInt16 nCount = pEntry->ItemCount();
2440  tools::Long nTabPos, nNextTabPos = 0;
2441  for( sal_uInt16 i = 0 ; i < nCount ; i++ )
2442  {
2443  SvLBoxItem& rTmpItem = pEntry->GetItem( i );
2444  if (rTmpItem.GetType() != SvLBoxItemType::String)
2445  continue;
2446 
2447  SvLBoxTab* pTab = GetTab( pEntry, &rTmpItem );
2448  nNextTabPos = -1;
2449  if( i < nCount - 1 )
2450  {
2451  SvLBoxItem& rNextItem = pEntry->GetItem( i + 1 );
2452  SvLBoxTab* pNextTab = GetTab( pEntry, &rNextItem );
2453  nNextTabPos = pNextTab->GetPos();
2454  }
2455 
2456  if( pTab && pTab->IsEditable() )
2457  {
2458  nTabPos = pTab->GetPos();
2459  if( !bIsMouseTriggered || (nClickX > nTabPos && (nNextTabPos == -1 || nClickX < nNextTabPos ) ) )
2460  {
2461  pItem = static_cast<SvLBoxString*>( &rTmpItem );
2462  break;
2463  }
2464  }
2465  }
2466 
2467  if( pItem && EditingEntry( pEntry ) )
2468  {
2470  SelectAll( false );
2471  MakeVisible( pEntry );
2472  EditItemText( pEntry, pItem, aSel );
2473  }
2474 }
2475 
2476 void SvTreeListBox::EditedText( const OUString& rStr )
2477 
2478 {
2479  if(pEdEntry) // we have to check if this entry is null that means that it is removed while editing
2480  {
2481  if( EditedEntry( pEdEntry, rStr ) )
2482  {
2483  static_cast<SvLBoxString*>(pEdItem)->SetText( rStr );
2484  pModel->InvalidateEntry( pEdEntry );
2485  }
2486  if( GetSelectionCount() == 0 )
2487  Select( pEdEntry );
2489  SetCurEntry( pEdEntry );
2490  }
2491 }
2492 
2494 {
2495  // scroll
2496  if( rPos.Y() < 12 )
2497  {
2499  ScrollOutputArea( +1 );
2500  }
2501  else
2502  {
2503  Size aSize( pImpl->GetOutputSize() );
2504  if( rPos.Y() > aSize.Height() - 12 )
2505  {
2507  ScrollOutputArea( -1 );
2508  }
2509  }
2510 
2511  SvTreeListEntry* pTarget = pImpl->GetEntry( rPos );
2512  // when dropping in a vacant space, use the last entry
2513  if( !pTarget )
2514  return LastVisible();
2515  else if( (GetDragDropMode() & DragDropMode::ENABLE_TOP) &&
2516  pTarget == First() && rPos.Y() < 6 )
2517  return nullptr;
2518 
2519  return pTarget;
2520 }
2521 
2522 
2523 SvTreeListEntry* SvTreeListBox::GetEntry( const Point& rPos, bool bHit ) const
2524 {
2525  SvTreeListEntry* pEntry = pImpl->GetEntry( rPos );
2526  if( pEntry && bHit )
2527  {
2528  tools::Long nLine = pImpl->GetEntryLine( pEntry );
2529  if( !(pImpl->EntryReallyHit( pEntry, rPos, nLine)) )
2530  return nullptr;
2531  }
2532  return pEntry;
2533 }
2534 
2536 {
2537  return pImpl ? pImpl->GetCurEntry() : nullptr;
2538 }
2539 
2541 {
2542  const WinBits nWindowStyle = GetStyle();
2543 
2545  if (nWindowStyle & WB_SORT)
2546  {
2549  }
2550  else
2551  {
2554  }
2555  pImpl->SetStyle(nWindowStyle);
2556  pImpl->Resize();
2557  Invalidate();
2558 }
2559 
2561 {
2562  DBG_ASSERT(pEntry,"InvalidateEntry:No Entry");
2563  if (pEntry)
2564  {
2565  GetModel()->InvalidateEntry(pEntry);
2566  }
2567 }
2568 
2570 {
2571  tools::Rectangle aRect; // multi purpose
2572 
2573  bool bHorSBar = pImpl->HasHorScrollBar();
2574 
2575  pImpl->UpdateContextBmpWidthMax(&rEntry);
2576 
2578  SetTabs();
2579 
2580  short nTempEntryHeight = GetEntryHeight();
2581  tools::Long nWidth = pImpl->GetOutputSize().Width();
2582 
2583  // Did we turn on the scrollbar within PreparePaints? If yes, we have to set
2584  // the ClipRegion anew.
2585  if (!bHorSBar && pImpl->HasHorScrollBar())
2586  rRenderContext.SetClipRegion(vcl::Region(pImpl->GetClipRegionRect()));
2587 
2588  Point aEntryPos(rRenderContext.GetMapMode().GetOrigin());
2589  aEntryPos.setX( aEntryPos.X() * -1 ); // conversion document coordinates
2590  tools::Long nMaxRight = nWidth + aEntryPos.X() - 1;
2591 
2592  Color aBackupTextColor(rRenderContext.GetTextColor());
2593  vcl::Font aBackupFont(rRenderContext.GetFont());
2594  Color aBackupColor = rRenderContext.GetFillColor();
2595 
2596  bool bCurFontIsSel = false;
2597  // if a ClipRegion was set from outside, we don't have to reset it
2598  const WinBits nWindowStyle = GetStyle();
2599  const bool bHideSelection = (nWindowStyle & WB_HIDESELECTION) !=0 && !HasFocus();
2600  const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
2601 
2602  vcl::Font aHighlightFont(rRenderContext.GetFont());
2603  const Color aHighlightTextColor(rSettings.GetHighlightTextColor());
2604  aHighlightFont.SetColor(aHighlightTextColor);
2605 
2606  Size aRectSize(0, nTempEntryHeight);
2607 
2608  SvViewDataEntry* pViewDataEntry = GetViewDataEntry( &rEntry );
2609 
2610  const size_t nTabCount = aTabs.size();
2611  const size_t nItemCount = rEntry.ItemCount();
2612  size_t nCurTab = 0;
2613  size_t nCurItem = 0;
2614 
2615  while (nCurTab < nTabCount && nCurItem < nItemCount)
2616  {
2617  SvLBoxTab* pTab = aTabs[nCurTab].get();
2618  const size_t nNextTab = nCurTab + 1;
2619  SvLBoxTab* pNextTab = nNextTab < nTabCount ? aTabs[nNextTab].get() : nullptr;
2620  SvLBoxItem& rItem = rEntry.GetItem(nCurItem);
2621 
2622  SvLBoxTabFlags nFlags = pTab->nFlags;
2623  Size aSize(rItem.GetWidth(this, pViewDataEntry, nCurItem),
2624  SvLBoxItem::GetHeight(pViewDataEntry, nCurItem));
2625  tools::Long nTabPos = GetTabPos(&rEntry, pTab);
2626 
2627  tools::Long nNextTabPos;
2628  if (pNextTab)
2629  nNextTabPos = GetTabPos(&rEntry, pNextTab);
2630  else
2631  {
2632  nNextTabPos = nMaxRight;
2633  if (nTabPos > nMaxRight)
2634  nNextTabPos += 50;
2635  }
2636 
2637  tools::Long nX;
2638  if( pTab->nFlags & SvLBoxTabFlags::ADJUST_RIGHT )
2639  // avoid cutting the right edge off the tab separation
2640  nX = nTabPos + pTab->CalcOffset(aSize.Width(), (nNextTabPos - SV_TAB_BORDER - 1) - nTabPos);
2641  else
2642  nX = nTabPos + pTab->CalcOffset(aSize.Width(), nNextTabPos - nTabPos);
2643 
2644  aEntryPos.setX( nX );
2645  aEntryPos.setY( nLine );
2646 
2647  // set background pattern/color
2648 
2649  Wallpaper aWallpaper = rRenderContext.GetBackground();
2650 
2651  bool bSelTab = bool(nFlags & SvLBoxTabFlags::SHOW_SELECTION);
2652 
2653  if (pViewDataEntry->IsHighlighted() && bSelTab)
2654  {
2655  Color aNewWallColor = rSettings.GetHighlightColor();
2656  // if the face color is bright then the deactivate color is also bright
2657  // -> so you can't see any deactivate selection
2658  if (bHideSelection && !rSettings.GetFaceColor().IsBright()
2659  && aWallpaper.GetColor().IsBright() != rSettings.GetDeactiveColor().IsBright())
2660  {
2661  aNewWallColor = rSettings.GetDeactiveColor();
2662  }
2663  // set font color to highlight
2664  if (!bCurFontIsSel)
2665  {
2666  rRenderContext.SetTextColor(aHighlightTextColor);
2667  rRenderContext.SetFont(aHighlightFont);
2668  bCurFontIsSel = true;
2669  }
2670  aWallpaper.SetColor(aNewWallColor);
2671  }
2672  else // no selection
2673  {
2674  if (bCurFontIsSel || rEntry.GetTextColor())
2675  {
2676  bCurFontIsSel = false;
2677  if (const auto & xCustomTextColor = rEntry.GetTextColor())
2678  rRenderContext.SetTextColor(*xCustomTextColor);
2679  else
2680  rRenderContext.SetTextColor(aBackupTextColor);
2681  rRenderContext.SetFont(aBackupFont);
2682  }
2683  else
2684  {
2685  aWallpaper.SetColor(rEntry.GetBackColor());
2686  }
2687  }
2688 
2689  // draw background
2691  {
2692  // only draw the area that is used by the item
2693  aRectSize.setWidth( aSize.Width() );
2694  aRect.SetPos(aEntryPos);
2695  aRect.SetSize(aRectSize);
2696  }
2697  else
2698  {
2699  // draw from the current to the next tab
2700  if (nCurTab != 0)
2701  aRect.SetLeft( nTabPos );
2702  else
2703  // if we're in the 0th tab, always draw from column 0 --
2704  // else we get problems with centered tabs
2705  aRect.SetLeft( 0 );
2706  aRect.SetTop( nLine );
2707  aRect.SetBottom( nLine + nTempEntryHeight - 1 );
2708  if (pNextTab)
2709  {
2710  tools::Long nRight;
2711  nRight = GetTabPos(&rEntry, pNextTab) - 1;
2712  if (nRight > nMaxRight)
2713  nRight = nMaxRight;
2714  aRect.SetRight( nRight );
2715  }
2716  else
2717  {
2718  aRect.SetRight( nMaxRight );
2719  }
2720  }
2721  // A custom selection that starts at a tab position > 0, do not fill
2722  // the background of the 0th item, else e.g. we might not be able to
2723  // realize tab listboxes with lines.
2724  if (!(nCurTab == 0 && (nTreeFlags & SvTreeFlags::USESEL) && nFirstSelTab))
2725  {
2726  Color aBackgroundColor = aWallpaper.GetColor();
2727  if (aBackgroundColor != COL_TRANSPARENT)
2728  {
2729  rRenderContext.SetFillColor(aBackgroundColor);
2730  // this case may occur for smaller horizontal resizes
2731  if (aRect.Left() < aRect.Right())
2732  rRenderContext.DrawRect(aRect);
2733  }
2734  }
2735  // draw item
2736  // center vertically
2737  aEntryPos.AdjustY((nTempEntryHeight - aSize.Height()) / 2 );
2738 
2739  rItem.Paint(aEntryPos, *this, rRenderContext, pViewDataEntry, rEntry);
2740 
2741  // division line between tabs
2742  if (pNextTab && rItem.GetType() == SvLBoxItemType::String &&
2743  // not at the right edge of the window!
2744  aRect.Right() < nMaxRight)
2745  {
2746  aRect.SetLeft( aRect.Right() - SV_TAB_BORDER );
2747  rRenderContext.DrawRect(aRect);
2748  }
2749 
2750  rRenderContext.SetFillColor(aBackupColor);
2751 
2752  nCurItem++;
2753  nCurTab++;
2754  }
2755 
2756  if (pViewDataEntry->IsDragTarget())
2757  {
2758  rRenderContext.Push();
2759  rRenderContext.SetLineColor(rSettings.GetDeactiveColor());
2760  rRenderContext.SetFillColor(rSettings.GetDeactiveColor());
2761  rRenderContext.DrawRect(tools::Rectangle(Point(0, nLine), Size(nWidth, 2)));
2762  rRenderContext.Pop();
2763  }
2764 
2765  if (bCurFontIsSel || rEntry.GetTextColor())
2766  {
2767  rRenderContext.SetTextColor(aBackupTextColor);
2768  rRenderContext.SetFont(aBackupFont);
2769  }
2770 
2771  sal_uInt16 nFirstDynTabPos(0);
2772  SvLBoxTab* pFirstDynamicTab = GetFirstDynamicTab(nFirstDynTabPos);
2773  tools::Long nDynTabPos = GetTabPos(&rEntry, pFirstDynamicTab);
2774  nDynTabPos += pImpl->m_nNodeBmpTabDistance;
2775  nDynTabPos += pImpl->m_nNodeBmpWidth / 2;
2776  nDynTabPos += 4; // 4 pixels of buffer, so the node bitmap is not too close
2777  // to the next tab
2778 
2779  if( !((!(rEntry.GetFlags() & SvTLEntryFlags::NO_NODEBMP)) &&
2780  (nWindowStyle & WB_HASBUTTONS) && pFirstDynamicTab &&
2781  (rEntry.HasChildren() || rEntry.HasChildrenOnDemand())))
2782  return;
2783 
2784  // find first tab and check if the node bitmap extends into it
2785  sal_uInt16 nNextTab = nFirstDynTabPos;
2786  SvLBoxTab* pNextTab;
2787  do
2788  {
2789  nNextTab++;
2790  pNextTab = nNextTab < nTabCount ? aTabs[nNextTab].get() : nullptr;
2791  } while (pNextTab && pNextTab->IsDynamic());
2792 
2793  if (pNextTab && (GetTabPos( &rEntry, pNextTab ) <= nDynTabPos))
2794  return;
2795 
2796  if (!((nWindowStyle & WB_HASBUTTONSATROOT) || pModel->GetDepth(&rEntry) > 0))
2797  return;
2798 
2799  Point aPos(GetTabPos(&rEntry, pFirstDynamicTab), nLine);
2800  aPos.AdjustX(pImpl->m_nNodeBmpTabDistance );
2801 
2802  const Image* pImg = nullptr;
2803 
2804  if (IsExpanded(&rEntry))
2805  pImg = &pImpl->GetExpandedNodeBmp();
2806  else
2807  {
2808  if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() &&
2809  (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) &&
2810  pImpl->GetDontKnowNodeBmp().GetSizePixel().Width())
2811  {
2812  pImg = &pImpl->GetDontKnowNodeBmp( );
2813  }
2814  else
2815  {
2816  pImg = &pImpl->GetCollapsedNodeBmp( );
2817  }
2818  }
2819  aPos.AdjustY((nTempEntryHeight - pImg->GetSizePixel().Height()) / 2 );
2820 
2822  if (!IsEnabled())
2823  nStyle |= DrawImageFlags::Disable;
2824 
2825  //native
2826  bool bNativeOK = false;
2828  {
2829  ImplControlValue aControlValue;
2830  tools::Rectangle aCtrlRegion(aPos, pImg->GetSizePixel());
2832 
2833  if (IsEnabled())
2834  nState |= ControlState::ENABLED;
2835 
2836  if (IsExpanded(&rEntry))
2837  aControlValue.setTristateVal(ButtonValue::On); //expanded node
2838  else
2839  {
2840  if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() &&
2841  (!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) &&
2842  pImpl->GetDontKnowNodeBmp().GetSizePixel().Width())
2843  {
2844  aControlValue.setTristateVal( ButtonValue::DontKnow ); //don't know
2845  }
2846  else
2847  {
2848  aControlValue.setTristateVal( ButtonValue::Off ); //collapsed node
2849  }
2850  }
2851 
2852  bNativeOK = rRenderContext.DrawNativeControl(ControlType::ListNode, ControlPart::Entire, aCtrlRegion, nState, aControlValue, OUString());
2853  }
2854 
2855  if (!bNativeOK)
2856  {
2857  rRenderContext.DrawImage(aPos, *pImg ,nStyle);
2858  }
2859 }
2860 
2861 void SvTreeListBox::DrawCustomEntry(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const SvTreeListEntry& rEntry)
2862 {
2863  aCustomRenderHdl.Call(std::tuple<vcl::RenderContext&, const tools::Rectangle&, const SvTreeListEntry&>(rRenderContext, rRect, rEntry));
2864 }
2865 
2867 {
2868  return aCustomMeasureHdl.Call(std::pair<vcl::RenderContext&, const SvTreeListEntry&>(rRenderContext, rEntry));
2869 }
2870 
2872 {
2873  pImpl->UpdateContextBmpWidthMax( pEntry );
2874 
2875  Size aSize;
2876  tools::Rectangle aRect;
2877  aRect.SetTop( nLine );
2878  aSize.setHeight( GetEntryHeight() );
2879 
2880  tools::Long nRealWidth = pImpl->GetOutputSize().Width();
2881  nRealWidth -= GetMapMode().GetOrigin().X();
2882 
2883  sal_uInt16 nCurTab;
2885  tools::Long nTabPos = 0;
2886  if( pTab )
2887  nTabPos = GetTabPos( pEntry, pTab );
2888  tools::Long nNextTabPos;
2889  if( pTab && nCurTab < aTabs.size() - 1 )
2890  {
2891  SvLBoxTab* pNextTab = aTabs[ nCurTab + 1 ].get();
2892  nNextTabPos = GetTabPos( pEntry, pNextTab );
2893  }
2894  else
2895  {
2896  nNextTabPos = nRealWidth;
2897  if( nTabPos > nRealWidth )
2898  nNextTabPos += 50;
2899  }
2900 
2901  bool bUserSelection = bool( nTreeFlags & SvTreeFlags::USESEL );
2902  if( !bUserSelection )
2903  {
2904  if( pTab && nCurTab < pEntry->ItemCount() )
2905  {
2906  const SvLBoxItem& rItem = pEntry->GetItem( nCurTab );
2907  aSize.setWidth(rItem.GetWidth(this, pEntry));
2908  if( !aSize.Width() )
2909  aSize.setWidth( 15 );
2910  tools::Long nX = nTabPos; //GetTabPos( pEntry, pTab );
2911  // alignment
2912  nX += pTab->CalcOffset( aSize.Width(), nNextTabPos - nTabPos );
2913  aRect.SetLeft( nX );
2914  // make sure that first and last letter aren't cut off slightly
2915  aRect.SetSize( aSize );
2916  if( aRect.Left() > 0 )
2917  aRect.AdjustLeft( -1 );
2918  aRect.AdjustRight( 1 );
2919  }
2920  }
2921  else
2922  {
2923  // if SelTab != 0, we have to calculate also
2924  if( nFocusWidth == -1 || nFirstSelTab )
2925  {
2926  SvLBoxTab* pLastTab = nullptr; // default to select whole width
2927 
2928  sal_uInt16 nLastTab;
2930  nLastTab++;
2931  if( nLastTab < aTabs.size() ) // is there another one?
2932  pLastTab = aTabs[ nLastTab ].get();
2933 
2934  aSize.setWidth( pLastTab ? pLastTab->GetPos() : 0x0fffffff );
2935  nFocusWidth = static_cast<short>(aSize.Width());
2936  if( pTab )
2937  nFocusWidth = nFocusWidth - static_cast<short>(nTabPos); //pTab->GetPos();
2938  }
2939  else
2940  {
2941  aSize.setWidth( nFocusWidth );
2942  if( pTab )
2943  {
2944  if( nCurTab )
2945  aSize.AdjustWidth(nTabPos );
2946  else
2947  aSize.AdjustWidth(pTab->GetPos() ); // Tab0 always from the leftmost position
2948  }
2949  }
2950  // if selection starts with 0th tab, draw from column 0 on
2951  if( nCurTab != 0 )
2952  {
2953  aRect.SetLeft( nTabPos );
2954  aSize.AdjustWidth( -nTabPos );
2955  }
2956  aRect.SetSize( aSize );
2957  }
2958  // adjust right edge because of clipping
2959  if( aRect.Right() >= nRealWidth )
2960  {
2961  aRect.SetRight( nRealWidth-1 );
2962  nFocusWidth = static_cast<short>(aRect.GetWidth());
2963  }
2964  return aRect;
2965 }
2966 
2967 sal_IntPtr SvTreeListBox::GetTabPos(const SvTreeListEntry* pEntry, const SvLBoxTab* pTab)
2968 {
2969  assert(pTab);
2970  sal_IntPtr nPos = pTab->GetPos();
2971  if( pTab->IsDynamic() )
2972  {
2973  sal_uInt16 nDepth = pModel->GetDepth( pEntry );
2974  nDepth = nDepth * static_cast<sal_uInt16>(nIndent);
2975  nPos += static_cast<sal_IntPtr>(nDepth);
2976  }
2977  return nPos + (pEntry->GetExtraIndent() * nIndent);
2978 }
2979 
2981  SvLBoxTab** ppTab )
2982 {
2983  SvLBoxItem* pItemClicked = nullptr;
2984  sal_uInt16 nTabCount = aTabs.size();
2985  sal_uInt16 nItemCount = pEntry->ItemCount();
2986  SvLBoxTab* pTab = aTabs.front().get();
2987  SvLBoxItem* pItem = &pEntry->GetItem(0);
2988  sal_uInt16 nNextItem = 1;
2989  nX -= GetMapMode().GetOrigin().X();
2990  tools::Long nRealWidth = pImpl->GetOutputSize().Width();
2991  nRealWidth -= GetMapMode().GetOrigin().X();
2992 
2993  while( true )
2994  {
2995  SvLBoxTab* pNextTab=nNextItem<nTabCount ? aTabs[nNextItem].get() : nullptr;
2996  tools::Long nStart = GetTabPos( pEntry, pTab );
2997 
2998  tools::Long nNextTabPos;
2999  if( pNextTab )
3000  nNextTabPos = GetTabPos( pEntry, pNextTab );
3001  else
3002  {
3003  nNextTabPos = nRealWidth;
3004  if( nStart > nRealWidth )
3005  nNextTabPos += 50;
3006  }
3007 
3008  auto nItemWidth(pItem->GetWidth(this, pEntry));
3009  nStart += pTab->CalcOffset(nItemWidth, nNextTabPos - nStart);
3010  auto nLen = nItemWidth;
3011  if( pNextTab )
3012  {
3013  tools::Long nTabWidth = GetTabPos( pEntry, pNextTab ) - nStart;
3014  if( nTabWidth < nLen )
3015  nLen = nTabWidth;
3016  }
3017 
3018  if( nX >= nStart && nX < (nStart+nLen ) )
3019  {
3020  pItemClicked = pItem;
3021  if( ppTab )
3022  {
3023  *ppTab = pTab;
3024  break;
3025  }
3026  }
3027  if( nNextItem >= nItemCount || nNextItem >= nTabCount)
3028  break;
3029  pTab = aTabs[ nNextItem ].get();
3030  pItem = &pEntry->GetItem( nNextItem );
3031  nNextItem++;
3032  }
3033  return pItemClicked;
3034 }
3035 
3036 std::pair<tools::Long, tools::Long> SvTreeListBox::GetItemPos(SvTreeListEntry* pEntry, sal_uInt16 nTabIdx)
3037 {
3038  sal_uInt16 nTabCount = aTabs.size();
3039  sal_uInt16 nItemCount = pEntry->ItemCount();
3040  if (nTabIdx >= nItemCount || nTabIdx >= nTabCount)
3041  return std::make_pair(-1, -1);
3042 
3043  SvLBoxTab* pTab = aTabs.front().get();
3044  SvLBoxItem* pItem = &pEntry->GetItem(nTabIdx);
3045  sal_uInt16 nNextItem = nTabIdx + 1;
3046 
3047  tools::Long nRealWidth = pImpl->GetOutputSize().Width();
3048  nRealWidth -= GetMapMode().GetOrigin().X();
3049 
3050  SvLBoxTab* pNextTab = nNextItem < nTabCount ? aTabs[nNextItem].get() : nullptr;
3051  tools::Long nStart = GetTabPos(pEntry, pTab);
3052 
3053  tools::Long nNextTabPos;
3054  if (pNextTab)
3055  nNextTabPos = GetTabPos(pEntry, pNextTab);
3056  else
3057  {
3058  nNextTabPos = nRealWidth;
3059  if (nStart > nRealWidth)
3060  nNextTabPos += 50;
3061  }
3062 
3063  auto nItemWidth(pItem->GetWidth(this, pEntry));
3064  nStart += pTab->CalcOffset(nItemWidth, nNextTabPos - nStart);
3065  auto nLen = nItemWidth;
3066  if (pNextTab)
3067  {
3068  tools::Long nTabWidth = GetTabPos(pEntry, pNextTab) - nStart;
3069  if (nTabWidth < nLen)
3070  nLen = nTabWidth;
3071  }
3072  return std::make_pair(nStart, nLen);
3073 }
3074 
3075 tools::Long SvTreeListBox::getPreferredDimensions(std::vector<tools::Long> &rWidths) const
3076 {
3077  tools::Long nHeight = 0;
3078  rWidths.clear();
3079  SvTreeListEntry* pEntry = First();
3080  while (pEntry)
3081  {
3082  sal_uInt16 nCount = pEntry->ItemCount();
3083  sal_uInt16 nCurPos = 0;
3084  if (nCount > rWidths.size())
3085  rWidths.resize(nCount);
3086  while (nCurPos < nCount)
3087  {
3088  SvLBoxItem& rItem = pEntry->GetItem( nCurPos );
3089  auto nWidth = rItem.GetWidth(this, pEntry);
3090  if (nWidth)
3091  {
3092  nWidth += SV_TAB_BORDER * 2;
3093  if (nWidth > rWidths[nCurPos])
3094  rWidths[nCurPos] = nWidth;
3095  }
3096  ++nCurPos;
3097  }
3098  pEntry = Next( pEntry );
3099  nHeight += GetEntryHeight();
3100  }
3101  return nHeight;
3102 }
3103 
3105 {
3106  std::vector<tools::Long> aWidths;
3107  Size aRet(0, getPreferredDimensions(aWidths));
3108  for (tools::Long aWidth : aWidths)
3109  aRet.AdjustWidth(aWidth );
3110 
3111  sal_Int32 nLeftBorder(0), nTopBorder(0), nRightBorder(0), nBottomBorder(0);
3112  GetBorder(nLeftBorder, nTopBorder, nRightBorder, nBottomBorder);
3113  aRet.AdjustWidth(nLeftBorder + nRightBorder);
3114  aRet.AdjustHeight(nTopBorder + nBottomBorder);
3115 
3117  aRet.setWidth( std::max(aRet.Width(), nMinWidth) );
3118 
3119  if (GetStyle() & WB_VSCROLL)
3120  aRet.AdjustWidth(GetSettings().GetStyleSettings().GetScrollBarSize());
3121 
3122  return aRet;
3123 }
3124 
3126 {
3128  {
3129  mbAlternatingRowColors = bEnable;
3130  return;
3131  }
3132 
3133  if( bEnable )
3134  {
3135  SvTreeListEntry* pEntry = pModel->First();
3136  for(size_t i = 0; pEntry; ++i)
3137  {
3138  pEntry->SetBackColor( i % 2 == 0 ? GetBackground().GetColor() : GetSettings().GetStyleSettings().GetAlternatingRowColor());
3139  SvTreeListEntry *pNextEntry = nullptr;
3140  if( IsExpanded( pEntry ) )
3141  pNextEntry = pModel->FirstChild( pEntry );
3142  else
3143  pNextEntry = pEntry->NextSibling();
3144 
3145  if( !pNextEntry )
3146  pEntry = pModel->Next( pEntry );
3147  else
3148  pEntry = pNextEntry;
3149  }
3150  }
3151  else if( mbAlternatingRowColors )
3152  for(SvTreeListEntry* pEntry = pModel->First(); pEntry; pEntry = pModel->Next(pEntry))
3153  pEntry->SetBackColor( GetBackground().GetColor() );
3154 
3155  mbAlternatingRowColors = bEnable;
3156  pImpl->UpdateAll(true);
3157 }
3158 
3160 {
3161  pImpl->SetForceMakeVisible(bEnable);
3162 }
3163 
3165 {
3166  return GetItem_Impl( pEntry, nX, ppTab );
3167 }
3168 
3170 {
3171  SvLBoxTab* pDummyTab;
3172  return GetItem_Impl( pEntry, nX, &pDummyTab );
3173 }
3174 
3176 {
3177  nFocusWidth = -1;
3178  SvLBoxTab* pTab = new SvLBoxTab( nTabPos, nFlags );
3179  aTabs.emplace_back( pTab );
3181  {
3182  sal_uInt16 nPos = aTabs.size() - 1;
3183  if( nPos >= nFirstSelTab && nPos <= nLastSelTab )
3185  else
3186  // string items usually have to be selected -- turn this off
3187  // explicitly
3189  }
3190 }
3191 
3192 
3194 {
3195  sal_uInt16 nCurTab = 0;
3196  sal_uInt16 nTabCount = aTabs.size();
3197  while( nCurTab < nTabCount )
3198  {
3199  SvLBoxTab* pTab = aTabs[nCurTab].get();
3200  if( pTab->nFlags & SvLBoxTabFlags::DYNAMIC )
3201  {
3202  rPos = nCurTab;
3203  return pTab;
3204  }
3205  nCurTab++;
3206  }
3207  return nullptr;
3208 }
3209 
3211 {
3212  sal_uInt16 nDummy;
3213  return GetFirstDynamicTab( nDummy );
3214 }
3215 
3216 SvLBoxTab* SvTreeListBox::GetTab( SvTreeListEntry const * pEntry, SvLBoxItem const * pItem) const
3217 {
3218  sal_uInt16 nPos = pEntry->GetPos( pItem );
3219  return aTabs[ nPos ].get();
3220 }
3221 
3223 {
3224  aTabs.clear();
3225 }
3226 
3227 
3229 {
3230  Size aSize = pImpl->GetOutputSize();
3231  return aSize;
3232 }
3233 
3235 {
3236  aScrolledHdl.Call( this );
3237 }
3238 
3240 {
3241  if (!pImpl)
3242  return;
3243  if( nFocusWidth == -1 )
3244  // to make sure that the control doesn't show the wrong focus rectangle
3245  // after painting
3246  pImpl->RecalcFocusRect();
3247  Control::Invalidate( nInvalidateFlags );
3248  pImpl->Invalidate();
3249 }
3250 
3251 void SvTreeListBox::Invalidate( const tools::Rectangle& rRect, InvalidateFlags nInvalidateFlags )
3252 {
3253  if( nFocusWidth == -1 )
3254  // to make sure that the control doesn't show the wrong focus rectangle
3255  // after painting
3256  pImpl->RecalcFocusRect();
3257  Control::Invalidate( rRect, nInvalidateFlags );
3258 }
3259 
3260 
3261 void SvTreeListBox::SetHighlightRange( sal_uInt16 nStart, sal_uInt16 nEnd)
3262 {
3263 
3265  if( nStart > nEnd )
3266  std::swap(nStart, nEnd);
3267  // select all tabs that lie within the area
3269  nFirstSelTab = nStart;
3270  nLastSelTab = nEnd;
3271  pImpl->RecalcFocusRect();
3272 }
3273 
3275 {
3276  if (!aPopupMenuHdl.Call(rCEvt))
3277  pImpl->Command(rCEvt);
3278  //pass at least alt press/release to parent impl
3280  Control::Command(rCEvt);
3281 }
3282 
3283 SvLBoxTab* SvTreeListBox::GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rPos )
3284 {
3285  sal_uInt16 nTabCount = aTabs.size();
3286  for( sal_uInt16 nPos = 0; nPos < nTabCount; nPos++ )
3287  {
3288  SvLBoxTab* pTab = aTabs[ nPos ].get();
3289  if( pTab->nFlags & nFlagMask )
3290  {
3291  rPos = nPos;
3292  return pTab;
3293  }
3294  }
3295  rPos = 0xffff;
3296  return nullptr;
3297 }
3298 
3299 void SvTreeListBox::GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos )
3300 {
3301  sal_uInt16 nPos = static_cast<sal_uInt16>(aTabs.size());
3302  while( nPos )
3303  {
3304  --nPos;
3305  SvLBoxTab* pTab = aTabs[ nPos ].get();
3306  if( pTab->nFlags & nFlagMask )
3307  {
3308  rTabPos = nPos;
3309  return;
3310  }
3311  }
3312  rTabPos = 0xffff;
3313 }
3314 
3316 {
3317  if (aTooltipHdl.IsSet() && aTooltipHdl.Call(rHEvt))
3318  return;
3319 
3320  if( !pImpl->RequestHelp( rHEvt ) )
3321  Control::RequestHelp( rHEvt );
3322 }
3323 
3324 sal_Int32 SvTreeListBox::DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText)
3325 {
3326  OUString aLeft = pLeftText ? pLeftText->GetText() : OUString();
3327  OUString aRight = pRightText ? pRightText->GetText() : OUString();
3328  pImpl->UpdateStringSorter();
3329  return pImpl->m_pStringSorter->compare(aLeft, aRight);
3330 }
3331 
3332 IMPL_LINK( SvTreeListBox, DefaultCompare, const SvSortData&, rData, sal_Int32 )
3333 {
3334  const SvTreeListEntry* pLeft = rData.pLeft;
3335  const SvTreeListEntry* pRight = rData.pRight;
3336  const SvLBoxString* pLeftText = static_cast<const SvLBoxString*>(pLeft->GetFirstItem(SvLBoxItemType::String));
3337  const SvLBoxString* pRightText = static_cast<const SvLBoxString*>(pRight->GetFirstItem(SvLBoxItemType::String));
3338  return DefaultCompare(pLeftText, pRightText);
3339 }
3340 
3342  SvTreeListEntry* pEntry2, sal_uInt32 nPos )
3343 {
3344  SolarMutexGuard aSolarGuard;
3345 
3346  if( nActionId == SvListAction::CLEARING )
3348 
3349  SvListView::ModelNotification( nActionId, pEntry1, pEntry2, nPos );
3350  switch( nActionId )
3351  {
3353  {
3354  SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry1->GetFirstItem( SvLBoxItemType::ContextBmp ) );
3355  if ( !pBmpItem )
3356  break;
3357  const Image& rBitmap1( pBmpItem->GetBitmap1() );
3358  const Image& rBitmap2( pBmpItem->GetBitmap2() );
3359  short nMaxWidth = short( std::max( rBitmap1.GetSizePixel().Width(), rBitmap2.GetSizePixel().Width() ) );
3360  nMaxWidth = pImpl->UpdateContextBmpWidthVector( pEntry1, nMaxWidth );
3361  if( nMaxWidth > nContextBmpWidthMax )
3362  {
3363  nContextBmpWidthMax = nMaxWidth;
3364  SetTabs();
3365  }
3366  if (get_width_request() == -1)
3367  queue_resize();
3368  }
3369  break;
3370 
3372  SetUpdateMode( false );
3373  break;
3374 
3376  // after a selection: show first entry and also keep the selection
3377  MakeVisible( pModel->First(), true );
3378  SetUpdateMode( true );
3379  break;
3380 
3381  case SvListAction::CLEARED:
3382  if( IsUpdateMode() )
3383  PaintImmediately();
3384  break;
3385 
3386  default: break;
3387  }
3388 }
3389 
3391 {
3392  return GetEntry( Point() );
3393 }
3394 
3396 {
3397  SvTreeListEntry* pNext = NextVisible( pEntry );
3398  if( pNext )
3399  {
3400  Point aPos( GetEntryPosition(pNext) );
3401  const Size& rSize = pImpl->GetOutputSize();
3402  if( aPos.Y() < 0 || aPos.Y() >= rSize.Height() )
3403  return nullptr;
3404  }
3405  return pNext;
3406 }
3407 
3408 
3410 {
3412  {
3413  nEntryHeight = 0; // _together_ with true of 1. par (bFont) of InitSettings() a zero-height
3414  // forces complete recalc of heights!
3415  InitSettings();
3416  Invalidate();
3417  }
3418  else
3419  Control::DataChanged( rDCEvt );
3420 }
3421 
3423 {
3424  if( eType == StateChangedType::Enable )
3426 
3427  Control::StateChanged( eType );
3428 
3429  if ( eType == StateChangedType::Style )
3430  ImplInitStyle();
3431 }
3432 
3434 {
3435  SetPointFont(rRenderContext, GetPointFont(*this));
3436 
3437  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
3438  rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
3439  rRenderContext.SetTextFillColor();
3440  rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
3441 
3442  // always try to re-create default-SvLBoxButtonData
3445 }
3446 
3448 {
3449  const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
3450  vcl::Font aFont = rStyleSettings.GetFieldFont();
3451  SetPointFont(*this, aFont);
3453 
3454  SetTextColor(rStyleSettings.GetFieldTextColor());
3455  SetTextFillColor();
3456 
3457  SetBackground(rStyleSettings.GetFieldColor());
3458 
3459  // always try to re-create default-SvLBoxButtonData
3462 }
3463 
3464 css::uno::Reference< XAccessible > SvTreeListBox::CreateAccessible()
3465 {
3467  DBG_ASSERT( pParent, "SvTreeListBox::CreateAccessible - accessible parent not found" );
3468 
3469  css::uno::Reference< XAccessible > xAccessible;
3470  if ( pParent )
3471  {
3472  css::uno::Reference< XAccessible > xAccParent = pParent->GetAccessible();
3473  if ( xAccParent.is() )
3474  {
3475  // need to be done here to get the vclxwindow later on in the accessible
3476  css::uno::Reference< css::awt::XWindowPeer > xHoldAlive(GetComponentInterface());
3477  xAccessible = pImpl->m_aFactoryAccess.getFactory().createAccessibleTreeListBox( *this, xAccParent );
3478  }
3479  }
3480  return xAccessible;
3481 }
3482 
3484 {
3485  assert(pEntry && "SvTreeListBox::FillAccessibleEntryStateSet: invalid entry");
3486 
3487  if ( pEntry->HasChildrenOnDemand() || pEntry->HasChildren() )
3488  {
3489  rStateSet.AddState( AccessibleStateType::EXPANDABLE );
3490  if ( IsExpanded( pEntry ) )
3491  rStateSet.AddState( sal_Int16(AccessibleStateType::EXPANDED) );
3492  }
3493 
3494  if ( GetCheckButtonState( pEntry ) == SvButtonState::Checked )
3495  rStateSet.AddState( AccessibleStateType::CHECKED );
3496  if ( IsEntryVisible( pEntry ) )
3497  rStateSet.AddState( AccessibleStateType::VISIBLE );
3498  if ( IsSelected( pEntry ) )
3499  rStateSet.AddState( AccessibleStateType::SELECTED );
3500  if ( IsEnabled() )
3501  {
3502  rStateSet.AddState( AccessibleStateType::ENABLED );
3503  rStateSet.AddState( AccessibleStateType::FOCUSABLE );
3504  rStateSet.AddState( AccessibleStateType::SELECTABLE );
3505  SvViewDataEntry* pViewDataNewCur = GetViewDataEntry(pEntry);
3506  if (pViewDataNewCur && pViewDataNewCur->HasFocus())
3507  rStateSet.AddState( AccessibleStateType::FOCUSED );
3508  }
3509 }
3510 
3512 {
3513  Point aPos = GetEntryPosition( pEntry );
3514  tools::Rectangle aRect = GetFocusRect( pEntry, aPos.Y() );
3515  return aRect;
3516 }
3517 
3519 {
3520  CallEventListeners(nEvent, pData);
3521 }
3522 
3524 {
3525  nMinWidthInChars = nChars;
3526  queue_resize();
3527 }
3528 
3529 bool SvTreeListBox::set_property(const OString &rKey, const OUString &rValue)
3530 {
3531  if (rKey == "min-width-chars")
3532  {
3533  set_min_width_in_chars(rValue.toInt32());
3534  }
3535  else if (rKey == "enable-tree-lines")
3536  {
3537  auto nStyle = GetStyle();
3538  nStyle &= ~(WB_HASLINES | WB_HASLINESATROOT);
3539  if (toBool(rValue))
3540  nStyle |= (WB_HASLINES | WB_HASLINESATROOT);
3541  SetStyle(nStyle);
3542  }
3543  else if (rKey == "show-expanders")
3544  {
3545  auto nStyle = GetStyle();
3546  nStyle &= ~(WB_HASBUTTONS | WB_HASBUTTONSATROOT);
3547  if (toBool(rValue))
3548  nStyle |= (WB_HASBUTTONS | WB_HASBUTTONSATROOT);
3549  SetStyle(nStyle);
3550  }
3551  else if (rKey == "enable-search")
3552  {
3553  SetQuickSearch(toBool(rValue));
3554  }
3555  else if (rKey == "activate-on-single-click")
3556  {
3558  }
3559  else if (rKey == "hover-selection")
3560  {
3561  SetHoverSelection(toBool(rValue));
3562  }
3563  else if (rKey == "reorderable")
3564  {
3565  if (toBool(rValue))
3567  }
3568  else
3569  return Control::set_property(rKey, rValue);
3570  return true;
3571 }
3572 
3574 {
3575  return TreeListUIObject::create;
3576 }
3577 
3578 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool toBool(std::string_view rValue)
Definition: builder.cxx:88
virtual void ModelHasInserted(SvTreeListEntry *pEntry) override
void AddItem(std::unique_ptr< SvLBoxItem > pItem)
Size GetSizePixel() const
Definition: Image.cxx:86
const Color & GetTextColor() const
Definition: outdev.hxx:1131
bool CheckDragAndDropMode(SvTreeListBox const *pSource, sal_Int8)
void SetPos(const Point &rPoint)
The child windows are invalidated, too.
Link< svtree_measure_args, Size > aCustomMeasureHdl
virtual void ModelIsMoving(SvTreeListEntry *pSource) override
Image const & GetExpandedNodeBmp() const
void dispose()
Definition: treelist.cxx:1037
SAL_DLLPRIVATE float approximate_char_width() const
Definition: text.cxx:904
void SetFillColor(const Color &)
Definition: font/font.cxx:96
SvTreeListEntry * NextVisible(SvTreeListEntry *pEntry) const
Definition: treelist.hxx:235
void EditedText(const OUString &)
VCL_DLLPRIVATE void ImpEntryInserted(SvTreeListEntry *pEntry)
virtual ~SvTreeListBox() override
const Wallpaper & GetBackground() const
Definition: outdev.hxx:642
void HideFocus()
Definition: window2.cxx:91
SvTreeListEntry * NextSelected(SvTreeListEntry *pEntry) const
Definition: treelist.hxx:255
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
Definition: transfer.hxx:117
const Color & GetDeactiveColor() const
const Color & GetBackColor() const
tools::Rectangle GetBoundingRect(const SvTreeListEntry *pEntry)
Calculate and return the bounding rectangle of an entry.
void InvalidateEntry(SvTreeListEntry *)
Definition: treelist.cxx:1007
static SvButtonState ConvertToButtonState(SvItemStateFlags nItemFlags)
Definition: svlbitm.cxx:102
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual void ModelNotification(SvListAction nActionId, SvTreeListEntry *pEntry1, SvTreeListEntry *pEntry2, sal_uInt32 nPos) override
void SetUserData(void *pPtr)
#define NO_BUTTONS
SvListAction
Definition: treelist.hxx:34
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
void SetNoAutoCurEntry(bool b)
void setWidth(tools::Long nWidth)
virtual void DragFinished(sal_Int8 nDropAction)
#define DND_ACTION_COPY
Definition: transfer.hxx:66
friend class SvImpLBox
const Color & GetHighlightTextColor() const
std::unique_ptr< ContentProperties > pData
virtual void ModelHasInsertedTree(SvTreeListEntry *pEntry) override
bool KeyInput(const KeyEvent &rKEvt)
virtual void Command(const CommandEvent &rCEvt) override
void CallCallBackHdl_Impl()
bool IsEntryVisible(SvTreeListEntry *pEntry) const
Definition: treelist.hxx:273
void CancelTextEditing()
void SetExpandedEntryBmp(SvTreeListEntry *_pEntry, const Image &_rImage)
Link< const HelpEvent &, bool > aTooltipHdl
InvalidateFlags
Definition: window.hxx:183
bool IsHighlighted() const
signed char sal_Int8
SvTreeList * GetModel() const
bool IsEditingActive() const
SvTLEntryFlags GetFlags() const
WinBits const WB_HASBUTTONSATROOT
vcl::Window * GetAccessibleParentWindow() const
void SetSortMode(SvSortMode eMode)
Definition: treelist.hxx:196
OUString const & GetSavedValue() const
VCL_DLLPRIVATE void AdjustEntryHeight()
#define SVLBOX_ACC_RETURN
Definition: treelistbox.cxx:58
void AdjustEntryHeightAndRecalc()
long Long
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
void disposeAndClear()
Definition: vclptr.hxx:200
virtual void StateChanged(StateChangedType eType) override
const StyleSettings & GetStyleSettings() const
const Color & GetFaceColor() const
virtual tools::Rectangle GetFocusRect(const SvTreeListEntry *, tools::Long nLine)
VCL_DLLPRIVATE void ImplInitStyle()
bool ExpandingHdl()
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:260
SvTreeListEntry * GetFirstEntryInView() const
const Image & GetDefaultExpandedEntryBmp() const
SvItemStateFlags
Definition: svlbitm.hxx:47
void SetFlags(SvTLEntryFlags nFlags)
bool HasDefaultImages() const
Definition: svlbitm.cxx:156
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual Size GetSizePixel() const
Definition: window.cxx:2383
void EditItemText(SvTreeListEntry *pEntry, SvLBoxString *pItem, const Selection &)
void SetColor(const Color &rColor)
Definition: wall.cxx:156
SvLBoxTab * GetFirstDynamicTab() const
virtual DragDropMode NotifyStartDrag()
SvLBoxTab * GetFirstTab(SvLBoxTabFlags nFlagMask, sal_uInt16 &rTabPos)
SvTreeListEntry * GetActEntry() const
Definition: svlbitm.cxx:120
tools::Long mnCheckboxItemWidth
SvTreeListBoxImpl(SvTreeListBox &_rBox)
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: edit.cxx:224
void FillAccessibleEntryStateSet(SvTreeListEntry *pEntry,::utl::AccessibleStateSetHelper &rStateSet) const
Fills the StateSet of one entry.
static const Image & GetDefaultCollapsedNodeImage()
Definition: svimpbox.cxx:3101
SvInplaceEdit2(vcl::Window *pParent, const Point &rPos, const Size &rSize, const OUString &rData, const Link< SvInplaceEdit2 &, void > &rNotifyEditEnd, const Selection &)
const MapMode & GetMapMode() const
Definition: outdev.hxx:1685
#define DND_ACTION_COPYMOVE
Definition: transfer.hxx:68
void SetTextFillColor()
Definition: text.cxx:697
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
sal_uInt16 GetCode() const
Definition: keycod.hxx:51
VCL_DLLPRIVATE void InitTreeView()
void setTristateVal(ButtonValue nTristate)
SelectionMode
Definition: vclenum.hxx:26
bool IsDynamic() const
void RemoveSelection()
DataChangedEventType GetType() const
Definition: event.hxx:354
void SetEntryText(SvTreeListEntry *, const OUString &)
void SetCurEntry(SvTreeListEntry *_pEntry)
Link< const CommandEvent &, bool > aPopupMenuHdl
short nContextBmpWidthMax
bool mbUpdateAlternatingRows
const OUString & GetText() const
Definition: svlbitm.hxx:133
virtual void InitViewData(SvTreeListBox *pView, SvTreeListEntry *pEntry, SvViewDataItem *pViewData=nullptr)=0
virtual void ModelNotification(SvListAction nActionId, SvTreeListEntry *pEntry1, SvTreeListEntry *pEntry2, sal_uInt32 nPos)
Definition: treelist.cxx:1248
WinBits const WB_VSCROLL
SelectionMode GetSelectionMode() const
virtual void RequestHelp(const HelpEvent &rHEvt) override
virtual int CalcWidth(const SvTreeListBox *pView) const
static const Image & GetExpandedEntryBmp(const SvTreeListEntry *_pEntry)
void SetBitmap2(const Image &rImage)
Definition: svlbitm.hxx:270
bool DoubleClickHdl()
IMPL_LINK_NOARG(SvInplaceEdit2, ReturnHdl_Impl, Accelerator &, void)
void SetType(WindowType nType)
Definition: window2.cxx:967
View-dependent data for a tree list entry created in the virtual function SvTreeListBox::CreateViewDa...
void PaintImmediately()
Definition: paint.cxx:1264
SvTreeListEntry * GetCurEntry() const
bool HasFormat(SotClipboardFormatId nFormat) const
Definition: transfer.cxx:1336
SvTreeListBoxFlags nImpFlags
TRISTATE_TRUE
sal_Int32 DefaultCompare(const SvLBoxString *pLeftText, const SvLBoxString *pRightText)
#define TABFLAGS_TEXT
static VclPtr< SvTreeListBox > g_pDDTarget
Definition: treelistbox.cxx:56
SvTreeListBox(vcl::Window *pParent, WinBits nWinStyle=0)
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
const vcl::Font & GetFieldFont() const
static VCL_DLLPRIVATE void RemoveBoxFromDDList_Impl(const SvTreeListBox &rB)
const Color & GetFieldTextColor() const
void SetRight(tools::Long v)
static const Image & GetDefaultExpandedNodeImage()
Definition: svimpbox.cxx:3094
#define CHECK_BUTTONS
const Color & GetHighlightColor() const
void SetBitmap1(const Image &rImage)
Definition: svlbitm.hxx:265
virtual bool set_property(const OString &rKey, const OUString &rValue) override
VCL_DLLPRIVATE bool HandleKeyInput(const KeyEvent &rKEvt)
Handles the given key event.
#define SV_ENTRYHEIGHTOFFS_PIXEL
Definition: treelistbox.hxx:85
void SetUpdateMode(bool)
const Image & GetBitmap2() const
Definition: svlbitm.hxx:281
void ExpandedHdl()
bool mbAlternatingRowColors
NONE
#define NODE_BUTTONS
SvTLEntryFlags
SvTreeListEntry * GetEntryFromPath(const ::std::deque< sal_Int32 > &_rPath) const
void MakeVisible(SvTreeListEntry *pEntry)
SvTreeFlags
Definition: treelistbox.hxx:87
#define DND_ACTION_MOVE
Definition: transfer.hxx:67
SvLBoxTabFlags nFlags
Accelerator aAccEscape
Definition: treelistbox.cxx:65
StateChangedType
Definition: window.hxx:288
constexpr tools::Long Width() const
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
sal_uInt32 GetExtraIndent() const
VclPtr< Edit > pEdit
Definition: treelistbox.cxx:67
void SetCompareHdl(const Link< const SvSortData &, sal_Int32 > &rLink)
Definition: treelist.hxx:199
sal_Int64 WinBits
int GetHeight(const SvTreeListBox *pView, const SvTreeListEntry *pEntry) const
void SetDragHelper(const rtl::Reference< TransferDataContainer > &rHelper, sal_uInt8 eDNDConstants)
#define NODE_AND_CHECK_BUTTONS
void SetBackground()
rtl::Reference< TransferDataContainer > m_xTransferHelper
virtual css::uno::Reference< css::awt::XWindowPeer > GetComponentInterface(bool bCreate=true)
Definition: window.cxx:3117
SvViewDataItem * GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *)
virtual Size GetOptimalSize() const override
void ScrollOutputArea(short nDeltaEntries)
virtual void GetFocus() override
void SetStateTristate()
Definition: svlbitm.hxx:217
void SetForceMakeVisible(bool bEnable)
tools::Long Left() const
DragDropMode
virtual void ModelIsRemoving(SvTreeListEntry *pEntry) override
void SetLeft(tools::Long v)
SvLBoxButtonData * pCheckButtonData
bool mbContextBmpExpanded
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
virtual bool EditingEntry(SvTreeListEntry *pEntry)
virtual void InitViewData(SvViewDataEntry *, SvTreeListEntry *pEntry) override
SvTreeListEntry * FirstSelected() const
Definition: treelist.hxx:252
const vcl::Font & GetFont() const
Definition: outdev.hxx:648
sal_Int32 nMinWidthInChars
TriState NotifyMoving(SvTreeListEntry *pTarget, const SvTreeListEntry *pEntry, SvTreeListEntry *&rpNewParent, sal_uInt32 &rNewChildPos)
SvTreeListBoxFlags
virtual ~SvLBoxItem()
void SetDragDropMode(DragDropMode)
SvTreeListEntries m_Children
VCL_DLLPRIVATE Size MeasureCustomEntry(vcl::RenderContext &rRenderContext, const SvTreeListEntry &rEntry)
virtual void KeyInput(const KeyEvent &rKEvt) override
void GetLastTab(SvLBoxTabFlags nFlagMask, sal_uInt16 &rTabPos)
#define TABFLAGS_CONTEXTBMP
SvLBoxItem * pEdItem
void Init(size_t nSize)
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
int nCount
#define DND_ACTION_NONE
Definition: transfer.hxx:65
void Hide()
Definition: window.hxx:918
AllSettingsFlags GetFlags() const
Definition: event.hxx:355
SvTreeListEntry * NextSibling() const
virtual void Start() override
Activates the timer task.
Definition: idle.cxx:34
virtual FactoryFunction GetUITestFactory() const override
Link< SvTreeListBox *, bool > aDoubleClickHdl
void SetCollapsedEntryBmp(SvTreeListEntry *_pEntry, const Image &_rImage)
VclEventId
Definition: vclevent.hxx:37
constexpr tools::Long GetWidth() const
void SetBackColor(const Color &rColor)
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1326
void EndEditing(bool bCancel=false)
void EnableSelectionAsDropTarget(bool bEnable=true)
Image aCurInsertedExpBmp
static const Image & GetDefaultExpandedNodeImage()
Returns the default image which clients should use for expanded nodes, to have a consistent user inte...
virtual void SelectEntry(vcl::StringEntryIdentifier _entry) override
selects a given entry
virtual OUString GetText() const
Definition: window.cxx:3036
const void * StringEntryIdentifier
sal_uInt32 SelectChildren(SvTreeListEntry *pParent, bool bSelect)
void SetCheckButtonData(SvLBoxButtonData *)
WinBits const WB_HASLINESATROOT
Definition: edit.hxx:55
void SetExpandedNodeBmp(const Image &)
void RecalcViewData()
void CallImplEventListeners(VclEventId nEvent, void *pData)
void SetAlternatingRowColors(const bool bEnable)
void NotifyScrolled()
vcl::QuickSelectionEngine m_aQuickSelectionEngine
sal_uInt16 nCode
TRISTATE_INDET
short GetEntryHeight() const
Link< SvTreeListBox *, void > aDeselectHdl
#define MOUSE_LEFT
Definition: event.hxx:102
VCL_DLLPRIVATE bool PosOverBody(const Point &rPos) const
void EnableInplaceEditing(bool bEnable)
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
#define TAB_STARTPOS
DragDropMode nOldDragMode
void SetHoverSelection(bool bEnable)
sal_IntPtr GetTabPos(const SvTreeListEntry *, const SvLBoxTab *)
constexpr OUStringLiteral aData
void SetDebugName(const char *pDebugName)
Definition: task.hxx:82
SvTreeListEntry * pHdlEntry
virtual void Paint(const Point &rPos, SvTreeListBox &rOutDev, vcl::RenderContext &rRenderContext, const SvViewDataEntry *pView, const SvTreeListEntry &rEntry)=0
#define SAL_N_ELEMENTS(arr)
virtual void RequestingChildren(SvTreeListEntry *pParent)
sal_Int8 mnAction
Definition: transfer.hxx:115
bool IsDragTarget() const
bool CopySelection(SvTreeListBox *pSource, SvTreeListEntry *pTarget)
sal_uInt16 nCurEntrySelPos
void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff)
SvTreeListEntry * pTargetEntry
std::optional< Color > const & GetTextColor() const
Image aCurInsertedColBmp
Image aPrevInsertedExpBmp
void StopEditing(bool bCancel)
void SetLineColor()
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Accelerator aAccReturn
Definition: treelistbox.cxx:64
void OnCurrentEntryChanged()
tools::Long getPreferredDimensions(std::vector< tools::Long > &rWidths) const
SelectionMode eSelMode
bool IsChild(const vcl::Window *pWindow) const
Definition: stacking.cxx:1106
size_t ItemCount() const
sal_uInt16 nLastSelTab
SvTreeListEntry * CloneEntry(SvTreeListEntry *pSource)
static VCL_DLLPRIVATE void AddBoxToDDList_Impl(const SvTreeListBox &rB)
sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt, SvTreeListBox *pSourceView)
#define DBG_ASSERT(sCon, aError)
void SetStateUnchecked()
Definition: svlbitm.hxx:212
void SetEntryWidth(short nWidth)
int i
DragDropMode nDragDropMode
bool IsEditable() const
void CheckButtonHdl()
std::pair< tools::Long, tools::Long > GetItemPos(SvTreeListEntry *pEntry, sal_uInt16 nTabIdx)
static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry *pEntry)
void SetSublistOpenWithLeftRight()
static bool InsertAccel(Accelerator *pAccel)
Insert accelerator.
Definition: svapp.cxx:1340
void SetLink(const Link< SvLBoxButtonData *, void > &rLink)
Definition: svlbitm.hxx:83
Link< SvInplaceEdit2 &, void > aCallBackHdl
Definition: treelistbox.cxx:63
virtual void SetTabs()
#define SVLBOX_ACC_ESCAPE
Definition: treelistbox.cxx:59
void ImplEditEntry(SvTreeListEntry *pEntry)
void SetCheckButtonState(SvTreeListEntry *, SvButtonState)
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:95
void DeselectHdl()
void SetSize(const Size &rSize)
sal_uInt32 GetSelectionCount() const
Definition: treelist.cxx:1047
bool IsBright() const
virtual void Resize() override
virtual vcl::StringEntryIdentifier NextEntry(vcl::StringEntryIdentifier _currentEntry, OUString &_out_entryText) const override
returns the next entry in the list.
OUString GetText() const
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1140
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
Definition: mouse.cxx:658
void SetUpdateMode(bool bUpdate)
Definition: window.cxx:2948
SvTreeListEntry * GetNextEntryInView(SvTreeListEntry *) const
Link< SvTreeListBox *, void > aExpandedHdl
const Color & GetColor() const
Definition: wall.hxx:71
virtual OUString GetText() const override
Definition: edit.cxx:2565
void CallEventListeners(VclEventId nEvent, void *pData=nullptr)
Definition: ctrl.cxx:297
bool IsSelected(const SvTreeListEntry *pEntry) const
Definition: treelist.cxx:1328
std::unique_ptr< SvTreeList > pModel
Definition: treelist.hxx:211
bool IsUpdateMode() const
Definition: window2.cxx:1172
SvTreeListEntry * FirstChild(SvTreeListEntry *pParent) const
SvLinkSource * pOwner
void SetFillColor()
void * GetUserData() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:288
const Color & GetFieldColor() const
CommandEventId GetCommand() const
std::unique_ptr< SvImpLBox > pImpl
static const Image & GetDefaultCollapsedNodeImage()
Returns the default image which clients should use for expanded nodes, to have a consistent user inte...
void SetTextColor(const Color &rColor)
Definition: text.cxx:662
SvViewDataEntry * GetViewDataEntry(SvTreeListEntry const *pEntry) const
bool Collapse(SvTreeListEntry *pParent)
SvLBoxItem * GetItem(SvTreeListEntry *, tools::Long nX, SvLBoxTab **ppTab)
Link< SvTreeListBox *, void > aSelectHdl
Link< sal_Int8, void > GetDragFinishedHdl() const
SvButtonState
Definition: treelistbox.hxx:56
bool MoveSelectionCopyFallbackPossible(SvTreeListBox *pSource, SvTreeListEntry *pTarget, bool bAllowCopyFallback)
SvTLEntryFlags nEntryFlags
All repaint events should go in here.
virtual void ModelHasMoved(SvTreeListEntry *pSource) override
bool IsMouseCaptured() const
Definition: mouse.cxx:468
#define TABFLAGS_CHECKBTN
const Image & GetBitmap1() const
Definition: svlbitm.hxx:275
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
Request rendering of a particular control and/or part.
void SetTop(tools::Long v)
void SetBottom(tools::Long v)
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:59
TriState NotifyCopying(SvTreeListEntry *pTarget, const SvTreeListEntry *pEntry, SvTreeListEntry *&rpNewParent, sal_uInt32 &rNewChildPos)
size_t GetPos(const SvLBoxItem *pItem) const
const AllSettings & GetSettings() const
Definition: outdev.hxx:405
#define SELECTION_MIN
Image aPrevInsertedColBmp
IMPL_LINK(SvTreeListBox, CloneHdl_Impl, SvTreeListEntry *, pEntry, SvTreeListEntry *)
virtual void InitEntry(SvTreeListEntry *, const OUString &, const Image &, const Image &)
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1444
#define DND_ACTION_LINK
Definition: transfer.hxx:69
virtual OUString GetEntryText(SvTreeListEntry *pEntry) const
void ModelHasEntryInvalidated(SvTreeListEntry *pEntry) override
DragDropMode GetDragDropMode() const
const SvLBoxItem & GetItem(size_t nPos) const
WinBits const WB_SORT
const Color & GetFillColor() const
Definition: font/font.cxx:822
bool Expand(SvTreeListEntry *pParent)
virtual void LoseFocus()
Definition: window.cxx:1837
void SelectAll(bool bSelect)
static VclPtr< SvTreeListBox > g_pDDSource
Definition: treelistbox.cxx:55
Point GetEntryPosition(const SvTreeListEntry *) const
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: edit.cxx:1711
virtual void ShowFocus(const tools::Rectangle &rRect)
Definition: window2.cxx:49
vcl::Window * GetParent() const
Definition: window2.cxx:1096
WinBits const WB_LEFT
void SetStyle(WinBits nStyle)
Definition: window.cxx:1944
SvItemStateFlags GetButtonFlags() const
Definition: svlbitm.hxx:180
sal_Int8 mnClicksToToggle
bool HasChildrenOnDemand() const
static const Image & GetCollapsedEntryBmp(const SvTreeListEntry *_pEntry)
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
void SetColor(const Color &)
Definition: font/font.cxx:88
constexpr Point TopLeft() const
virtual SvLBoxItemType GetType() const =0
void EnableCheckButton(SvLBoxButtonData *)
void SetPointFont(vcl::RenderContext &rRenderContext, const vcl::Font &rFont)
Definition: window.cxx:2155
static sal_uInt32 GetRelPos(const SvTreeListEntry *pChild)
Definition: treelist.cxx:831
bool SelectListEntry(SvTreeListEntry *pEntry, bool bSelect)
Definition: treelist.cxx:887
std::vector< std::unique_ptr< SvLBoxTab > > aTabs
SvTreeListEntry * Next(SvTreeListEntry *pEntry) const
void SetSpaceBetweenEntries(short nSpace)
void ReleaseMouse()
Definition: mouse.cxx:457
std::unique_ptr< SvTreeListBoxImpl > mpImpl
WinBits const WB_HASLINES
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1787
virtual bool EditedEntry(SvTreeListEntry *pEntry, const OUString &rNewText)
SvTreeListEntry * LastVisible() const
Definition: treelist.hxx:241
bool IsExpanded(SvTreeListEntry *pEntry) const
Definition: treelist.cxx:1301
const SvViewDataEntry * GetViewData(const SvTreeListEntry *pEntry) const
Definition: treelist.cxx:1345
int GetWidth(const SvTreeListBox *pView, const SvTreeListEntry *pEntry) const
void GetBorder(sal_Int32 &rLeftBorder, sal_Int32 &rTopBorder, sal_Int32 &rRightBorder, sal_Int32 &rBottomBorder) const
Definition: window.cxx:2405
SvTreeListEntry * First() const
virtual void LoseFocus() override
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE) override
bool HasChildren() const
void UnsetDropTarget()
sal_uInt32 GetLevelChildCount(SvTreeListEntry *pParent) const
WinBits const WB_HIDESELECTION
sal_uInt16 GetChildCount() const
Definition: stacking.cxx:1001
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
static vcl::Window * GetFocusWindow()
Get the currently focused window.
Definition: svapp.cxx:1068
Link< SvTreeListBox *, bool > aExpandingHdl
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Creates and returns the accessible object of the Box.
void SetSelectionMode(SelectionMode)
constexpr Size GetSize() const
const Color & GetColor() const
Definition: font/font.cxx:821
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
virtual void ModelHasCleared() override
virtual void Resize() override
Definition: ctrl.cxx:74
Size GetOutputSizePixel() const
void SetActivateOnSingleClick(bool bEnable)
void ClickHdl(SvTreeListEntry *)
Definition: svlbitm.cxx:353
void Stop()
Definition: scheduler.cxx:587
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
SvTreeListEntry * pEdEntry
Definition: ctrl.hxx:33
short nEntryHeightOffs
virtual void GetFocus()
Definition: window.cxx:1823
SvLBoxTab * GetTab(SvTreeListEntry const *, SvLBoxItem const *) const
#define SV_LBOX_DEFAULT_INDENT_PIXEL
virtual SvTreeListEntry * InsertEntry(const OUString &rText, SvTreeListEntry *pParent=nullptr, bool bChildrenOnDemand=false, sal_uInt32 nPos=TREELIST_APPEND, void *pUserData=nullptr)
void set_min_width_in_chars(sal_Int32 nChars)
constexpr tools::Long Height() const
void ExpandListEntry(SvTreeListEntry *pParent)
Definition: treelist.cxx:849
unsigned char sal_uInt8
sal_uInt16 nFirstSelTab
void CollapseListEntry(SvTreeListEntry *pParent)
Definition: treelist.cxx:868
constexpr sal_uInt16 KEY_ESCAPE
Definition: keycodes.hxx:120
void SetFont(const vcl::Font &rNewFont)
SvTreeListEntry * GetEntry(SvTreeListEntry *pParent, sal_uInt32 nPos) const
void SetFont(const vcl::Font &rFont)
void SetTransparent(bool bTransparent)
Definition: font/font.cxx:103
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:891
sal_Int32 get_width_request() const
Definition: window2.cxx:1917
bool bAlreadyInCallBack
Definition: treelistbox.cxx:69
const OUString & GetSavedValue() const
Definition: edit.hxx:209
VCL_DLLPRIVATE void SetEntryHeight(SvTreeListEntry const *pEntry)
sal_Int8 mnDragAction
bool IsLeft() const
Definition: event.hxx:149
bool IsTransparent() const
Definition: font/font.cxx:823
void SetDefaultImages(const Control *pControlForSettings)
Definition: svlbitm.cxx:132
double mnWidth
tools::Long AdjustWidth(tools::Long n)
Definition: image.hxx:39
VCL_DLLPRIVATE void CheckBoxInserted(SvTreeListEntry *pEntry)
bool IsMod1() const
Definition: keycod.hxx:58
static VclPtr< reference_type > Create(Arg &&...arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
void InvalidateEntry(SvTreeListEntry *)
SvButtonState GetCheckButtonState(SvTreeListEntry *) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: text.cxx:880
const SvViewDataItem & GetItem(size_t nPos) const
const SvLBoxItem * GetFirstItem(SvLBoxItemType eType) const
#define SV_TAB_BORDER
Definition: treelistbox.hxx:83
Point maPosPixel
Definition: transfer.hxx:93
void SetNodeBitmaps(const Image &rCollapsedNodeBmp, const Image &rExpandedNodeBmp)
void * p
void RemoveEntry(SvTreeListEntry const *pEntry)
Removes the entry along with all of its descendants.
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1017
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Definition: timer.hxx:56
VCL_DLLPRIVATE SvLBoxItem * GetItem_Impl(SvTreeListEntry *, tools::Long nX, SvLBoxTab **ppTab)
const Point & GetPosPixel() const
Definition: event.hxx:123
const Point & GetOrigin() const
Definition: mapmod.cxx:138
tools::Long nPos
void FillEntryPath(SvTreeListEntry *pEntry,::std::deque< sal_Int32 > &_rPath) const
void EditEntry(SvTreeListEntry *pEntry)
tools::Long AdjustHeight(tools::Long n)
bool IsDropFormatSupported(SotClipboardFormatId nFormat) const
Definition: transfer2.cxx:298
VCL_DLLPRIVATE void DrawCustomEntry(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect, const SvTreeListEntry &rEntry)
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
void setHeight(tools::Long nHeight)
bool EditingCanceled() const
Definition: treelistbox.cxx:83
WinBits const WB_HASBUTTONS
#define SELECTION_MAX
bool IsEnabled() const
Definition: window2.cxx:1121
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
#define SAL_WARN(area, stream)
virtual void ModelHasRemoved(SvTreeListEntry *pEntry) override
Link< svtree_render_args, void > aCustomRenderHdl
const Image & GetDefaultCollapsedEntryBmp() const
WinBits GetStyle() const
Definition: window2.cxx:952
Definition: timer.hxx:26
tools::Long GetPos() const
void SetPriority(TaskPriority ePriority)
Definition: scheduler.cxx:594
void ImplShowTargetEmphasis(SvTreeListEntry *pEntry, bool bShow)
bool Select(SvTreeListEntry *pEntry, bool bSelect=true)
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
VCL_DLLPRIVATE void PaintEntry1(SvTreeListEntry &, tools::Long nLine, vcl::RenderContext &rRenderContext)
virtual void ModelHasCleared()
Definition: treelist.cxx:1103
void EditText(const OUString &, const tools::Rectangle &, const Selection &)
virtual vcl::StringEntryIdentifier CurrentEntry(OUString &_out_entryText) const override
returns the current entry in the list of searchable strings.
void dispose()
SvLBoxTabFlags
Definition: treelistbox.hxx:62
virtual sal_uInt32 Insert(SvTreeListEntry *pEnt, SvTreeListEntry *pPar, sal_uInt32 nPos=TREELIST_APPEND)
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1905
sal_Int8 mnAction
Definition: transfer.hxx:92
SvTreeFlags nTreeFlags
vcl::Font GetPointFont(vcl::RenderContext const &rRenderContext) const
Definition: window.cxx:2162
TriState
virtual void MouseMove(const MouseEvent &rMEvt) override
tools::Long CalcOffset(tools::Long nItemLength, tools::Long nTabWidth)
bool HasFocus() const
Definition: window.cxx:2962
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:59
virtual void InitViewData(SvTreeListBox *pView, SvTreeListEntry *pEntry, SvViewDataItem *pViewData=nullptr) override
Definition: svlbitm.cxx:280
void AddState(sal_Int16 aState)
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1851
void ScrollToAbsPos(tools::Long nPos)
void SetupDragOrigin()
This sets the global variables used to determine the in-process drag source.
WinBits const WB_CLIPCHILDREN
void SetCollapsedNodeBmp(const Image &)
sal_Int32 nState
DrawImageFlags
Definition: outdev.hxx:156
aStr
void SetStateChecked()
Definition: svlbitm.hxx:206
static void RemoveAccel(Accelerator const *pAccel)
Remove accelerator.
Definition: svapp.cxx:1349
tools::Long Right() const
void SetDefaultExpandedEntryBmp(const Image &rBmp)
void SetQuickSearch(bool bEnable)
Link< SvTreeListBox *, void > aScrolledHdl
SvTreeListEntry * pParent
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
std::unique_ptr< SvInplaceEdit2 > pEdCtrl
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:34
sal_uInt16 nPos
const Color & GetFillColor() const
Definition: outdev.hxx:634
bool HasFocus() const
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
void SetText(const OUString &rText)
Definition: svlbitm.hxx:137
#define TREELIST_APPEND
void EnableChildrenOnDemand(bool bEnable=true)
void SetDefaultCollapsedEntryBmp(const Image &rBmp)
void AddTab(tools::Long nPos, SvLBoxTabFlags nFlags)