OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TTreeNode Class Reference

Use this class to navigate the TTreeViewCtrl. More...

#include <owl/treeviewctrl.h>

Public Types

enum  THowToInsert { First = reinterpret_cast<INT_PTR>(TVI_FIRST) , Last = reinterpret_cast<INT_PTR>(TVI_LAST) , Sort = reinterpret_cast<INT_PTR>(TVI_SORT) }
 Specifies how to insert a new item into a Tree-View control. More...
 
enum  TExpandCode { Collapse = TVE_COLLAPSE , Expand = TVE_EXPAND , Toggle = TVE_TOGGLE , CollapseReset = TVE_COLLAPSERESET }
 How to expand the item. More...
 
enum  TNextCode { Root = TVGN_ROOT , Next = TVGN_NEXT , Previous = TVGN_PREVIOUS , Parent = TVGN_PARENT , Child = TVGN_CHILD , FirstVisible = TVGN_FIRSTVISIBLE , NextVisible = TVGN_NEXTVISIBLE , PreviousVisible = TVGN_PREVIOUSVISIBLE , DropHilite = TVGN_DROPHILITE , Caret = TVGN_CARET }
 How to retrieve the next node. More...
 

Public Member Functions

 TTreeNode (TTreeViewCtrl &tree, LPCTSTR text)
 Construct a new node given the node's text.
 
 TTreeNode (TTreeViewCtrl &tree, LPCTSTR text, int index, int selIndex)
 Construct a new node given the node's text and image info.
 
 TTreeNode (TTreeViewCtrl &tree, TVITEM item)
 Construct based on an item.
 
 TTreeNode (TTreeViewCtrl &tree, HTREEITEM hItem=TVI_ROOT)
 Parameters:
 
 TTreeNode (const TTreeNode &node, uint32 flag)
 Construct the node neighboring a given node.
 
 TTreeNode (const TTreeNode &)
 Copy constructor: create a new node by copying another node Called implicitly by functions that return a TTreeNode by value; otherwise, shouldn't be needed.
 
TTreeNodeoperator= (const TTreeNode &other)
 
TTreeViewCtrlGetTreeView () const
 Returns a reference to the associated tree view.
 
TTreeNode GetParent () const
 Return the parent of the current node.
 
TTreeNode GetChild () const
 Get the first child of the current node.
 
TTreeNode GetNextSibling () const
 Return the next sibling.
 
TTreeNode GetPrevSibling () const
 Return the previous sibling.
 
TTreeNode GetNextVisible () const
 Return the next visible item.
 
TTreeNode GetPrevVisible () const
 Return the next previous item.
 
TTreeNode GetNextItem (uint32 flag) const
 Return the next item.
 
TTreeNode AddChild (const TTreeNode &node) const
 Inserts a new child item into the Tree-View (TreeView) control.
 
TTreeNode AddSibling (const TTreeNode &node) const
 
TTreeNode InsertChild (const TTreeNode &node, THowToInsert how) const
 
TTreeNode InsertItem (const TTreeNode &node) const
 
bool Delete (void)
 
TTreeNode AddChild (const TTvItem &) const
 
TTreeNode AddSibling (const TTvItem &) const
 Inserts a new sibling item into the Tree-View (TreeView) control. (Adds the item above this item.)
 
TTreeNode InsertChild (const TTvItem &, THowToInsert) const
 
TTreeNode InsertItem (const TTvItem &) const
 
void SetMask (uint mask)
 
uint GetMask (void) const
 
void SetStateMask (uint mask)
 
uint GetStateMask (void) const
 
void SetHTreeItem (HTREEITEM hItem)
 Set and Get the node's item handle.
 
HTREEITEM GetHTreeItem () const
 
bool SetHasChildren (int hasChildren, bool sendNow=true)
 
bool GetHasChildren (int &hasChildren, bool getNew=true)
 
bool SetState (uint state, bool sendNow=true)
 
bool GetState (uint &state, bool getNew=true)
 
bool SetImageIndex (int index, bool sendNow=true)
 
bool SetSelectedImageIndex (int index, bool sendNow=true)
 
bool SetItemData (LPARAM data, bool sendNow=true)
 
bool GetItemData (LPARAM &data, bool getNew=true)
 
