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