LibreOffice Module vcl (master)  1
treelistbox.hxx
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 #ifndef INCLUDED_VCL_TREELISTBOX_HXX
21 #define INCLUDED_VCL_TREELISTBOX_HXX
22 
23 #include <vcl/dllapi.h>
24 
25 #include <deque>
26 #include <memory>
27 #include <vector>
28 
29 #include <vcl/ctrl.hxx>
30 #include <vcl/accel.hxx>
31 #include <vcl/mnemonicengine.hxx>
33 #include <vcl/image.hxx>
34 #include <tools/gen.hxx>
35 #include <tools/contnr.hxx>
36 #include <vcl/treelist.hxx>
37 #include <vcl/transfer.hxx>
38 #include <vcl/idle.hxx>
39 #include <vcl/menu.hxx>
40 #include <o3tl/typed_flags_set.hxx>
41 
42 class SvTreeListBox;
43 class SvTreeListEntry;
44 struct SvViewDataItem;
45 class SvViewDataEntry;
46 class SvInplaceEdit2;
47 class SvLBoxString;
48 class SvImpLBox;
49 class SvLBoxButtonData;
50 class Timer;
51 class Edit;
52 
53 namespace utl {
54  class AccessibleStateSetHelper;
55 }
56 
58 
59 // *********************************************************************
60 // *************************** Tabulators ******************************
61 // *********************************************************************
62 
63 enum class SvLBoxTabFlags
64 {
65  NONE = 0x0000,
66  DYNAMIC = 0x0001, // Item's output column changes according to the Child Depth
67  ADJUST_RIGHT = 0x0002, // Item's right margin at the tabulator
68  ADJUST_LEFT = 0x0004, // Left margin
69  ADJUST_CENTER = 0x0008, // Center the item at the tabulator
70 
71  SHOW_SELECTION = 0x0010, // Visualize selection state
72  // Item needs to be able to return the surrounding polygon (D'n'D cursor)
73  EDITABLE = 0x0020, // Item editable at the tabulator
74  FORCE = 0x0040, // Switch off the default calculation of the first tabulator
75  // (on which Abo Tabpage/Extras/Option/Customize, etc. rely on)
76  // The first tab's position corresponds precisely to the Flags set
77  // and column widths
78 };
79 namespace o3tl
80 {
81  template<> struct typed_flags<SvLBoxTabFlags> : is_typed_flags<SvLBoxTabFlags, 0x007f> {};
82 }
83 
84 #define SV_TAB_BORDER 8
85 
86 #define SV_ENTRYHEIGHTOFFS_PIXEL 2
87 
88 enum class SvTreeFlags
89 {
90  CHKBTN = 0x01,
91  USESEL = 0x02,
92  MANINS = 0x04,
93  RECALCTABS = 0x08,
94  FIXEDHEIGHT = 0x10,
95 };
96 namespace o3tl
97 {
98  template<> struct typed_flags<SvTreeFlags> : is_typed_flags<SvTreeFlags, 0x1f> {};
99 }
100 
102 
104 {
105  long nPos;
106 public:
107  SvLBoxTab();
108  SvLBoxTab( long nPos, SvLBoxTabFlags nFlags );
109  SvLBoxTab( const SvLBoxTab& );
110  ~SvLBoxTab();
111 
113 
114  bool IsDynamic() const { return bool(nFlags & SvLBoxTabFlags::DYNAMIC); }
115  void SetPos( long nNewPos) { nPos = nNewPos; }
116  long GetPos() const { return nPos; }
117  long CalcOffset( long nItemLength, long nTabWidth );
118  bool IsEditable() const { return bool(nFlags & SvLBoxTabFlags::EDITABLE); }
119 };
120 
122 {
123 protected:
125 
126 public:
127  SvLBoxItem();
128  virtual ~SvLBoxItem();
129  virtual SvLBoxItemType GetType() const = 0;
130  virtual int CalcWidth(const SvTreeListBox* pView) const;
131  int GetWidth(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
132  int GetWidth(const SvTreeListBox* pView, const SvViewDataEntry* pData, sal_uInt16 nItemPos);
133  int GetHeight(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
134  static int GetHeight(const SvViewDataEntry* pData, sal_uInt16 nItemPos);
135  void Enable(bool bEnabled) { mbDisabled = !bEnabled; }
136 
137  virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) = 0;
138 
139  virtual void InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry,
140  // If != 0: this Pointer must be used!
141  // If == 0: it needs to be retrieved via the View
142  SvViewDataItem* pViewData = nullptr) = 0;
143  // View-dependent data is not cloned
144  virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const = 0;
145 };
146 
147 enum class DragDropMode
148 {
149  NONE = 0x0000,
150  CTRL_MOVE = 0x0001,
151  CTRL_COPY = 0x0002,
152  APP_MOVE = 0x0004,
153  APP_COPY = 0x0008,
154  APP_DROP = 0x0010,
155  // Entries may be dropped via the uppermost Entry
156  // The DropTarget is 0 in that case
157  ENABLE_TOP = 0x0020,
158  ALL = 0x003f,
159 };
160 namespace o3tl
161 {
162  template<> struct typed_flags<DragDropMode> : is_typed_flags<DragDropMode, 0x003f> {};
163 }
164 
166 {
167  NONE = 0x0000,
168  IN_EDT = 0x0001,
169  EDT_ENABLED = 0x0002,
170  TARGEMPH_VIS = 0x0004,
171  EDTEND_CALLED = 0x0008,
172 };
173 namespace o3tl
174 {
175  template<> struct typed_flags<SvTreeListBoxFlags> : is_typed_flags<SvTreeListBoxFlags, 0x000f> {};
176 }
177 
178 struct SvTreeListBoxImpl;
179 
181  :public Control
182  ,public SvListView
183  ,public DropTargetHelper
184  ,public DragSourceHelper
187 {
188  friend class SvImpLBox;
189  friend class IconViewImpl;
190  friend class TreeControlPeer;
191  friend class SalInstanceIconView;
192  friend class SalInstanceTreeView;
194 
195  std::unique_ptr<SvTreeListBoxImpl> mpImpl;
204 
209 
212  short nIndent;
213  short nFocusWidth;
214  sal_uInt16 nFirstSelTab;
215  sal_uInt16 nLastSelTab;
220  bool mbQuickSearch; // Enables type-ahead search in the check list box.
221 
223 
227  sal_Int32 nMinWidthInChars;
228 
230 
233 
235 
236 protected:
237  std::unique_ptr<SvImpLBox> pImpl;
238  short nColumns;
240  short nEntryWidth;
242 
246  std::vector<std::unique_ptr<SvLBoxTab>> aTabs;
249  // Move/CopySelection: Position of the current Entry in SelectionList
250  sal_uInt16 nCurEntrySelPos;
251 
252 private:
253  DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData *, void );
254  DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl, SvInplaceEdit2&, void );
255  // Handler that is called by TreeList to clone an Entry
257 
258  // Handler and methods for Drag - finished handler.
259  // The Handle retrieved by GetDragFinishedHdl can be set on the
260  // TransferDataContainer. This link is a callback for the DragFinished
261  // call. The AddBox method is called from the GetDragFinishedHdl() and the
262  // remove is called in the link callback and in the dtor. So it can't be
263  // called for a deleted object.
264  VCL_DLLPRIVATE static void AddBoxToDDList_Impl( const SvTreeListBox& rB );
265  VCL_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvTreeListBox& rB );
266  DECL_DLLPRIVATE_LINK( DragFinishHdl_Impl, sal_Int8, void );
267 
268  // after a checkbox entry is inserted, use this to get its width to support
269  // autowidth for the 1st checkbox column
270  VCL_DLLPRIVATE void CheckBoxInserted(SvTreeListEntry* pEntry);
271 
272 protected:
273 
274  bool CheckDragAndDropMode( SvTreeListBox const * pSource, sal_Int8 );
275  void ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow);
276  void EnableSelectionAsDropTarget( bool bEnable = true );
277  // Standard impl returns 0; derived classes which support D'n'D must override
278  using Window::GetDropTarget;
279  virtual SvTreeListEntry* GetDropTarget( const Point& );
280 
281  // Invalidate children on enable/disable
282  virtual void StateChanged( StateChangedType eType ) override;
283 
284  virtual sal_uLong Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uLong nPos=TREELIST_APPEND);
285  virtual sal_uLong Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos = TREELIST_APPEND );
286 
287  // In-place editing
288  std::unique_ptr<SvInplaceEdit2> pEdCtrl;
289  void EditText( const OUString&, const tools::Rectangle&,const Selection&);
290  void CancelTextEditing();
291  bool EditingCanceled() const;
292 
293  // InitViewData is called right after CreateViewData
294  // The Entry is has not yet been added to the View in InitViewData!
295  virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ) override;
296  // Calls InitViewData for all Items
297  void RecalcViewData();
298 
299  // Handler and methods for Drag - finished handler. This link can be set
300  // to the TransferDataContainer. The AddBox/RemoveBox methods must be
301  // called before the StartDrag call.
302  // The Remove will be called from the handler, which then calls DragFinish.
303  // The Remove is also called in the DTOR of the SvTreeListBox -
304  // so it can't be called for a deleted object.
305  Link<sal_Int8,void> GetDragFinishedHdl() const;
306 
307  // For asynchronous D'n'D
308  sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView );
309 
310  void OnCurrentEntryChanged();
311 
312  // IMnemonicEntryList
313  virtual const void* FirstSearchEntry( OUString& _rEntryText ) const override;
314  virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, OUString& _rEntryText ) const override;
315  virtual void SelectSearchEntry( const void* _pEntry ) override;
316  virtual void ExecuteSearchEntry( const void* _pEntry ) const override;
317 
318  // ISearchableStringList
319  virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const override;
320  virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const override;
321  virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) override;
322 
323 public:
324 
325  SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 );
326  virtual ~SvTreeListBox() override;
327  virtual void dispose() override;
328 
330  {
331  return pModel.get();
332  }
333 
335  {
336  return pModel ? pModel->GetEntryCount() : 0;
337  }
339  {
340  return pModel ? pModel->First() : nullptr;
341  }
343  {
344  return pModel->Next(pEntry);
345  }
347  {
348  return pModel->Prev(pEntry);
349  }
351  {
352  return pModel ? pModel->Last() : nullptr;
353  }
354 
355  SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const;
356 
357  bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget );
358  bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback );
359  void RemoveSelection();
363  void RemoveEntry(SvTreeListEntry const * pEntry);
364 
365  DragDropMode GetDragDropMode() const { return nDragDropMode; }
366  SelectionMode GetSelectionMode() const { return eSelMode; }
367 
368  // pParent == 0 -> Root level
369  SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const;
370  SvTreeListEntry* GetEntry( sal_uLong nRootPos ) const;
371 
372  SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const;
373  void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const;
374 
375  using Window::GetParent;
376  const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const;
377  SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const;
378  SvTreeListEntry* GetRootLevelParent(SvTreeListEntry* pEntry ) const;
379 
380  using Window::GetChildCount;
381  sal_uLong GetChildCount( SvTreeListEntry const * pParent ) const;
382  sal_uLong GetLevelChildCount( SvTreeListEntry* pParent ) const;
383 
384  SvViewDataEntry* GetViewDataEntry( SvTreeListEntry const * pEntry ) const;
385  SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *);
386  const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const;
387 
388  bool IsInplaceEditingEnabled() const { return bool(nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); }
389  bool IsEditingActive() const { return bool(nImpFlags & SvTreeListBoxFlags::IN_EDT); }
390  void EndEditing( bool bCancel = false );
391 
392  void Clear();
393 
406  void EnableEntryMnemonics();
407  bool IsEntryMnemonicsEnabled() const;
408 
409  bool TextCenterAndClipEnabled() const { return mbCenterAndClipText; }
410 
428  bool HandleKeyInput( const KeyEvent& rKEvt );
429 
430  void SetSelectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aSelectHdl=rNewHdl; }
431  void SetDeselectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aDeselectHdl=rNewHdl; }
432  void SetDoubleClickHdl(const Link<SvTreeListBox*,bool>& rNewHdl) {aDoubleClickHdl=rNewHdl;}
433  const Link<SvTreeListBox*,bool>& GetDoubleClickHdl() const { return aDoubleClickHdl; }
434  void SetExpandingHdl(const Link<SvTreeListBox*,bool>& rNewHdl){aExpandingHdl=rNewHdl;}
435  void SetExpandedHdl(const Link<SvTreeListBox*,void>& rNewHdl){aExpandedHdl=rNewHdl;}
436  void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink) { aPopupMenuHdl = rLink; }
437  void SetTooltipHdl(const Link<const HelpEvent&, bool>& rLink) { aTooltipHdl = rLink; }
438 
439  virtual void ExpandedHdl();
440  virtual bool ExpandingHdl();
441  virtual void SelectHdl();
442  virtual void DeselectHdl();
443  virtual bool DoubleClickHdl();
444  SvTreeListEntry* GetHdlEntry() const { return pHdlEntry; }
445 
446  // Is called for an Entry that gets expanded with the Flag
447  // ENTRYFLAG_CHILDREN_ON_DEMAND set.
448  virtual void RequestingChildren( SvTreeListEntry* pParent );
449 
450  // Drag & Drop
451  // New D'n'D API
452  virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
453  virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
454  virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
455  virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
456  SvTreeListEntry* );
457  virtual void DragFinished( sal_Int8 nDropAction );
458  virtual bool NotifyAcceptDrop( SvTreeListEntry* );
459 
460  SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource );
461 
462  // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
463  virtual TriState NotifyMoving(
464  SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel()
465  SvTreeListEntry* pEntry, // Entry to be moved from GetSourceListBox()->GetModel()
466  SvTreeListEntry*& rpNewParent, // New TargetParent
467  sal_uLong& rNewChildPos); // The TargetParent's position in Childlist
468 
469  // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
470  virtual TriState NotifyCopying(
471  SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel()
472  SvTreeListEntry* pEntry, // Entry to be copied from GetSourceListBox()->GetModel()
473  SvTreeListEntry*& rpNewParent, // New TargetParent
474  sal_uLong& rNewChildPos); // The TargetParent's position in Childlist
475 
476  // ACCESSIBILITY ==========================================================
477 
479  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
480 
482  void FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const;
483 
488  tools::Rectangle GetBoundingRect(const SvTreeListEntry* pEntry);
489 
490  SvTreeFlags GetTreeFlags() const {return nTreeFlags;}
491 
492  static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry);
493  virtual OUString GetEntryAltText(SvTreeListEntry* pEntry) const;
494  virtual OUString GetEntryLongDescription(SvTreeListEntry* pEntry) const;
495 
496  void set_min_width_in_chars(sal_Int32 nChars);
497 
498  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
499 
500 protected:
501 
502  VCL_DLLPRIVATE void SetEntryHeight( SvTreeListEntry const * pEntry );
503  void AdjustEntryHeight( const Image& rBmp );
504  VCL_DLLPRIVATE void AdjustEntryHeight();
505 
506  VCL_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry );
507  VCL_DLLPRIVATE void PaintEntry1( SvTreeListEntry&, long nLine, vcl::RenderContext& rRenderContext );
508 
509  VCL_DLLPRIVATE void InitTreeView();
510  VCL_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, long nX, SvLBoxTab** ppTab );
511  VCL_DLLPRIVATE void ImplInitStyle();
512 
513  void SetupDragOrigin();
514  void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem,
515  const Selection& );
516  void EditedText(const OUString&);
517 
518  // Recalculate all tabs depending on TreeListStyle and Bitmap sizes
519  // Is called automatically when inserting/changing Bitmaps, changing the Model etc.
520  virtual void SetTabs();
521  void AddTab( long nPos, SvLBoxTabFlags nFlags );
522  sal_uInt16 TabCount() const { return aTabs.size(); }
523  SvLBoxTab* GetFirstDynamicTab() const;
524  SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const;
525  SvLBoxTab* GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos );
526  void GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos );
527  SvLBoxTab* GetTab( SvTreeListEntry const *, SvLBoxItem const * ) const;
528  void ClearTabList();
529 
530  virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&);
531 
532  virtual void NotifyEndScroll();
533  virtual void NotifyScrolled();
534  void SetScrolledHdl( const Link<SvTreeListBox*,void>& rLink ) { aScrolledHdl = rLink; }
535  long GetXOffset() const { return GetMapMode().GetOrigin().X(); }
536 
537  virtual void Command( const CommandEvent& rCEvt ) override;
538 
539  virtual void RequestHelp( const HelpEvent& rHEvt ) override;
540  virtual void PreparePaint(vcl::RenderContext& rRenderContext, SvTreeListEntry& rEntry);
541  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
542 
543  void InitSettings();
544 
545  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
546 
547  void CallImplEventListeners(VclEventId nEvent, void* pData);
548 
549  void ImplEditEntry( SvTreeListEntry* pEntry );
550 
551  void AdjustEntryHeightAndRecalc();
552 public:
553 
554  void SetNoAutoCurEntry( bool b );
555 
556  void EnableCheckButton( SvLBoxButtonData* );
557  void SetCheckButtonData( SvLBoxButtonData* );
558  void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp );
559 
563  static const Image& GetDefaultExpandedNodeImage( );
564 
568  static const Image& GetDefaultCollapsedNodeImage( );
569 
573  {
574  SetNodeBitmaps(
575  GetDefaultCollapsedNodeImage( ),
576  GetDefaultExpandedNodeImage( )
577  );
578  }
579 
580  virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr,
581  bool bChildrenOnDemand = false,
582  sal_uLong nPos=TREELIST_APPEND, void* pUserData = nullptr);
583 
584  virtual SvTreeListEntry* InsertEntry( const OUString& rText,
585  const Image& rExpandedEntryBmp,
586  const Image& rCollapsedEntryBmp,
587  SvTreeListEntry* pParent = nullptr,
588  bool bChildrenOnDemand = false,
589  sal_uLong nPos = TREELIST_APPEND, void* pUserData = nullptr );
590 
591  const Image& GetDefaultExpandedEntryBmp( ) const;
592  const Image& GetDefaultCollapsedEntryBmp( ) const;
593 
594  void SetDefaultExpandedEntryBmp( const Image& rBmp );
595  void SetDefaultCollapsedEntryBmp( const Image& rBmp );
596 
597  void SetCheckButtonState( SvTreeListEntry*, SvButtonState );
598  SvButtonState GetCheckButtonState( SvTreeListEntry* ) const;
599 
600  void SetEntryText(SvTreeListEntry*, const OUString& );
601  void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
602  void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
603 
604  virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const;
605  static const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry );
606  static const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry );
607 
608  void SetCheckButtonHdl( const Link<SvTreeListBox*,void>& rLink ) { aCheckButtonHdl=rLink; }
609  virtual void CheckButtonHdl();
610 
611  void SetSublistOpenWithReturn(); // open/close sublist with return/enter
612  void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right
613  void SetSublistDontOpenWithDoubleClick( bool bDontOpen ); // set mouse double click open/close sublist behavior
614 
615  void EnableInplaceEditing( bool bEnable );
616  // Edits the Entry's first StringItem, 0 == Cursor
617  void EditEntry( SvTreeListEntry* pEntry );
618  virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& );
619  virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText );
620 
621  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
622  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
623  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
624  virtual void MouseMove( const MouseEvent& rMEvt ) override;
625  virtual void KeyInput( const KeyEvent& rKEvt ) override;
626  virtual void Resize() override;
627  virtual void GetFocus() override;
628  virtual void LoseFocus() override;
629  void SetUpdateMode( bool );
630 
631  virtual void ModelHasCleared() override;
632  virtual void ModelHasInserted( SvTreeListEntry* pEntry ) override;
633  virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ) override;
634  virtual void ModelIsMoving(SvTreeListEntry* pSource ) override;
635  virtual void ModelHasMoved(SvTreeListEntry* pSource ) override;
636  virtual void ModelIsRemoving( SvTreeListEntry* pEntry ) override;
637  virtual void ModelHasRemoved( SvTreeListEntry* pEntry ) override;
638  void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ) override;
639 
640  void ScrollOutputArea( short nDeltaEntries );
641 
642  short GetColumnsCount() const { return nColumns; }
643  short GetEntryHeight() const { return nEntryHeight; }
644  void SetEntryHeight( short nHeight, bool bForce = false );
645  short GetEntryWidth() const { return nEntryWidth; }
646  void SetEntryWidth( short nWidth );
647  Size GetOutputSizePixel() const;
648  short GetIndent() const { return nIndent; }
649  void SetIndent( short nIndent );
650  // Place the expander checkitem at the optimal indent for hierarchical lists
651  void SetOptimalImageIndent() { SetIndent(12); }
652  void SetSpaceBetweenEntries( short nSpace );
653  Point GetEntryPosition(const SvTreeListEntry*) const;
654  void MakeVisible( SvTreeListEntry* pEntry );
655  void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop );
656 
657  void SetCollapsedNodeBmp( const Image& );
658  void SetExpandedNodeBmp( const Image& );
659  Image const & GetExpandedNodeBmp( ) const;
660 
661  void SetFont( const vcl::Font& rFont );
662 
663  using Window::SetCursor;
664  void SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect = false );
665 
666  SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const;
667 
668  virtual tools::Rectangle GetFocusRect(const SvTreeListEntry*, long nLine );
669  // Respects indentation
670  virtual sal_IntPtr GetTabPos(const SvTreeListEntry*, SvLBoxTab*);
671  void InvalidateEntry( SvTreeListEntry* );
672  SvLBoxItem* GetItem( SvTreeListEntry*, long nX, SvLBoxTab** ppTab);
673  SvLBoxItem* GetItem( SvTreeListEntry*, long nX );
674 
675  void SetDragDropMode( DragDropMode );
676  void SetSelectionMode( SelectionMode );
677 
678  virtual bool Expand( SvTreeListEntry* pParent );
679  virtual bool Collapse( SvTreeListEntry* pParent );
680  virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true );
681  sal_uLong SelectChildren( SvTreeListEntry* pParent, bool bSelect );
682  void SelectAll( bool bSelect, bool bPaint = true );
683 
684  void SetCurEntry( SvTreeListEntry* _pEntry );
685  SvTreeListEntry* GetCurEntry() const;
686 
687  using Window::Invalidate;
688  virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE) override;
689  virtual void Invalidate( const tools::Rectangle&, InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
690 
691  void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff);
692 
693  // A Parent's Children are turned into Children of the Parent which comes next in hierarchy
694  void RemoveParentKeepChildren( SvTreeListEntry* pParent );
695 
696  sal_Int32 DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText);
697 
698  DECL_LINK( DefaultCompare, const SvSortData&, sal_Int32 );
699  virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1,
700  SvTreeListEntry* pEntry2, sal_uLong nPos ) override;
701 
702  void EndSelection();
703  ScrollBar* GetVScroll();
704  void EnableAsyncDrag( bool b );
705 
706  SvTreeListEntry* GetFirstEntryInView() const;
707  SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const;
708  SvTreeListEntry* GetPrevEntryInView(SvTreeListEntry*) const;
709  SvTreeListEntry* GetLastEntryInView() const;
710  void ScrollToAbsPos( long nPos );
711 
712  void ShowFocusRect( const SvTreeListEntry* pEntry );
713 
714  virtual VclPtr<PopupMenu> CreateContextMenu();
715  virtual void ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
716 
717  void EnableContextMenuHandling();
718 
719  long getPreferredDimensions(std::vector<long> &rWidths) const;
720 
721  virtual Size GetOptimalSize() const override;
722 
723  void SetAlternatingRowColors( const bool bEnable );
724 
725  // Enables type-ahead search in the check list box.
726  void SetQuickSearch(bool bEnable) { mbQuickSearch = bEnable; }
727 
728  void SetForceMakeVisible(bool bEnable);
729 
730  virtual FactoryFunction GetUITestFactory() const override;
731 
732  void SetDragHelper(rtl::Reference<TransferDataContainer>& rHelper, sal_uInt8 eDNDConstants);
733 };
734 
736 {
738  Accelerator aAccReturn;
739  Accelerator aAccEscape;
742  bool bCanceled;
744 
745  void CallCallBackHdl_Impl();
746  DECL_LINK( Timeout_Impl, Timer *, void );
747  DECL_LINK( ReturnHdl_Impl, Accelerator&, void );
748  DECL_LINK( EscapeHdl_Impl, Accelerator&, void );
749 
750 public:
751  SvInplaceEdit2( vcl::Window* pParent, const Point& rPos, const Size& rSize,
752  const OUString& rData, const Link<SvInplaceEdit2&,void>& rNotifyEditEnd,
753  const Selection& );
754  ~SvInplaceEdit2();
755  bool KeyInput( const KeyEvent& rKEvt );
756  void LoseFocus();
757  bool EditingCanceled() const { return bCanceled; }
758  OUString GetText() const;
759  OUString const & GetSavedValue() const;
760  void StopEditing( bool bCancel );
761  void Hide();
762 };
763 
764 #endif
765 
766 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void ModelHasEntryInvalidated(SvTreeListEntry *pEntry)
Definition: treelist.cxx:1176
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3943
void SetDeselectHdl(const Link< SvTreeListBox *, void > &rNewHdl)
SvListAction
Definition: treelist.hxx:32
sal_uInt16 TabCount() const
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:414
bool KeyInput(const KeyEvent &rKEvt)
void CallCallBackHdl_Impl()
Link< const HelpEvent &, bool > aTooltipHdl
void SetExpandingHdl(const Link< SvTreeListBox *, bool > &rNewHdl)
InvalidateFlags
Definition: window.hxx:213
signed char sal_Int8
SvTreeList * GetModel() const
bool IsEditingActive() const
const SfxPoolItem * GetItem(const SwTextAttr &rAttr, sal_uInt16 nWhich)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void SetDoubleClickHdl(const Link< SvTreeListBox *, bool > &rNewHdl)
OUString const & GetSavedValue() const
sal_uIntPtr sal_uLong
sal_uLong GetEntryCount() const
bool mbCenterAndClipText
virtual StringEntryIdentifier CurrentEntry(OUString &_out_entryText) const =0
returns the current entry in the list of searchable strings.
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:260
void SetScrolledHdl(const Link< SvTreeListBox *, void > &rLink)
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
SvInplaceEdit2(vcl::Window *pParent, const Point &rPos, const Size &rSize, const OUString &rData, const Link< SvInplaceEdit2 &, void > &rNotifyEditEnd, const Selection &)
Definition: treelistbox.cxx:98
const MapMode & GetMapMode() const
Definition: outdev.hxx:1681
SelectionMode
Definition: vclenum.hxx:26
bool IsDynamic() const
Link< const CommandEvent &, bool > aPopupMenuHdl
short nContextBmpWidthMax
bool mbUpdateAlternatingRows
SelectionMode GetSelectionMode() const
long GetPos() const
short GetColumnsCount() const
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ctrl.cxx:418
View-dependent data for a tree list entry created in the virtual function SvTreeListBox::CreateViewDa...
virtual void MouseButtonUp(const MouseEvent &rMEvt)
Definition: mouse.cxx:421
SvTreeListBoxFlags nImpFlags
bool mbAlternatingRowColors
long mnCheckboxItemWidth
SvTreeFlags
Definition: treelistbox.hxx:88
SvLBoxTabFlags nFlags
Accelerator aAccEscape
StateChangedType
Definition: window.hxx:311
VclPtr< Edit > pEdit
SvLBoxItemType
sal_Int64 WinBits
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
rtl::Reference< TransferDataContainer > m_xTransferHelper
DragDropMode
SvLBoxButtonData * pCheckButtonData
virtual void SelectEntry(StringEntryIdentifier _entry)=0
selects a given entry
bool mbContextBmpExpanded
sal_Int32 nMinWidthInChars
SvTreeListBoxFlags
SvLBoxItem * pEdItem
virtual void ModelHasInsertedTree(SvTreeListEntry *pEntry)
Definition: treelist.cxx:1152
Link< SvTreeListBox *, bool > aDoubleClickHdl
VclEventId
Definition: vclevent.hxx:41
Image aCurInsertedExpBmp
const void * StringEntryIdentifier
virtual void SelectSearchEntry(const void *_pEntry)=0
"selects" a given entry.
void SetSelectHdl(const Link< SvTreeListBox *, void > &rNewHdl)
Definition: edit.hxx:55
void Enable(bool bEnabled)
short GetEntryHeight() const
Link< SvTreeListBox *, void > aDeselectHdl
SvTreeListEntry * GetHdlEntry() const
DragDropMode nOldDragMode
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
Definition: transfer2.cxx:292
SvTreeListEntry * pHdlEntry
callback for a MnemonicEngine
sal_uInt16 nCurEntrySelPos
SvTreeListEntry * pTargetEntry
Image aCurInsertedColBmp
Image aPrevInsertedExpBmp
void StopEditing(bool bCancel)
short GetEntryWidth() const
Accelerator aAccReturn
SelectionMode eSelMode
void SetPos(long nNewPos)
sal_uInt16 nLastSelTab
virtual void InitViewData(SvViewDataEntry *, SvTreeListEntry *pEntry)
Definition: treelist.cxx:1337
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
DragDropMode nDragDropMode
bool IsEditable() const
void Clear()
Definition: treelist.cxx:1128
DECL_LINK(AutocompleteHdl, Edit &, void)
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt)
Definition: transfer2.cxx:286
Link< SvInplaceEdit2 &, void > aCallBackHdl
OUString GetText() const
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1160
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
Definition: mouse.cxx:659
void SetUpdateMode(bool bUpdate)
Definition: window.cxx:3022
Link< SvTreeListBox *, void > aExpandedHdl
virtual void ExecuteSearchEntry(const void *_pEntry) const =0
"executes" the current search entry, i.e.
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
std::unique_ptr< SvImpLBox > pImpl
virtual void ModelHasRemoved(SvTreeListEntry *pEntry)
Definition: treelist.cxx:1169
void SetPopupMenuHdl(const Link< const CommandEvent &, bool > &rLink)
Link< SvTreeListBox *, void > aSelectHdl
void SetCheckButtonHdl(const Link< SvTreeListBox *, void > &rLink)
SvButtonState
Definition: treelistbox.hxx:57
bool TextCenterAndClipEnabled() const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:59
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
void SetNodeDefaultImages()
Sets default bitmaps for collapsed and expanded nodes.
Image aPrevInsertedColBmp
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1432
Link< SvTreeListBox *, void > aCheckButtonHdl
DragDropMode GetDragDropMode() const
virtual void LoseFocus()
Definition: window.cxx:1869
void SetTooltipHdl(const Link< const HelpEvent &, bool > &rLink)
vcl::Window * GetParent() const
Definition: window2.cxx:1097
void SetExpandedHdl(const Link< SvTreeListBox *, void > &rNewHdl)
long CalcOffset(long nItemLength, long nTabWidth)
SvTreeListEntry * Next(SvTreeListEntry *pEntry) const
std::vector< std::unique_ptr< SvLBoxTab > > aTabs
std::unique_ptr< SvTreeListBoxImpl > mpImpl
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1819
virtual Size GetOptimalSize() const override
Definition: ctrl.cxx:374
SvTreeListEntry * First() const
void SetOptimalImageIndent()
bool IsInplaceEditingEnabled() const
sal_uInt16 GetChildCount() const
Definition: stacking.cxx:1012
Link< SvTreeListBox *, bool > aExpandingHdl
virtual StringEntryIdentifier NextEntry(StringEntryIdentifier _currentEntry, OUString &_out_entryText) const =0
returns the next entry in the list.
virtual void Resize() override
Definition: ctrl.cxx:74
virtual void ModelIsRemoving(SvTreeListEntry *pEntry)
Definition: treelist.cxx:1165
SvTreeListEntry * pEdEntry
Definition: ctrl.hxx:33
short nEntryHeightOffs
virtual const void * NextSearchEntry(const void *_pCurrentSearchEntry, OUString &_rEntryText) const =0
returns the next list entry for the mnemonic search
virtual void GetFocus()
Definition: window.cxx:1855
unsigned char sal_uInt8
sal_uInt16 nFirstSelTab
void SetCursor(vcl::Cursor *pCursor)
Definition: window.cxx:3068
void SetFont(const vcl::Font &rNewFont)
sal_Int8 mnDragAction
Definition: image.hxx:40
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1017
SvTreeListEntry * Last() const
const Point & GetOrigin() const
Definition: mapmod.cxx:170
#define VCL_DLLPRIVATE
Definition: dllapi.h:31
bool EditingCanceled() const
virtual void ModelIsMoving(SvTreeListEntry *pSource)
Definition: treelist.cxx:1156
virtual void MouseMove(const MouseEvent &rMEvt)
Definition: mouse.cxx:408
short GetIndent() const
Definition: timer.hxx:26
long GetXOffset() const
virtual void ModelHasCleared()
Definition: treelist.cxx:1144
SvLBoxTabFlags
Definition: treelistbox.hxx:63
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1937
SvTreeFlags nTreeFlags
TriState
DECL_LINK(Timeout_Impl, Timer *, void)
virtual void ModelNotification(SvListAction nActionId, SvTreeListEntry *pEntry1, SvTreeListEntry *pEntry2, sal_uLong nPos)
Definition: treelist.cxx:1289
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1883
virtual const void * FirstSearchEntry(OUString &_rEntryText) const =0
returns the first list entry for the mnemonic search
virtual void ModelHasMoved(SvTreeListEntry *pSource)
Definition: treelist.cxx:1161
virtual void ModelHasInserted(SvTreeListEntry *pEntry)
Definition: treelist.cxx:1148
SvTreeListEntry * Prev(SvTreeListEntry *pEntry) const
SvTreeFlags GetTreeFlags() const
void SetQuickSearch(bool bEnable)
Link< SvTreeListBox *, void > aScrolledHdl
std::unique_ptr< SvInplaceEdit2 > pEdCtrl
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:30
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35
const Link< SvTreeListBox *, bool > & GetDoubleClickHdl() const