FDOSTUI
FreeDOS Text User Interface
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | List of all members
tree Class Reference

tree widget class More...

#include <tree.hpp>

Inheritance diagram for tree:
Inheritance graph
[legend]

Public Types

typedef void(* signal_selected_t) (tree const *const i_tree, void *io_user_data)
 function prototype to recieve signal More...
 
- Public Types inherited from widget
enum  damage {
  DAMAGE_NONE = 0, DAMAGE_ALL = (1<<0), DAMAGE_LABEL = (1<<1), DAMAGE_VALUE = (1<<2),
  DAMAGE_SCROLL = (1<<3), DAMAGE_MOVED = (1<<4), DAMAGE_RESERVED1 = (1<<5), DAMAGE_RESERVED2 = (1<<6),
  DAMAGE_RESERVED3 = (1<<7)
}
 bit mask indicating what needs to be redrawn More...
 

Public Member Functions

 tree (int const i_pos_x, int const i_pos_y, unsigned int const i_len_x, unsigned int const i_len_y)
 construct an empty tree widget More...
 
void attach (treeitem *const io_root)
 attach a treeitem to this tree More...
 
virtual void draw () const
 draws the widget More...
 
virtual ~tree ()
 desctructor More...
 
virtual enum event_response event_key (struct event_key const &i_event)
 handle key event More...
 
virtual enum event_response event_mouse (struct event_mouse const &i_event)
 handle mouse event More...
 
virtual void move (int const i_pos_x, int const i_pos_y)
 move the widget to a new position More...
 
virtual void resize (unsigned int const i_len_x, unsigned int const i_len_y)
 resize the widget More...
 
- Public Member Functions inherited from widget
 widget (int const i_pos_x, int const i_pos_y, unsigned int const i_len_x, unsigned int const i_len_y)
 constructor More...
 
virtual ~widget ()
 destructor More...
 
virtual void set_damage (unsigned int const i_damage=DAMAGE_NONE)
 set the damage bits More...
 
virtual bool close (bool const i_shutting_down)
 called when widget is about to be destroyed More...
 
bool contains (int const i_pos_x, int const i_pos_y) const
 test if point is contained within the widget More...
 
bool contains (struct box const &i_box) const
 test if rectangular region is contained within the widget More...
 
virtual enum event_response event_key_default (enum scancodes const i_scan)
 default key event handler More...
 
virtual void focus_enter ()
 called when the widget receives focus More...
 
virtual void focus_leave ()
 called when the widget looses focus More...
 
void get_box (struct box &o_box) const
 gets the rectangular region this widget occupies More...
 
bool get_can_focus () const
 gets whether or not the widget can receive focus More...
 
bool get_enabled () const
 gets whether or not the widget is enabled More...
 
bool get_has_focus () const
 gets whether or not the widget has focus More...
 
group *const get_parent () const
 gets the parent widget More...
 
void * get_user_data () const
 gets user defined data pointer More...
 
bool get_visible () const
 gets whether or not the widget is visible More...
 
int get_pos_x () const
 gets the relative x position of the widget More...
 
int get_pos_y () const
 gets the relative y position of the widget More...
 
unsigned int get_len_x () const
 gets the horizontal length of the widget More...
 
unsigned int get_len_y () const
 gets the vertical length of the widget More...
 
void set_can_close (bool const i_can_close)
 set internal indicator if widget can be closed More...
 
void set_disabled ()
 disable the widget More...
 
void set_enabled ()
 enable the widget
 
void set_hidden ()
 hide the widget More...
 
virtual void set_parent (group *const i_parent)
 sets the parent group of the widget More...
 
void set_user_data (void *io_user_data)
 sets the user defined data pointer More...
 
void set_visible ()
 sets the widget as visible More...
 
void translate_screen (int *const o_pos_x, int *const o_pos_y) const
 translate a widgets relative coordinates to screen coordinates More...
 

Protected Attributes

treeitemm_root
 
treeitemm_selected
 
signal_selected_t m_signal_selected
 
scrollbar m_horizontal
 
scrollbar m_vertical
 
- Protected Attributes inherited from widget
unsigned int m_damage
 
unsigned int m_flags
 
struct box m_box
 
groupm_parent
 
void * m_user_data
 

Private Member Functions

 tree (const tree &)
 
treeoperator= (tree const &)
 
int draw (treeitem *const io_item, int const i_pos_x, int const i_pos_y) const
 
void emit_selected ()
 emit selected signal More...
 
bool event_hit (treeitem *const io_item, unsigned int const i_pos_y)
 test if event is in item or it's children More...
 
void key_down ()
 handle key down event
 
void key_up ()
 handle key up event
 
void scrollbar_configure ()
 configure horizontal and veritcal scrollbars
 
