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 <vcl/dllapi.h> 27 28 #include <deque> 29 #include <memory> 30 #include <vector> 31 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> 40 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; 51 52 namespace utl { 53 class AccessibleStateSetHelper; 54 } 55 56 enum class SvButtonState { Unchecked, Checked, Tristate }; 57 58 // ********************************************************************* 59 // *************************** Tabulators ****************************** 60 // ********************************************************************* 61 62 enum class SvLBoxTabFlags 63 { 64 NONE = 0x0000, 65 DYNAMIC = 0x0001, // Item's output column changes according to the Child Depth 66 ADJUST_RIGHT = 0x0002, // Item's right margin at the tabulator 67 ADJUST_LEFT = 0x0004, // Left margin 68 ADJUST_CENTER = 0x0008, // Center the item at the tabulator 69 70 SHOW_SELECTION = 0x0010, // Visualize selection state 71 // Item needs to be able to return the surrounding polygon (D'n'D cursor) 72 EDITABLE = 0x0020, // Item editable at the tabulator 73 FORCE = 0x0040, // Switch off the default calculation of the first tabulator 74 // (on which Abo Tabpage/Extras/Option/Customize, etc. rely on) 75 // The first tab's position corresponds precisely to the Flags set 76 // and column widths 77 }; 78 namespace o3tl 79 { 80 template<> struct typed_flags<SvLBoxTabFlags> : is_typed_flags<SvLBoxTabFlags, 0x007f> {}; 81 } 82 83 #define SV_TAB_BORDER 8 84 85 #define SV_ENTRYHEIGHTOFFS_PIXEL 2 86 87 enum class SvTreeFlags 88 { 89 CHKBTN = 0x01, 90 USESEL = 0x02, 91 MANINS = 0x04, 92 RECALCTABS = 0x08, 93 FIXEDHEIGHT = 0x10, 94 }; 95 namespace o3tl 96 { 97 template<> struct typed_flags<SvTreeFlags> : is_typed_flags<SvTreeFlags, 0x1f> {}; 98 } 99 100 enum class SvLBoxItemType {String, Button, ContextBmp}; 101 102 class SvLBoxTab 103 { 104 tools::Long nPos; 105 public: 106 SvLBoxTab(); 107 SvLBoxTab( tools::Long nPos, SvLBoxTabFlags nFlags ); 108 SvLBoxTab( const SvLBoxTab& ); 109 ~SvLBoxTab(); 110 111 SvLBoxTabFlags nFlags; 112 IsDynamic() const113 bool IsDynamic() const { return bool(nFlags & SvLBoxTabFlags::DYNAMIC); } SetPos(tools::Long nNewPos)114 void SetPos( tools::Long nNewPos) { nPos = nNewPos; } GetPos() const115 tools::Long GetPos() const { return nPos; } 116 tools::Long CalcOffset( tools::Long nItemLength, tools::Long nTabWidth ); IsEditable() const117 bool IsEditable() const { return bool(nFlags & SvLBoxTabFlags::EDITABLE); } 118 }; 119 120 class VCL_DLLPUBLIC SvLBoxItem 121 { 122 protected: 123 bool mbDisabled; 124 125 public: 126 SvLBoxItem(); 127 virtual ~SvLBoxItem(); 128 virtual SvLBoxItemType GetType() const = 0; 129 virtual int CalcWidth(const SvTreeListBox* pView) const; 130 int GetWidth(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const; 131 int GetWidth(const SvTreeListBox* pView, const SvViewDataEntry* pData, sal_uInt16 nItemPos); 132 int GetHeight(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const; 133 static int GetHeight(const SvViewDataEntry* pData, sal_uInt16 nItemPos); Enable(bool bEnabled)134 void Enable(bool bEnabled) { mbDisabled = !bEnabled; } 135 136 virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext, const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) = 0; 137 138 virtual void InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry, 139 // If != 0: this Pointer must be used! 140 // If == 0: it needs to be retrieved via the View 141 SvViewDataItem* pViewData = nullptr) = 0; 142 // View-dependent data is not cloned 143 virtual std::unique_ptr<SvLBoxItem> Clone(SvLBoxItem const * pSource) const = 0; 144 }; 145 146 enum class DragDropMode 147 { 148 NONE = 0x0000, 149 CTRL_MOVE = 0x0001, 150 APP_COPY = 0x0004, 151 // Entries may be dropped via the uppermost Entry 152 // The DropTarget is 0 in that case 153 ENABLE_TOP = 0x0010, 154 ALL = 0x0015, 155 }; 156 namespace o3tl 157 { 158 template<> struct typed_flags<DragDropMode> : is_typed_flags<DragDropMode, 0x0015> {}; 159 } 160 161 enum class SvTreeListBoxFlags 162 { 163 NONE = 0x0000, 164 IN_EDT = 0x0001, 165 EDT_ENABLED = 0x0002, 166 TARGEMPH_VIS = 0x0004, 167 EDTEND_CALLED = 0x0008, 168 }; 169 namespace o3tl 170 { 171 template<> struct typed_flags<SvTreeListBoxFlags> : is_typed_flags<SvTreeListBoxFlags, 0x000f> {}; 172 } 173 174 struct SvTreeListBoxImpl; 175 176 typedef std::pair<vcl::RenderContext&, const SvTreeListEntry&> svtree_measure_args; 177 typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, const SvTreeListEntry&> svtree_render_args; 178 179 class VCL_DLLPUBLIC SvTreeListBox 180 :public Control 181 ,public SvListView 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 194 std::unique_ptr<SvTreeListBoxImpl> mpImpl; 195 Link<SvTreeListBox*,void> aScrolledHdl; 196 Link<SvTreeListBox*,void> aExpandedHdl; 197 Link<SvTreeListBox*,bool> aExpandingHdl; 198 Link<SvTreeListBox*,void> aSelectHdl; 199 Link<SvTreeListBox*,void> aDeselectHdl; 200 Link<const CommandEvent&, bool> aPopupMenuHdl; 201 Link<const HelpEvent&, bool> aTooltipHdl; 202 Link<svtree_render_args, void> aCustomRenderHdl; 203 Link<svtree_measure_args, Size> aCustomMeasureHdl; 204 205 Image aPrevInsertedExpBmp; 206 Image aPrevInsertedColBmp; 207 Image aCurInsertedExpBmp; 208 Image aCurInsertedColBmp; 209 210 short nContextBmpWidthMax; 211 short nEntryHeightOffs; 212 short nIndent; 213 short nFocusWidth; 214 sal_uInt16 nFirstSelTab; 215 sal_uInt16 nLastSelTab; 216 tools::Long mnCheckboxItemWidth; 217 bool mbContextBmpExpanded; 218 bool mbAlternatingRowColors; 219 bool mbUpdateAlternatingRows; 220 bool mbQuickSearch; // Enables type-ahead search in the check list box. 221 bool mbActivateOnSingleClick; // Make single click "activate" a row like a double-click normally does 222 bool mbHoverSelection; // Make mouse over a row "select" a row like a single-click normally does 223 sal_Int8 mnClicksToToggle; // 0 == Click on a row not toggle its checkbox. 224 // 1 == Every click on row toggle its checkbox. 225 // 2 == First click select, second click toggle. 226 227 SvTreeListEntry* pHdlEntry; 228 229 DragDropMode nDragDropMode; 230 DragDropMode nOldDragMode; 231 SelectionMode eSelMode; 232 sal_Int32 nMinWidthInChars; 233 234 sal_Int8 mnDragAction; 235 236 SvTreeListEntry* pEdEntry; 237 SvLBoxItem* pEdItem; 238 239 rtl::Reference<TransferDataContainer> m_xTransferHelper; 240 241 protected: 242 std::unique_ptr<SvImpLBox> pImpl; 243 short nColumns; 244 short nEntryHeight; 245 short nEntryWidth; 246 bool mbCenterAndClipText; 247 248 Link<SvTreeListBox*,bool> aDoubleClickHdl; 249 SvTreeListEntry* pTargetEntry; 250 SvLBoxButtonData* pCheckButtonData; 251 std::vector<std::unique_ptr<SvLBoxTab>> aTabs; 252 SvTreeFlags nTreeFlags; 253 SvTreeListBoxFlags nImpFlags; 254 // Move/CopySelection: Position of the current Entry in SelectionList 255 sal_uInt16 nCurEntrySelPos; 256 257 private: 258 DECL_DLLPRIVATE_LINK( CheckButtonClick, SvLBoxButtonData *, void ); 259 DECL_DLLPRIVATE_LINK( TextEditEndedHdl_Impl, SvInplaceEdit2&, void ); 260 // Handler that is called by TreeList to clone an Entry 261 DECL_DLLPRIVATE_LINK( CloneHdl_Impl, SvTreeListEntry*, SvTreeListEntry* ); 262 263 // Handler and methods for Drag - finished handler. 264 // The Handle retrieved by GetDragFinishedHdl can be set on the 265 // TransferDataContainer. This link is a callback for the DragFinished 266 // call. The AddBox method is called from the GetDragFinishedHdl() and the 267 // remove is called in the link callback and in the dtor. So it can't be 268 // called for a deleted object. 269 VCL_DLLPRIVATE static void AddBoxToDDList_Impl( const SvTreeListBox& rB ); 270 VCL_DLLPRIVATE static void RemoveBoxFromDDList_Impl( const SvTreeListBox& rB ); 271 DECL_DLLPRIVATE_LINK( DragFinishHdl_Impl, sal_Int8, void ); 272 273 // after a checkbox entry is inserted, use this to get its width to support 274 // autowidth for the 1st checkbox column 275 VCL_DLLPRIVATE void CheckBoxInserted(SvTreeListEntry* pEntry); 276 277 VCL_DLLPRIVATE void DrawCustomEntry(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const SvTreeListEntry& rEntry); 278 VCL_DLLPRIVATE Size MeasureCustomEntry(vcl::RenderContext& rRenderContext, const SvTreeListEntry& rEntry); 279 280 /** Handles the given key event. 281 282 At the moment this merely does typeahead if typeahead is enabled. 283 284 @return 285 <TRUE/> if the event has been consumed, <FALSE/> otherwise. 286 */ 287 VCL_DLLPRIVATE bool HandleKeyInput(const KeyEvent& rKEvt); 288 289 void UnsetDropTarget(); 290 291 protected: 292 293 bool CheckDragAndDropMode( SvTreeListBox const * pSource, sal_Int8 ); 294 void ImplShowTargetEmphasis( SvTreeListEntry* pEntry, bool bShow); 295 void EnableSelectionAsDropTarget( bool bEnable = true ); 296 // Standard impl returns 0; derived classes which support D'n'D must override 297 using Window::GetDropTarget; 298 virtual SvTreeListEntry* GetDropTarget( const Point& ); 299 300 // Invalidate children on enable/disable 301 virtual void StateChanged( StateChangedType eType ) override; 302 303 virtual sal_uInt32 Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uInt32 nPos=TREELIST_APPEND); 304 virtual sal_uInt32 Insert( SvTreeListEntry* pEntry,sal_uInt32 nRootPos = TREELIST_APPEND ); 305 306 // In-place editing 307 std::unique_ptr<SvInplaceEdit2> pEdCtrl; 308 void EditText( const OUString&, const tools::Rectangle&,const Selection&); 309 void CancelTextEditing(); 310 311 // InitViewData is called right after CreateViewData 312 // The Entry is has not yet been added to the View in InitViewData! 313 virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ) override; 314 // Calls InitViewData for all Items 315 void RecalcViewData(); 316 317 // Handler and methods for Drag - finished handler. This link can be set 318 // to the TransferDataContainer. The AddBox/RemoveBox methods must be 319 // called before the StartDrag call. 320 // The Remove will be called from the handler, which then calls DragFinish. 321 // The Remove is also called in the DTOR of the SvTreeListBox - 322 // so it can't be called for a deleted object. 323 Link<sal_Int8,void> GetDragFinishedHdl() const; 324 325 // For asynchronous D'n'D 326 sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt, SvTreeListBox* pSourceView ); 327 328 void OnCurrentEntryChanged(); 329 330 // ISearchableStringList 331 virtual vcl::StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const override; 332 virtual vcl::StringEntryIdentifier NextEntry( vcl::StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const override; 333 virtual void SelectEntry( vcl::StringEntryIdentifier _entry ) override; 334 335 public: 336 337 SvTreeListBox( vcl::Window* pParent, WinBits nWinStyle=0 ); 338 virtual ~SvTreeListBox() override; 339 virtual void dispose() override; 340 GetModel() const341 SvTreeList* GetModel() const 342 { 343 return pModel.get(); 344 } 345 GetEntryCount() const346 sal_uInt32 GetEntryCount() const 347 { 348 return pModel ? pModel->GetEntryCount() : 0; 349 } First() const350 SvTreeListEntry* First() const 351 { 352 return pModel ? pModel->First() : nullptr; 353 } Next(SvTreeListEntry * pEntry) const354 SvTreeListEntry* Next( SvTreeListEntry* pEntry ) const 355 { 356 return pModel->Next(pEntry); 357 } Prev(SvTreeListEntry * pEntry) const358 SvTreeListEntry* Prev( SvTreeListEntry* pEntry ) const 359 { 360 return pModel->Prev(pEntry); 361 } Last() const362 SvTreeListEntry* Last() const 363 { 364 return pModel ? pModel->Last() : nullptr; 365 } 366 367 SvTreeListEntry* FirstChild( SvTreeListEntry* pParent ) const; 368 369 bool CopySelection( SvTreeListBox* pSource, SvTreeListEntry* pTarget ); 370 bool MoveSelectionCopyFallbackPossible( SvTreeListBox* pSource, SvTreeListEntry* pTarget, bool bAllowCopyFallback ); 371 void RemoveSelection(); 372 /** 373 * Removes the entry along with all of its descendants 374 */ 375 void RemoveEntry(SvTreeListEntry const * pEntry); 376 GetDragDropMode() const377 DragDropMode GetDragDropMode() const { return nDragDropMode; } GetSelectionMode() const378 SelectionMode GetSelectionMode() const { return eSelMode; } 379 380 // pParent == 0 -> Root level 381 SvTreeListEntry* GetEntry( SvTreeListEntry* pParent, sal_uInt32 nPos ) const; 382 SvTreeListEntry* GetEntry( sal_uInt32 nRootPos ) const; 383 384 SvTreeListEntry* GetEntryFromPath( const ::std::deque< sal_Int32 >& _rPath ) const; 385 void FillEntryPath( SvTreeListEntry* pEntry, ::std::deque< sal_Int32 >& _rPath ) const; 386 387 using Window::GetParent; 388 SvTreeListEntry* GetParent( SvTreeListEntry* pEntry ) const; 389 390 using Window::GetChildCount; 391 sal_uInt32 GetChildCount( SvTreeListEntry const * pParent ) const; 392 sal_uInt32 GetLevelChildCount( SvTreeListEntry* pParent ) const; 393 394 SvViewDataEntry* GetViewDataEntry( SvTreeListEntry const * pEntry ) const; 395 SvViewDataItem* GetViewDataItem(SvTreeListEntry const *, SvLBoxItem const *); 396 const SvViewDataItem* GetViewDataItem(const SvTreeListEntry*, const SvLBoxItem*) const; 397 IsInplaceEditingEnabled() const398 bool IsInplaceEditingEnabled() const { return bool(nImpFlags & SvTreeListBoxFlags::EDT_ENABLED); } IsEditingActive() const399 bool IsEditingActive() const { return bool(nImpFlags & SvTreeListBoxFlags::IN_EDT); } 400 void EndEditing( bool bCancel = false ); 401 402 void Clear(); 403 TextCenterAndClipEnabled() const404 bool TextCenterAndClipEnabled() const { return mbCenterAndClipText; } 405 SetSelectHdl(const Link<SvTreeListBox *,void> & rNewHdl)406 void SetSelectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aSelectHdl=rNewHdl; } SetDeselectHdl(const Link<SvTreeListBox *,void> & rNewHdl)407 void SetDeselectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aDeselectHdl=rNewHdl; } SetDoubleClickHdl(const Link<SvTreeListBox *,bool> & rNewHdl)408 void SetDoubleClickHdl(const Link<SvTreeListBox*,bool>& rNewHdl) {aDoubleClickHdl=rNewHdl;} SetExpandingHdl(const Link<SvTreeListBox *,bool> & rNewHdl)409 void SetExpandingHdl(const Link<SvTreeListBox*,bool>& rNewHdl){aExpandingHdl=rNewHdl;} SetExpandedHdl(const Link<SvTreeListBox *,void> & rNewHdl)410 void SetExpandedHdl(const Link<SvTreeListBox*,void>& rNewHdl){aExpandedHdl=rNewHdl;} SetPopupMenuHdl(const Link<const CommandEvent &,bool> & rLink)411 void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink) { aPopupMenuHdl = rLink; } SetTooltipHdl(const Link<const HelpEvent &,bool> & rLink)412 void SetTooltipHdl(const Link<const HelpEvent&, bool>& rLink) { aTooltipHdl = rLink; } SetCustomRenderHdl(const Link<svtree_render_args,void> & rLink)413 void SetCustomRenderHdl(const Link<svtree_render_args, void>& rLink) { aCustomRenderHdl = rLink; } SetCustomMeasureHdl(const Link<svtree_measure_args,Size> & rLink)414 void SetCustomMeasureHdl(const Link<svtree_measure_args, Size>& rLink) { aCustomMeasureHdl = rLink; } 415 416 void ExpandedHdl(); 417 bool ExpandingHdl(); 418 void SelectHdl(); 419 void DeselectHdl(); 420 bool DoubleClickHdl(); GetHdlEntry() const421 SvTreeListEntry* GetHdlEntry() const { return pHdlEntry; } 422 423 // Is called for an Entry that gets expanded with the Flag 424 // ENTRYFLAG_CHILDREN_ON_DEMAND set. 425 virtual void RequestingChildren( SvTreeListEntry* pParent ); 426 427 // Drag & Drop 428 // New D'n'D API 429 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; 430 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override; 431 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) override; 432 virtual DragDropMode NotifyStartDrag(); 433 virtual void DragFinished( sal_Int8 nDropAction ); 434 435 SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ); 436 437 // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry 438 TriState NotifyMoving( 439 SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel() 440 const SvTreeListEntry* pEntry, // Entry to be moved from GetSourceListBox()->GetModel() 441 SvTreeListEntry*& rpNewParent, // New TargetParent 442 sal_uInt32& rNewChildPos); // The TargetParent's position in Childlist 443 444 // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry 445 TriState NotifyCopying( 446 SvTreeListEntry* pTarget, // D'n'D DropPosition in GetModel() 447 const SvTreeListEntry* pEntry, // Entry to be copied from GetSourceListBox()->GetModel() 448 SvTreeListEntry*& rpNewParent, // New TargetParent 449 sal_uInt32& rNewChildPos); // The TargetParent's position in Childlist 450 451 // ACCESSIBILITY ========================================================== 452 453 /** Creates and returns the accessible object of the Box. */ 454 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; 455 456 /** Fills the StateSet of one entry. */ 457 void FillAccessibleEntryStateSet( SvTreeListEntry* pEntry, ::utl::AccessibleStateSetHelper& rStateSet ) const; 458 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); 464 GetTreeFlags() const465 SvTreeFlags GetTreeFlags() const {return nTreeFlags;} 466 467 static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry); 468 469 void set_min_width_in_chars(sal_Int32 nChars); 470 471 virtual bool set_property(const OString &rKey, const OUString &rValue) override; 472 473 protected: 474 475 VCL_DLLPRIVATE void SetEntryHeight( SvTreeListEntry const * pEntry ); 476 void AdjustEntryHeight( const Image& rBmp ); 477 VCL_DLLPRIVATE void AdjustEntryHeight(); 478 479 VCL_DLLPRIVATE void ImpEntryInserted( SvTreeListEntry* pEntry ); 480 VCL_DLLPRIVATE void PaintEntry1( SvTreeListEntry&, tools::Long nLine, vcl::RenderContext& rRenderContext ); 481 482 VCL_DLLPRIVATE void InitTreeView(); 483 VCL_DLLPRIVATE SvLBoxItem* GetItem_Impl( SvTreeListEntry*, tools::Long nX, SvLBoxTab** ppTab ); 484 VCL_DLLPRIVATE void ImplInitStyle(); 485 486 void SetupDragOrigin(); 487 void EditItemText( SvTreeListEntry* pEntry, SvLBoxString* pItem, 488 const Selection& ); 489 void EditedText(const OUString&); 490 491 // Recalculate all tabs depending on TreeListStyle and Bitmap sizes 492 // Is called automatically when inserting/changing Bitmaps, changing the Model etc. 493 virtual void SetTabs(); 494 void AddTab( tools::Long nPos, SvLBoxTabFlags nFlags ); TabCount() const495 sal_uInt16 TabCount() const { return aTabs.size(); } 496 SvLBoxTab* GetFirstDynamicTab() const; 497 SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const; 498 SvLBoxTab* GetFirstTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ); 499 void GetLastTab( SvLBoxTabFlags nFlagMask, sal_uInt16& rTabPos ); 500 SvLBoxTab* GetTab( SvTreeListEntry const *, SvLBoxItem const * ) const; 501 void ClearTabList(); 502 503 virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&); 504 505 void NotifyScrolled(); SetScrolledHdl(const Link<SvTreeListBox *,void> & rLink)506 void SetScrolledHdl( const Link<SvTreeListBox*,void>& rLink ) { aScrolledHdl = rLink; } GetXOffset() const507 tools::Long GetXOffset() const { return GetMapMode().GetOrigin().X(); } 508 509 virtual void Command( const CommandEvent& rCEvt ) override; 510 511 virtual void RequestHelp( const HelpEvent& rHEvt ) override; 512 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; 513 514 void InitSettings(); 515 516 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; 517 518 void CallImplEventListeners(VclEventId nEvent, void* pData); 519 520 void ImplEditEntry( SvTreeListEntry* pEntry ); 521 522 void AdjustEntryHeightAndRecalc(); 523 524 // true if rPos is over the SvTreeListBox body, i.e. not over a 525 // scrollbar 526 VCL_DLLPRIVATE bool PosOverBody(const Point& rPos) const; 527 public: 528 529 void SetNoAutoCurEntry( bool b ); 530 531 void EnableCheckButton( SvLBoxButtonData* ); 532 void SetCheckButtonData( SvLBoxButtonData* ); 533 void SetNodeBitmaps( const Image& rCollapsedNodeBmp, const Image& rExpandedNodeBmp ); 534 535 /** Returns the default image which clients should use for expanded nodes, to have a consistent user 536 interface experience in the whole product. 537 */ 538 static const Image& GetDefaultExpandedNodeImage( ); 539 540 /** Returns the default image which clients should use for expanded nodes, to have a consistent user 541 interface experience in the whole product. 542 */ 543 static const Image& GetDefaultCollapsedNodeImage( ); 544 545 /** Sets default bitmaps for collapsed and expanded nodes. 546 */ SetNodeDefaultImages()547 void SetNodeDefaultImages( ) 548 { 549 SetNodeBitmaps( 550 GetDefaultCollapsedNodeImage( ), 551 GetDefaultExpandedNodeImage( ) 552 ); 553 } 554 555 virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr, 556 bool bChildrenOnDemand = false, 557 sal_uInt32 nPos=TREELIST_APPEND, void* pUserData = nullptr); 558 559 virtual SvTreeListEntry* InsertEntry( const OUString& rText, 560 const Image& rExpandedEntryBmp, 561 const Image& rCollapsedEntryBmp, 562 SvTreeListEntry* pParent = nullptr, 563 bool bChildrenOnDemand = false, 564 sal_uInt32 nPos = TREELIST_APPEND, void* pUserData = nullptr ); 565 566 const Image& GetDefaultExpandedEntryBmp( ) const; 567 const Image& GetDefaultCollapsedEntryBmp( ) const; 568 569 void SetDefaultExpandedEntryBmp( const Image& rBmp ); 570 void SetDefaultCollapsedEntryBmp( const Image& rBmp ); 571 572 void SetCheckButtonState( SvTreeListEntry*, SvButtonState ); 573 SvButtonState GetCheckButtonState( SvTreeListEntry* ) const; 574 575 void SetEntryText(SvTreeListEntry*, const OUString& ); 576 void SetExpandedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage ); 577 void SetCollapsedEntryBmp( SvTreeListEntry* _pEntry, const Image& _rImage ); 578 579 virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const; 580 static const Image& GetExpandedEntryBmp(const SvTreeListEntry* _pEntry ); 581 static const Image& GetCollapsedEntryBmp(const SvTreeListEntry* _pEntry ); 582 583 void CheckButtonHdl(); 584 585 void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right 586 587 void EnableInplaceEditing( bool bEnable ); 588 // Edits the Entry's first StringItem, 0 == Cursor 589 void EditEntry( SvTreeListEntry* pEntry ); 590 virtual bool EditingEntry( SvTreeListEntry* pEntry ); 591 virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ); 592 593 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; 594 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; 595 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; 596 virtual void MouseMove( const MouseEvent& rMEvt ) override; 597 virtual void KeyInput( const KeyEvent& rKEvt ) override; 598 virtual void Resize() override; 599 virtual void GetFocus() override; 600 virtual void LoseFocus() override; 601 void SetUpdateMode( bool ); 602 603 virtual void ModelHasCleared() override; 604 virtual void ModelHasInserted( SvTreeListEntry* pEntry ) override; 605 virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ) override; 606 virtual void ModelIsMoving(SvTreeListEntry* pSource ) override; 607 virtual void ModelHasMoved(SvTreeListEntry* pSource ) override; 608 virtual void ModelIsRemoving( SvTreeListEntry* pEntry ) override; 609 virtual void ModelHasRemoved( SvTreeListEntry* pEntry ) override; 610 void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ) override; 611 612 void ScrollOutputArea( short nDeltaEntries ); 613 GetColumnsCount() const614 short GetColumnsCount() const { return nColumns; } GetEntryHeight() const615 short GetEntryHeight() const { return nEntryHeight; } 616 void SetEntryHeight( short nHeight ); GetEntryWidth() const617 short GetEntryWidth() const { return nEntryWidth; } 618 void SetEntryWidth( short nWidth ); 619 Size GetOutputSizePixel() const; GetIndent() const620 short GetIndent() const { return nIndent; } 621 void SetSpaceBetweenEntries( short nSpace ); 622 Point GetEntryPosition(const SvTreeListEntry*) const; 623 void MakeVisible( SvTreeListEntry* pEntry ); 624 void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop ); 625 626 void SetCollapsedNodeBmp( const Image& ); 627 void SetExpandedNodeBmp( const Image& ); 628 Image const & GetExpandedNodeBmp( ) const; 629 630 void SetFont( const vcl::Font& rFont ); 631 632 SvTreeListEntry* GetEntry( const Point& rPos, bool bHit = false ) const; 633 634 virtual tools::Rectangle GetFocusRect(const SvTreeListEntry*, tools::Long nLine ); 635 // Respects indentation 636 sal_IntPtr GetTabPos(const SvTreeListEntry*, const SvLBoxTab*); 637 void InvalidateEntry( SvTreeListEntry* ); 638 SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX, SvLBoxTab** ppTab); 639 SvLBoxItem* GetItem( SvTreeListEntry*, tools::Long nX ); 640 std::pair<tools::Long, tools::Long> GetItemPos(SvTreeListEntry* pEntry, sal_uInt16 nTabIdx); 641 642 void SetDragDropMode( DragDropMode ); 643 void SetSelectionMode( SelectionMode ); 644 645 bool Expand( SvTreeListEntry* pParent ); 646 bool Collapse( SvTreeListEntry* pParent ); 647 bool Select( SvTreeListEntry* pEntry, bool bSelect=true ); 648 sal_uInt32 SelectChildren( SvTreeListEntry* pParent, bool bSelect ); 649 void SelectAll( bool bSelect ); 650 651 void SetCurEntry( SvTreeListEntry* _pEntry ); 652 SvTreeListEntry* GetCurEntry() const; 653 654 using Window::Invalidate; 655 virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE) override; 656 virtual void Invalidate( const tools::Rectangle&, InvalidateFlags nFlags = InvalidateFlags::NONE ) override; 657 658 void SetHighlightRange(sal_uInt16 nFirstTab=0, sal_uInt16 nLastTab=0xffff); 659 660 sal_Int32 DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText); 661 662 DECL_LINK( DefaultCompare, const SvSortData&, sal_Int32 ); 663 virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1, 664 SvTreeListEntry* pEntry2, sal_uInt32 nPos ) override; 665 666 SvTreeListEntry* GetFirstEntryInView() const; 667 SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const; 668 void ScrollToAbsPos( tools::Long nPos ); 669 670 tools::Long getPreferredDimensions(std::vector<tools::Long> &rWidths) const; 671 672 virtual Size GetOptimalSize() const override; 673 674 void SetAlternatingRowColors( const bool bEnable ); 675 676 // Enables type-ahead search in the check list box. SetQuickSearch(bool bEnable)677 void SetQuickSearch(bool bEnable) { mbQuickSearch = bEnable; } 678 679 // Make single click "activate" a row like a double-click normally does SetActivateOnSingleClick(bool bEnable)680 void SetActivateOnSingleClick(bool bEnable) { mbActivateOnSingleClick = bEnable; } GetActivateOnSingleClick() const681 bool GetActivateOnSingleClick() const { return mbActivateOnSingleClick; } 682 683 // Make mouse over a row "select" a row like a single-click normally does SetHoverSelection(bool bEnable)684 void SetHoverSelection(bool bEnable) { mbHoverSelection = bEnable; } GetHoverSelection() const685 bool GetHoverSelection() const { return mbHoverSelection; } 686 687 // Set when clicks toggle the checkbox of the row. SetClicksToToggle(sal_Int8 nCount)688 void SetClicksToToggle(sal_Int8 nCount) { mnClicksToToggle = nCount; } 689 690 void SetForceMakeVisible(bool bEnable); 691 692 virtual FactoryFunction GetUITestFactory() const override; 693 694 void SetDragHelper(const rtl::Reference<TransferDataContainer>& rHelper, sal_uInt8 eDNDConstants); 695 }; 696 697 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 698