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

base class for all derived widgets More...

#include <widget.hpp>

Inheritance diagram for widget:
Inheritance graph
[legend]

Public Types

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

 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 void draw () const =0
 draws the widget More...
 
virtual enum event_response event_key_default (enum scancodes const i_scan)
 default key event handler 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 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...
 
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...
 
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 Types

enum  flags {
  VISIBLE = (1 << 0), ENABLED = (1 << 1), CAN_FOCUS = (1 << 2), HAS_FOCUS = (1 << 3),
  CAN_CLOSE = (1 << 4)
}
 

Protected Attributes

unsigned int m_damage
 
unsigned int m_flags
 
struct box m_box
 
groupm_parent
 
void * m_user_data
 

Private Member Functions

 widget (const widget &)
 
widgetoperator= (widget const &)
 

Detailed Description

base class for all derived widgets

Member Enumeration Documentation

◆ damage

bit mask indicating what needs to be redrawn

Enumerator
DAMAGE_NONE 

no damage

DAMAGE_ALL 

entire widget should be redrawn

DAMAGE_LABEL 

label portion of widget should be redrawn

DAMAGE_VALUE 

value portion of widget should be redrawn

DAMAGE_SCROLL 

contents of widget should be redrawn

DAMAGE_MOVED 

entire widget should be redrawn

DAMAGE_RESERVED1 

reserved

DAMAGE_RESERVED2 

reserved

DAMAGE_RESERVED3 

reserved

◆ flags

enum widget::flags
protected
Enumerator
VISIBLE 

indicator if widget is visible

ENABLED 

indicator if widget is enabled

CAN_FOCUS 

indicator if widget can receive focus

HAS_FOCUS 

indicator if widget has focus

CAN_CLOSE 

indicator if widget can close

Constructor & Destructor Documentation

◆ widget()

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

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

◆ ~widget()

widget::~widget ( )
virtual

destructor

Returns
none

Member Function Documentation

◆ close()

bool widget::close ( bool const  i_shutting_down)
virtual

called when widget is about to be destroyed

Parameters
[in]i_shutting_downindicator if application is exiting
Returns
true indicator it is okay to close
false indicator it is not okay to close (ignored if shutting down)
See also
widget::set_can_close

◆ contains() [1/2]

bool widget::contains ( int const  i_pos_x,
int const  i_pos_y 
) const
inline

test if point is contained within the widget

Parameters
[in]i_pos_xx coordinate of point
[in]i_pos_yy coordinate of point
Returns
0 point is not contained within the widget
!0 point is contained within the widget

◆ contains() [2/2]

bool widget::contains ( struct box const &  i_box) const
inline

test if rectangular region is contained within the widget

Parameters
[in]i_boxrectangle to test
Returns
0 box is not contained within the widget
!0 box is contained within the widget

◆ draw()

void widget::draw ( ) const
pure virtual

draws the widget

This method should not be called directly. The position of the widget is relative to it's parent. Using this method directly will cause the widget to be drawn relative to the display screen. It will also ignore state flags such as visibility.

wm_draw_widget to draw a widget wm_draw to draw a window

Implemented in slider, button, window, listbox, entry, group, menu, label, tree, combobox, scroller, edit, spinner, menubar, and scrollbar.

◆ event_key()

enum event_response widget::event_key ( struct event_key const &  i_event)
inlinevirtual

handle key event

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

Reimplemented in slider, button, listbox, entry, group, tree, spinner, menu, combobox, scroller, edit, menubar, and scrollbar.

◆ event_key_default()

enum event_response widget::event_key_default ( enum scancodes const  i_scan)
inlinevirtual

default key event handler

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

This routine is called by the window manager when there was no response (RESPONSE_NONE) to event_key.

The menubar widget overrides this routine to intercept accelerators that could active the menu.

Reimplemented in group, and menubar.

◆ event_mouse()

enum event_response widget::event_mouse ( struct event_mouse const &  i_event)
inlinevirtual

handle mouse event

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

Reimplemented in slider, button, listbox, group, tree, spinner, menu, combobox, scroller, menubar, and scrollbar.

◆ focus_enter()

void widget::focus_enter ( )
inlinevirtual

called when the widget receives focus

Sets the flags bit mask to widget::HAS_FOCUS

Reimplemented in button, menu, group, entry, and edit.

◆ focus_leave()

void widget::focus_leave ( )
inlinevirtual

called when the widget looses focus

Unsets the widget::HAS_FOCUS flags bit mask

Reimplemented in button, group, entry, and edit.

◆ get_box()

void widget::get_box ( struct box o_box) const
inline

gets the rectangular region this widget occupies

Parameters
[out]o_boxrectangle to fill
Returns
none

◆ get_can_focus()

bool widget::get_can_focus ( ) const
inline

gets whether or not the widget can receive focus

Returns
0 widget cannot receive focus
!0 widget can receive focus

◆ get_enabled()

bool widget::get_enabled ( ) const
inline

gets whether or not the widget is enabled

Returns
0 widget is disabled returns !0 widget is enabled

◆ get_has_focus()

bool widget::get_has_focus ( ) const
inline

gets whether or not the widget has focus

Returns
0 widget does not have focus returns !0 widget has focus

◆ get_len_x()

unsigned int widget::get_len_x ( ) const
inline

gets the horizontal length of the widget

Returns
horizontal length of the widget

◆ get_len_y()

unsigned int widget::get_len_y ( ) const
inline

gets the vertical length of the widget

Returns
vertical length of the widget

◆ get_parent()

group *const widget::get_parent ( ) const
inline

gets the parent widget

Returns
0 no parent
!0 pointer to the parent widget

◆ get_pos_x()

int widget::get_pos_x ( ) const
inline

gets the relative x position of the widget

Returns
relative x position of the widget

◆ get_pos_y()

int widget::get_pos_y ( ) const
inline

gets the relative y position of the widget

Returns
relative y position of the widget

◆ get_user_data()

void * widget::get_user_data ( ) const
inline

gets user defined data pointer

Returns
0 no user defined data
!0 pointer to user defined data

◆ get_visible()

bool widget::get_visible ( ) const
inline

gets whether or not the widget is visible

Returns
0 widget is invisible
!0 widget is visible

◆ move()

void widget::move ( int const  i_pos_x,
int const  i_pos_y 
)
inlinevirtual

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

This method does not redraw the widget

Reimplemented in menu, listbox, and tree.

◆ resize()

void widget::resize ( unsigned int const  i_len_x,
unsigned int const  i_len_y 
)
inlinevirtual

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 in menu, listbox, and tree.

◆ set_can_close()

void widget::set_can_close ( bool const  i_can_close)
inline

set internal indicator if widget can be closed

Parameters
[in]i_can_closeindicator if widget can be closed
Returns
none
See also
widget::close

This is usefull to hide instead of close window widgets.

◆ set_damage()

void widget::set_damage ( unsigned int const  i_damage = DAMAGE_NONE)
inlinevirtual

set the damage bits

Parameters
[in]i_damagedamage bits
Returns
none

Reimplemented in group.

◆ set_disabled()

void widget::set_disabled ( )
inline

disable the widget

Returns
none

◆ set_hidden()

void widget::set_hidden ( )
inline

hide the widget

Returns
none

◆ set_parent()

void widget::set_parent ( group *const  i_parent)
inlinevirtual

sets the parent group of the widget

Returns
none

Setting the parent group is handled automatically when adding the widget to a container such as a window.

A widget can only belong to one group. This method will not remove the widget from an existing group.

Reimplemented in listbox, and scroller.

◆ set_user_data()

void widget::set_user_data ( void *  io_user_data)
inline

sets the user defined data pointer

Parameters
[in]io_user_datapointer to user data or NULL to unset
Returns
none

◆ set_visible()

void widget::set_visible ( )
inline

sets the widget as visible

Returns
none

◆ translate_screen()

void widget::translate_screen ( int *const  o_pos_x,
int *const  o_pos_y 
) const

translate a widgets relative coordinates to screen coordinates

Parameters
[out]o_pos_xtranslated x position
[out]o_pos_ytranslated y position
Returns
none

Member Data Documentation

◆ m_box

widget::m_box
protected

rectangular region the widget occupies

◆ m_damage

widget::m_damage
protected

bit mask of widget::damage flags

◆ m_flags

widget::m_flags
protected

bit mask of widget::damage flags

◆ m_parent

widget::m_parent
protected

parent group this widget belongs too

◆ m_user_data

widget::m_user_data
protected

user defined data pointer


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