bool GetItemRect (TRect &rect, bool textOnly=true) const
 
void Check (bool state=true)
 Sets the node's checked state.
 
bool IsChecked () const
 Retrieves the node's checked state.
 
bool SetText (LPCTSTR text, bool sendNow=true)
 
bool SetText (const tstring &text, bool sendNow=true)
 
bool GetText (TCHAR *text, uint length, bool getNew=false)
 
LPCTSTR GetText (bool getNew=false)
 
void SetCacheSize (uint size)
 
void FlushCache (void)
 
bool GetItem (void)
 Update the item information in the node.
 
bool SetItem (void)
 
bool GetItem (TTvItem *item)
 Return the item associated with the node.
 
bool SetItem (TTvItem *item)
 Set the item associated with this node.
 
HIMAGELIST CreateDragImage ()
 Return the image list used for a dragging purposes.
 
HWND EditLabel ()
 Return the HWND of the edit control to change the text.
 
bool EnsureVisible ()
 Makes sure the item is visible.
 
bool ExpandItem (uint32 flag)
 Expand or contract a parent node.
 
bool SelectItem (uint32 flag)
 Make the next item selected.
 
bool SortChildren (bool recurse=false)
 Sort the children of this node.
 
bool SortChildren (const TTvComparator &Comparator, bool recurse=false, LPARAM extraParam=0)
 
 operator HTREEITEM () const
 Return the magic cookie used by the control associated with the item.
 

Protected Attributes

TTvItem ItemStruct
 contains a TVITEM with HTREEITEM
 
TTreeViewCtrlTreeView
 wrapper for item of this tree
 

Detailed Description

Use this class to navigate the TTreeViewCtrl.

Each node conceptually contains a pointer to a TTvItem.

Definition at line 106 of file treeviewctrl.h.

Member Enumeration Documentation

◆ TExpandCode

How to expand the item.

Enumerator
Collapse 

Always collapse.

Expand 

Always expand.

Toggle 

Toggle between collapse and expand.

CollapseReset 

Collapse this node and all children.

Definition at line 294 of file treeviewctrl.h.

◆ THowToInsert

Specifies how to insert a new item into a Tree-View control.

In 32-bit applications, the THowToInsert values correspond to Tree-View Insert constants.

Enumerator
First 

First child.

Last 

Last child.

Sort 

Sort order.

Definition at line 112 of file treeviewctrl.h.

◆ TNextCode

How to retrieve the next node.

Enumerator
Root 

Get the root node.

Next 

Get the next sibling.

Previous 

Get the prev sibling.

Parent 

Get the parent of this node.

Child 

Get the first child.

FirstVisible 

Get the first visible item.

NextVisible 

Get the next visible item.

PreviousVisible 

Get the prev visible item.

DropHilite 

Get the item that is the drop target.

Caret 

Get the item with the caret.

Definition at line 303 of file treeviewctrl.h.

Constructor & Destructor Documentation

◆ TTreeNode() [1/6]

owl::TTreeNode::TTreeNode ( TTreeViewCtrl & tree,
LPCTSTR text )

Construct a new node given the node's text.

Parameters:

  • tree A TTreeViewCtrl object to associate with the node.
  • text A text label for the node.

Remarks:

  • Initializes the TreeView data member to the address of tree.
  • Calls the SetText function, passing it text. In 32-bit applications, the text is not displayed in the Tree-View control until the the TTreeNode object encapsulates an item (the ItemStruct.hItem data member is valid) and the Tree-View control is updated (the SetItem function is called, for example).

Definition at line 49 of file treeviewctrl.cpp.

References SetText().

◆ TTreeNode() [2/6]

owl::TTreeNode::TTreeNode ( TTreeViewCtrl & tree,
LPCTSTR text,
int index,
int selIndex )

Construct a new node given the node's text and image info.

Parameters:

  • tree A TTreeViewCtrl object to associate with the node.
  • text A text label for the node.
  • index The index of the image in the TTreeViewCtrl image list that corresponds to the node's unselected state.
  • selIndex The index of the image in the TTreeViewCtrl image list that corresponds to the node's selected state.

