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

Allows a user to enter text. More...

#include <entry.hpp>

Inheritance diagram for entry:
Inheritance graph
[legend]

Public Types

enum  purpose {
  PURPOSE_ANY, PURPOSE_ALPHA, PURPOSE_DIGIT, PURPOSE_INTEGER,
  PURPOSE_FLOAT
}
 indicator of the type of input the entry can accept More...
 
typedef void(* signal_changed_t) (entry const *i_entry, 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

 entry (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 ~entry ()
 destructor More...
 
virtual void draw () const
 draws the widget More...
 
virtual enum event_response event_key (struct event_key const &i_event)
 handle key event More...
 
virtual void focus_enter ()
 handle entering focus More...
 
virtual void focus_leave ()
 handle leaving focus More...
 
unsigned char const * get_text () const
 get text buffer More...
 
size_t get_text_length () const
 get the number of characters in the text buffer More...
 
enum purpose get_purpose () const
 get the text entry purpose More...
 
void set_editable (bool const i_editable=true)
 set whether or not the entry is editable More...
 
void set_purpose (enum purpose const i_purpose)
 set the input purpose More...
 
void set_text (unsigned char const *i_str)
 set the text of the entry More...
 
void set_signal_changed (signal_changed_t i_signal)
 set callback 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 enum event_response event_mouse (struct event_mouse const &i_event)
 handle mouse event 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 Member Functions

void show_cursor ()
 sets the cursor type/shape. Cursor shape depends on the state of the cursor (insert/overwrite) and widget itself. More...
 
void grow (size_t const i_needed)
 grow internal buffer More...
 
virtual void get_bbox (struct box &o_bbox) const
 get the inner bounding box param[out] o_bbox bounding box to fill More...
 
int pos_inc ()
 increments position (m_caret, m_slot, m_offset) More...
 
int pos_dec ()
 decrements position (m_caret, m_slot, m_offset) More...
 
void del ()
 delete character at current position from the buffer More...
 
void ins (unsigned char const i_char)
 insert character at current position into the buffer More...
 
void ovw (unsigned char const i_char)
 insert character at current position into the buffer More...
 
bool validate (unsigned char const i_char)
 validates a character against the widgets purpose More...
 
void caret_set_position () const
 moves the cursor to the current position (m_caret) More...
 
void emit_changed ()
 emit the changed signal More...
 

Protected Attributes

enum purpose m_purpose
 
size_t m_caret
 
size_t m_offset
 
size_t m_slot
 
size_t m_length
 
size_t m_block_size
 
unsigned char * m_block
 
bool m_editable
 
signal_changed_t m_signal_changed
 
- 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

 entry (const entry &)
 
entryoperator= (entry const &)
 

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

Allows a user to enter text.

Member Typedef Documentation

◆ signal_changed_t

void(* entry::signal_changed_t)(entry const *i_entry, void *io_user_data)

function prototype to recieve signal

Parameters
[in]i_entryentry widget
[in,out]io_user_datauser defined
Returns
none As of this writing, a signal is not emitted

Member Enumeration Documentation

◆ purpose

indicator of the type of input the entry can accept

Enumerator
PURPOSE_ANY 

Accept any type of input

PURPOSE_ALPHA 

Accept only alphabetic characters

PURPOSE_DIGIT 

Accept only numeric characters

PURPOSE_INTEGER 

Accept only numeric characters and also the negative ('-') character

PURPOSE_FLOAT 

Accept only numeric characters and also the plus ('+'), negative ('-'), period ('.'), and exponent ('E' or 'e') character

Constructor & Destructor Documentation

◆ entry()

entry::entry ( 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

◆ ~entry()

entry::~entry ( )
virtual

destructor

Returns
none

Member Function Documentation

◆ caret_set_position()

void entry::caret_set_position ( ) const
protected

moves the cursor to the current position (m_caret)

Returns
none

This routine does not alter the shape or visibility

◆ del()

void entry::del ( )
protected

delete character at current position from the buffer

Returns
none

Characters to the right of the cursor are shifted left.

◆ draw()

void entry::draw ( ) const
virtual

draws the widget

This method should not be called directly.

See also
widget::draw for details.

Implements widget.

Reimplemented in combobox, and spinner.

◆ emit_changed()

void entry::emit_changed ( )
inlineprotected

emit the changed signal

Returns
none

◆ event_key()

enum event_response entry::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.

Reimplemented in spinner, and combobox.

◆ focus_enter()

void entry::focus_enter ( )
virtual

handle entering focus

Returns
none

Reimplemented from widget.

◆ focus_leave()

void entry::focus_leave ( )
virtual

handle leaving focus

Returns
none

Reimplemented from widget.

◆ get_bbox()

void entry::get_bbox ( struct box o_bbox) const
inlineprotectedvirtual

get the inner bounding box param[out] o_bbox bounding box to fill

Returns
none This will return the normal widget box m_box

Combobox and spinner overrides this method so a down button can be displayed.

Reimplemented in combobox, and spinner.

◆ get_purpose()

enum entry::purpose entry::get_purpose ( ) const
inline

get the text entry purpose

Returns
purpose

◆ get_text()

unsigned char const * entry::get_text ( ) const
inline

get text buffer

Returns
pointer to a null terminated text buffer

This routine will not return a null pointer. However, the buffer itself could be empty.

◆ get_text_length()

size_t entry::get_text_length ( ) const
inline

get the number of characters in the text buffer

Returns
number of characters in the text buffer

◆ grow()

void entry::grow ( size_t const  i_needed)
protected

grow internal buffer

Parameters
[in]i_neededrequested buffer size
Returns
none The memory block allocated is twice the size of the request. If the buffer is already big enough to hold the request, nothing happens.
none

◆ ins()

void entry::ins ( unsigned char const  i_char)
protected

insert character at current position into the buffer

Parameters
[in]i_charcharacter to insert
Returns
none

Characters at the cursor position are shifted right, and then the character is inserted.

◆ ovw()

void entry::ovw ( unsigned char const  i_char)
protected

insert character at current position into the buffer

Parameters
[in]i_charcharacter to insert
Returns
none

The character at the cursor position is replaced.

◆ pos_dec()

int entry::pos_dec ( )
protected

decrements position (m_caret, m_slot, m_offset)

Returns
none

◆ pos_inc()

int entry::pos_inc ( )
protected

increments position (m_caret, m_slot, m_offset)

Returns
none

◆ set_editable()

void entry::set_editable ( bool const  i_editable = true)
inline

set whether or not the entry is editable

Parameters
[in]i_editableindicator if the user can edit the entry
Returns
none

◆ set_purpose()

void entry::set_purpose ( enum purpose const  i_purpose)
inline

set the input purpose

Parameters
[in]i_purposeinput purpose
Returns
none

◆ set_signal_changed()

void entry::set_signal_changed ( signal_changed_t  i_signal)
inline

set callback

Parameters
[in]i_signalcallback signal
Returns
none As of this writing, a signal is not emitted

◆ set_text()

void entry::set_text ( unsigned char const *  i_str)

set the text of the entry

Parameters
[in]i_strnull terminated string to set the entry too
Returns
none

◆ show_cursor()

void entry::show_cursor ( )
inlineprotected

sets the cursor type/shape. Cursor shape depends on the state of the cursor (insert/overwrite) and widget itself.

Returns
none

◆ validate()

bool entry::validate ( unsigned char const  i_char)
protected

validates a character against the widgets purpose

Parameters
[in]i_charcharacter to validate
Returns
none

Member Data Documentation

◆ m_block

entry::m_block
protected

memory block/text buffer to hold content

◆ m_block_size

entry::m_block_size
protected

size of the memory block

◆ m_caret

entry::m_caret
protected

cursor position (limited to length of entry)

◆ m_editable

entry::m_editable
protected

indicator if text widget is editable

◆ m_length

entry::m_length
protected

number of actual characters in buffer

◆ m_offset

entry::m_offset
protected

horizontal scroll position/offset

◆ m_purpose

entry::m_purpose
protected

input purpose

◆ m_signal_changed

entry::m_signal_changed
protected

signal to emit when entry has changed. as of this writing, a signal is not emitted

◆ m_slot

entry::m_slot
protected

physical cursor position (0..m_length)


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