FDOSTUI
FreeDOS Text User Interface
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
treeitem Class Reference

treeitem widget class More...

#include <treeitem.hpp>

Public Member Functions

 treeitem (unsigned char const *i_str, void *const io_user_data=0)
 constructor - create a tree item More...
 
bool add (unsigned char const *i_str, void *const io_user_data=0)
 add a child item to the tree More...
 
bool add (treeitem *const io_item)
 add a tree item (sibling) to tree More...
 
treeitem *const next () const
 returns the next item More...
 
treeitem *const prev () const
 returns the previous item More...
 
virtual ~treeitem ()
 destructor
 

Static Public Member Functions

static void set_links (treeitem *const io_item, treeitem *const io_parent, treeitem *const io_prev, unsigned int const i_level)
 sets linkage between tree items More...
 

Protected Attributes

unsigned int m_open:1
 
unsigned char * m_text
 
unsigned int m_len
 
int m_pos_y
 
void * m_user_data
 
struct array m_child
 
treeitemm_parent
 
treeitemm_next
 
treeitemm_prev
 
unsigned int m_level
 

Private Member Functions

 treeitem (const treeitem &)
 
treeitemoperator= (treeitem const &)
 

Friends

class tree
 

Detailed Description

treeitem widget class

A tree item, which consists of a label and possible children. A tree item can be connected to other tree items to form a hierarchy.

Internal links such as m_parent, m_next and m_prev are deferred. Once a tree has been created or modified, the links are set through a call to ::set_links. The tree class does this automatically when a root tree item is attached.

Constructor & Destructor Documentation

◆ treeitem()

treeitem::treeitem ( unsigned char const *  i_str,
void *const  io_user_data = 0 
)

constructor - create a tree item

Parameters
[in]i_strlabel of item
[in,out]io_user_datauser defined data for signal
Returns
none

Member Function Documentation

◆ add() [1/2]

bool treeitem::add ( unsigned char const *  i_str,
void *const  io_user_data = 0 
)

add a child item to the tree

Parameters
[in]i_strlabel of item
[in,out]io_user_datauser defined data for signal
Returns
false item was not added (out of memory)
true item was added to tree

◆ add() [2/2]

bool treeitem::add ( treeitem *const  io_item)

add a tree item (sibling) to tree

Parameters
[in,out]io_itemitem to add
Returns
false item was not added (out of memory)
true item was added to tree

io_item will become owned by the tree. It must not already be in the tree or anyother tree.

◆ next()

treeitem *const treeitem::next ( ) const

returns the next item

Returns
0 end of tree
!0 pointer to next item

◆ prev()

treeitem *const treeitem::prev ( ) const

returns the previous item

Returns
0 end of tree
!0 pointer to previous item

◆ set_links()

void treeitem::set_links ( treeitem *const  io_item,
treeitem *const  io_parent,
treeitem *const  io_prev,
unsigned int const  i_level 
)
static

sets linkage between tree items

Parameters
[in,out]io_itemtree item to link
[in,out]io_parentparent of tree item
[in,out]io_prevtree item the precedes io_item
[in]i_levellevel of tree item (0...N)
Returns
none

Internal links such as m_parent, m_next and m_prev are deferred. This routine will establish the relationship between tree items.

treeitem* root= new treeitem(reinterpret_cast<unsigned char const*>("ROOT"));
root->add(reinterpret_cast<unsigned char const*>("1"));
root->add(reinterpret_cast<unsigned char const*>("2"));
treeitem* sibling= new treeitem(reinterpret_cast<unsigned char const*>("SIBLING"));
sibling->add(reinterpret_cast<unsigned char const*>("1"));
sibling->add(reinterpret_cast<unsigned char const*>("2"));
root->add(sibling);
treeitem::set_links(root, 0, 0, 0);

Member Data Documentation

◆ m_child

treeitem::m_child
protected

array of child tree items

◆ m_len

treeitem::m_len
protected

length of m_text

◆ m_level

treeitem::m_level
protected

level/depth of tree item

◆ m_next

treeitem::m_next
protected

next item

◆ m_open

treeitem::m_open
protected

indicator if item is open or closed

◆ m_parent

treeitem::m_parent
protected

parent

◆ m_pos_y

treeitem::m_pos_y
protected

y position of tree item

◆ m_prev

treeitem::m_prev
protected

previous item

◆ m_text

treeitem::m_text
protected

label text

◆ m_user_data

treeitem::m_user_data
protected

user data


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