Remarks:

  • Initializes the TreeView data member to the address of tree.
  • Calls the SetText function, passing it text. The text is not displayed in the Tree-View control until the the TTreeNode object encapsulates an item (the ItemStruct.hItem data member is valid) and the Tree-View control is updated (the SetItem function is called, for example).
  • Calls the SetImageIndex function, passing it index.
  • Calls the SetSelectedImageIndex function, passing it selIndex.

Definition at line 76 of file treeviewctrl.cpp.

References SetImageIndex(), SetSelectedImageIndex(), and SetText().

◆ TTreeNode() [3/6]

owl::TTreeNode::TTreeNode ( TTreeViewCtrl & tree,
TVITEM item )

Construct based on an item.

Parameters:

  • tree A TTreeViewCtrl object to associate with the node.
  • item A TVITEM object representing the item.

Remarks:

  • Initializes the TreeView data member to the address of tree.
  • Initializes the ItemStruct data member to item.
  • If the node has a valid label (if the TVIF_TEXT flag of item.mask is set), the SetText function is called (it is passed item.pszText).

Definition at line 99 of file treeviewctrl.cpp.

References SetText().

◆ TTreeNode() [4/6]

owl::TTreeNode::TTreeNode ( TTreeViewCtrl & tw,
HTREEITEM hItem = TVI_ROOT )

Parameters:

  • tree A TTreeViewCtrl object to associate with the node.
  • hItem A handle to a TVITEM object representing the item, a Tree-View Insert constant (32-bit applications), or a THowToInsert value.

Remarks:

  • Initializes the TreeView data member to the address of tree.
  • Displays a warning message if hItem is null.
  • Initializes the ItemStruct.hItem data member to hItem.
  • Initializes the ItemStruct.mask data member to TVIF_HANDLE.

Definition at line 121 of file treeviewctrl.cpp.

References ItemStruct, and WARNX.

◆ TTreeNode() [5/6]

owl::TTreeNode::TTreeNode ( const TTreeNode & tn,
uint32 flag )

Construct the node neighboring a given node.

The flag indicates whether to create the next, previous, parent, or first child node.

Parameters:

  • node A TTreeNode object having a relationship to the TTreeNode object to be created.
  • flag A Tree-View Get Next constant (32-bit applications) or a TNextCode value specifying the relationship between node and the TTreeNode object to be created.

Remarks:

  • Initializes the TreeView data member to node.TreeView.
  • Initializes the ItemStruct data member to node.ItemStruct.
  • In 32-bit applications, determines which item in the Tree-View control to associate with the new TTreeNode object by sending a TVM_GETNEXTITEM message to the control.

Definition at line 190 of file treeviewctrl.cpp.

References owl::TTreeViewCtrl::GetNextItem(), and TreeView.

◆ TTreeNode() [6/6]

owl::TTreeNode::TTreeNode ( const TTreeNode & other)

Copy constructor: create a new node by copying another node Called implicitly by functions that return a TTreeNode by value; otherwise, shouldn't be needed.

Parameters

Definition at line 138 of file treeviewctrl.cpp.

Member Function Documentation

◆ AddChild() [1/2]

TTreeNode owl::TTreeNode::AddChild ( const TTreeNode & node) const
inline

Inserts a new child item into the Tree-View (TreeView) control.

Parameters

  • node A TTreeNode object encapsulating an item that will be the parent of the new item.

Returns a TTreeNode object encapsulating the new item. Returns NULL upon failure. (In 32-bit applications, you can check for a NULL handle using the HTREEITEM() operator.)

Definition at line 572 of file treeviewctrl.h.

References InsertChild(), and Last.

◆ AddChild() [2/2]

TTreeNode owl::TTreeNode::AddChild ( const TTvItem & item) const
inline

Definition at line 578 of file treeviewctrl.h.

References InsertChild(), and Last.

◆ AddSibling() [1/2]

TTreeNode owl::TTreeNode::AddSibling ( const TTreeNode & node) const

Definition at line 218 of file treeviewctrl.cpp.

References InsertItem().

◆ AddSibling() [2/2]

TTreeNode owl::TTreeNode::AddSibling ( const TTvItem & item) const

Inserts a new sibling item into the Tree-View (TreeView) control. (Adds the item above this item.)

Parameters

  • node A TTreeNode object encapsulating an item that will be a sibling of the new item.

Return Value Returns a TTreeNode object encapsulating the new item. Returns NULL upon failure. (In 32-bit applications, you can check for a NULL handle using the HTREEITEM() operator.)

Definition at line 211 of file treeviewctrl.cpp.

References InsertItem().

◆ Check()

void owl::TTreeNode::Check ( bool state = true)

Sets the node's checked state.

Assumes that the tree has the TVS_CHECKBOXES style, or has state images manually implemented in a similar manner to represent checked state.

Definition at line 570 of file treeviewctrl.cpp.

References owl::TWindow::GetHandle(), GetHTreeItem(), owl::TTreeViewCtrl::HasStyle(), ItemStruct, PRECONDITION, TreeView, and WARNX.

◆ CreateDragImage()

HIMAGELIST owl::TTreeNode::CreateDragImage ( )
inline

Return the image list used for a dragging purposes.

Definition at line 507 of file treeviewctrl.h.

References owl::TTreeViewCtrl::CreateDragImage(), and TreeView.

◆ Delete()

bool owl::TTreeNode::Delete ( void )

Definition at line 609 of file treeviewctrl.cpp.

References owl::TTreeViewCtrl::Delete(), ItemStruct, PRECONDITION, and TreeView.

◆ EditLabel()

HWND owl::TTreeNode::EditLabel ( )
inline

Return the HWND of the edit control to change the text.

Definition at line 498 of file treeviewctrl.h.

References owl::TTreeViewCtrl::EditLabel(), and TreeView.

◆ EnsureVisible()

bool owl::TTreeNode::EnsureVisible ( )
inline

Makes sure the item is visible.

Scroll the items if necessary.

Definition at line 517 of file treeviewctrl.h.

References owl::TTreeViewCtrl::EnsureVisible(), and TreeView.

◆ ExpandItem()

bool owl::TTreeNode::ExpandItem ( uint32 flag)
inline

Expand or contract a parent node.

Similar to the user clicking on the '-' or '+' area of the control.

Definition at line 527 of file treeviewctrl.h.

References owl::TTreeViewCtrl::ExpandItem(), and TreeView.

◆ FlushCache()

void owl::TTreeNode::FlushCache ( void )

Definition at line 600 of file treeviewctrl.cpp.

◆ GetChild()

TTreeNode owl::TTreeNode::GetChild ( ) const
inline

Get the first child of the current node.

Definition at line 596 of file treeviewctrl.h.

References Child, and GetNextItem().

◆ GetHasChildren()

bool owl::TTreeNode::GetHasChildren ( int & hasChildren,
bool getNew = true )

Definition at line 483 of file treeviewctrl.cpp.

References GetItem(), ItemStruct, PRECONDITION, and TreeView.

◆ GetHTreeItem()

HTREEITEM owl::TTreeNode::GetHTreeItem ( ) const
inline

Definition at line 681 of file treeviewctrl.h.

References owl::TTvItem::GetHTreeitem(), and ItemStruct.

◆ GetItem() [1/2]

bool owl::TTreeNode::GetItem ( TTvItem * item)
inline

Return the item associated with the node.

Definition at line 710 of file treeviewctrl.h.

References ItemStruct, PRECONDITION, owl::TWindow::SendMessage(), owl::TTvItem::SetHTreeItem(), and TreeView.

◆ GetItem() [2/2]

bool owl::TTreeNode::GetItem ( void )
inline

Update the item information in the node.

What's set in the mask determines what will be retrieved. Unless the user has explicitly called SetMask, the call should retrieve everything.

Definition at line 725 of file treeviewctrl.h.

References ItemStruct, PRECONDITION, owl::TWindow::SendMessage(), and TreeView.

◆ GetItemData()

bool owl::TTreeNode::GetItemData ( LPARAM & data,
bool getNew = true )

Definition at line 457 of file treeviewctrl.cpp.

References GetItem(), ItemStruct, PRECONDITION, and TreeView.

◆ GetItemRect()

bool owl::TTreeNode::GetItemRect ( TRect & rect,
bool textOnly = true ) const

◆ GetMask()

uint owl::TTreeNode::GetMask ( void ) const
inline

Definition at line 653 of file treeviewctrl.h.

References ItemStruct.

◆ GetNextItem()

TTreeNode owl::TTreeNode::GetNextItem ( uint32 flag) const
inline

Return the next item.

Definition at line 545 of file treeviewctrl.h.

References owl::TTreeViewCtrl::GetNextItem(), and TreeView.

◆ GetNextSibling()

TTreeNode owl::TTreeNode::GetNextSibling ( ) const
inline

Return the next sibling.

Definition at line 605 of file treeviewctrl.h.

References GetNextItem(), and Next.

◆ GetNextVisible()

TTreeNode owl::TTreeNode::GetNextVisible ( ) const
inline

Return the next visible item.

Definition at line 623 of file treeviewctrl.h.

References GetNextItem(), and NextVisible.

◆ GetParent()

TTreeNode owl::TTreeNode::GetParent ( ) const
inline

Return the parent of the current node.

Definition at line 587 of file treeviewctrl.h.

References GetNextItem(), and Parent.

◆ GetPrevSibling()

TTreeNode owl::TTreeNode::GetPrevSibling ( ) const
inline

Return the previous sibling.

Definition at line 614 of file treeviewctrl.h.

References GetNextItem(), and Previous.

◆ GetPrevVisible()

TTreeNode owl::TTreeNode::GetPrevVisible ( ) const
inline

Return the next previous item.

Definition at line 632 of file treeviewctrl.h.

References GetNextItem(), and PreviousVisible.

◆ GetState()

bool owl::TTreeNode::GetState ( uint & state,
bool getNew = true )

Definition at line 300 of file treeviewctrl.cpp.

References GetItem(), ItemStruct, PRECONDITION, and TreeView.

◆ GetStateMask()

uint owl::TTreeNode::GetStateMask ( void ) const
inline

Definition at line 665 of file treeviewctrl.h.

References ItemStruct.

◆ GetText() [1/2]

LPCTSTR owl::TTreeNode::GetText ( bool getNew = false)

Definition at line 394 of file treeviewctrl.cpp.

References FlushCache(), GetItem(), ItemStruct, PRECONDITION, and TreeView.

◆ GetText() [2/2]

bool owl::TTreeNode::GetText ( TCHAR * text,
uint length,
bool getNew = false )

Definition at line 377 of file treeviewctrl.cpp.

References _tcsncpy, and GetText().

◆ GetTreeView()

TTreeViewCtrl & owl::TTreeNode::GetTreeView ( ) const
inline

Returns a reference to the associated tree view.

Definition at line 164 of file treeviewctrl.h.

◆ InsertChild() [1/2]

TTreeNode owl::TTreeNode::InsertChild ( const TTreeNode & node,
THowToInsert how ) const
inline

Definition at line 551 of file treeviewctrl.h.

References InsertChild().

◆ InsertChild() [2/2]

TTreeNode owl::TTreeNode::InsertChild ( const TTvItem & item,
THowToInsert how ) const

Definition at line 239 of file treeviewctrl.cpp.

References owl::TTreeViewCtrl::InsertItem(), and TreeView.

◆ InsertItem() [1/2]

TTreeNode owl::TTreeNode::InsertItem ( const TTreeNode & node) const
inline

Definition at line 557 of file treeviewctrl.h.

References InsertItem().

◆ InsertItem() [2/2]

TTreeNode owl::TTreeNode::InsertItem ( const TTvItem & item) const

Definition at line 253 of file treeviewctrl.cpp.

References GetParent(), owl::TTreeViewCtrl::InsertItem(), and TreeView.

◆ IsChecked()

bool owl::TTreeNode::IsChecked ( ) const

Retrieves the node's checked state.

Assumes that the tree has the TVS_CHECKBOXES style, or has state images manually implemented in a similar manner to represent checked state.

Definition at line 585 of file treeviewctrl.cpp.

References owl::TWindow::GetHandle(), GetHTreeItem(), owl::TTreeViewCtrl::HasStyle(), ItemStruct, PRECONDITION, TreeView, and WARNX.

◆ operator HTREEITEM()

owl::TTreeNode::operator HTREEITEM ( ) const
inline

Return the magic cookie used by the control associated with the item.

Definition at line 489 of file treeviewctrl.h.

◆ operator=()

TTreeNode & owl::TTreeNode::operator= ( const TTreeNode & other)

