Bump version to 6.4-15
[LibreOffice.git] / include / vcl / treelistbox.hxx
blob0f47b402dc91ef67b4bd0dddcc2b28fa318dd231
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 #ifndef INCLUDED_VCL_TREELISTBOX_HXX
21 #define INCLUDED_VCL_TREELISTBOX_HXX
23 #include <vcl/dllapi.h>
25 #include <deque>
26 #include <memory>
27 #include <vector>
29 #include <vcl/ctrl.hxx>
30 #include <vcl/accel.hxx>
31 #include <vcl/mnemonicengine.hxx>
32 #include <vcl/quickselectionengine.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>
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 namespace utl {
54 class AccessibleStateSetHelper;
57 enum class SvButtonState { Unchecked, Checked, Tristate };
59 // *********************************************************************
60 // *************************** Tabulators ******************************
61 // *********************************************************************
63 enum class SvLBoxTabFlags
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
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
79 namespace o3tl
81 template<> struct typed_flags<SvLBoxTabFlags> : is_typed_flags<SvLBoxTabFlags, 0x007f> {};
84 #define SV_TAB_BORDER 8
86 #define SV_ENTRYHEIGHTOFFS_PIXEL 2
88 enum class SvTreeFlags
90 CHKBTN = 0x01,
91 USESEL = 0x02,
92 MANINS = 0x04,
93 RECALCTABS = 0x08,
94 FIXEDHEIGHT = 0x10,
96 namespace o3tl
98 template<> struct typed_flags<SvTreeFlags> : is_typed_flags<SvTreeFlags, 0x1f> {};
101 enum class SvLBoxItemType {String, Button, ContextBmp};
103 class SvLBoxTab
105 long nPos;
106 public:
107 SvLBoxTab();
108 SvLBoxTab( long nPos, SvLBoxTabFlags nFlags );
109 SvLBoxTab( const SvLBoxTab& );
110 ~SvLBoxTab();
112 SvLBoxTabFlags nFlags;
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); }
121 class VCL_DLLPUBLIC SvLBoxItem
123 protected:
124 bool mbDisabled;
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; }
137 virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) = 0;
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;
147 enum class DragDropMode
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,
160 namespace o3tl
162 template<> struct typed_flags<DragDropMode> : is_typed_flags<DragDropMode, 0x003f> {};
165 enum class SvTreeListBoxFlags
167 NONE = 0x0000,
168 IN_EDT = 0x0001,
169 EDT_ENABLED = 0x0002,
170 TARGEMPH_VIS = 0x0004,
171 EDTEND_CALLED = 0x0008,
173 namespace o3tl
175 template<> struct typed_flags<SvTreeListBoxFlags> : is_typed_flags<SvTreeListBoxFlags, 0x000f> {};
178 struct SvTreeListBoxImpl;
180 class VCL_DLLPUBLIC SvTreeListBox
181 :public Control
182 ,public SvListView
183 ,public DropTargetHelper
184 ,public DragSourceHelper
185 ,public vcl::IMnemonicEntryList
186 ,public vcl::ISearchableStringList
188 friend class SvImpLBox;
189 friend class IconViewImpl;
190 friend class TreeControlPeer;
191 friend class SalInstanceIconView;
192 friend class SalInstanceTreeView;
193 friend class SalInstanceEntryTreeView;
195 std::unique_ptr<SvTreeListBoxImpl> mpImpl;
196 Link<SvTreeListBox*,void> aCheckButtonHdl;
197 Link<SvTreeListBox*,void> aScrolledHdl;
198 Link<SvTreeListBox*,void> aExpandedHdl;
199 Link<SvTreeListBox*,bool> aExpandingHdl;
200 Link<SvTreeListBox*,void> aSelectHdl;
201 Link<SvTreeListBox*,void> aDeselectHdl;
202 Link<const CommandEvent&, bool> aPopupMenuHdl;
204 Image aPrevInsertedExpBmp;
205 Image aPrevInsertedColBmp;
206 Image aCurInsertedExpBmp;
207 Image aCurInsertedColBmp;
209 short nContextBmpWidthMax;
210 short nEntryHeightOffs;
211 short nIndent;
212 short nFocusWidth;
213 sal_uInt16 nFirstSelTab;
214 sal_uInt16 nLastSelTab;
215 long mnCheckboxItemWidth;
216 bool mbContextBmpExpanded;
217 bool mbAlternatingRowColors;
218 bool mbUpdateAlternatingRows;
219 bool mbQuickSearch; // Enables type-ahead search in the check list box.
221 SvTreeListEntry* pHdlEntry;
223 DragDropMode nDragDropMode;
224 DragDropMode nOldDragMode;
225 SelectionMode eSelMode;
226 sal_Int32 nMinWidthInChars;
228 SvTreeListEntry* pEdEntry;
229 SvLBoxItem* pEdItem;
231 protected:
232 std::unique_ptr<SvImpLBox> pImpl;
233 short nColumns;
234 short nEntryHeight;
235 short nEntryWidth;
236 bool mbCenterAndClipText;
238 Link<SvTreeListBox*,bool> aDoubleClickHdl;
239 SvTreeListEntry* pTargetEntry;
240 SvLBoxButtonData* pCheckButtonData;
241 std::vector<std::unique_ptr<SvLBoxTab>> aTabs;
242 SvTreeFlags nTreeFlags;
243 SvTreeListBoxFlags nImpFlags;
244 // Move/CopySelection: Position of the current Entry in SelectionList
245 sal_uInt16 nCurEntrySelPos;
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
251 DECL_DLLPRIVATE_LINK( CloneHdl_Impl, SvTreeListEntry*, SvTreeListEntry* );
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 );
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);
267 protected:
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& );
276 // Invalidate children on enable/disable
277 virtual void StateChanged( StateChangedType eType ) override;
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 );
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;
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();
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;
302 // For asynchronous D'n'D
303 sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView );
305 void OnCurrentEntryChanged();
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;
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;
318 public:
320 SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 );
321 virtual ~SvTreeListBox() override;
322 virtual void dispose() override;
324 SvTreeList* GetModel() const
326 return pModel.get();
329 sal_uLong GetEntryCount() const
331 return pModel ? pModel->GetEntryCount() : 0;
333 SvTreeListEntry* First() const
335 return pModel ? pModel->First() : nullptr;
337 SvTreeListEntry* Next( SvTreeListEntry* pEntry ) const
339 return pModel->Next(pEntry);
341 SvTreeListEntry* Prev( SvTreeListEntry* pEntry ) const
343 return pModel->Prev(pEntry);
345 SvTreeListEntry* Last() const
347 return pModel ? pModel->Last() : nullptr;
350 SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const;
352 bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget );
353 bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback );
354 void RemoveSelection();
356 * Removes the entry along with all of its descendants
358 void RemoveEntry(SvTreeListEntry const * pEntry);
360 DragDropMode GetDragDropMode() const { return nDragDropMode; }
361 SelectionMode GetSelectionMode() const { return eSelMode; }
363 // pParent == 0 -> Root level
364 SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uLong nPos ) const;
365 SvTreeListEntry* GetEntry( sal_uLong nRootPos ) const;
367 SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const;
368 void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const;
370 using Window::GetParent;
371 const SvTreeListEntry* GetParent( const SvTreeListEntry* pEntry ) const;
372 SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const;
373 SvTreeListEntry* GetRootLevelParent(SvTreeListEntry* pEntry ) const;
375 using Window::GetChildCount;
376 sal_uLong GetChildCount( SvTreeListEntry const * pParent ) const;
377 sal_uLong GetLevelChildCount( SvTreeListEntry* pParent ) const;
379 SvViewDataEntry* GetViewDataEntry( SvTreeListEntry const * pEntry ) const;
380 SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *);
381 const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const;
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 );
387 void Clear();
389 /** Enables or disables mnemonic characters in the entry texts.
391 If mnemonics are enabled, then entries are selected and made current when
392 there mnemonic character is pressed. If there are multiple entries with the
393 same mnemonic, the selection cycles between them.
395 Entries with a collapsed ancestor are not included in the calculation of
396 mnemonics. That is, if you press the accelerator key of an invisible
397 entry, then this entry is *not* selected.
399 Be aware that enabling mnemonics gets more expensive as you add to the list.
401 void EnableEntryMnemonics();
402 bool IsEntryMnemonicsEnabled() const;
404 bool TextCenterAndClipEnabled() const { return mbCenterAndClipText; }
406 /** Handles the given key event.
408 At the moment this merely checks for accelerator keys, if entry mnemonics
409 are enabled.
411 This method may come in handy if you want to use keyboard acceleration
412 while the control does not have the focus.
414 If the key event describes the pressing of a shortcut for an entry,
415 then SelectSearchEntry resp. ExecuteSearchEntry are called.
417 @see IMnemonicEntryList
418 @see MnemonicEngine
420 @return
421 <TRUE/> if the event has been consumed, <FALSE/> otherwise.
423 bool HandleKeyInput( const KeyEvent& rKEvt );
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; }
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; }
440 // Is called for an Entry that gets expanded with the Flag
441 // ENTRYFLAG_CHILDREN_ON_DEMAND set.
442 virtual void RequestingChildren( SvTreeListEntry* pParent );
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* );
454 virtual SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource );
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
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
470 // ACCESSIBILITY ==========================================================
472 /** Creates and returns the accessible object of the Box. */
473 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
475 /** Fills the StateSet of one entry. */
476 void FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const;
478 /** Calculate and return the bounding rectangle of an entry.
479 @param pEntry
480 The entry.
481 @return The bounding rectangle of an entry. */
482 tools::Rectangle GetBoundingRect( SvTreeListEntry* pEntry );
484 SvTreeFlags GetTreeFlags() const {return nTreeFlags;}
486 static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry);
487 virtual OUString GetEntryAltText(SvTreeListEntry* pEntry) const;
488 virtual OUString GetEntryLongDescription(SvTreeListEntry* pEntry) const;
490 void set_min_width_in_chars(sal_Int32 nChars);
492 virtual bool set_property(const OString &rKey, const OUString &rValue) override;
494 protected:
496 VCL_DLLPRIVATE void SetEntryHeight( SvTreeListEntry const * pEntry );
497 void AdjustEntryHeight( const Image& rBmp );
498 VCL_DLLPRIVATE void AdjustEntryHeight();
500 VCL_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry );
501 VCL_DLLPRIVATE void PaintEntry1( SvTreeListEntry&, long nLine, vcl::RenderContext& rRenderContext );
503 VCL_DLLPRIVATE void InitTreeView();
504 VCL_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, long nX, SvLBoxTab** ppTab );
505 VCL_DLLPRIVATE void ImplInitStyle();
507 void SetupDragOrigin();
508 void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem,
509 const Selection& );
510 void EditedText(const OUString&);
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();
524 virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&);
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(); }
531 virtual void Command( const CommandEvent& rCEvt ) override;
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;
537 void InitSettings();
539 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
541 bool IsCellFocusEnabled() const;
542 bool SetCurrentTabPos( sal_uInt16 _nNewPos );
543 sal_uInt16 GetCurrentTabPos() const;
544 void CallImplEventListeners(VclEventId nEvent, void* pData);
546 void ImplEditEntry( SvTreeListEntry* pEntry );
548 bool AreChildrenTransient() const;
550 void AdjustEntryHeightAndRecalc();
551 public:
553 void SetNoAutoCurEntry( bool b );
555 void EnableCheckButton( SvLBoxButtonData* );
556 void SetCheckButtonData( SvLBoxButtonData* );
557 void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp );
559 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
560 interface experience in the whole product.
562 static const Image& GetDefaultExpandedNodeImage( );
564 /** Returns the default image which clients should use for expanded nodes, to have a consistent user
565 interface experience in the whole product.
567 static const Image& GetDefaultCollapsedNodeImage( );
569 /** Sets default bitmaps for collapsed and expanded nodes.
571 void SetNodeDefaultImages( )
573 SetNodeBitmaps(
574 GetDefaultCollapsedNodeImage( ),
575 GetDefaultExpandedNodeImage( )
579 virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr,
580 bool bChildrenOnDemand = false,
581 sal_uLong nPos=TREELIST_APPEND, void* pUserData = nullptr);
583 virtual SvTreeListEntry* InsertEntry( const OUString& rText,
584 const Image& rExpandedEntryBmp,
585 const Image& rCollapsedEntryBmp,
586 SvTreeListEntry* pParent = nullptr,
587 bool bChildrenOnDemand = false,
588 sal_uLong nPos = TREELIST_APPEND, void* pUserData = nullptr );
590 const Image& GetDefaultExpandedEntryBmp( ) const;
591 const Image& GetDefaultCollapsedEntryBmp( ) const;
593 void SetDefaultExpandedEntryBmp( const Image& rBmp );
594 void SetDefaultCollapsedEntryBmp( const Image& rBmp );
596 void SetCheckButtonState( SvTreeListEntry*, SvButtonState );
597 SvButtonState GetCheckButtonState( SvTreeListEntry* ) const;
599 void SetEntryText(SvTreeListEntry*, const OUString& );
600 void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
601 void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage );
603 virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const;
604 static const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry );
605 static const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry );
607 void SetCheckButtonHdl( const Link<SvTreeListBox*,void>& rLink ) { aCheckButtonHdl=rLink; }
608 virtual void CheckButtonHdl();
610 void SetSublistOpenWithReturn(); // open/close sublist with return/enter
611 void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right
612 void SetSublistDontOpenWithDoubleClick( bool bDontOpen ); // set mouse double click open/close sublist behavior
614 void EnableInplaceEditing( bool bEnable );
615 // Edits the Entry's first StringItem, 0 == Cursor
616 void EditEntry( SvTreeListEntry* pEntry );
617 virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& );
618 virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText );
620 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
621 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
622 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
623 virtual void MouseMove( const MouseEvent& rMEvt ) override;
624 virtual void KeyInput( const KeyEvent& rKEvt ) override;
625 virtual void Resize() override;
626 virtual void GetFocus() override;
627 virtual void LoseFocus() override;
628 void SetUpdateMode( bool );
630 virtual void ModelHasCleared() override;
631 virtual void ModelHasInserted( SvTreeListEntry* pEntry ) override;
632 virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ) override;
633 virtual void ModelIsMoving(SvTreeListEntry* pSource ) override;
634 virtual void ModelHasMoved(SvTreeListEntry* pSource ) override;
635 virtual void ModelIsRemoving( SvTreeListEntry* pEntry ) override;
636 virtual void ModelHasRemoved( SvTreeListEntry* pEntry ) override;
637 void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ) override;
639 void ScrollOutputArea( short nDeltaEntries );
641 short GetColumnsCount() const { return nColumns; }
642 short GetEntryHeight() const { return nEntryHeight; }
643 void SetEntryHeight( short nHeight, bool bForce = false );
644 short GetEntryWidth() const { return nEntryWidth; }
645 void SetEntryWidth( short nWidth );
646 Size GetOutputSizePixel() const;
647 short GetIndent() const { return nIndent; }
648 void SetIndent( short nIndent );
649 // Place the expander checkitem at the optimal indent for hierarchical lists
650 void SetOptimalImageIndent() { SetIndent(12); }
651 void SetSpaceBetweenEntries( short nSpace );
652 Point GetEntryPosition( SvTreeListEntry* ) const;
653 void MakeVisible( SvTreeListEntry* pEntry );
654 void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop );
656 void SetCollapsedNodeBmp( const Image& );
657 void SetExpandedNodeBmp( const Image& );
658 Image const & GetExpandedNodeBmp( ) const;
660 void SetFont( const vcl::Font& rFont );
662 using Window::SetCursor;
663 void SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect = false );
665 SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const;
667 virtual tools::Rectangle GetFocusRect( SvTreeListEntry*, long nLine );
668 // Respects indentation
669 virtual sal_IntPtr GetTabPos( SvTreeListEntry*, SvLBoxTab* );
670 void InvalidateEntry( SvTreeListEntry* );
671 SvLBoxItem* GetItem( SvTreeListEntry*, long nX, SvLBoxTab** ppTab);
672 SvLBoxItem* GetItem( SvTreeListEntry*, long nX );
674 void SetDragDropMode( DragDropMode );
675 void SetSelectionMode( SelectionMode );
677 virtual bool Expand( SvTreeListEntry* pParent );
678 virtual bool Collapse( SvTreeListEntry* pParent );
679 virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true );
680 sal_uLong SelectChildren( SvTreeListEntry* pParent, bool bSelect );
681 void SelectAll( bool bSelect, bool bPaint = true );
683 void SetCurEntry( SvTreeListEntry* _pEntry );
684 SvTreeListEntry* GetCurEntry() const;
686 using Window::Invalidate;
687 virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE) override;
688 virtual void Invalidate( const tools::Rectangle&, InvalidateFlags nFlags = InvalidateFlags::NONE ) override;
690 void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff);
692 // A Parent's Children are turned into Children of the Parent which comes next in hierarchy
693 void RemoveParentKeepChildren( SvTreeListEntry* pParent );
695 sal_Int32 DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText);
697 DECL_LINK( DefaultCompare, const SvSortData&, sal_Int32 );
698 virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1,
699 SvTreeListEntry* pEntry2, sal_uLong nPos ) override;
701 void EndSelection();
702 ScrollBar* GetVScroll();
703 ScrollBar* GetHScroll();
704 void EnableAsyncDrag( bool b );
706 SvTreeListEntry* GetFirstEntryInView() const;
707 SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const;
708 SvTreeListEntry* GetPrevEntryInView(SvTreeListEntry*) const;
709 SvTreeListEntry* GetLastEntryInView() const;
710 void ScrollToAbsPos( long nPos );
712 void ShowFocusRect( const SvTreeListEntry* pEntry );
714 virtual VclPtr<PopupMenu> CreateContextMenu();
715 virtual void ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry );
717 void EnableContextMenuHandling();
719 long getPreferredDimensions(std::vector<long> &rWidths) const;
721 virtual Size GetOptimalSize() const override;
723 void SetAlternatingRowColors( const bool bEnable );
725 // Enables type-ahead search in the check list box.
726 void SetQuickSearch(bool bEnable) { mbQuickSearch = bEnable; }
728 void SetForceMakeVisible(bool bEnable);
730 virtual FactoryFunction GetUITestFactory() const override;
733 class SvInplaceEdit2
735 Link<SvInplaceEdit2&,void> const aCallBackHdl;
736 Accelerator aAccReturn;
737 Accelerator aAccEscape;
738 Idle aIdle;
739 VclPtr<Edit> pEdit;
740 bool bCanceled;
741 bool bAlreadyInCallBack;
743 void CallCallBackHdl_Impl();
744 DECL_LINK( Timeout_Impl, Timer *, void );
745 DECL_LINK( ReturnHdl_Impl, Accelerator&, void );
746 DECL_LINK( EscapeHdl_Impl, Accelerator&, void );
748 public:
749 SvInplaceEdit2( vcl::Window* pParent, const Point& rPos, const Size& rSize,
750 const OUString& rData, const Link<SvInplaceEdit2&,void>& rNotifyEditEnd,
751 const Selection& );
752 ~SvInplaceEdit2();
753 bool KeyInput( const KeyEvent& rKEvt );
754 void LoseFocus();
755 bool EditingCanceled() const { return bCanceled; }
756 OUString GetText() const;
757 OUString const & GetSavedValue() const;
758 void StopEditing( bool bCancel );
759 void Hide();
762 #endif
764 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */