Update git submodules
[LibreOffice.git] / include / vcl / toolkit / treelistbox.hxx
blob78db5bcc2231b17d2037d3131465700f13540f75
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
26 #include <config_options.h>
27 #include <vcl/dllapi.h>
29 #include <deque>
30 #include <memory>
31 #include <vector>
33 #include <vcl/ctrl.hxx>
34 #include <vcl/quickselectionengine.hxx>
35 #include <vcl/image.hxx>
36 #include <tools/gen.hxx>
37 #include <tools/contnr.hxx>
38 #include <vcl/toolkit/treelist.hxx>
39 #include <vcl/transfer.hxx>
40 #include <o3tl/typed_flags_set.hxx>
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;
53 enum class SvButtonState { Unchecked, Checked, Tristate };
55 // *********************************************************************
56 // *************************** Tabulators ******************************
57 // *********************************************************************
59 enum class SvLBoxTabFlags
61 NONE = 0x0000,
62 DYNAMIC = 0x0001, // Item's output column changes according to the Child Depth
63 ADJUST_RIGHT = 0x0002, // Item's right margin at the tabulator
64 ADJUST_LEFT = 0x0004, // Left margin
65 ADJUST_CENTER = 0x0008, // Center the item at the tabulator
67 SHOW_SELECTION = 0x0010, // Visualize selection state
68 // Item needs to be able to return the surrounding polygon (D'n'D cursor)
69 EDITABLE = 0x0020, // Item editable at the tabulator
70 FORCE = 0x0040, // Switch off the default calculation of the first tabulator
71 // (on which Abo Tabpage/Extras/Option/Customize, etc. rely on)
72 // The first tab's position corresponds precisely to the Flags set
73 // and column widths
75 namespace o3tl
77 template<> struct typed_flags<SvLBoxTabFlags> : is_typed_flags<SvLBoxTabFlags, 0x007f> {};
80 #define SV_TAB_BORDER 8
82 #define SV_ENTRYHEIGHTOFFS_PIXEL 2
84 enum class SvTreeFlags
86 CHKBTN = 0x01,
87 USESEL = 0x02,
88 MANINS = 0x04,
89 RECALCTABS = 0x08,
90 FIXEDHEIGHT = 0x10,
92 namespace o3tl
94 template<> struct typed_flags<SvTreeFlags> : is_typed_flags<SvTreeFlags, 0x1f> {};
97 enum class SvLBoxItemType {String, Button, ContextBmp};
99 class SvLBoxTab
101 tools::Long nPos;
102 public:
103 SvLBoxTab();
104 SvLBoxTab( tools::Long nPos, SvLBoxTabFlags nFlags );
105 SvLBoxTab( const SvLBoxTab& );
107 SvLBoxTabFlags nFlags;
109 bool IsDynamic() const { return bool(nFlags & SvLBoxTabFlags::DYNAMIC); }
110 void SetPos( tools::Long nNewPos) { nPos = nNewPos; }
111 tools::Long GetPos() const { return nPos; }
112 tools::Long CalcOffset( tools::Long nItemLength, tools::Long nTabWidth );
113 bool IsEditable() const { return bool(nFlags & SvLBoxTabFlags::EDITABLE); }
116 class UNLESS_MERGELIBS(VCL_DLLPUBLIC) SvLBoxItem
118 protected:
119 bool mbDisabled;
121 public:
122 SvLBoxItem();
123 virtual ~SvLBoxItem();
124 virtual SvLBoxItemType GetType() const = 0;
125 virtual int CalcWidth(const SvTreeListBox* pView) const;
126 int GetWidth(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
127 int GetWidth(const SvTreeListBox* pView, const SvViewDataEntry* pData, sal_uInt16 nItemPos) const;
128 int GetHeight(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
129 static int GetHeight(const SvViewDataEntry* pData, sal_uInt16 nItemPos);
130 void Enable(bool bEnabled) { mbDisabled = !bEnabled; }
131 bool isEnable() const { return !mbDisabled; }
133 virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) = 0;
135 virtual void InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry,
136 // If != 0: this Pointer must be used!
137 // If == 0: it needs to be retrieved via the View
138 SvViewDataItem* pViewData = nullptr) = 0;
139 // View-dependent data is not cloned
140 virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const = 0;
143 enum class DragDropMode
145 NONE = 0x0000,
146 CTRL_MOVE = 0x0001,
147 APP_COPY = 0x0004,
148 // Entries may be dropped via the uppermost Entry
149 // The DropTarget is 0 in that case
150 ENABLE_TOP = 0x0010,
151 ALL = 0x0015,
153 namespace o3tl
155 template<> struct typed_flags<DragDropMode> : is_typed_flags<DragDropMode, 0x0015> {};
158 enum class SvTreeListBoxFlags
160 NONE = 0x0000,
161 IN_EDT = 0x0001,
162 EDT_ENABLED = 0x0002,
163 TARGEMPH_VIS = 0x0004,
164 EDTEND_CALLED = 0x0008,
166 namespace o3tl
168 template<> struct typed_flags<SvTreeListBoxFlags> : is_typed_flags<SvTreeListBoxFlags, 0x000f> {};
171 struct SvTreeListBoxImpl;
173 typedef std::pair<vcl::RenderContext&, const SvTreeListEntry&> svtree_measure_args;
174 typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, const SvTreeListEntry&> svtree_render_args;
175 typedef std::pair<SvTreeListEntry*, OUString> IterString;
177 class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTreeListBox
178 :public Control
179 ,public SvListView
180 ,public DropTargetHelper
181 ,public DragSourceHelper
182 ,public vcl::ISearchableStringList
184 friend class SvImpLBox;
185 friend class SvLBoxString;
186 friend class IconViewImpl;
187 friend class TreeControlPeer;
188 friend class SalInstanceIconView;
189 friend class SalInstanceTreeView;
190 friend class SalInstanceEntryTreeView;
192 std::unique_ptr<SvTreeListBoxImpl> mpImpl;
193 Link<SvTreeListBox*,void> aScrolledHdl;
194 Link<SvTreeListBox*,void> aExpandedHdl;
195 Link<SvTreeListBox*,bool> aExpandingHdl;
196 Link<SvTreeListBox*,void> aSelectHdl;
197 Link<SvTreeListBox*,void> aDeselectHdl;
198 Link<const CommandEvent&, bool> aPopupMenuHdl;
199 Link<SvTreeListEntry*, OUString> aTooltipHdl;
200 Link<svtree_render_args, void> aCustomRenderHdl;
201 Link<svtree_measure_args, Size> aCustomMeasureHdl;
203 Image aPrevInsertedExpBmp;
204 Image aPrevInsertedColBmp;
205 Image aCurInsertedExpBmp;
206 Image aCurInsertedColBmp;
208 short nContextBmpWidthMax;
209 short nEntryHeightOffs;
210 short nIndent;
211 short nFocusWidth;
212 sal_uInt16 nFirstSelTab;
213 sal_uInt16 nLastSelTab;
214 tools::Long mnCheckboxItemWidth;
215 bool mbContextBmpExpanded;
216 bool mbQuickSearch; // Enables type-ahead search in the check list box.
217 bool mbActivateOnSingleClick; // Make single click "activate" a row like a double-click normally does
218 bool mbHoverSelection; // Make mouse over a row "select" a row like a single-click normally does
219 bool mbSelectingByHover; // true during "Select" if it was due to hover
220 bool mbIsTextColumEnabled; // true if the property name text-column is enabled
221 sal_Int8 mnClicksToToggle; // 0 == Click on a row not toggle its checkbox.
222 // 1 == Every click on row toggle its checkbox.
223 // 2 == First click select, second click toggle.
225 SvTreeListEntry* pHdlEntry;
227 DragDropMode nDragDropMode;
228 DragDropMode nOldDragMode;
229 SelectionMode eSelMode;
230 sal_Int32 nMinWidthInChars;
232 sal_Int8 mnDragAction;
234 SvTreeListEntry* pEdEntry;
235 SvLBoxString* pEdItem;
237 rtl::Reference<TransferDataContainer> m_xTransferHelper;
239 protected:
240 std::unique_ptr<SvImpLBox> pImpl;
241 short nColumns;
242 short nEntryHeight;
243 short nEntryWidth;
244 bool mbCenterAndClipText;
246 Link<SvTreeListBox*,bool> aDoubleClickHdl;
247 SvTreeListEntry* pTargetEntry;
248 SvLBoxButtonData* pCheckButtonData;
249 std::vector<std::unique_ptr<SvLBoxTab>> aTabs;
250 SvTreeFlags nTreeFlags;
251 SvTreeListBoxFlags nImpFlags;
252 // Move/CopySelection: Position of the current Entry in SelectionList
253 sal_uInt16 nCurEntrySelPos;
255 private:
256 DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData *, void );
257 DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl, SvInplaceEdit2&, void );
258 // Handler that is called by TreeList to clone an Entry
259 DECL_DLLPRIVATE_LINK( CloneHdl_Impl, SvTreeListEntry*, SvTreeListEntry* );
261 // Handler and methods for Drag - finished handler.
262 // The Handle retrieved by GetDragFinishedHdl can be set on the
263 // TransferDataContainer. This link is a callback for the DragFinished
264 // call. The AddBox method is called from the GetDragFinishedHdl() and the
265 // remove is called in the link callback and in the dtor. So it can't be
266 // called for a deleted object.
267 SAL_DLLPRIVATE static void AddBoxToDDList_Impl( const SvTreeListBox& rB );
268 SAL_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvTreeListBox& rB );
269 DECL_DLLPRIVATE_LINK( DragFinishHdl_Impl, sal_Int8, void );
271 // after a checkbox entry is inserted, use this to get its width to support
272 // autowidth for the 1st checkbox column
273 SAL_DLLPRIVATE void CheckBoxInserted(SvTreeListEntry* pEntry);
275 SAL_DLLPRIVATE void DrawCustomEntry(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const SvTreeListEntry& rEntry);
276 SAL_DLLPRIVATE Size MeasureCustomEntry(vcl::RenderContext& rRenderContext, const SvTreeListEntry& rEntry) const;
278 /** Handles the given key event.
280 At the moment this merely does typeahead if typeahead is enabled.
282 @return
283 <TRUE/> if the event has been consumed, <FALSE/> otherwise.
285 SAL_DLLPRIVATE bool HandleKeyInput(const KeyEvent& rKEvt);
287 void UnsetDropTarget();
289 protected:
291 bool CheckDragAndDropMode( SvTreeListBox const * pSource, sal_Int8 );
292 void ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow);
293 void EnableSelectionAsDropTarget( bool bEnable = true );
294 // Standard impl returns 0; derived classes which support D'n'D must override
295 using Window::GetDropTarget;
296 virtual SvTreeListEntry* GetDropTarget( const Point& );
298 // Invalidate children on enable/disable
299 virtual void StateChanged( StateChangedType eType ) override;
301 virtual sal_uInt32 Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uInt32 nPos=TREELIST_APPEND);
302 virtual sal_uInt32 Insert( SvTreeListEntry* pEntry,sal_uInt32 nRootPos = TREELIST_APPEND );
304 // In-place editing
305 std::unique_ptr<SvInplaceEdit2> pEdCtrl;
306 void EditText( const OUString&, const tools::Rectangle&,const Selection&);
307 void CancelTextEditing();
309 // InitViewData is called right after CreateViewData
310 // The Entry is has not yet been added to the View in InitViewData!
311 virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ) override;
312 // Calls InitViewData for all Items
313 void RecalcViewData();
315 // Handler and methods for Drag - finished handler. This link can be set
316 // to the TransferDataContainer. The AddBox/RemoveBox methods must be
317 // called before the StartDrag call.
318 // The Remove will be called from the handler, which then calls DragFinish.
319 // The Remove is also called in the DTOR of the SvTreeListBox -
320 // so it can't be called for a deleted object.
321 Link<sal_Int8,void> GetDragFinishedHdl() const;
323 // For asynchronous D'n'D
324 sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView );
326 void OnCurrentEntryChanged();
328 // ISearchableStringList
329 virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const override;
330 virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const override;
331 virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) override;
333 public:
335 SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 );
336 virtual ~SvTreeListBox() override;
337 virtual void dispose() override;
339 SvTreeList* GetModel() const
341 return pModel.get();
344 sal_uInt32 GetEntryCount() const
346 return pModel ? pModel->GetEntryCount() : 0;
348 SvTreeListEntry* First() const
350 return pModel ? pModel->First() : nullptr;
352 SvTreeListEntry* Next( SvTreeListEntry* pEntry ) const
354 return pModel->Next(pEntry);
356 SvTreeListEntry* Prev( SvTreeListEntry* pEntry ) const
358 return pModel->Prev(pEntry);
360 SvTreeListEntry* Last() const
362 return pModel ? pModel->Last() : nullptr;
365 SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const;
367 bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget );
368 bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback );
369 void RemoveSelection();
371 * Removes the entry along with all of its descendants
373 void RemoveEntry(SvTreeListEntry const * pEntry);
375 DragDropMode GetDragDropMode() const { return nDragDropMode; }
376 SelectionMode GetSelectionMode() const { return eSelMode; }
378 // pParent == 0 -> Root level
379 SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uInt32 nPos ) const;
380 SvTreeListEntry* GetEntry( sal_uInt32 nRootPos ) const;
382 SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const;
383 void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const;
385 using Window::GetParent;
386 SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const;
388 using Window::GetChildCount;
389 sal_uInt32 GetChildCount( SvTreeListEntry const * pParent ) const;
390 sal_uInt32 GetLevelChildCount( SvTreeListEntry* pParent ) const;
392 SvViewDataEntry* GetViewDataEntry( SvTreeListEntry const * pEntry ) const;
393 SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *);
394 const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const;
396 OUString GetEntryTooltip(SvTreeListEntry* pEntry) const { return aTooltipHdl.Call(pEntry); }
398 VclPtr<Edit> GetEditWidget() const; // for UITest
399 bool IsInplaceEditingEnabled() const { return bool(nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); }
400 bool IsEditingActive() const { return bool(nImpFlags & SvTreeListBoxFlags::IN_EDT); }
401 void EndEditing( bool bCancel = false );
403 void Clear();
405 bool TextCenterAndClipEnabled() const { return mbCenterAndClipText; }
407 void SetSelectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aSelectHdl=rNewHdl; }
408 void SetDeselectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aDeselectHdl=rNewHdl; }
409 void SetDoubleClickHdl(const Link<SvTreeListBox*,bool>& rNewHdl) {aDoubleClickHdl=rNewHdl;}
410 void SetExpandingHdl(const Link<SvTreeListBox*,bool>& rNewHdl){aExpandingHdl=rNewHdl;}
411 void SetExpandedHdl(const Link<SvTreeListBox*,void>& rNewHdl){aExpandedHdl=rNewHdl;}
412 void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink) { aPopupMenuHdl = rLink; }
413 void SetTooltipHdl(const Link<SvTreeListEntry*, OUString>& rLink) { aTooltipHdl = rLink; }
414 void SetCustomRenderHdl(const Link<svtree_render_args, void>& rLink) { aCustomRenderHdl = rLink; }
415 void SetCustomMeasureHdl(const Link<svtree_measure_args, Size>& rLink) { aCustomMeasureHdl = rLink; }
417 void ExpandedHdl();
418 bool ExpandingHdl();
419 void SelectHdl();
420 void DeselectHdl();
421 bool DoubleClickHdl();
422 SvTreeListEntry* GetHdlEntry() const { return pHdlEntry; }
424 // Is called for an Entry that gets expanded with the Flag
425 // ENTRYFLAG_CHILDREN_ON_DEMAND set.
426 virtual void RequestingChildren( SvTreeListEntry* pParent );
428 // Drag & Drop
429 // New D'n'D API
430 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
431 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
432 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
433 virtual DragDropMode NotifyStartDrag();
434 virtual void DragFinished( sal_Int8 nDropAction );
436 SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource );
438 // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
439 TriState NotifyMoving(
440 SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel()
441 const SvTreeListEntry* pEntry, // Entry to be moved from GetSourceListBox()->GetModel()
442 SvTreeListEntry*& rpNewParent, // New TargetParent
443 sal_uInt32& rNewChildPos); // The TargetParent's position in Childlist
445 // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
446 TriState NotifyCopying(
447 SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel()
448 const SvTreeListEntry* pEntry, // Entry to be copied from GetSourceListBox()->GetModel()
449 SvTreeListEntry*& rpNewParent, // New TargetParent
450 sal_uInt32& rNewChildPos); // The TargetParent's position in Childlist
452 // ACCESSIBILITY ==========================================================
454 /** Creates and returns the accessible object of the Box. */
455 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
457 /** Fills the StateSet of one entry. */
458 void FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, sal_Int64& rStateSet ) const;
460 virtual OUString GetEntryAccessibleDescription(SvTreeListEntry* pEntry) const;
462 /** Calculate and return the bounding rectangle of an entry.
463 @param pEntry
464 The entry.
465 @return The bounding rectangle of an entry. */
466 tools::Rectangle GetBoundingRect(const SvTreeListEntry* pEntry);
468 SvTreeFlags GetTreeFlags() const {return nTreeFlags;}
470 static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry);
472 void set_min_width_in_chars(sal_Int32 nChars);
474 virtual bool set_property(const OUString &rKey, const OUString &rValue) override;
476 SAL_DLLPRIVATE void SetCollapsedNodeBmp( const Image& );
477 SAL_DLLPRIVATE void SetExpandedNodeBmp( const Image& );
478 SAL_DLLPRIVATE Image const & GetExpandedNodeBmp( ) const;
480 protected:
482 virtual void CalcEntryHeight(SvTreeListEntry const* pEntry);
483 void AdjustEntryHeight( const Image& rBmp );
484 SAL_DLLPRIVATE void AdjustEntryHeight();
486 SAL_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry );
487 SAL_DLLPRIVATE void PaintEntry1( SvTreeListEntry&, tools::Long nLine, vcl::RenderContext& rRenderContext );
489 SAL_DLLPRIVATE void InitTreeView();
490 SAL_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, tools::Long nX, SvLBoxTab** ppTab );
491 SAL_DLLPRIVATE void ImplInitStyle();
493 void SetupDragOrigin();
494 void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem,
495 const Selection& );
496 void EditedText(const OUString&);
498 // Recalculate all tabs depending on TreeListStyle and Bitmap sizes
499 // Is called automatically when inserting/changing Bitmaps, changing the Model etc.
500 virtual void SetTabs();
501 void AddTab( tools::Long nPos, SvLBoxTabFlags nFlags );
502 sal_uInt16 TabCount() const { return aTabs.size(); }
503 SvLBoxTab* GetFirstDynamicTab() const;
504 SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const;
505 SvLBoxTab* GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos );
506 void GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos );
507 SvLBoxTab* GetTab( SvTreeListEntry const *, SvLBoxItem const * ) const;
508 void ClearTabList();
510 virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&);
512 void NotifyScrolled();
513 void SetScrolledHdl( const Link<SvTreeListBox*,void>& rLink ) { aScrolledHdl = rLink; }
514 tools::Long GetXOffset() const { return GetMapMode().GetOrigin().X(); }
516 virtual void Command( const CommandEvent& rCEvt ) override;
518 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
519 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
521 void InitSettings();
523 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
525 void CallImplEventListeners(VclEventId nEvent, void* pData);
527 void ImplEditEntry( SvTreeListEntry* pEntry );
529 void AdjustEntryHeightAndRecalc();
531 // true if rPos is over the SvTreeListBox body, i.e. not over a
532 // scrollbar
533 SAL_DLLPRIVATE bool PosOverBody(const Point& rPos) const;
534 public:
536 void SetNoAutoCurEntry( bool b );
538 void EnableCheckButton( SvLBoxButtonData* );
539 void SetCheckButtonData( SvLBoxButtonData* );
541 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
542 interface experience in the whole product.
544 static const Image& GetDefaultExpandedNodeImage( );
546 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
547 interface experience in the whole product.
549 static const Image& GetDefaultCollapsedNodeImage( );
551 /** Sets default bitmaps for collapsed and expanded nodes.
553 void SetNodeDefaultImages();
555 virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr,
556 bool bChildrenOnDemand = false,
557 sal_uInt32 nPos=TREELIST_APPEND, void* pUserData = nullptr);
559 const Image& GetDefaultExpandedEntryBmp( ) const;
560 const Image& GetDefaultCollapsedEntryBmp( ) const;
562 void SetDefaultExpandedEntryBmp( const Image& rBmp );
563 void SetDefaultCollapsedEntryBmp( const Image& rBmp );
565 void SetCheckButtonState( SvTreeListEntry*, SvButtonState );
566 SvButtonState GetCheckButtonState( SvTreeListEntry* ) const;
567 bool GetCheckButtonEnabled(SvTreeListEntry* pEntry) const;
569 void SetEntryText(SvTreeListEntry*, const OUString& );
570 void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
571 void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
573 virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const;
574 static const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry );
575 static const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry );
577 void CheckButtonHdl();
579 void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right
581 void EnableInplaceEditing( bool bEnable );
582 // Edits the Entry's first StringItem, 0 == Cursor
583 void EditEntry( SvTreeListEntry* pEntry );
584 virtual bool EditingEntry( SvTreeListEntry* pEntry );
585 virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText );
587 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
588 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
589 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
590 virtual void MouseMove( const MouseEvent& rMEvt ) override;
591 virtual void KeyInput( const KeyEvent& rKEvt ) override;
592 virtual void Resize() override;
593 virtual void GetFocus() override;
594 virtual void LoseFocus() override;
595 void SetUpdateMode( bool );
597 virtual void ModelHasCleared() override;
598 virtual void ModelHasInserted( SvTreeListEntry* pEntry ) override;
599 virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ) override;
600 virtual void ModelIsMoving(SvTreeListEntry* pSource ) override;
601 virtual void ModelHasMoved(SvTreeListEntry* pSource ) override;
602 virtual void ModelIsRemoving( SvTreeListEntry* pEntry ) override;
603 virtual void ModelHasRemoved( SvTreeListEntry* pEntry ) override;
604 void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ) override;
606 void ScrollOutputArea( short nDeltaEntries );
608 short GetColumnsCount() const { return nColumns; }
609 short GetEntryHeight() const { return nEntryHeight; }
610 void SetEntryHeight( short nHeight );
611 short GetEntryWidth() const { return nEntryWidth; }
612 void SetEntryWidth( short nWidth );
613 Size GetOutputSizePixel() const;
614 short GetIndent() const { return nIndent; }
615 void SetSpaceBetweenEntries( short nSpace );
616 Point GetEntryPosition(const SvTreeListEntry*) const;
617 void MakeVisible( SvTreeListEntry* pEntry );
618 void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop );
620 void SetFont( const vcl::Font& rFont );
622 SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const;
624 virtual tools::Rectangle GetFocusRect(const SvTreeListEntry*, tools::Long nLine );
625 // Respects indentation
626 sal_IntPtr GetTabPos(const SvTreeListEntry*, const SvLBoxTab*) const;
627 void InvalidateEntry( SvTreeListEntry* );
628 SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX, SvLBoxTab** ppTab);
629 SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX );
630 std::pair<tools::Long, tools::Long> GetItemPos(SvTreeListEntry* pEntry, sal_uInt16 nTabIdx);
632 void SetDragDropMode( DragDropMode );
633 void SetSelectionMode( SelectionMode );
635 bool Expand( SvTreeListEntry* pParent );
636 bool Collapse( SvTreeListEntry* pParent );
637 bool Select( SvTreeListEntry* pEntry, bool bSelect=true );
638 sal_uInt32 SelectChildren( SvTreeListEntry* pParent, bool bSelect );
639 void SelectAll( bool bSelect );
641 void SetCurEntry( SvTreeListEntry* _pEntry );
642 SvTreeListEntry* GetCurEntry() const;
644 virtual void ImplInvalidate( const vcl::Region* rRegion, InvalidateFlags nFlags ) override;
646 void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff);
648 sal_Int32 DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText);
650 DECL_DLLPRIVATE_LINK( DefaultCompare, const SvSortData&, sal_Int32 );
651 virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1,
652 SvTreeListEntry* pEntry2, sal_uInt32 nPos ) override;
654 SvTreeListEntry* GetFirstEntryInView() const;
655 SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const;
656 void ScrollToAbsPos( tools::Long nPos );
658 tools::Long getPreferredDimensions(std::vector<tools::Long> &rWidths) const;
660 virtual Size GetOptimalSize() const override;
662 // Enables type-ahead search in the check list box.
663 void SetQuickSearch(bool bEnable) { mbQuickSearch = bEnable; }
665 // Make single click "activate" a row like a double-click normally does
666 void SetActivateOnSingleClick(bool bEnable) { mbActivateOnSingleClick = bEnable; }
667 bool GetActivateOnSingleClick() const { return mbActivateOnSingleClick; }
669 // Make mouse over a row "select" a row like a single-click normally does
670 void SetHoverSelection(bool bEnable) { mbHoverSelection = bEnable; }
671 bool GetHoverSelection() const { return mbHoverSelection; }
673 // to get enable or disable the text-column
674 void SetTextColumnEnabled(bool bEnable) { mbIsTextColumEnabled = bEnable; }
675 bool IsTextColumnEnabled() const { return mbIsTextColumEnabled; }
677 // only true during Select if the Select is due to a Hover
678 bool IsSelectDueToHover() const { return mbSelectingByHover; }
680 // Set when clicks toggle the checkbox of the row.
681 void SetClicksToToggle(sal_Int8 nCount) { mnClicksToToggle = nCount; }
683 void SetForceMakeVisible(bool bEnable);
685 virtual FactoryFunction GetUITestFactory() const override;
687 void SetDragHelper(const rtl::Reference<TransferDataContainer>& rHelper, sal_uInt8 eDNDConstants);
689 virtual void EnableRTL(bool bEnable = true) override;
692 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */