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;
203 
208 
211  short nIndent;
212  short nFocusWidth;
213  sal_uInt16 nFirstSelTab;
214  sal_uInt16 nLastSelTab;
219  bool mbQuickSearch; // Enables type-ahead search in the check list box.
220 
222 
226  sal_Int32 nMinWidthInChars;
227 
230 
231 protected:
232  std::unique_ptr<SvImpLBox> pImpl;
233  short nColumns;
235  short nEntryWidth;
237 
241  std::vector<std::unique_ptr<SvLBoxTab>> aTabs;
244  // Move/CopySelection: Position of the current Entry in SelectionList
245  sal_uInt16 nCurEntrySelPos;
246 
247 private:
248  DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData *, void );
249  DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl, SvInplaceEdit2&, void );
250  // Handler that is called by TreeList to clone an Entry
252 
253  // Handler and methods for Drag - finished handler.
254  // The Handle retrieved by GetDragFinishedHdl can be set on the
255  // TransferDataContainer. This link is a callback for the DragFinished
256  // call. The AddBox method is called from the GetDragFinishedHdl() and the
257  // remove is called in the link callback and in the dtor. So it can't be
258  // called for a deleted object.
259  VCL_DLLPRIVATE static void AddBoxToDDList_Impl( const SvTreeListBox& rB );
260  VCL_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvTreeListBox& rB );
261  DECL_DLLPRIVATE_LINK( DragFinishHdl_Impl, sal_Int8, void );
262 
263  // after a checkbox entry is inserted, use this to get its width to support
264  // autowidth for the 1st checkbox column
265  VCL_DLLPRIVATE void CheckBoxInserted(SvTreeListEntry* pEntry);
266 
267 protected:
268 
269  bool CheckDragAndDropMode( SvTreeListBox const * pSource, sal_Int8 );
270  void ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow);
271  void EnableSelectionAsDropTarget( bool bEnable = true );
272  // Standard impl returns 0; derived classes which support D'n'D must override
273  using Window::GetDropTarget;
274  virtual SvTreeListEntry* GetDropTarget( const Point& );
275 
276  // Invalidate children on enable/disable
277  virtual void StateChanged( StateChangedType eType ) override;
278 
279  virtual sal_uLong Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uLong nPos=TREELIST_APPEND);
280  virtual sal_uLong Insert( SvTreeListEntry* pEntry,sal_uLong nRootPos = TREELIST_APPEND );
281 
282  // In-place editing
283  std::unique_ptr<SvInplaceEdit2> pEdCtrl;
284  void EditText( const OUString&, const tools::Rectangle&,const Selection&);
285  void CancelTextEditing();
286  bool EditingCanceled() const;
287 
288  // InitViewData is called right after CreateViewData
289  // The Entry is has not yet been added to the View in InitViewData!
290  virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ) override;
291  // Calls InitViewData for all Items
292  void RecalcViewData();
293 
294  // Handler and methods for Drag - finished handler. This link can be set
295  // to the TransferDataContainer. The AddBox/RemoveBox methods must be
296  // called before the StartDrag call.
297  // The Remove will be called from the handler, which then calls DragFinish.
298  // The Remove is also called in the DTOR of the SvTreeListBox -
299  // so it can't be called for a deleted object.
300  Link<sal_Int8,void> GetDragFinishedHdl() const;
301 
302  // For asynchronous D'n'D
303  sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView );
304 
305  void OnCurrentEntryChanged();
306 
307  // IMnemonicEntryList
308  virtual const void* FirstSearchEntry( OUString& _rEntryText ) const override;
309  virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, OUString& _rEntryText ) const override;
310  virtual void SelectSearchEntry( const void* _pEntry ) override;
311  virtual void ExecuteSearchEntry( const void* _pEntry ) const override;
312 
313  // ISearchableStringList
314  virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const override;
315  virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const override;
316  virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) override;
317 
318 public:
319 
320  SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 );
321  virtual ~SvTreeListBox() override;
322  virtual void dispose() override;
323 
325  {
326  return pModel.get();
327  }
328 
330  {
331  return pModel ? pModel->GetEntryCount() : 0;
332  }
334  {
335  return pModel ? pModel->First() : nullptr;
336  }
338  {
339  return pModel->Next(pEntry);
340  }
342  {
343  return pModel->Prev(pEntry);
344  }
346  {
347  return pModel ? pModel->Last() : nullptr;
348  }
349 
350  SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const;
351 
352  bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget );
353  bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback );
354  void RemoveSelection();
358  void RemoveEntry(SvTreeListEntry const * pEntry);
359 
360  DragDropMode GetDragDropMode() const { return nDragDropMode; }
361  SelectionMode GetSelectionMode() const { return eSelMode; }
362 
363  // pParent == 0 -> Root level
364  SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const;
365  SvTreeListEntry* GetEntry( sal_uLong nRootPos ) const;
366 
367  SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const;
368  void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const;
369 
370  using Window::GetParent;
371  const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const;
372  SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const;
373  SvTreeListEntry* GetRootLevelParent(SvTreeListEntry* pEntry ) const;
374 
375  using Window::GetChildCount;
376  sal_uLong GetChildCount( SvTreeListEntry const * pParent ) const;
377  sal_uLong GetLevelChildCount( SvTreeListEntry* pParent ) const;
378 
379  SvViewDataEntry* GetViewDataEntry( SvTreeListEntry const * pEntry ) const;
380  SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *);
381  const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const;
382 
383  bool IsInplaceEditingEnabled() const { return bool(nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); }
384  bool IsEditingActive() const { return bool(nImpFlags & SvTreeListBoxFlags::IN_EDT); }
385  void EndEditing( bool bCancel = false );
386 
387  void Clear();
388 
401  void EnableEntryMnemonics();
402  bool IsEntryMnemonicsEnabled() const;
403 
404  bool TextCenterAndClipEnabled() const { return mbCenterAndClipText; }
405 
423  bool HandleKeyInput( const KeyEvent& rKEvt );
424 
425  void SetSelectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aSelectHdl=rNewHdl; }
426  void SetDeselectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aDeselectHdl=rNewHdl; }
427  void SetDoubleClickHdl(const Link<SvTreeListBox*,bool>& rNewHdl) {aDoubleClickHdl=rNewHdl;}
428  const Link<SvTreeListBox*,bool>& GetDoubleClickHdl() const { return aDoubleClickHdl; }
429  void SetExpandingHdl(const Link<SvTreeListBox*,bool>& rNewHdl){aExpandingHdl=rNewHdl;}
430  void SetExpandedHdl(const Link<SvTreeListBox*,void>& rNewHdl){aExpandedHdl=rNewHdl;}
431  void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink) { aPopupMenuHdl = rLink; }
432 
433  virtual void ExpandedHdl();
434  virtual bool ExpandingHdl();
435  virtual void SelectHdl();
436  virtual void DeselectHdl();
437  virtual bool DoubleClickHdl();
438  SvTreeListEntry* GetHdlEntry() const { return pHdlEntry; }
439 
440  // Is called for an Entry that gets expanded with the Flag
441  // ENTRYFLAG_CHILDREN_ON_DEMAND set.
442  virtual void RequestingChildren( SvTreeListEntry* pParent );
443 
444  // Drag & Drop
445  // New D'n'D API
446  virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
447  virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
448  virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
449  virtual DragDropMode NotifyStartDrag( TransferDataContainer& rData,
450  SvTreeListEntry* );
451  virtual void DragFinished( sal_Int8 nDropAction );
452  virtual bool NotifyAcceptDrop( SvTreeListEntry* );
453 
454  virtual SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource );
455 
456  // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
457  virtual TriState NotifyMoving(
458  SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel()
459  SvTreeListEntry* pEntry, // Entry to be moved from GetSourceListBox()->GetModel()
460  SvTreeListEntry*& rpNewParent, // New TargetParent
461  sal_uLong& rNewChildPos); // The TargetParent's position in Childlist
462 
463  // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
464  virtual TriState NotifyCopying(
465  SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel()
466  SvTreeListEntry* pEntry, // Entry to be copied from GetSourceListBox()->GetModel()
467  SvTreeListEntry*& rpNewParent, // New TargetParent
468  sal_uLong& rNewChildPos); // The TargetParent's position in Childlist
469 
470  // ACCESSIBILITY ==========================================================
471 
473  virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
474 
476  void FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const;
477 
482  tools::Rectangle GetBoundingRect( SvTreeListEntry* pEntry );
483 
484  SvTreeFlags GetTreeFlags() const {return nTreeFlags;}
485 
486  static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry);
487  virtual OUString GetEntryAltText(SvTreeListEntry* pEntry) const;
488  virtual OUString GetEntryLongDescription(SvTreeListEntry* pEntry) const;
489 
490  void set_min_width_in_chars(sal_Int32 nChars);
491 
492  virtual bool set_property(const OString &rKey, const OUString &rValue) override;
493 
494 protected:
495 
496  VCL_DLLPRIVATE void SetEntryHeight( SvTreeListEntry const * pEntry );
497  void AdjustEntryHeight( const Image& rBmp );
498  VCL_DLLPRIVATE void AdjustEntryHeight();
499 
500  VCL_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry );
501  VCL_DLLPRIVATE void PaintEntry1( SvTreeListEntry&, long nLine, vcl::RenderContext& rRenderContext );
502 
503  VCL_DLLPRIVATE void InitTreeView();
504  VCL_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, long nX, SvLBoxTab** ppTab );
505  VCL_DLLPRIVATE void ImplInitStyle();
506 
507  void SetupDragOrigin();
508  void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem,
509  const Selection& );
510  void EditedText(const OUString&);
511 
512  // Recalculate all tabs depending on TreeListStyle and Bitmap sizes
513  // Is called automatically when inserting/changing Bitmaps, changing the Model etc.
514  virtual void SetTabs();
515  void AddTab( long nPos, SvLBoxTabFlags nFlags );
516  sal_uInt16 TabCount() const { return aTabs.size(); }
517  SvLBoxTab* GetFirstDynamicTab() const;
518  SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const;
519  SvLBoxTab* GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos );
520  void GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos );
521  SvLBoxTab* GetTab( SvTreeListEntry const *, SvLBoxItem const * ) const;
522  void ClearTabList();
523 
524  virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&);
525 
526  virtual void NotifyEndScroll();
527  virtual void NotifyScrolled();
528  void SetScrolledHdl( const Link<SvTreeListBox*,void>& rLink ) { aScrolledHdl = rLink; }
529  long GetXOffset() const { return GetMapMode().GetOrigin().X(); }
530 
531  virtual void Command( const CommandEvent& rCEvt ) override;
532 
533  virtual void RequestHelp( const HelpEvent& rHEvt ) override;
534  virtual void PreparePaint(vcl::RenderContext& rRenderContext, SvTreeListEntry& rEntry);
535  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
536 
537  void InitSettings();
538 
539  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
540 
541  bool IsCellFocusEnabled() const;
542  bool SetCurrentTabPos( sal_uInt16 _nNewPos );
543  sal_uInt16 GetCurrentTabPos() const;
544  void CallImplEventListeners(VclEventId nEvent, void* pData);
545 
546  void ImplEditEntry( SvTreeListEntry* pEntry );
547 
548  void AdjustEntryHeightAndRecalc();
549 public:
550 
551  void SetNoAutoCurEntry( bool b );
552 
553  void EnableCheckButton( SvLBoxButtonData* );
554  void SetCheckButtonData( SvLBoxButtonData* );
555  void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp );
556 
560  static const Image& GetDefaultExpandedNodeImage( );
561 
565  static const Image& GetDefaultCollapsedNodeImage( );
566 
570  {
571  SetNodeBitmaps(
572  GetDefaultCollapsedNodeImage( ),
573  GetDefaultExpandedNodeImage( )
574  );
575  }
576 
577  virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr,
578  bool bChildrenOnDemand = false,
579  sal_uLong nPos=TREELIST_APPEND, void* pUserData = nullptr);
580 
581  virtual SvTreeListEntry* InsertEntry( const OUString& rText,
582  const Image& rExpandedEntryBmp,
583  const Image& rCollapsedEntryBmp,
584  SvTreeListEntry* pParent = nullptr,
585  bool bChildrenOnDemand = false,
586  sal_uLong nPos = TREELIST_APPEND, void* pUserData = nullptr );
587 
588  const Image& GetDefaultExpandedEntryBmp( ) const;
589  const Image& GetDefaultCollapsedEntryBmp( ) const;
590 
591  void SetDefaultExpandedEntryBmp( const Image& rBmp );
592  void SetDefaultCollapsedEntryBmp( const Image& rBmp );
593 
594  void SetCheckButtonState( SvTreeListEntry*, SvButtonState );
595  SvButtonState GetCheckButtonState( SvTreeListEntry* ) const;
596 
597  void SetEntryText(SvTreeListEntry*, const OUString& );
598  void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
599  void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
600 
601  virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const;
602  static const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry );
603  static const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry );
604 
605  void SetCheckButtonHdl( const Link<SvTreeListBox*,void>& rLink ) { aCheckButtonHdl=rLink; }
606  virtual void CheckButtonHdl();
607 
608  void SetSublistOpenWithReturn(); // open/close sublist with return/enter
609  void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right
610  void SetSublistDontOpenWithDoubleClick( bool bDontOpen ); // set mouse double click open/close sublist behavior
611 
612  void EnableInplaceEditing( bool bEnable );
613  // Edits the Entry's first StringItem, 0 == Cursor
614  void EditEntry( SvTreeListEntry* pEntry );
615  virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& );
616  virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText );
617 
618  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
619  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
620  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
621  virtual void MouseMove( const MouseEvent& rMEvt ) override;
622  virtual void KeyInput( const KeyEvent& rKEvt ) override;
623  virtual void Resize() override;
624  virtual void GetFocus() override;
625  virtual void LoseFocus() override;
626  void SetUpdateMode( bool );
627 
628  virtual void ModelHasCleared() override;
629  virtual void ModelHasInserted( SvTreeListEntry* pEntry ) override;
630  virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ) override;
631  virtual void ModelIsMoving(SvTreeListEntry* pSource ) override;
632  virtual void ModelHasMoved(SvTreeListEntry* pSource ) override;
633  virtual void ModelIsRemoving( SvTreeListEntry* pEntry ) override;
634  virtual void ModelHasRemoved( SvTreeListEntry* pEntry ) override;
635  void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ) override;
636 
637  void ScrollOutputArea( short nDeltaEntries );
638 
639  short GetColumnsCount() const { return nColumns; }
640  short GetEntryHeight() const { return nEntryHeight; }
641  void SetEntryHeight( short nHeight, bool bForce = false );
642  short GetEntryWidth() const { return nEntryWidth; }
643  void SetEntryWidth( short nWidth );
644  Size GetOutputSizePixel() const;
645  short GetIndent() const { return nIndent; }
646  void SetIndent( short nIndent );
647  // Place the expander checkitem at the optimal indent for hierarchical lists
648  void SetOptimalImageIndent() { SetIndent(12); }
649  void SetSpaceBetweenEntries( short nSpace );
650  Point GetEntryPosition( SvTreeListEntry* ) const;
651  void MakeVisible( SvTreeListEntry* pEntry );
652  void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop );
653 
654  void SetCollapsedNodeBmp( const Image& );
655  void SetExpandedNodeBmp( const Image& );
656  Image const & GetExpandedNodeBmp( ) const;
657 
658  void SetFont( const vcl::Font& rFont );
659 
660  using Window::SetCursor;
661  void SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect = false );
662 
663  SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const;
664 
665  virtual tools::Rectangle GetFocusRect( SvTreeListEntry*, long nLine );
666  // Respects indentation
667  virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* );
668  void InvalidateEntry( SvTreeListEntry* );
669  SvLBoxItem* GetItem( SvTreeListEntry*, long nX, SvLBoxTab** ppTab);
670  SvLBoxItem* GetItem( SvTreeListEntry*, long nX );
671 
672  void SetDragDropMode( DragDropMode );
673  void SetSelectionMode( SelectionMode );
674 
675  virtual bool Expand( SvTreeListEntry* pParent );
676  virtual bool Collapse( SvTreeListEntry* pParent );
677  virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true );
678  sal_uLong SelectChildren( SvTreeListEntry* pParent, bool bSelect );
679  void SelectAll( bool bSelect, bool bPaint = true );
680 
681  void SetCurEntry( SvTreeListEntry* _pEntry );
682  SvTreeListEntry* GetCurEntry() const;
683 
684  using Window::Invalidate;
685  virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE) override;
686  virtual void Invalidate( const tools::Rectangle&, InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
687 
688  void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff);
689 
690  // A Parent's Children are turned into Children of the Parent which comes next in hierarchy
691  void RemoveParentKeepChildren( SvTreeListEntry* pParent );
692 
693  sal_Int32 DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText);
694 
695  DECL_LINK( DefaultCompare, const SvSortData&, sal_Int32 );
696  virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1,
697  SvTreeListEntry* pEntry2, sal_uLong nPos ) override;
698 
699  void EndSelection();
700  ScrollBar* GetVScroll();
701  ScrollBar* GetHScroll();
702  void EnableAsyncDrag( bool b );
703 
704  SvTreeListEntry* GetFirstEntryInView() const;
705  SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const;
706  SvTreeListEntry* GetPrevEntryInView(SvTreeListEntry*) const;
707  SvTreeListEntry* GetLastEntryInView() const;
708  void ScrollToAbsPos( long nPos );
709 
710  void ShowFocusRect( const SvTreeListEntry* pEntry );
711 
712  virtual VclPtr<PopupMenu> CreateContextMenu();
713  virtual void ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
714 
715  void EnableContextMenuHandling();
716 
717  long getPreferredDimensions(std::vector<long> &rWidths) const;
718 
719  virtual Size GetOptimalSize() const override;
720 
721  void SetAlternatingRowColors( const bool bEnable );
722 
723  // Enables type-ahead search in the check list box.
724  void SetQuickSearch(bool bEnable) { mbQuickSearch = bEnable; }
725 
726  void SetForceMakeVisible(bool bEnable);
727 
728  virtual FactoryFunction GetUITestFactory() const override;
729 };
730 
732 {
738  bool bCanceled;
740 
741  void CallCallBackHdl_Impl();
742  DECL_LINK( Timeout_Impl, Timer *, void );
743  DECL_LINK( ReturnHdl_Impl, Accelerator&, void );
744  DECL_LINK( EscapeHdl_Impl, Accelerator&, void );
745 
746 public:
747  SvInplaceEdit2( vcl::Window* pParent, const Point& rPos, const Size& rSize,
748  const OUString& rData, const Link<SvInplaceEdit2&,void>& rNotifyEditEnd,
749  const Selection& );
750  ~SvInplaceEdit2();
751  bool KeyInput( const KeyEvent& rKEvt );
752  void LoseFocus();
753  bool EditingCanceled() const { return bCanceled; }
754  OUString GetText() const;
755  OUString const & GetSavedValue() const;
756  void StopEditing( bool bCancel );
757  void Hide();
758 };
759 
760 #endif
761 
762 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void ModelHasEntryInvalidated(SvTreeListEntry *pEntry)
Definition: treelist.cxx:1180
virtual FactoryFunction GetUITestFactory() const
Definition: window.cxx:3888
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:413
bool KeyInput(const KeyEvent &rKEvt)
void CallCallBackHdl_Impl()
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:94
const MapMode & GetMapMode() const
Definition: outdev.hxx:1674
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:420
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()
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:1156
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:57
void Enable(bool bEnabled)
short GetEntryHeight() const
Link< SvTreeListBox *, void > aDeselectHdl
SvTreeListEntry * GetHdlEntry() const
DragDropMode nOldDragMode
Link< SvInplaceEdit2 &, void > const aCallBackHdl
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
Definition: transfer2.cxx:290
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:1341
Reference< XAnimationNode > Clone(const Reference< XAnimationNode > &xSourceNode, const SdPage *pSource, const SdPage *pTarget)
DragDropMode nDragDropMode
bool IsEditable() const
void Clear()
Definition: treelist.cxx:1132
DECL_LINK(AutocompleteHdl, Edit &, void)
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt)
Definition: transfer2.cxx:284
OUString GetText() const
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1156
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
Definition: mouse.cxx:658
void SetUpdateMode(bool bUpdate)
Definition: window.cxx:2971
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:1173
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:1420
Link< SvTreeListBox *, void > aCheckButtonHdl
DragDropMode GetDragDropMode() const
virtual void LoseFocus()
Definition: window.cxx:1818
vcl::Window * GetParent() const
Definition: window2.cxx:1086
long X() const
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:1768
virtual Size GetOptimalSize() const override
Definition: ctrl.cxx:374
SvTreeListEntry * First() const
void SetOptimalImageIndent()
bool IsInplaceEditingEnabled() const
sal_uInt16 GetChildCount() const
Definition: stacking.cxx:1001
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:1169
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:1804
sal_uInt16 nFirstSelTab
void SetCursor(vcl::Cursor *pCursor)
Definition: window.cxx:3017
void SetFont(const vcl::Font &rNewFont)
Definition: image.hxx:40
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1013
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:1160
virtual void MouseMove(const MouseEvent &rMEvt)
Definition: mouse.cxx:407
short GetIndent() const
Definition: timer.hxx:26
long GetXOffset() const
virtual void ModelHasCleared()
Definition: treelist.cxx:1148
SvLBoxTabFlags
Definition: treelistbox.hxx:63
virtual void Command(const CommandEvent &rCEvt)
Definition: window.cxx:1886
SvTreeFlags nTreeFlags
TriState
DECL_LINK(Timeout_Impl, Timer *, void)
virtual void ModelNotification(SvListAction nActionId, SvTreeListEntry *pEntry1, SvTreeListEntry *pEntry2, sal_uLong nPos)
Definition: treelist.cxx:1293
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1832
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:1165
virtual void ModelHasInserted(SvTreeListEntry *pEntry)
Definition: treelist.cxx:1152
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