void scrollbar_configure (unsigned int &io_height, unsigned int &io_width, treeitem const &i_item, unsigned int const i_pos_y)
 configure horizontal and veritcal scrollbars More...
 

Additional Inherited Members

- Protected Types inherited from widget
enum  flags {
  VISIBLE = (1 << 0), ENABLED = (1 << 1), CAN_FOCUS = (1 << 2), HAS_FOCUS = (1 << 3),
  CAN_CLOSE = (1 << 4)
}
 

Detailed Description

tree widget class

A tree consists of a hierarchy of treeitems. The tree widget class manages the treeitems.

treeitem* root= new treeitem(reinterpret_cast<unsigned char const*>("Capital"));
treeitem* state= new treeitem(reinterpret_cast<unsigned char const*>("NY"));
state->add(reinterpret_cast<unsigned char const*>("Albany"));
root->add(state);
state= new treeitem(reinterpret_cast<unsigned char const*>("UT"));
state->add(reinterpret_cast<unsigned char const*>("Salt Lake City"));
root->add(state);
state= new treeitem(reinterpret_cast<unsigned char const*>("NV"));
state->add(reinterpret_cast<unsigned char const*>("Carson City"));
root->add(state);
tree* mytree= new tree(0, 0, 20, 10);
mytree->attach(root);

Member Typedef Documentation

◆ signal_selected_t

void(* tree::signal_selected_t)(tree const *const i_tree, void *io_user_data)

function prototype to recieve signal

Parameters
[in]i_treetree widget
[in,out]io_user_datauser defined
Returns
none

Constructor & Destructor Documentation

◆ tree()

tree::tree ( int const  i_pos_x,
int const  i_pos_y,
unsigned int const  i_len_x,
unsigned int const  i_len_y 
)

construct an empty tree widget

Parameters
[in]i_pos_xx position to place widget
[in]i_pos_yy position to place widget
[in]i_len_xx length of widget
[in]i_len_yy length of widget
Returns
none

◆ ~tree()

tree::~tree ( )
virtual

desctructor

Returns
none

Member Function Documentation

◆ attach()

void tree::attach ( treeitem *const  io_root)
inline

attach a treeitem to this tree

Parameters
[in,out]io_rootvalid treeitem. takes ownership of object.
Returns
none

If an object is already attached, it will be deleted.

◆ draw()

void tree::draw ( ) const
virtual

draws the widget

This method should not be called directly.

See also
widget::draw for details.

Implements widget.

◆ emit_selected()

void tree::emit_selected ( )
inlineprivate

emit selected signal

Returns
none

◆ event_hit()

bool tree::event_hit ( treeitem *const  io_item,
unsigned int const  i_pos_y 
)
private

test if event is in item or it's children

Parameters
[in,out]io_itemitem to test
[in]i_pos_yy position of event
Returns
true event is in item
false event is not in item

emits signal and toggles item open flag if event is in item or it's children.

◆ event_key()

enum event_response tree::event_key ( struct event_key const &  i_event)
virtual

handle key event

Parameters
[in]i_eventkey event to handle
Returns
response how event was handled

Reimplemented from widget.

◆ event_mouse()

enum event_response tree::event_mouse ( struct event_mouse const &  i_event)
virtual

handle mouse event

Parameters
[in]i_eventmouse event to handle
Returns
event_response::RESPONSE_NONE

Reimplemented from widget.

◆ move()

void tree::move ( int const  i_pos_x,
int const  i_pos_y 
)
virtual

move the widget to a new position

Parameters
[in]i_pos_xrelative x position to move the widget
[in]i_pos_yrelative y position to move the widget
Returns
none

Reimplemented from widget.

◆ resize()

void tree::resize ( unsigned int const  i_len_x,
unsigned int const  i_len_y 
)
virtual

resize the widget

Parameters
[in]i_len_xnew length of widget
[in]i_len_ynew height of widget
Returns
none

This method does not redraw the widget

Reimplemented from widget.

◆ scrollbar_configure()

void tree::scrollbar_configure ( unsigned int &  io_height,
unsigned int &  io_width,
treeitem const &  i_item,
unsigned int const  i_pos_y 
)
private

configure horizontal and veritcal scrollbars

Parameters
[in,out]io_heightheight tracker
[in,out]io_widthwidth tracker
[in]i_itemcurrent item
[in]i_pos_yy position tracker

Member Data Documentation

◆ m_horizontal

tree::m_horizontal
protected

horizontal scrollbar

◆ m_root

tree::m_root
protected

root treeitem (owned and managed by object)

◆ m_selected

tree::m_selected
protected

selected treeitem

◆ m_signal_selected

tree::m_signal_selected
protected

selected signal

◆ m_vertical

tree::m_vertical
protected

vertical scrollbar


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