/src/libreoffice/include/vcl/toolkit/treelistbox.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) |
23 | | #error "don't use this in new code" |
24 | | #endif |
25 | | |
26 | | #include <config_options.h> |
27 | | #include <vcl/dllapi.h> |
28 | | |
29 | | #include <deque> |
30 | | #include <memory> |
31 | | #include <vector> |
32 | | |
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/toolkit/viewdataentry.hxx> |
40 | | #include <vcl/transfer.hxx> |
41 | | #include <o3tl/typed_flags_set.hxx> |
42 | | |
43 | | class SvTreeListBox; |
44 | | class SvTreeListEntry; |
45 | | class SvInplaceEdit2; |
46 | | class SvLBoxString; |
47 | | class SvImpLBox; |
48 | | class SvLBoxButtonData; |
49 | | class Timer; |
50 | | class Edit; |
51 | | |
52 | | enum class SvButtonState { Unchecked, Checked, Tristate }; |
53 | | |
54 | | // ********************************************************************* |
55 | | // *************************** Tabulators ****************************** |
56 | | // ********************************************************************* |
57 | | |
58 | | enum class SvLBoxTabFlags |
59 | | { |
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 |
65 | | |
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 |
73 | | HIDDEN = 0x0080, // Tab is not visible |
74 | | |
75 | | ADJUST_FLAGS = ADJUST_RIGHT | ADJUST_LEFT | ADJUST_CENTER, |
76 | | }; |
77 | | namespace o3tl |
78 | | { |
79 | | template<> struct typed_flags<SvLBoxTabFlags> : is_typed_flags<SvLBoxTabFlags, 0x00ff> {}; |
80 | | } |
81 | | |
82 | 0 | #define SV_TAB_BORDER 8 |
83 | | |
84 | 0 | #define SV_ENTRYHEIGHTOFFS_PIXEL 2 |
85 | | |
86 | | enum class SvTreeFlags |
87 | | { |
88 | | CHKBTN = 0x01, |
89 | | USESEL = 0x02, |
90 | | MANINS = 0x04, |
91 | | RECALCTABS = 0x08, |
92 | | FIXEDHEIGHT = 0x10, |
93 | | }; |
94 | | namespace o3tl |
95 | | { |
96 | | template<> struct typed_flags<SvTreeFlags> : is_typed_flags<SvTreeFlags, 0x1f> {}; |
97 | | } |
98 | | |
99 | | enum class SvLBoxItemType {String, Button, ContextBmp}; |
100 | | |
101 | | class SvLBoxTab |
102 | | { |
103 | | tools::Long nPos; |
104 | | public: |
105 | | SvLBoxTab(); |
106 | | SvLBoxTab( tools::Long nPos, SvLBoxTabFlags nFlags ); |
107 | | SvLBoxTab( const SvLBoxTab& ); |
108 | | |
109 | | SvLBoxTabFlags nFlags; |
110 | | |
111 | 0 | bool IsDynamic() const { return bool(nFlags & SvLBoxTabFlags::DYNAMIC); } |
112 | 0 | void SetPos( tools::Long nNewPos) { nPos = nNewPos; } |
113 | 0 | tools::Long GetPos() const { return nPos; } |
114 | | tools::Long CalcOffset( tools::Long nItemLength, tools::Long nTabWidth ); |
115 | 0 | bool IsEditable() const { return bool(nFlags & SvLBoxTabFlags::EDITABLE); } |
116 | 0 | bool IsHidden() const { return bool(nFlags & SvLBoxTabFlags::HIDDEN); } |
117 | | }; |
118 | | |
119 | | class UNLESS_MERGELIBS(VCL_DLLPUBLIC) SvLBoxItem |
120 | | { |
121 | | protected: |
122 | | bool mbDisabled; |
123 | | |
124 | | public: |
125 | | SvLBoxItem(); |
126 | | virtual ~SvLBoxItem(); |
127 | | virtual SvLBoxItemType GetType() const = 0; |
128 | | virtual int CalcWidth(const SvTreeListBox& rView) const; |
129 | | int GetWidth(const SvTreeListBox& rView, const SvTreeListEntry* pEntry) const; |
130 | | int GetWidth(const SvTreeListBox& rView, const SvViewDataEntry* pData, |
131 | | sal_uInt16 nItemPos) const; |
132 | | int GetHeight(const SvTreeListBox& rView, const SvTreeListEntry* pEntry) const; |
133 | | static int GetHeight(const SvViewDataEntry* pData, sal_uInt16 nItemPos); |
134 | 0 | void Enable(bool bEnabled) { mbDisabled = !bEnabled; } |
135 | 0 | bool isEnable() const { return !mbDisabled; } |
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& rView, 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 | | APP_COPY = 0x0004, |
152 | | // Entries may be dropped via the uppermost Entry |
153 | | // The DropTarget is 0 in that case |
154 | | ENABLE_TOP = 0x0010, |
155 | | ALL = 0x0015, |
156 | | }; |
157 | | namespace o3tl |
158 | | { |
159 | | template<> struct typed_flags<DragDropMode> : is_typed_flags<DragDropMode, 0x0015> {}; |
160 | | } |
161 | | |
162 | | enum class SvTreeListBoxFlags |
163 | | { |
164 | | NONE = 0x0000, |
165 | | IN_EDT = 0x0001, |
166 | | EDT_ENABLED = 0x0002, |
167 | | TARGEMPH_VIS = 0x0004, |
168 | | EDTEND_CALLED = 0x0008, |
169 | | }; |
170 | | namespace o3tl |
171 | | { |
172 | | template<> struct typed_flags<SvTreeListBoxFlags> : is_typed_flags<SvTreeListBoxFlags, 0x000f> {}; |
173 | | } |
174 | | |
175 | | struct SvTreeListBoxImpl; |
176 | | |
177 | | typedef std::pair<vcl::RenderContext&, const SvTreeListEntry&> svtree_measure_args; |
178 | | typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, const SvTreeListEntry&> svtree_render_args; |
179 | | typedef std::pair<SvTreeListEntry*, OUString> IterString; |
180 | | |
181 | | class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTreeListBox : public Control, |
182 | | public DropTargetHelper, |
183 | | public DragSourceHelper, |
184 | | public vcl::ISearchableStringList |
185 | | { |
186 | | friend class SvImpLBox; |
187 | | friend class SvLBoxString; |
188 | | friend class IconViewImpl; |
189 | | friend class TreeControlPeer; |
190 | | friend class SalInstanceIconView; |
191 | | friend class SalInstanceTreeView; |
192 | | friend class SalInstanceEntryTreeView; |
193 | | friend class SvTreeList; |
194 | | friend class JSTreeView; |
195 | | |
196 | | using SvDataTable = std::unordered_map<SvTreeListEntry*, SvViewDataEntry>; |
197 | | SvDataTable m_DataTable; // Mapping SvTreeListEntry -> ViewData |
198 | | |
199 | | sal_uInt32 m_nVisibleCount; |
200 | | sal_uInt32 m_nSelectionCount; |
201 | | bool m_bVisPositionsValid; |
202 | | |
203 | | std::unique_ptr<SvTreeList> m_pModel; |
204 | | |
205 | | std::unique_ptr<SvTreeListBoxImpl> mpImpl; |
206 | | Link<SvTreeListBox*, void> m_aScrolledHdl; |
207 | | Link<SvTreeListBox*, void> m_aExpandedHdl; |
208 | | Link<SvTreeListBox*, bool> m_aExpandingHdl; |
209 | | Link<SvTreeListBox*, void> m_aSelectHdl; |
210 | | Link<SvTreeListBox*, void> m_aDeselectHdl; |
211 | | Link<SvTreeListEntry*, OUString> m_aTooltipHdl; |
212 | | Link<svtree_render_args, void> m_aCustomRenderHdl; |
213 | | Link<svtree_measure_args, Size> m_aCustomMeasureHdl; |
214 | | |
215 | | Image m_aPrevInsertedExpBmp; |
216 | | Image m_aPrevInsertedColBmp; |
217 | | Image m_aCurInsertedExpBmp; |
218 | | Image m_aCurInsertedColBmp; |
219 | | |
220 | | short m_nContextBmpWidthMax; |
221 | | short m_nEntryHeightOffs; |
222 | | short m_nIndent; |
223 | | short m_nFocusWidth; |
224 | | sal_uInt16 m_nFirstSelTab; |
225 | | sal_uInt16 m_nLastSelTab; |
226 | | tools::Long mnCheckboxItemWidth; |
227 | | bool mbContextBmpExpanded; |
228 | | bool mbQuickSearch; // Enables type-ahead search in the check list box. |
229 | | bool mbActivateOnSingleClick; // Make single click "activate" a row like a double-click normally does |
230 | | bool mbCustomEntryRenderer; // Used to define if the list entries are updated on demand |
231 | | bool mbHoverSelection; // Make mouse over a row "select" a row like a single-click normally does |
232 | | bool mbSelectingByHover; // true during "Select" if it was due to hover |
233 | | bool mbIsTextColumEnabled; // true if the property name text-column is enabled |
234 | | sal_Int8 mnClicksToToggle; // 0 == Click on a row not toggle its checkbox. |
235 | | // 1 == Every click on row toggle its checkbox. |
236 | | // 2 == First click select, second click toggle. |
237 | | |
238 | | SvTreeListEntry* m_pHdlEntry; |
239 | | |
240 | | DragDropMode m_nDragDropMode; |
241 | | DragDropMode m_nOldDragMode; |
242 | | SelectionMode m_eSelMode; |
243 | | sal_Int32 m_nMinWidthInChars; |
244 | | |
245 | | sal_Int8 mnDragAction; |
246 | | |
247 | | SvTreeListEntry* m_pEdEntry; |
248 | | SvLBoxString* m_pEdItem; |
249 | | |
250 | | rtl::Reference<TransferDataContainer> m_xTransferHelper; |
251 | | |
252 | | protected: |
253 | | std::unique_ptr<SvImpLBox> m_pImpl; |
254 | | short m_nEntryHeight; |
255 | | short m_nEntryWidth; |
256 | | bool mbCenterAndClipText; |
257 | | |
258 | | Link<SvTreeListBox*, bool> m_aDoubleClickHdl; |
259 | | SvTreeListEntry* m_pTargetEntry; |
260 | | SvLBoxButtonData* m_pCheckButtonData; |
261 | | std::vector<std::unique_ptr<SvLBoxTab>> m_aTabs; |
262 | | SvTreeFlags m_nTreeFlags; |
263 | | SvTreeListBoxFlags m_nImpFlags; |
264 | | // Move/CopySelection: Position of the current Entry in SelectionList |
265 | | sal_uInt16 m_nCurEntrySelPos; |
266 | | |
267 | | std::unique_ptr<SvInplaceEdit2> m_pEdCtrl; |
268 | | |
269 | | private: |
270 | | DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData *, void ); |
271 | | DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl, SvInplaceEdit2&, void ); |
272 | | // Handler that is called by TreeList to clone an Entry |
273 | | DECL_DLLPRIVATE_LINK( CloneHdl_Impl, SvTreeListEntry*, SvTreeListEntry* ); |
274 | | |
275 | | void ExpandListEntry(SvTreeListEntry* pParent); |
276 | | void CollapseListEntry(SvTreeListEntry* pParent); |
277 | | bool SelectListEntry(SvTreeListEntry* pEntry, bool bSelect); |
278 | | |
279 | | void Reset(); |
280 | | |
281 | | void RemoveViewData(SvTreeListEntry* pParent); |
282 | | |
283 | | void ActionMoving(SvTreeListEntry* pEntry); |
284 | | void ActionMoved(); |
285 | | void ActionInserted(SvTreeListEntry* pEntry); |
286 | | void ActionInsertedTree(SvTreeListEntry* pEntry); |
287 | | void ActionRemoving(SvTreeListEntry* pEntry); |
288 | | |
289 | | // Handler and methods for Drag - finished handler. |
290 | | // The Handle retrieved by GetDragFinishedHdl can be set on the |
291 | | // TransferDataContainer. This link is a callback for the DragFinished |
292 | | // call. The AddBox method is called from the GetDragFinishedHdl() and the |
293 | | // remove is called in the link callback and in the dtor. So it can't be |
294 | | // called for a deleted object. |
295 | | SAL_DLLPRIVATE static void AddBoxToDDList_Impl( const SvTreeListBox& rB ); |
296 | | SAL_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvTreeListBox& rB ); |
297 | | DECL_DLLPRIVATE_LINK( DragFinishHdl_Impl, sal_Int8, void ); |
298 | | |
299 | | // after a checkbox entry is inserted, use this to get its width to support |
300 | | // autowidth for the 1st checkbox column |
301 | | SAL_DLLPRIVATE void CheckBoxInserted(SvTreeListEntry* pEntry); |
302 | | |
303 | | SAL_DLLPRIVATE void DrawCustomEntry(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const SvTreeListEntry& rEntry); |
304 | | SAL_DLLPRIVATE Size MeasureCustomEntry(vcl::RenderContext& rRenderContext, const SvTreeListEntry& rEntry) const; |
305 | | |
306 | | /** Handles the given key event. |
307 | | |
308 | | At the moment this merely does typeahead if typeahead is enabled. |
309 | | |
310 | | @return |
311 | | <TRUE/> if the event has been consumed, <FALSE/> otherwise. |
312 | | */ |
313 | | SAL_DLLPRIVATE bool HandleKeyInput(const KeyEvent& rKEvt); |
314 | | |
315 | | void UnsetDropTarget(); |
316 | | |
317 | | protected: |
318 | | |
319 | | bool CheckDragAndDropMode( SvTreeListBox const * pSource, sal_Int8 ); |
320 | | void ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow); |
321 | | void EnableSelectionAsDropTarget( bool bEnable = true ); |
322 | | // Standard impl returns 0; derived classes which support D'n'D must override |
323 | | using Window::GetDropTarget; |
324 | | virtual SvTreeListEntry* GetDropTarget( const Point& ); |
325 | | |
326 | | // Invalidate children on enable/disable |
327 | | virtual void StateChanged( StateChangedType eType ) override; |
328 | | |
329 | | virtual void Insert(SvTreeListEntry* pEnt, SvTreeListEntry* pPar, |
330 | | sal_uInt32 nPos = TREELIST_APPEND); |
331 | | virtual void Insert(SvTreeListEntry* pEntry, sal_uInt32 nRootPos = TREELIST_APPEND); |
332 | | |
333 | | // In-place editing |
334 | | void EditText( const OUString&, const tools::Rectangle&,const Selection&); |
335 | | void CancelTextEditing(); |
336 | | |
337 | | // InitViewData is called right after CreateViewData |
338 | | // The Entry is has not yet been added to the View in InitViewData! |
339 | | virtual void InitViewData(SvViewDataEntry*, SvTreeListEntry* pEntry); |
340 | | // Calls InitViewData for all Items |
341 | | void RecalcViewData(); |
342 | | |
343 | | // Handler and methods for Drag - finished handler. This link can be set |
344 | | // to the TransferDataContainer. The AddBox/RemoveBox methods must be |
345 | | // called before the StartDrag call. |
346 | | // The Remove will be called from the handler, which then calls DragFinish. |
347 | | // The Remove is also called in the DTOR of the SvTreeListBox - |
348 | | // so it can't be called for a deleted object. |
349 | | Link<sal_Int8,void> GetDragFinishedHdl() const; |
350 | | |
351 | | // For asynchronous D'n'D |
352 | | sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView ); |
353 | | |
354 | | void OnCurrentEntryChanged(); |
355 | | |
356 | | // ISearchableStringList |
357 | | virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const override; |
358 | | virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const override; |
359 | | virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) override; |
360 | | |
361 | | public: |
362 | | |
363 | | SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 ); |
364 | | virtual ~SvTreeListBox() override; |
365 | | virtual void dispose() override; |
366 | | |
367 | | sal_uInt32 GetVisibleCount() const |
368 | 0 | { |
369 | 0 | return m_pModel->GetVisibleCount(const_cast<SvTreeListBox*>(this)); |
370 | 0 | } |
371 | | |
372 | 0 | SvTreeListEntry* FirstVisible() const { return m_pModel->FirstVisible(); } |
373 | | |
374 | | SvTreeListEntry* NextVisible(SvTreeListEntry* pEntry) const |
375 | 0 | { |
376 | 0 | return m_pModel->NextVisible(this, pEntry); |
377 | 0 | } |
378 | | |
379 | | SvTreeListEntry* PrevVisible(SvTreeListEntry* pEntry) const |
380 | 0 | { |
381 | 0 | return m_pModel->PrevVisible(this, pEntry); |
382 | 0 | } |
383 | | |
384 | 0 | SvTreeListEntry* LastVisible() const { return m_pModel->LastVisible(this); } |
385 | | |
386 | | SvTreeListEntry* NextVisible(SvTreeListEntry* pEntry, sal_uInt16& rDelta) const |
387 | 0 | { |
388 | 0 | return m_pModel->NextVisible(this, pEntry, rDelta); |
389 | 0 | } |
390 | | |
391 | | SvTreeListEntry* PrevVisible(SvTreeListEntry* pEntry, sal_uInt16& rDelta) const |
392 | 0 | { |
393 | 0 | return m_pModel->PrevVisible(this, pEntry, rDelta); |
394 | 0 | } |
395 | | |
396 | | sal_uInt32 GetSelectionCount() const; |
397 | | |
398 | 0 | SvTreeListEntry* FirstSelected() const { return m_pModel->FirstSelected(this); } |
399 | | |
400 | | SvTreeListEntry* NextSelected(SvTreeListEntry* pEntry) const |
401 | 0 | { |
402 | 0 | return m_pModel->NextSelected(this, pEntry); |
403 | 0 | } |
404 | | |
405 | | SvTreeListEntry* GetEntryAtAbsPos(sal_uInt32 nAbsPos) const |
406 | 0 | { |
407 | 0 | return m_pModel->GetEntryAtAbsPos(nAbsPos); |
408 | 0 | } |
409 | | |
410 | | SvTreeListEntry* GetEntryAtVisPos(sal_uInt32 nVisPos) const |
411 | 0 | { |
412 | 0 | return m_pModel->GetEntryAtVisPos(this, nVisPos); |
413 | 0 | } |
414 | | |
415 | | sal_uInt32 GetAbsPos(SvTreeListEntry const* pEntry) const |
416 | 0 | { |
417 | 0 | return m_pModel->GetAbsPos(pEntry); |
418 | 0 | } |
419 | | |
420 | | sal_uInt32 GetVisiblePos(SvTreeListEntry const* pEntry) const |
421 | 0 | { |
422 | 0 | return m_pModel->GetVisiblePos(this, pEntry); |
423 | 0 | } |
424 | | |
425 | | sal_uInt32 GetVisibleChildCount(SvTreeListEntry* pParent) const |
426 | 0 | { |
427 | 0 | return m_pModel->GetVisibleChildCount(this, pParent); |
428 | 0 | } |
429 | | |
430 | | bool IsEntryVisible(SvTreeListEntry* pEntry) const |
431 | 0 | { |
432 | 0 | return m_pModel->IsEntryVisible(this, pEntry); |
433 | 0 | } |
434 | | |
435 | | bool IsExpanded(SvTreeListEntry* pEntry) const; |
436 | | bool IsAllExpanded(SvTreeListEntry* pEntry) const; |
437 | | bool IsSelected(const SvTreeListEntry* pEntry) const; |
438 | | void SetEntryFocus(SvTreeListEntry* pEntry, bool bFocus); |
439 | | const SvViewDataEntry* GetViewData(const SvTreeListEntry* pEntry) const; |
440 | | SvViewDataEntry* GetViewData(SvTreeListEntry* pEntry); |
441 | | bool HasViewData() const; |
442 | | |
443 | 0 | SvTreeList* GetModel() const { return m_pModel.get(); } |
444 | | |
445 | 0 | sal_uInt32 GetEntryCount() const { return m_pModel ? m_pModel->GetEntryCount() : 0; } |
446 | 0 | SvTreeListEntry* First() const { return m_pModel ? m_pModel->First() : nullptr; } |
447 | 0 | SvTreeListEntry* Next(SvTreeListEntry* pEntry) const { return m_pModel->Next(pEntry); } |
448 | 0 | SvTreeListEntry* Last() const { return m_pModel ? m_pModel->Last() : nullptr; } |
449 | | |
450 | | SvTreeListEntry* FirstChild(const SvTreeListEntry* pParent) const; |
451 | | |
452 | | sal_uInt32 GetEntryPos(const SvTreeListEntry* pEntry) const; |
453 | | |
454 | | bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget ); |
455 | | bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback ); |
456 | | void RemoveSelection(); |
457 | | /** |
458 | | * Removes the entry along with all of its descendants |
459 | | */ |
460 | | void RemoveEntry(SvTreeListEntry const * pEntry); |
461 | | |
462 | 0 | DragDropMode GetDragDropMode() const { return m_nDragDropMode; } |
463 | 0 | SelectionMode GetSelectionMode() const { return m_eSelMode; } |
464 | | |
465 | | // pParent == 0 -> Root level |
466 | | SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uInt32 nPos ) const; |
467 | | SvTreeListEntry* GetEntry( sal_uInt32 nRootPos ) const; |
468 | | |
469 | | SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const; |
470 | | void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const; |
471 | | |
472 | | using Window::GetParent; |
473 | | SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const; |
474 | | |
475 | | using Window::GetChildCount; |
476 | | sal_uInt32 GetChildCount( SvTreeListEntry const * pParent ) const; |
477 | | sal_uInt32 GetLevelChildCount( const SvTreeListEntry* pParent ) const; |
478 | | |
479 | | SvViewDataEntry* GetViewDataEntry( SvTreeListEntry const * pEntry ) const; |
480 | | SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *); |
481 | | const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const; |
482 | | |
483 | | OUString GetEntryTooltip(SvTreeListEntry* pEntry) const; |
484 | | |
485 | | VclPtr<Edit> GetEditWidget() const; // for UITest |
486 | | bool IsInplaceEditingEnabled() const |
487 | 0 | { |
488 | 0 | return bool(m_nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); |
489 | 0 | } |
490 | 0 | bool IsEditingActive() const { return bool(m_nImpFlags & SvTreeListBoxFlags::IN_EDT); } |
491 | | void EndEditing( bool bCancel = false ); |
492 | | |
493 | | void Clear(); |
494 | | |
495 | 0 | bool TextCenterAndClipEnabled() const { return mbCenterAndClipText; } |
496 | | |
497 | 0 | void SetSelectHdl(const Link<SvTreeListBox*, void>& rNewHdl) { m_aSelectHdl = rNewHdl; } |
498 | 0 | void SetDeselectHdl(const Link<SvTreeListBox*, void>& rNewHdl) { m_aDeselectHdl = rNewHdl; } |
499 | | void SetDoubleClickHdl(const Link<SvTreeListBox*, bool>& rNewHdl) |
500 | 0 | { |
501 | 0 | m_aDoubleClickHdl = rNewHdl; |
502 | 0 | } |
503 | 0 | void SetExpandingHdl(const Link<SvTreeListBox*, bool>& rNewHdl) { m_aExpandingHdl = rNewHdl; } |
504 | 0 | void SetExpandedHdl(const Link<SvTreeListBox*, void>& rNewHdl) { m_aExpandedHdl = rNewHdl; } |
505 | 0 | void SetTooltipHdl(const Link<SvTreeListEntry*, OUString>& rLink) { m_aTooltipHdl = rLink; } |
506 | | void SetCustomRenderHdl(const Link<svtree_render_args, void>& rLink) |
507 | 0 | { |
508 | 0 | m_aCustomRenderHdl = rLink; |
509 | 0 | } |
510 | | void SetCustomMeasureHdl(const Link<svtree_measure_args, Size>& rLink) |
511 | 0 | { |
512 | 0 | m_aCustomMeasureHdl = rLink; |
513 | 0 | } |
514 | | |
515 | | void ExpandedHdl(); |
516 | | bool ExpandingHdl(); |
517 | | void SelectHdl(); |
518 | | void DeselectHdl(); |
519 | | bool DoubleClickHdl(); |
520 | 0 | SvTreeListEntry* GetHdlEntry() const { return m_pHdlEntry; } |
521 | | |
522 | | // Is called for an Entry that gets expanded with the Flag |
523 | | // ENTRYFLAG_CHILDREN_ON_DEMAND set. |
524 | | virtual void RequestingChildren( SvTreeListEntry* pParent ); |
525 | | |
526 | | // Drag & Drop |
527 | | // New D'n'D API |
528 | | virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; |
529 | | virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; |
530 | | virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; |
531 | | virtual DragDropMode NotifyStartDrag(); |
532 | | virtual void DragFinished( sal_Int8 nDropAction ); |
533 | | |
534 | | SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ); |
535 | | |
536 | | // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry |
537 | | TriState NotifyMoving( |
538 | | SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel() |
539 | | const SvTreeListEntry* pEntry, // Entry to be moved from GetSourceListBox()->GetModel() |
540 | | SvTreeListEntry*& rpNewParent, // New TargetParent |
541 | | sal_uInt32& rNewChildPos); // The TargetParent's position in Childlist |
542 | | |
543 | | // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry |
544 | | TriState NotifyCopying( |
545 | | SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel() |
546 | | const SvTreeListEntry* pEntry, // Entry to be copied from GetSourceListBox()->GetModel() |
547 | | SvTreeListEntry*& rpNewParent, // New TargetParent |
548 | | sal_uInt32& rNewChildPos); // The TargetParent's position in Childlist |
549 | | |
550 | | /** Creates and returns the accessible object of the Box. */ |
551 | | virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override; |
552 | | |
553 | | /** Calculate and return the bounding rectangle of an entry. |
554 | | @param pEntry |
555 | | The entry. |
556 | | @return The bounding rectangle of an entry. */ |
557 | | tools::Rectangle GetBoundingRect(const SvTreeListEntry* pEntry); |
558 | | |
559 | 0 | SvTreeFlags GetTreeFlags() const { return m_nTreeFlags; } |
560 | | |
561 | | static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry); |
562 | | |
563 | | void set_min_width_in_chars(sal_Int32 nChars); |
564 | | |
565 | | virtual bool set_property(const OUString &rKey, const OUString &rValue) override; |
566 | | |
567 | | SAL_DLLPRIVATE void SetCollapsedNodeBmp( const Image& ); |
568 | | SAL_DLLPRIVATE void SetExpandedNodeBmp( const Image& ); |
569 | | SAL_DLLPRIVATE Image const & GetExpandedNodeBmp( ) const; |
570 | | |
571 | | protected: |
572 | | |
573 | | virtual void CalcEntryHeight(SvTreeListEntry const* pEntry); |
574 | | void AdjustEntryHeight( const Image& rBmp ); |
575 | | SAL_DLLPRIVATE void AdjustEntryHeight(); |
576 | | |
577 | | SAL_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry ); |
578 | | SAL_DLLPRIVATE void PaintEntry1( SvTreeListEntry&, tools::Long nLine, vcl::RenderContext& rRenderContext ); |
579 | | |
580 | | SAL_DLLPRIVATE void InitTreeView(); |
581 | | SAL_DLLPRIVATE void ImplInitStyle(); |
582 | | |
583 | | void SetupDragOrigin(); |
584 | | void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem, |
585 | | const Selection& ); |
586 | | void EditedText(const OUString&); |
587 | | |
588 | | // Recalculate all tabs depending on TreeListStyle and Bitmap sizes |
589 | | // Is called automatically when inserting/changing Bitmaps, changing the Model etc. |
590 | | virtual void SetTabs(); |
591 | | void AddTab( tools::Long nPos, SvLBoxTabFlags nFlags ); |
592 | 0 | sal_uInt16 TabCount() const { return m_aTabs.size(); } |
593 | | SvLBoxTab* GetFirstDynamicTab() const; |
594 | | SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const; |
595 | | SvLBoxTab* GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ); |
596 | | void GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ); |
597 | | SvLBoxTab* GetTab( SvTreeListEntry const *, SvLBoxItem const * ) const; |
598 | | void ClearTabList(); |
599 | | |
600 | | virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&); |
601 | | |
602 | | void NotifyScrolled(); |
603 | 0 | void SetScrolledHdl(const Link<SvTreeListBox*, void>& rLink) { m_aScrolledHdl = rLink; } |
604 | 0 | tools::Long GetXOffset() const { return GetMapMode().GetOrigin().X(); } |
605 | | |
606 | | virtual void Command( const CommandEvent& rCEvt ) override; |
607 | | |
608 | | virtual void RequestHelp( const HelpEvent& rHEvt ) override; |
609 | | virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; |
610 | | |
611 | | void InitSettings(); |
612 | | |
613 | | virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; |
614 | | |
615 | | void CallImplEventListeners(VclEventId nEvent, void* pData); |
616 | | |
617 | | void ImplEditEntry( SvTreeListEntry* pEntry ); |
618 | | |
619 | | void AdjustEntryHeightAndRecalc(); |
620 | | |
621 | | // true if rPos is over the SvTreeListBox body, i.e. not over a |
622 | | // scrollbar |
623 | | SAL_DLLPRIVATE bool PosOverBody(const Point& rPos) const; |
624 | | public: |
625 | | |
626 | | void SetNoAutoCurEntry( bool b ); |
627 | | |
628 | | void EnableCheckButton(SvLBoxButtonData&); |
629 | | |
630 | | /** Returns the default image which clients should use for expanded nodes, to have a consistent user |
631 | | interface experience in the whole product. |
632 | | */ |
633 | | static const Image& GetDefaultExpandedNodeImage( ); |
634 | | |
635 | | /** Returns the default image which clients should use for expanded nodes, to have a consistent user |
636 | | interface experience in the whole product. |
637 | | */ |
638 | | static const Image& GetDefaultCollapsedNodeImage( ); |
639 | | |
640 | | /** Sets default bitmaps for collapsed and expanded nodes. |
641 | | */ |
642 | | void SetNodeDefaultImages(); |
643 | | |
644 | | virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr, |
645 | | bool bChildrenOnDemand = false, |
646 | | sal_uInt32 nPos=TREELIST_APPEND, OUString* pUserData = nullptr); |
647 | | |
648 | | const Image& GetDefaultExpandedEntryBmp( ) const; |
649 | | const Image& GetDefaultCollapsedEntryBmp( ) const; |
650 | | |
651 | | void SetDefaultExpandedEntryBmp( const Image& rBmp ); |
652 | | void SetDefaultCollapsedEntryBmp( const Image& rBmp ); |
653 | | |
654 | | void SetCheckButtonState( SvTreeListEntry*, SvButtonState ); |
655 | | SvButtonState GetCheckButtonState( SvTreeListEntry* ) const; |
656 | | bool GetCheckButtonEnabled(SvTreeListEntry* pEntry) const; |
657 | | |
658 | | void SetEntryText(SvTreeListEntry*, const OUString& ); |
659 | | void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage ); |
660 | | void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage ); |
661 | | |
662 | | virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const; |
663 | | static const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry ); |
664 | | static const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry ); |
665 | | |
666 | | void CheckButtonHdl(); |
667 | | |
668 | | void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right |
669 | | |
670 | | void EnableInplaceEditing( bool bEnable ); |
671 | | // Edits the Entry's first StringItem, 0 == Cursor |
672 | | void EditEntry( SvTreeListEntry* pEntry ); |
673 | | virtual bool EditingEntry( SvTreeListEntry* pEntry ); |
674 | | virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ); |
675 | | |
676 | | virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; |
677 | | virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; |
678 | | virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; |
679 | | virtual void MouseMove( const MouseEvent& rMEvt ) override; |
680 | | virtual void KeyInput( const KeyEvent& rKEvt ) override; |
681 | | virtual void Resize() override; |
682 | | virtual void GetFocus() override; |
683 | | virtual void LoseFocus() override; |
684 | | void SetUpdateMode( bool ); |
685 | | |
686 | | virtual void ModelHasCleared(); |
687 | | virtual void ModelHasInserted(SvTreeListEntry* pEntry); |
688 | | virtual void ModelHasInsertedTree(SvTreeListEntry* pEntry); |
689 | | virtual void ModelIsMoving(SvTreeListEntry* pSource); |
690 | | virtual void ModelHasMoved(SvTreeListEntry* pSource); |
691 | | virtual void ModelIsRemoving(SvTreeListEntry* pEntry); |
692 | | virtual void ModelHasRemoved(SvTreeListEntry* pEntry); |
693 | | void ModelHasEntryInvalidated(SvTreeListEntry* pEntry); |
694 | | |
695 | | void ScrollOutputArea( short nDeltaEntries ); |
696 | | |
697 | 0 | short GetEntryHeight() const { return m_nEntryHeight; } |
698 | | void SetEntryHeight( short nHeight ); |
699 | 0 | short GetEntryWidth() const { return m_nEntryWidth; } |
700 | | void SetEntryWidth( short nWidth ); |
701 | | Size GetOutputSizePixel() const; |
702 | 0 | short GetIndent() const { return m_nIndent; } |
703 | | void SetSpaceBetweenEntries( short nSpace ); |
704 | | Point GetEntryPosition(const SvTreeListEntry*) const; |
705 | | void MakeVisible( SvTreeListEntry* pEntry ); |
706 | | void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop ); |
707 | | |
708 | | void SetFont( const vcl::Font& rFont ); |
709 | | |
710 | | SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const; |
711 | | |
712 | | virtual tools::Rectangle GetFocusRect(const SvTreeListEntry*, tools::Long nLine ); |
713 | | // Respects indentation |
714 | | tools::Long GetTabPos(const SvTreeListEntry*, const SvLBoxTab*) const; |
715 | | void InvalidateEntry( SvTreeListEntry* ); |
716 | | SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX, SvLBoxTab** ppTab); |
717 | | SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX ); |
718 | | std::pair<tools::Long, tools::Long> GetItemPos(SvTreeListEntry* pEntry, sal_uInt16 nTabIdx); |
719 | | |
720 | | void SetDragDropMode( DragDropMode ); |
721 | | void SetSelectionMode( SelectionMode ); |
722 | | |
723 | | bool Expand( SvTreeListEntry* pParent ); |
724 | | bool Collapse( SvTreeListEntry* pParent ); |
725 | | bool Select( SvTreeListEntry* pEntry, bool bSelect=true ); |
726 | | sal_uInt32 SelectChildren( const SvTreeListEntry* pParent, bool bSelect ); |
727 | | void SelectAll( bool bSelect ); |
728 | | |
729 | | void SetCurEntry( SvTreeListEntry* _pEntry ); |
730 | | SvTreeListEntry* GetCurEntry() const; |
731 | | |
732 | | virtual void ImplInvalidate( const vcl::Region* rRegion, InvalidateFlags nFlags ) override; |
733 | | |
734 | | void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff); |
735 | | |
736 | | sal_Int32 DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText); |
737 | | |
738 | | DECL_DLLPRIVATE_LINK( DefaultCompare, const SvSortData&, sal_Int32 ); |
739 | | void ModelNotification(SvListAction nActionId, SvTreeListEntry* pEntry); |
740 | | |
741 | | SvTreeListEntry* GetFirstEntryInView() const; |
742 | | SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const; |
743 | | void ScrollToAbsPos( tools::Long nPos ); |
744 | | |
745 | | tools::Long getPreferredDimensions(std::vector<tools::Long> &rWidths) const; |
746 | | |
747 | | virtual Size GetOptimalSize() const override; |
748 | | |
749 | | // Enables type-ahead search in the check list box. |
750 | 0 | void SetQuickSearch(bool bEnable) { mbQuickSearch = bEnable; } |
751 | | |
752 | | // Make single click "activate" a row like a double-click normally does |
753 | 0 | void SetActivateOnSingleClick(bool bEnable) { mbActivateOnSingleClick = bEnable; } |
754 | 0 | bool GetActivateOnSingleClick() const { return mbActivateOnSingleClick; } |
755 | | |
756 | 0 | void SetCustomEntryRenderer(bool bEnable) { mbCustomEntryRenderer = bEnable; } |
757 | 0 | bool GetCustomEntryRenderer() const { return mbCustomEntryRenderer; } |
758 | | |
759 | | // Make mouse over a row "select" a row like a single-click normally does |
760 | 0 | void SetHoverSelection(bool bEnable) { mbHoverSelection = bEnable; } |
761 | 0 | bool GetHoverSelection() const { return mbHoverSelection; } |
762 | | |
763 | | // to get enable or disable the text-column |
764 | 0 | void SetTextColumnEnabled(bool bEnable) { mbIsTextColumEnabled = bEnable; } |
765 | 0 | bool IsTextColumnEnabled() const { return mbIsTextColumEnabled; } |
766 | | |
767 | | // only true during Select if the Select is due to a Hover |
768 | 0 | bool IsSelectDueToHover() const { return mbSelectingByHover; } |
769 | | |
770 | | // Set when clicks toggle the checkbox of the row. |
771 | 0 | void SetClicksToToggle(sal_Int8 nCount) { mnClicksToToggle = nCount; } |
772 | | |
773 | | void SetForceMakeVisible(bool bEnable); |
774 | | |
775 | | virtual FactoryFunction GetUITestFactory() const override; |
776 | | |
777 | | void SetDragHelper(const rtl::Reference<TransferDataContainer>& rHelper, sal_uInt8 eDNDConstants); |
778 | | |
779 | | virtual void EnableRTL(bool bEnable = true) override; |
780 | | }; |
781 | | |
782 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |