OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
treeviewctrl.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Declares TTreeViewCtrl, TTreeNode, and TTvItem
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_TREEVIEWCTRL_H)
10#define OWL_TREEVIEWCTRL_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/commctrl.h>
18#include <owl/control.h>
19
20//
21// Resolve naming conflicts from <windowsx.h>.
22//
23
24#ifdef GetNextSibling
25#undef GetNextSibling
26#endif
27
28#ifdef GetPrevSibling
29#undef GetPrevSibling
30#endif
31
32namespace owl {
33
34#include <owl/preclass.h>
35
36class _OWLCLASS TTreeViewCtrl;
37class _OWLCLASS TTreeNode;
38class _OWLCLASS TTvItem;
39
40class _OWLCLASS TTvHitTestInfo;
41class _OWLCLASS TTvComparator;
42
43//
44/// \class TTvItem
45// ~~~~~ ~~~~~~~~~
46/// Used to represent the data to be stored in the TTreeViewCtrl.
47/// TODO: Make the object hold a copy of the item text. See TLvItem.
48//
49class _OWLCLASS TTvItem : public TVITEM {
50 public:
51 TTvItem(); ///< this is called by some TTreeNode constructors
52 TTvItem(TVITEM item);
53 TTvItem(LPCTSTR, int len = 0);
54 TTvItem(LPCTSTR, int index, int selIndex);
55
56 /// Initialize the text
57 //
58 void SetText(LPCTSTR, int len = -1);
59 void GetText(LPTSTR, int len);
60
61 // Set/Get the "magic cookie"
62 //
63 void SetHTreeItem(HTREEITEM hItem);
64 HTREEITEM GetHTreeitem() const;
65
66 /// Set the imagelist index
67 //
68 void SetImageIndex(int index);
69
70 /// Set the selected image index
71 //
72 void SetSelectedImageIndex(int index);
73
74 /// Store additional information
75 //
76 void SetItemData(LPARAM);
77 LPARAM GetItemData() const;
78
79 protected:
80 void Init();
81};
82
83//
84/// Base class for comparing tree nodes.
85/// \sa TTreeNode::SortChildren.
86//
88 public:
89 /// Returns a value < 0 if `item1` < `item2`, 0 if `item1` == `item2`, or > 0 if `item1` > `item2`.
90 /// Parameter `lParam` is the user-defined value, passed to TTreeNode::SortChildren.
91 /// Note that `item1` and `item2` are the used-defined values associated with the items.
92 /// Values can be associated with items using TTreeNode::SetItemData.
93 //
94 /// \sa http://msdn.microsoft.com/en-us/library/windows/desktop/bb773782.aspx
95 //
96 virtual int Compare(LPARAM item1, LPARAM item2, LPARAM lParam) const;
97};
98typedef TTvComparator TTwComparator; // Old alternative name - deprecated.
99
100//
101/// \class TTreeNode
102// ~~~~~ ~~~~~~~~~
103/// Use this class to navigate the TTreeViewCtrl.
104/// Each node conceptually contains a pointer to a TTvItem.
105//
107 public:
108
109 /// Specifies how to insert a new item into a Tree-View control. In 32-bit
110 /// applications, the THowToInsert values correspond to Tree-View Insert constants.
111 //
113#if defined __GNUC__ //a cast to a type other than an integral or enumeration type cannot appear in a constant-expression
114 First = -65535, //TVI_FIRST: First child
115 Last = -65534, //TVI_LAST: Last child
116 Sort = -65533, //TVI_SORT: Sort order
117#else
118 First = reinterpret_cast<INT_PTR>(TVI_FIRST), ///< First child
119 Last = reinterpret_cast<INT_PTR>(TVI_LAST), ///< Last child
120 Sort = reinterpret_cast<INT_PTR>(TVI_SORT) ///< Sort order
121#endif
122 };
123
124 // Constructors
125 //
126
127 // The next two constructors are for creating new nodes. Both create only
128 // the C++ TTreeNode object. Call SetItem to make the new node appear in
129 // the treeview control.
130 //
132 TTreeNode(TTreeViewCtrl& tree, LPCTSTR text, int index, int selIndex);
133
134 // The next two constructors create a node object to represent a node
135 // that already exists.
136
137 // Use this constructor in event handlers. The event message carries
138 // a TTvNotify structure.
139 //
140 TTreeNode(TTreeViewCtrl& tree, TVITEM item);
141
142 // This constructor is useful for enumerating nodes on a tree.
143 // Passing just the first parameter creates the node object for
144 // the tree's root, a good starting point.
145 //
147
148 // Construct the node neighboring a given node. A TVGN_* flag indicates
149 // whether to create the next, previous, parent, or first child node.
150 //
152
153 // Copy constructor. Used by functions such as TTreeViewCtrl::GetRoot
154 // that return a TTreeNode by value.
155 //
156 TTreeNode(const TTreeNode&);
157
158 // Assignment operator
159 //
160 TTreeNode& operator=(const TTreeNode& other);
161
162 /// Returns a reference to the associated tree view.
163 //
164 TTreeViewCtrl& GetTreeView() const {return *TreeView;}
165
166 // Navigation
167 //
168 TTreeNode GetParent() const;
169 TTreeNode GetChild() const;
170 TTreeNode GetNextSibling() const;
171 TTreeNode GetPrevSibling() const;
172 TTreeNode GetNextVisible() const;
173 TTreeNode GetPrevVisible() const;
174 TTreeNode GetNextItem(uint32 flag) const;
175
176 // Adding and deleting items from the tree
177 //
178 TTreeNode AddChild(const TTreeNode& node) const;
179 TTreeNode AddSibling(const TTreeNode& node) const;
180 TTreeNode InsertChild(const TTreeNode& node, THowToInsert how) const;
181 TTreeNode InsertItem(const TTreeNode& node) const;
182 bool Delete(void);
183
184 // These older add/delete methods use TTvItem. They have
185 // been replaced by the versions that operate on the node
186 // itself. They are retained for backward compatibility.
187 //
188 TTreeNode AddChild(const TTvItem&) const; // add item at end
189 TTreeNode AddSibling(const TTvItem&) const;
190 TTreeNode InsertChild(const TTvItem&, THowToInsert) const;
191 TTreeNode InsertItem(const TTvItem&) const;
192
193 // These operations affect only information stored in the node object,
194 // not the Windows treeview control itself.
195 //
196 void SetMask(uint mask);
197 uint GetMask(void) const;
198 void SetStateMask(uint mask);
199 uint GetStateMask(void) const;
200 void SetHTreeItem(HTREEITEM hItem);
201 HTREEITEM GetHTreeItem() const;
202
203 // These operations send messages to the control. The message delivery
204 // might fail, so they return bool.
205 //
206 bool SetHasChildren(int hasChildren, bool sendNow = true);
207 bool GetHasChildren(int& hasChildren, bool getNew = true);
208 bool SetState(uint state, bool sendNow = true);
209 bool GetState(uint& state, bool getNew = true);
210 bool SetImageIndex(int index, bool sendNow = true);
211 bool SetSelectedImageIndex(int index, bool sendNow = true);
212 bool SetItemData(LPARAM data, bool sendNow = true);
213 bool GetItemData(LPARAM& data, bool getNew = true);
214 bool GetItemRect(TRect& rect, bool textOnly = true) const;
215 void Check(bool state = true);
216 bool IsChecked() const;
217
218 // Set/GetText store the text in the node's internal buffer so the
219 // caller doesn't have to worry about string length and buffer
220 // ownership.
221 //
222 bool SetText(LPCTSTR text, bool sendNow = true);
223 bool SetText(const tstring& text, bool sendNow = true) {return SetText(text.c_str(), sendNow);}
224
225 // This GetText copies the string into the caller's buffer
226 //
227 bool GetText(LPTSTR text, uint length, bool getNew = false);
228
229 // This GetText returns a pointer to the node's own internal text buffer
230 //
231 LPCTSTR GetText(bool getNew = false);
232
233 // The default cache size is _MAX_PATH. The cache size is used only in
234 // Get functions when allocating buffers for strings received from the
235 // control. For a control with strings longer than _MAX_PATH, be sure to
236 // bump the cache size before calling Get. (The buffer size is kept
237 // in a static variable, so any alteration affects all TTreeNodes.)
238 //
239 void SetCacheSize(uint size);
240 void FlushCache(void); // empty this node's text cache
241
242 // The Set/Get accessors for individual node attributes send a message
243 // to put data into, or receive data from, the treeview control. The
244 // sendNow and getNew parameters make it possible to accumulate requests
245 // and send them in a single message.
246 //
247 // SetItemData(myData, false); // this sends no message
248 // SetText("MyText", false); // this sends no message
249 // SetHasChildren(1, true); // this sends all 3 attributes
250
251 // The recommended way to get and set attributes is with the access
252 // functions for individual attributes. Those commands call these
253 // two function to interact with the Windows control.
254 //
255 bool GetItem(void);
256 bool SetItem(void);
257
258 // Preserved for 5.0 code that still uses the TTvItem struct.
259 //
260 bool GetItem(TTvItem* item);
261 bool SetItem(TTvItem* item);
262
263 // Miscellaneous
264 //
265 HIMAGELIST CreateDragImage();
266 HWND EditLabel();
267 bool EnsureVisible();
268 bool ExpandItem(uint32 flag);
269 bool SelectItem(uint32 flag);
270
271 // Sort the nodes of the subtree
272 //
273 bool SortChildren(bool recurse = false);
274 bool SortChildren(const TTvComparator& Comparator, bool recurse = false, LPARAM extraParam = 0);
275
276 // The HTREEITEM() operator is useful when enumerating nodes.
277 // For example, to enumerate all the top-level nodes:
278 //
279 // for (TTreeNode& node = GetRoot().GetChild();
280 // node; // evaluates to null handle after last node
281 // node = node.GetNextSibling())
282 // { /* loop code */ };
283 //
284 operator HTREEITEM() const;
285
286 // Codes for TTreeNode (TExpandCode, TNextCode)
287 //
288 // Retained for compatiblity, but no longer recommended.
289 // Use the TVE_ and TVGN_ constants directly instead of
290 // these enums.
291
292 /// How to expand the item.
293 //
295 Collapse = TVE_COLLAPSE, ///< Always collapse
296 Expand = TVE_EXPAND, ///< Always expand
297 Toggle = TVE_TOGGLE, ///< Toggle between collapse and expand
298 CollapseReset = TVE_COLLAPSERESET ///< Collapse this node and all children
299 };
300
301 /// How to retrieve the next node
302 //
304 Root = TVGN_ROOT, ///< Get the root node
305 Next = TVGN_NEXT, ///< Get the next sibling
306 Previous = TVGN_PREVIOUS, ///< Get the prev sibling
307 Parent = TVGN_PARENT, ///< Get the parent of this node
308 Child = TVGN_CHILD, ///< Get the first child
309 FirstVisible = TVGN_FIRSTVISIBLE, ///< Get the first visible item
310 NextVisible = TVGN_NEXTVISIBLE, ///< Get the next visible item
311 PreviousVisible = TVGN_PREVIOUSVISIBLE, ///< Get the prev visible item
312 DropHilite = TVGN_DROPHILITE, ///< Get the item that is the drop target
313 Caret = TVGN_CARET ///< Get the item with the caret
314 };
315
316 protected:
317 TTvItem ItemStruct; ///< contains a TVITEM with HTREEITEM
318 TTreeViewCtrl* TreeView; ///< wrapper for item of this tree
319
320 private:
321 TAPointer<tchar> CacheText; ///< buffer for node text
322
323 /// Clone function used by copy constructor
324 //
325 TTreeNode& CopyNode(const TTreeNode& node);
326
327 /// default constructor disallowed
328 //
329 TTreeNode(void);
330};
331
332//
333/// \class TTreeViewCtrl
334// ~~~~~ ~~~~~~~~~~~
335/// Encapsulates the TreeView common control.
336//
337/// A TreeWindow displays information in a hierarchical manner.
338/// Each item in the tree can contain text and a picture.
339//
341 public:
342 /// The type of the image list
343 //
345 Normal = TVSIL_NORMAL, ///< Normal imagelist for selected and non-selected items
346 State = TVSIL_STATE ///< Imagelist contains images for user-defined states
347 };
348
349 // Constructors and destructor
350 //
351 TTreeViewCtrl(TWindow* parent, int id, int x, int y, int w, int h,
352 uint32 style = 0, TModule* module = 0);
353 TTreeViewCtrl(TWindow* parent, int resourceId, TModule* module = 0);
354 ~TTreeViewCtrl() override;
355
356 // Style management
357 //
358 void SetStyle(uint32 style);
359 bool HasStyle(uint32 style);
360
361 // TreeNode retrieval
362 //
363 TTreeNode GetRoot();
364 TTreeNode GetSelection();
365 TTreeNode GetDropHilite();
366 TTreeNode GetFirstVisible();
367
368 // Indent level
369 //
370 uint GetIndent();
371 void SetIndent(uint);
372
373 // Image list
374 //
375 HIMAGELIST GetImageList(TImageListType type);
376 HIMAGELIST SetImageList(TImageListType type, HIMAGELIST newList);
377
378 // Miscellaneous
379 //
380 bool DeleteAllItems();
381 uint GetItemCount();
382 uint GetVisibleCount();
383 HWND GetEditControl();
384
385 // New commctrl.dll functionalty
386 //
387 TColor GetBkColor() const; // Version 4.71
388 void SetBkColor(const TColor& clr); // Version 4.71
389
390 TColor GetTextColor() const; // Version 4.71
391 void SetTextColor(const TColor& clr);// Version 4.71
392
393 TColor GetInsertMarkColor() const; // Version 4.71
394 void SetInsertMarkColor(const TColor& clr); // Version 4.71
395
396 int GetItemHeight(int /*dummy*/) const; // Version 4.71
397 int SetItemHeight(int /*dummy*/, int height=-1); // Version 4.71
398
399 HWND GetToolTips() const; // Version 4.71
400 void SetToolTips(HWND tooltip); // Version 4.71
401
402 bool SetInsertMark(HTREEITEM, bool after = true); // Version 4.71
403
404
405 // Provided for API compatability, use TTreeNode instead.
406 // These functions are called from TTreeNode
407 //
408 void Update();
409 bool SortChildren(PFNTVCOMPARE, HTREEITEM parent, bool recurse = false, LPARAM lParam = 0);
410 bool SortChildren(HTREEITEM item, bool recurse = false);
411 bool Delete(HTREEITEM);
412 bool EnsureVisible(HTREEITEM);
413 bool ExpandItem(uint32 flag, HTREEITEM);
414 bool SelectItem(uint32 flag, HTREEITEM hItem);
415 HWND EditLabel(HTREEITEM item);
416 HTREEITEM HitTest(TTvHitTestInfo* info);
417 HTREEITEM GetNextItem(uint32 nc, HTREEITEM);
418 HTREEITEM InsertItem(TV_INSERTSTRUCT *);
419 HIMAGELIST CreateDragImage(HTREEITEM item);
420
421 /// Styles for TTreeViewCtrl
422 //
423 /// Retained for compatiblity, but no longer recommended.
424 /// Use the TVS_* style constants directly instead of this enum.
425 //
426 enum TStyle {
427 twsNone = 0, ///< No style
428 twsHasButtons = TVS_HASBUTTONS, ///< Each parent has a button
429 ///< for toggling collapse and expand
430 twsHasLines = TVS_HASLINES, ///< There are lines between nodes
431 twsLinesAtRoot = TVS_LINESATROOT, ///< There are lines at the root
432 twsEditLabels = TVS_EDITLABELS, ///< Text labels for items can be edited
433 twsDisableDragDrop = TVS_DISABLEDRAGDROP, ///< Do not allow drag and drop
434 twsShowSelAlways = TVS_SHOWSELALWAYS, ///< Always keep the selection visible
435 ///< scroll if needed
436 };
437
438 // Override TWindow virtual member functions
439 //
440 auto Transfer(void* buffer, TTransferDirection) -> uint override;
441
442 protected:
443 // Override TWindow virtual member functions
444 //
445 auto GetWindowClassName() -> TWindowClassName override;
446
447 // Event handlers
448 //
449 void EvKeyDown(uint key, uint repeatCount, uint flags);
450 void EvSysKeyDown(uint key, uint repeatCount, uint flags);
451
453 uint32 Style;
454
455 private:
456 // Hidden to prevent accidental copying or assignment
457 //
459 TTreeViewCtrl& operator=(const TTreeViewCtrl&);
460
463};
464
466
467#include <owl/posclass.h>
468
469
470//----------------------------------------------------------------------------
471// Inline implementation
472//
473
474//
475/// Default comparison function that makes every item equal to every
476/// other item.
477/// Derived classes should override this to return proper sorting codes.
478//
479inline int
480TTvComparator::Compare(LPARAM /*item1*/, LPARAM /*item2*/, LPARAM /*lParam*/) const
481{
482 return 0;
483}
484
485//
486/// Return the magic cookie used by the control associated with the item
487//
488inline
489TTreeNode::operator HTREEITEM() const
490{
491 return ItemStruct.hItem;
492}
493
494//
495/// Return the HWND of the edit control to change the text
496//
497inline HWND
499{
500 return TreeView->EditLabel(*this);
501}
502
503//
504/// Return the image list used for a dragging purposes
505//
506inline HIMAGELIST
511
512//
513/// Makes sure the item is visible.
514/// Scroll the items if necessary.
515//
516inline bool
518{
519 return TreeView->EnsureVisible(*this);
520}
521
522//
523/// Expand or contract a parent node.
524/// Similar to the user clicking on the '-' or '+' area of the control.
525//
526inline bool
528{
529 return TreeView->ExpandItem(flag, static_cast<HTREEITEM>(*this));
530}
531
532//
533/// Make the next item selected.
534//
535inline bool
537{
538 return TreeView->SelectItem(flag, *this);
539}
540
541//
542/// Return the next item.
543//
544inline TTreeNode
549
550inline TTreeNode
552{
553 return InsertChild(node.ItemStruct, how);
554}
555
556inline TTreeNode
558{
559 return InsertItem(node.ItemStruct);
560}
561
562/// Inserts a new child item into the Tree-View (TreeView) control.
563//
564/// Parameters
565/// \arg \c \b node A TTreeNode object encapsulating an item that will be the parent of the
566/// new item.
567///
568/// Returns a TTreeNode object encapsulating the new item. Returns NULL upon
569/// failure. (In 32-bit applications, you can check for a NULL handle using the
570/// HTREEITEM() operator.)
571inline TTreeNode
573{
574 return InsertChild(node.ItemStruct, Last);
575}
576
577inline TTreeNode
578TTreeNode::AddChild(const TTvItem& item) const
579{
580 return InsertChild(item, Last);
581}
582
583//
584/// Return the parent of the current node.
585//
586inline TTreeNode
588{
589 return GetNextItem(Parent);
590}
591
592//
593/// Get the first child of the current node.
594//
595inline TTreeNode
597{
598 return GetNextItem(Child);
599}
600
601//
602/// Return the next sibling.
603//
604inline TTreeNode
606{
607 return GetNextItem(Next);
608}
609
610//
611/// Return the previous sibling.
612//
613inline TTreeNode
615{
616 return GetNextItem(Previous);
617}
618
619//
620/// Return the next visible item.
621//
622inline TTreeNode
624{
625 return GetNextItem(NextVisible);
626}
627
628//
629/// Return the next previous item.
630//
631inline TTreeNode
636
637//
638/// Sort the children of this node
639//
640inline bool
642{
643 return TreeView->SortChildren(*this, recurse);
644}
645
646inline void
651
652inline uint
654{
655 return ItemStruct.mask;
656}
657
658inline void
660{
661 ItemStruct.stateMask = mask;
662}
663
664inline uint
666{
667 return ItemStruct.stateMask;
668}
669
670//
671/// Set and Get the node's item handle.
672//
673
674inline void
679
680inline HTREEITEM
682{
683 return ItemStruct.GetHTreeitem();
684}
685
686//
687/// Set the item associated with this node
688//
689inline bool
691{
693 PRECONDITION(item && item->mask);
694 item->SetHTreeItem(*this);
695 return TreeView->SendMessage(TVM_SETITEM, 0, TParam2(item)) != 0;
696}
697
698inline bool
705
706//
707/// Return the item associated with the node
708//
709inline bool
711{
714 item->SetHTreeItem(*this);
715 return TreeView->SendMessage(TVM_GETITEM, 0, TParam2(item)) != 0;
716}
717
718//
719/// Update the item information in the node.
720/// What's set in the mask determines what will be retrieved.
721/// Unless the user has explicitly called SetMask, the call should
722/// retrieve everything.
723//
724inline bool
732
733//----------------------------------------------------------------------------
734// TTreeViewCtrl
735
736//
737/// Return the item that contains the point.
738//
739inline HTREEITEM
741{
742 return reinterpret_cast<HTREEITEM>(SendMessage(TVM_HITTEST, 0, TParam2(&info)));
743}
744
745//
746/// Set the image list used by the control.
747//
748inline HIMAGELIST
753
754//
755/// Return the image list used by the control.
756//
757inline HIMAGELIST
762
763//
764/// Create a drag image.
765//
766inline HIMAGELIST
768{
769 return reinterpret_cast<HIMAGELIST>(SendMessage(TVM_CREATEDRAGIMAGE, 0, TParam2(item)));
770}
771
772//
773/// Return the edit control used for editing the text.
774//
775inline HWND
777{
778 return reinterpret_cast<HWND>(SendMessage(TVM_GETEDITCONTROL));
779}
780
781// Version 4.71
782inline TColor
784{
785 return static_cast<COLORREF>(CONST_CAST(TTreeViewCtrl*,this)->SendMessage(TVM_GETBKCOLOR));
786}
787
788// Version 4.71
789inline void
794
795// Version 4.71
796inline TColor
798{
799 return static_cast<COLORREF>(CONST_CAST(TTreeViewCtrl*,this)->SendMessage(TVM_GETTEXTCOLOR));
800}
801
802// Version 4.71
803inline void
808
809//Version 4.71
810inline TColor
812{
813 return static_cast<COLORREF>(CONST_CAST(TTreeViewCtrl*,this)->SendMessage(TVM_GETINSERTMARKCOLOR));
814}
815
816//Version 4.71
817inline void
822
823// Version 4.71
824inline int
826{
827 return static_cast<int>(CONST_CAST(TTreeViewCtrl*,this)->SendMessage(TVM_GETITEMHEIGHT));
828}
829
830// Version 4.71
831inline int
832TTreeViewCtrl::SetItemHeight(int /*dummy*/, int height)
833{
834 return static_cast<int>(SendMessage(TVM_SETITEMHEIGHT, TParam1(static_cast<int16>(height))));
835}
836
837// Version 4.71
838inline HWND
843
844// Version 4.71
845inline void
850
851// Version 4.71
852inline bool
854{
855 return ToBool(SendMessage(TVM_SETINSERTMARK, TParam1(static_cast<BOOL>(after)), TParam2(item)));
856}
857
858//
859/// Enable the user to edit the text of an item.
860//
861inline HWND
863{
864 return reinterpret_cast<HWND>(SendMessage(TVM_EDITLABEL, 0, TParam2(item)));
865}
866
867//
868/// Return the next item.
869//
870inline HTREEITEM
872{
873 if (hItem == TVI_ROOT) // Workaround for Win95 bug.
874 hItem = nullptr;
875 return reinterpret_cast<HTREEITEM>(SendMessage(TVM_GETNEXTITEM, nc, TParam2(hItem)));
876}
877
878//
879/// Delete the item.
880//
881inline bool
886
887//
888/// Makes sure the item is visible.
889//
890inline bool
895
896//
897/// Expand and contract the parent node.
898//
899inline bool
904
905//
906/// Select the next item.
907//
908inline bool
913
914//
915/// Insert an item.
916//
917inline HTREEITEM
922
923//
924/// Remove all items from the control
925//
926inline bool
931
932//
933/// Return the number of items in the control.
934//
935inline uint
937{
938 return static_cast<uint>(SendMessage(TVM_GETCOUNT));
939}
940
941//
942/// Return the number of the fully visible items in the control.
943//
944inline uint
949
950//
951/// Return the number of pixels per indent level.
952//
953inline uint
955{
956 return static_cast<uint>(SendMessage(TVM_GETINDENT));
957}
958
959//
960/// Set the number of pixels per indent level.
961//
962inline void
967
968//
969/// Sort the children of 'item'.
970/// Recursively sort each children if 'recurse' is true.
971//
972inline bool
977
978//
979/// Return the root node.
980//
981inline TTreeNode
983{
984 return TTreeNode(*this);
985}
986
987//
988/// Compatability for Win32
989//
990inline void
994
995} // OWL namespace
996
997
998
999#endif // OWL_TREEVIEWCTRL_H
#define PRECONDITION(condition)
Definition checks.h:227
Class wrapper for management of color values.
Definition color.h:245
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
Use this class to navigate the TTreeViewCtrl.
TTreeNode InsertChild(const TTreeNode &node, THowToInsert how) const
HWND EditLabel()
Return the HWND of the edit control to change the text.
TTreeViewCtrl * TreeView
wrapper for item of this tree
TExpandCode
How to expand the item.
HIMAGELIST CreateDragImage()
Return the image list used for a dragging purposes.
TTvItem ItemStruct
contains a TVITEM with HTREEITEM
THowToInsert
Specifies how to insert a new item into a Tree-View control.
@ Last
Last child.
void SetMask(uint mask)
bool ExpandItem(uint32 flag)
Expand or contract a parent node.
bool GetItem(void)
Update the item information in the node.
bool SelectItem(uint32 flag)
Make the next item selected.
void SetStateMask(uint mask)
void SetHTreeItem(HTREEITEM hItem)
Set and Get the node's item handle.
TTreeNode GetPrevSibling() const
Return the previous sibling.
TTreeNode AddChild(const TTreeNode &node) const
Inserts a new child item into the Tree-View (TreeView) control.
TTreeViewCtrl & GetTreeView() const
Returns a reference to the associated tree view.
bool SetItem(void)
bool SortChildren(bool recurse=false)
Sort the children of this node.
TTreeNode GetChild() const
Get the first child of the current node.
TTreeNode GetNextSibling() const
Return the next sibling.
TTreeNode GetNextVisible() const
Return the next visible item.
uint GetMask(void) const
TTreeNode GetNextItem(uint32 flag) const
Return the next item.
TNextCode
How to retrieve the next node.
@ Previous
Get the prev sibling.
@ PreviousVisible
Get the prev visible item.
@ Parent
Get the parent of this node.
@ Child
Get the first child.
@ Next
Get the next sibling.
@ NextVisible
Get the next visible item.
void SetCacheSize(uint size)
uint GetStateMask(void) const
HTREEITEM GetHTreeItem() const
bool SetText(const tstring &text, bool sendNow=true)
TTreeNode GetParent() const
Return the parent of the current node.
TTreeNode InsertItem(const TTreeNode &node) const
TTreeNode GetPrevVisible() const
Return the next previous item.
bool EnsureVisible()
Makes sure the item is visible.
Encapsulates the TreeView common control.
HTREEITEM GetNextItem(uint32 nc, HTREEITEM)
Return the next item.
HTREEITEM InsertItem(TV_INSERTSTRUCT *)
Insert an item.
HIMAGELIST GetImageList(TImageListType type)
Return the image list used by the control.
HIMAGELIST CreateDragImage(HTREEITEM item)
Create a drag image.
void SetTextColor(const TColor &clr)
int GetItemHeight(int) const
void SetBkColor(const TColor &clr)
TStyle
Styles for TTreeViewCtrl.
bool Delete(HTREEITEM)
Delete the item.
uint GetIndent()
Return the number of pixels per indent level.
bool DeleteAllItems()
Remove all items from the control.
bool EnsureVisible(HTREEITEM)
Makes sure the item is visible.
void Update()
Compatability for Win32.
TColor GetBkColor() const
void SetInsertMarkColor(const TColor &clr)
HWND EditLabel(HTREEITEM item)
Enable the user to edit the text of an item.
void SetToolTips(HWND tooltip)
HTREEITEM HitTest(TTvHitTestInfo *info)
Return the item that contains the point.
bool SelectItem(uint32 flag, HTREEITEM hItem)
Select the next item.
int SetItemHeight(int, int height=-1)
HWND GetEditControl()
Return the edit control used for editing the text.
HIMAGELIST SetImageList(TImageListType type, HIMAGELIST newList)
Set the image list used by the control.
uint GetVisibleCount()
Return the number of the fully visible items in the control.
TColor GetInsertMarkColor() const
TImageListType
The type of the image list.
void SetIndent(uint)
Set the number of pixels per indent level.
TTreeNode GetRoot()
Return the root node.
HWND GetToolTips() const
uint GetItemCount()
Return the number of items in the control.
bool SetInsertMark(HTREEITEM, bool after=true)
bool SortChildren(PFNTVCOMPARE, HTREEITEM parent, bool recurse=false, LPARAM lParam=0)
bool ExpandItem(uint32 flag, HTREEITEM)
Expand and contract the parent node.
TColor GetTextColor() const
Base class for comparing tree nodes.
virtual int Compare(LPARAM item1, LPARAM item2, LPARAM lParam) const
Returns a value < 0 if item1 < item2, 0 if item1 == item2, or > 0 if item1 > item2.
A TTreeViewCtrl notification for hit-testing.
Definition commctrl.h:503
Used to represent the data to be stored in the TTreeViewCtrl.
void SetHTreeItem(HTREEITEM hItem)
HTREEITEM GetHTreeitem() const
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:47
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
Definition of classes for CommonControl encapsulation.
Definition of class TControl.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
Definition window.h:92
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long uint32
Definition number.h:34
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
bool ToBool(const T &t)
Definition defs.h:291
TTvComparator TTwComparator
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
bool IsChecked(HWND ctrl)
Returns true if the given control has BST_CHECKED state.
Definition transfer.h:69
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define CONST_CAST(targetType, object)
Definition defs.h:273
#define _OWLCLASS
Definition defs.h:338