Definition at line 146 of file treeviewctrl.cpp.

◆ SelectItem()

bool owl::TTreeNode::SelectItem ( uint32 flag)
inline

Make the next item selected.

Definition at line 536 of file treeviewctrl.h.

References owl::TTreeViewCtrl::SelectItem(), and TreeView.

◆ SetCacheSize()

void owl::TTreeNode::SetCacheSize ( uint size)

◆ SetHasChildren()

bool owl::TTreeNode::SetHasChildren ( int hasChildren,
bool sendNow = true )

Definition at line 508 of file treeviewctrl.cpp.

References ItemStruct, PRECONDITION, SetItem(), and TreeView.

◆ SetHTreeItem()

void owl::TTreeNode::SetHTreeItem ( HTREEITEM hItem)
inline

Set and Get the node's item handle.

Definition at line 675 of file treeviewctrl.h.

References ItemStruct, and owl::TTvItem::SetHTreeItem().

◆ SetImageIndex()

bool owl::TTreeNode::SetImageIndex ( int index,
bool sendNow = true )

Definition at line 420 of file treeviewctrl.cpp.

References ItemStruct, PRECONDITION, SetItem(), and TreeView.

◆ SetItem() [1/2]

bool owl::TTreeNode::SetItem ( TTvItem * item)
inline

Set the item associated with this node.

Definition at line 690 of file treeviewctrl.h.

References PRECONDITION, owl::TWindow::SendMessage(), owl::TTvItem::SetHTreeItem(), and TreeView.

◆ SetItem() [2/2]

bool owl::TTreeNode::SetItem ( void )
inline

Definition at line 699 of file treeviewctrl.h.

References ItemStruct, PRECONDITION, owl::TWindow::SendMessage(), and TreeView.

◆ SetItemData()

bool owl::TTreeNode::SetItemData ( LPARAM data,
bool sendNow = true )

Definition at line 445 of file treeviewctrl.cpp.

References ItemStruct, PRECONDITION, SetItem(), and TreeView.

◆ SetMask()

void owl::TTreeNode::SetMask ( uint mask)
inline

Definition at line 647 of file treeviewctrl.h.

References ItemStruct.

◆ SetSelectedImageIndex()

bool owl::TTreeNode::SetSelectedImageIndex ( int index,
bool sendNow = true )

Definition at line 432 of file treeviewctrl.cpp.

References ItemStruct, PRECONDITION, SetItem(), and TreeView.

◆ SetState()

bool owl::TTreeNode::SetState ( uint state,
bool sendNow = true )

Definition at line 325 of file treeviewctrl.cpp.

References ItemStruct, PRECONDITION, SetItem(), and TreeView.

◆ SetStateMask()

void owl::TTreeNode::SetStateMask ( uint mask)
inline

Definition at line 659 of file treeviewctrl.h.

References ItemStruct.

◆ SetText() [1/2]

bool owl::TTreeNode::SetText ( const tstring & text,
bool sendNow = true )
inline

Definition at line 223 of file treeviewctrl.h.

References SetText().

◆ SetText() [2/2]

bool owl::TTreeNode::SetText ( LPCTSTR text,
bool sendNow = true )

Definition at line 347 of file treeviewctrl.cpp.

References _tcslen, _tcsncpy, FlushCache(), ItemStruct, PRECONDITION, SetItem(), and TreeView.

◆ SortChildren() [1/2]

bool owl::TTreeNode::SortChildren ( bool recurse = false)
inline

Sort the children of this node.

Definition at line 641 of file treeviewctrl.h.

References owl::TTreeViewCtrl::SortChildren(), and TreeView.

◆ SortChildren() [2/2]

bool owl::TTreeNode::SortChildren ( const TTvComparator & Comparator,
bool recurse = false,
LPARAM extraParam = 0 )

Member Data Documentation

◆ ItemStruct

TTvItem owl::TTreeNode::ItemStruct
protected

contains a TVITEM with HTREEITEM

Definition at line 317 of file treeviewctrl.h.

◆ TreeView

TTreeViewCtrl* owl::TTreeNode::TreeView
protected

wrapper for item of this tree

Definition at line 318 of file treeviewctrl.h.


The documentation for this class was generated from the following files: