Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / vcl / toolkit / treelistbox.hxx
blob0fd864f9d1046d27e341ad0c54de34d614d3e27e
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 <vcl/dllapi.h>
28 #include <deque>
29 #include <memory>
30 #include <vector>
32 #include <vcl/ctrl.hxx>
33 #include <vcl/quickselectionengine.hxx>
34 #include <vcl/image.hxx>
35 #include <tools/gen.hxx>
36 #include <tools/contnr.hxx>
37 #include <vcl/toolkit/treelist.hxx>
38 #include <vcl/transfer.hxx>
39 #include <o3tl/typed_flags_set.hxx>
41 class SvTreeListBox;
42 class SvTreeListEntry;
43 struct SvViewDataItem;
44 class SvViewDataEntry;
45 class SvInplaceEdit2;
46 class SvLBoxString;
47 class SvImpLBox;
48 class SvLBoxButtonData;
49 class Timer;
50 class Edit;
52 enum class SvButtonState { Unchecked, Checked, Tristate };
54 // *********************************************************************
55 // *************************** Tabulators ******************************
56 // *********************************************************************
58 enum class SvLBoxTabFlags
60 NONE = 0x0000,
61 DYNAMIC = 0x0001, // Item's output column changes according to the Child Depth
62 ADJUST_RIGHT = 0x0002, // Item's right margin at the tabulator
63 ADJUST_LEFT = 0x0004, // Left margin
64 ADJUST_CENTER = 0x0008, // Center the item at the tabulator
66 SHOW_SELECTION = 0x0010, // Visualize selection state
67 // Item needs to be able to return the surrounding polygon (D'n'D cursor)
68 EDITABLE = 0x0020, // Item editable at the tabulator
69 FORCE = 0x0040, // Switch off the default calculation of the first tabulator
70 // (on which Abo Tabpage/Extras/Option/Customize, etc. rely on)
71 // The first tab's position corresponds precisely to the Flags set
72 // and column widths
74 namespace o3tl
76 template<> struct typed_flags<SvLBoxTabFlags> : is_typed_flags<SvLBoxTabFlags, 0x007f> {};
79 #define SV_TAB_BORDER 8
81 #define SV_ENTRYHEIGHTOFFS_PIXEL 2
83 enum class SvTreeFlags
85 CHKBTN = 0x01,
86 USESEL = 0x02,
87 MANINS = 0x04,
88 RECALCTABS = 0x08,
89 FIXEDHEIGHT = 0x10,
91 namespace o3tl
93 template<> struct typed_flags<SvTreeFlags> : is_typed_flags<SvTreeFlags, 0x1f> {};
96 enum class SvLBoxItemType {String, Button, ContextBmp};
98 class SvLBoxTab
100 tools::Long nPos;
101 public:
102 SvLBoxTab();
103 SvLBoxTab( tools::Long nPos, SvLBoxTabFlags nFlags );
104 SvLBoxTab( const SvLBoxTab& );
106 SvLBoxTabFlags nFlags;
108 bool IsDynamic() const { return bool(nFlags & SvLBoxTabFlags::DYNAMIC); }
109 void SetPos( tools::Long nNewPos) { nPos = nNewPos; }
110 tools::Long GetPos() const { return nPos; }
111 tools::Long CalcOffset( tools::Long nItemLength, tools::Long nTabWidth );
112 bool IsEditable() const { return bool(nFlags & SvLBoxTabFlags::EDITABLE); }
115 class VCL_DLLPUBLIC SvLBoxItem
117 protected:
118 bool mbDisabled;
120 public:
121 SvLBoxItem();
122 virtual ~SvLBoxItem();
123 virtual SvLBoxItemType GetType() const = 0;
124 virtual int CalcWidth(const SvTreeListBox* pView) const;
125 int GetWidth(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
126 int GetWidth(const SvTreeListBox* pView, const SvViewDataEntry* pData, sal_uInt16 nItemPos) const;
127 int GetHeight(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const;
128 static int GetHeight(const SvViewDataEntry* pData, sal_uInt16 nItemPos);
129 void Enable(bool bEnabled) { mbDisabled = !bEnabled; }
130 bool isEnable() const { return !mbDisabled; }
132 virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) = 0;
134 virtual void InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry,
135 // If != 0: this Pointer must be used!
136 // If == 0: it needs to be retrieved via the View
137 SvViewDataItem* pViewData = nullptr) = 0;
138 // View-dependent data is not cloned
139 virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const = 0;
142 enum class DragDropMode
144 NONE = 0x0000,
145 CTRL_MOVE = 0x0001,
146 APP_COPY = 0x0004,
147 // Entries may be dropped via the uppermost Entry
148 // The DropTarget is 0 in that case
149 ENABLE_TOP = 0x0010,
150 ALL = 0x0015,
152 namespace o3tl
154 template<> struct typed_flags<DragDropMode> : is_typed_flags<DragDropMode, 0x0015> {};
157 enum class SvTreeListBoxFlags
159 NONE = 0x0000,
160 IN_EDT = 0x0001,
161 EDT_ENABLED = 0x0002,
162 TARGEMPH_VIS = 0x0004,
163 EDTEND_CALLED = 0x0008,
165 namespace o3tl
167 template<> struct typed_flags<SvTreeListBoxFlags> : is_typed_flags<SvTreeListBoxFlags, 0x000f> {};
170 struct SvTreeListBoxImpl;
172 typedef std::pair<vcl::RenderContext&, const SvTreeListEntry&> svtree_measure_args;
173 typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, const SvTreeListEntry&> svtree_render_args;
175 class VCL_DLLPUBLIC SvTreeListBox
176 :public Control
177 ,public SvListView
178 ,public DropTargetHelper
179 ,public DragSourceHelper
180 ,public vcl::ISearchableStringList
182 friend class SvImpLBox;
183 friend class SvLBoxString;
184 friend class IconViewImpl;
185 friend class TreeControlPeer;
186 friend class SalInstanceIconView;
187 friend class SalInstanceTreeView;
188 friend class SalInstanceEntryTreeView;
190 std::unique_ptr<SvTreeListBoxImpl> mpImpl;
191 Link<SvTreeListBox*,void> aScrolledHdl;
192 Link<SvTreeListBox*,void> aExpandedHdl;
193 Link<SvTreeListBox*,bool> aExpandingHdl;
194 Link<SvTreeListBox*,void> aSelectHdl;
195 Link<SvTreeListBox*,void> aDeselectHdl;
196 Link<const CommandEvent&, bool> aPopupMenuHdl;
197 Link<SvTreeListEntry*, OUString> aTooltipHdl;
198 Link<svtree_render_args, void> aCustomRenderHdl;
199 Link<svtree_measure_args, Size> aCustomMeasureHdl;
201 Image aPrevInsertedExpBmp;
202 Image aPrevInsertedColBmp;
203 Image aCurInsertedExpBmp;
204 Image aCurInsertedColBmp;
206 short nContextBmpWidthMax;
207 short nEntryHeightOffs;
208 short nIndent;
209 short nFocusWidth;
210 sal_uInt16 nFirstSelTab;
211 sal_uInt16 nLastSelTab;
212 tools::Long mnCheckboxItemWidth;
213 bool mbContextBmpExpanded;
214 bool mbQuickSearch; // Enables type-ahead search in the check list box.
215 bool mbActivateOnSingleClick; // Make single click "activate" a row like a double-click normally does
216 bool mbHoverSelection; // Make mouse over a row "select" a row like a single-click normally does
217 bool mbSelectingByHover; // true during "Select" if it was due to hover
218 sal_Int8 mnClicksToToggle; // 0 == Click on a row not toggle its checkbox.
219 // 1 == Every click on row toggle its checkbox.
220 // 2 == First click select, second click toggle.
222 SvTreeListEntry* pHdlEntry;
224 DragDropMode nDragDropMode;
225 DragDropMode nOldDragMode;
226 SelectionMode eSelMode;
227 sal_Int32 nMinWidthInChars;
229 sal_Int8 mnDragAction;
231 SvTreeListEntry* pEdEntry;
232 SvLBoxItem* pEdItem;
234 rtl::Reference<TransferDataContainer> m_xTransferHelper;
236 protected:
237 std::unique_ptr<SvImpLBox> pImpl;
238 short nColumns;
239 short nEntryHeight;
240 short nEntryWidth;
241 bool mbCenterAndClipText;
243 Link<SvTreeListBox*,bool> aDoubleClickHdl;
244 SvTreeListEntry* pTargetEntry;
245 SvLBoxButtonData* pCheckButtonData;
246 std::vector<std::unique_ptr<SvLBoxTab>> aTabs;
247 SvTreeFlags nTreeFlags;
248 SvTreeListBoxFlags nImpFlags;
249 // Move/CopySelection: Position of the current Entry in SelectionList
250 sal_uInt16 nCurEntrySelPos;
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
256 DECL_DLLPRIVATE_LINK( CloneHdl_Impl, SvTreeListEntry*, SvTreeListEntry* );
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 );
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);
272 VCL_DLLPRIVATE void DrawCustomEntry(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const SvTreeListEntry& rEntry);
273 VCL_DLLPRIVATE Size MeasureCustomEntry(vcl::RenderContext& rRenderContext, const SvTreeListEntry& rEntry) const;
275 /** Handles the given key event.
277 At the moment this merely does typeahead if typeahead is enabled.
279 @return
280 <TRUE/> if the event has been consumed, <FALSE/> otherwise.
282 VCL_DLLPRIVATE bool HandleKeyInput(const KeyEvent& rKEvt);
284 void UnsetDropTarget();
286 protected:
288 bool CheckDragAndDropMode( SvTreeListBox const * pSource, sal_Int8 );
289 void ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow);
290 void EnableSelectionAsDropTarget( bool bEnable = true );
291 // Standard impl returns 0; derived classes which support D'n'D must override
292 using Window::GetDropTarget;
293 virtual SvTreeListEntry* GetDropTarget( const Point& );
295 // Invalidate children on enable/disable
296 virtual void StateChanged( StateChangedType eType ) override;
298 virtual sal_uInt32 Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uInt32 nPos=TREELIST_APPEND);
299 virtual sal_uInt32 Insert( SvTreeListEntry* pEntry,sal_uInt32 nRootPos = TREELIST_APPEND );
301 // In-place editing
302 std::unique_ptr<SvInplaceEdit2> pEdCtrl;
303 void EditText( const OUString&, const tools::Rectangle&,const Selection&);
304 void CancelTextEditing();
306 // InitViewData is called right after CreateViewData
307 // The Entry is has not yet been added to the View in InitViewData!
308 virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ) override;
309 // Calls InitViewData for all Items
310 void RecalcViewData();
312 // Handler and methods for Drag - finished handler. This link can be set
313 // to the TransferDataContainer. The AddBox/RemoveBox methods must be
314 // called before the StartDrag call.
315 // The Remove will be called from the handler, which then calls DragFinish.
316 // The Remove is also called in the DTOR of the SvTreeListBox -
317 // so it can't be called for a deleted object.
318 Link<sal_Int8,void> GetDragFinishedHdl() const;
320 // For asynchronous D'n'D
321 sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView );
323 void OnCurrentEntryChanged();
325 // ISearchableStringList
326 virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const override;
327 virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const override;
328 virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) override;
330 public:
332 SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 );
333 virtual ~SvTreeListBox() override;
334 virtual void dispose() override;
336 SvTreeList* GetModel() const
338 return pModel.get();
341 sal_uInt32 GetEntryCount() const
343 return pModel ? pModel->GetEntryCount() : 0;
345 SvTreeListEntry* First() const
347 return pModel ? pModel->First() : nullptr;
349 SvTreeListEntry* Next( SvTreeListEntry* pEntry ) const
351 return pModel->Next(pEntry);
353 SvTreeListEntry* Prev( SvTreeListEntry* pEntry ) const
355 return pModel->Prev(pEntry);
357 SvTreeListEntry* Last() const
359 return pModel ? pModel->Last() : nullptr;
362 SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const;
364 bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget );
365 bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback );
366 void RemoveSelection();
368 * Removes the entry along with all of its descendants
370 void RemoveEntry(SvTreeListEntry const * pEntry);
372 DragDropMode GetDragDropMode() const { return nDragDropMode; }
373 SelectionMode GetSelectionMode() const { return eSelMode; }
375 // pParent == 0 -> Root level
376 SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uInt32 nPos ) const;
377 SvTreeListEntry* GetEntry( sal_uInt32 nRootPos ) const;
379 SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const;
380 void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const;
382 using Window::GetParent;
383 SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const;
385 using Window::GetChildCount;
386 sal_uInt32 GetChildCount( SvTreeListEntry const * pParent ) const;
387 sal_uInt32 GetLevelChildCount( SvTreeListEntry* pParent ) const;
389 SvViewDataEntry* GetViewDataEntry( SvTreeListEntry const * pEntry ) const;
390 SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *);
391 const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const;
393 OUString GetEntryTooltip(SvTreeListEntry* pEntry) const { return aTooltipHdl.Call(pEntry); }
395 VclPtr<Edit> GetEditWidget() const; // for UITest
396 bool IsInplaceEditingEnabled() const { return bool(nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); }
397 bool IsEditingActive() const { return bool(nImpFlags & SvTreeListBoxFlags::IN_EDT); }
398 void EndEditing( bool bCancel = false );
400 void Clear();
402 bool TextCenterAndClipEnabled() const { return mbCenterAndClipText; }
404 void SetSelectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aSelectHdl=rNewHdl; }
405 void SetDeselectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aDeselectHdl=rNewHdl; }
406 void SetDoubleClickHdl(const Link<SvTreeListBox*,bool>& rNewHdl) {aDoubleClickHdl=rNewHdl;}
407 void SetExpandingHdl(const Link<SvTreeListBox*,bool>& rNewHdl){aExpandingHdl=rNewHdl;}
408 void SetExpandedHdl(const Link<SvTreeListBox*,void>& rNewHdl){aExpandedHdl=rNewHdl;}
409 void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink) { aPopupMenuHdl = rLink; }
410 void SetTooltipHdl(const Link<SvTreeListEntry*, OUString>& rLink) { aTooltipHdl = rLink; }
411 void SetCustomRenderHdl(const Link<svtree_render_args, void>& rLink) { aCustomRenderHdl = rLink; }
412 void SetCustomMeasureHdl(const Link<svtree_measure_args, Size>& rLink) { aCustomMeasureHdl = rLink; }
414 void ExpandedHdl();
415 bool ExpandingHdl();
416 void SelectHdl();
417 void DeselectHdl();
418 bool DoubleClickHdl();
419 SvTreeListEntry* GetHdlEntry() const { return pHdlEntry; }
421 // Is called for an Entry that gets expanded with the Flag
422 // ENTRYFLAG_CHILDREN_ON_DEMAND set.
423 virtual void RequestingChildren( SvTreeListEntry* pParent );
425 // Drag & Drop
426 // New D'n'D API
427 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
428 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
429 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override;
430 virtual DragDropMode NotifyStartDrag();
431 virtual void DragFinished( sal_Int8 nDropAction );
433 SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource );
435 // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
436 TriState NotifyMoving(
437 SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel()
438 const SvTreeListEntry* pEntry, // Entry to be moved from GetSourceListBox()->GetModel()
439 SvTreeListEntry*& rpNewParent, // New TargetParent
440 sal_uInt32& rNewChildPos); // The TargetParent's position in Childlist
442 // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry
443 TriState NotifyCopying(
444 SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel()
445 const SvTreeListEntry* pEntry, // Entry to be copied from GetSourceListBox()->GetModel()
446 SvTreeListEntry*& rpNewParent, // New TargetParent
447 sal_uInt32& rNewChildPos); // The TargetParent's position in Childlist
449 // ACCESSIBILITY ==========================================================
451 /** Creates and returns the accessible object of the Box. */
452 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
454 /** Fills the StateSet of one entry. */
455 void FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, sal_Int64& rStateSet ) const;
457 virtual OUString GetEntryAccessibleDescription(SvTreeListEntry* pEntry) const;
459 /** Calculate and return the bounding rectangle of an entry.
460 @param pEntry
461 The entry.
462 @return The bounding rectangle of an entry. */
463 tools::Rectangle GetBoundingRect(const SvTreeListEntry* pEntry);
465 SvTreeFlags GetTreeFlags() const {return nTreeFlags;}
467 static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry);
469 void set_min_width_in_chars(sal_Int32 nChars);
471 virtual bool set_property(const OUString &rKey, const OUString &rValue) override;
473 VCL_DLLPRIVATE void SetCollapsedNodeBmp( const Image& );
474 VCL_DLLPRIVATE void SetExpandedNodeBmp( const Image& );
475 VCL_DLLPRIVATE Image const & GetExpandedNodeBmp( ) const;
477 protected:
479 virtual void CalcEntryHeight(SvTreeListEntry const* pEntry);
480 void AdjustEntryHeight( const Image& rBmp );
481 VCL_DLLPRIVATE void AdjustEntryHeight();
483 VCL_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry );
484 VCL_DLLPRIVATE void PaintEntry1( SvTreeListEntry&, tools::Long nLine, vcl::RenderContext& rRenderContext );
486 VCL_DLLPRIVATE void InitTreeView();
487 VCL_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, tools::Long nX, SvLBoxTab** ppTab );
488 VCL_DLLPRIVATE void ImplInitStyle();
490 void SetupDragOrigin();
491 void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem,
492 const Selection& );
493 void EditedText(const OUString&);
495 // Recalculate all tabs depending on TreeListStyle and Bitmap sizes
496 // Is called automatically when inserting/changing Bitmaps, changing the Model etc.
497 virtual void SetTabs();
498 void AddTab( tools::Long nPos, SvLBoxTabFlags nFlags );
499 sal_uInt16 TabCount() const { return aTabs.size(); }
500 SvLBoxTab* GetFirstDynamicTab() const;
501 SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const;
502 SvLBoxTab* GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos );
503 void GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos );
504 SvLBoxTab* GetTab( SvTreeListEntry const *, SvLBoxItem const * ) const;
505 void ClearTabList();
507 virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&);
509 void NotifyScrolled();
510 void SetScrolledHdl( const Link<SvTreeListBox*,void>& rLink ) { aScrolledHdl = rLink; }
511 tools::Long GetXOffset() const { return GetMapMode().GetOrigin().X(); }
513 virtual void Command( const CommandEvent& rCEvt ) override;
515 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
516 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
518 void InitSettings();
520 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
522 void CallImplEventListeners(VclEventId nEvent, void* pData);
524 void ImplEditEntry( SvTreeListEntry* pEntry );
526 void AdjustEntryHeightAndRecalc();
528 // true if rPos is over the SvTreeListBox body, i.e. not over a
529 // scrollbar
530 VCL_DLLPRIVATE bool PosOverBody(const Point& rPos) const;
531 public:
533 void SetNoAutoCurEntry( bool b );
535 void EnableCheckButton( SvLBoxButtonData* );
536 void SetCheckButtonData( SvLBoxButtonData* );
538 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
539 interface experience in the whole product.
541 static const Image& GetDefaultExpandedNodeImage( );
543 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
544 interface experience in the whole product.
546 static const Image& GetDefaultCollapsedNodeImage( );
548 /** Sets default bitmaps for collapsed and expanded nodes.
550 void SetNodeDefaultImages();
552 virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr,
553 bool bChildrenOnDemand = false,
554 sal_uInt32 nPos=TREELIST_APPEND, void* pUserData = nullptr);
556 const Image& GetDefaultExpandedEntryBmp( ) const;
557 const Image& GetDefaultCollapsedEntryBmp( ) const;
559 void SetDefaultExpandedEntryBmp( const Image& rBmp );
560 void SetDefaultCollapsedEntryBmp( const Image& rBmp );
562 void SetCheckButtonState( SvTreeListEntry*, SvButtonState );
563 SvButtonState GetCheckButtonState( SvTreeListEntry* ) const;
565 void SetEntryText(SvTreeListEntry*, const OUString& );
566 void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
567 void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
569 virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const;
570 static const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry );
571 static const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry );
573 void CheckButtonHdl();
575 void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right
577 void EnableInplaceEditing( bool bEnable );
578 // Edits the Entry's first StringItem, 0 == Cursor
579 void EditEntry( SvTreeListEntry* pEntry );
580 virtual bool EditingEntry( SvTreeListEntry* pEntry );
581 virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText );
583 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
584 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
585 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
586 virtual void MouseMove( const MouseEvent& rMEvt ) override;
587 virtual void KeyInput( const KeyEvent& rKEvt ) override;
588 virtual void Resize() override;
589 virtual void GetFocus() override;
590 virtual void LoseFocus() override;
591 void SetUpdateMode( bool );
593 virtual void ModelHasCleared() override;
594 virtual void ModelHasInserted( SvTreeListEntry* pEntry ) override;
595 virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ) override;
596 virtual void ModelIsMoving(SvTreeListEntry* pSource ) override;
597 virtual void ModelHasMoved(SvTreeListEntry* pSource ) override;
598 virtual void ModelIsRemoving( SvTreeListEntry* pEntry ) override;
599 virtual void ModelHasRemoved( SvTreeListEntry* pEntry ) override;
600 void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ) override;
602 void ScrollOutputArea( short nDeltaEntries );
604 short GetColumnsCount() const { return nColumns; }
605 short GetEntryHeight() const { return nEntryHeight; }
606 void SetEntryHeight( short nHeight );
607 short GetEntryWidth() const { return nEntryWidth; }
608 void SetEntryWidth( short nWidth );
609 Size GetOutputSizePixel() const;
610 short GetIndent() const { return nIndent; }
611 void SetSpaceBetweenEntries( short nSpace );
612 Point GetEntryPosition(const SvTreeListEntry*) const;
613 void MakeVisible( SvTreeListEntry* pEntry );
614 void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop );
616 void SetFont( const vcl::Font& rFont );
618 SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const;
620 virtual tools::Rectangle GetFocusRect(const SvTreeListEntry*, tools::Long nLine );
621 // Respects indentation
622 sal_IntPtr GetTabPos(const SvTreeListEntry*, const SvLBoxTab*) const;
623 void InvalidateEntry( SvTreeListEntry* );
624 SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX, SvLBoxTab** ppTab);
625 SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX );
626 std::pair<tools::Long, tools::Long> GetItemPos(SvTreeListEntry* pEntry, sal_uInt16 nTabIdx);
628 void SetDragDropMode( DragDropMode );
629 void SetSelectionMode( SelectionMode );
631 bool Expand( SvTreeListEntry* pParent );
632 bool Collapse( SvTreeListEntry* pParent );
633 bool Select( SvTreeListEntry* pEntry, bool bSelect=true );
634 sal_uInt32 SelectChildren( SvTreeListEntry* pParent, bool bSelect );
635 void SelectAll( bool bSelect );
637 void SetCurEntry( SvTreeListEntry* _pEntry );
638 SvTreeListEntry* GetCurEntry() const;
640 using Window::Invalidate;
641 virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE) override;
642 virtual void Invalidate( const tools::Rectangle&, InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
644 void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff);
646 sal_Int32 DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText);
648 DECL_DLLPRIVATE_LINK( DefaultCompare, const SvSortData&, sal_Int32 );
649 virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1,
650 SvTreeListEntry* pEntry2, sal_uInt32 nPos ) override;
652 SvTreeListEntry* GetFirstEntryInView() const;
653 SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const;
654 void ScrollToAbsPos( tools::Long nPos );
656 tools::Long getPreferredDimensions(std::vector<tools::Long> &rWidths) const;
658 virtual Size GetOptimalSize() const override;
660 // Enables type-ahead search in the check list box.
661 void SetQuickSearch(bool bEnable) { mbQuickSearch = bEnable; }
663 // Make single click "activate" a row like a double-click normally does
664 void SetActivateOnSingleClick(bool bEnable) { mbActivateOnSingleClick = bEnable; }
665 bool GetActivateOnSingleClick() const { return mbActivateOnSingleClick; }
667 // Make mouse over a row "select" a row like a single-click normally does
668 void SetHoverSelection(bool bEnable) { mbHoverSelection = bEnable; }
669 bool GetHoverSelection() const { return mbHoverSelection; }
671 // only true during Select if the Select is due to a Hover
672 bool IsSelectDueToHover() const { return mbSelectingByHover; }
674 // Set when clicks toggle the checkbox of the row.
675 void SetClicksToToggle(sal_Int8 nCount) { mnClicksToToggle = nCount; }
677 void SetForceMakeVisible(bool bEnable);
679 virtual FactoryFunction GetUITestFactory() const override;
681 void SetDragHelper(const rtl::Reference<TransferDataContainer>& rHelper, sal_uInt8 eDNDConstants);
683 virtual void EnableRTL(bool bEnable = true) override;
686 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */