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