An input element in a Dialog. This is an abstract base class from which you can derive -- although there are some builtins (Ok,string, etc). The popup() function will handle some keys and some will be sent to the element's handle_key method. The draw() method may be invoked multiples times within the popup() function call. More...
#include <cursorwindow.h>
Public Member Functions | |
virtual void | draw_input_area (viewport *v, bool highlighted)=0 |
Draw the input area of this field in the specified viewport. The cursor will already be positioned for you. Do not draw more than 'input_width_' characters. If the highlighted flag is passed in, the field is active, otherwise it is not. | |
Element (std::string const &name, std::string const &label, int width=0) | |
virtual void | handle_key (viewport *v, int key)=0 |
Interpret keys passed to this field by popup() as the user wants to make changes. Only some keys get to the field -- data keys, and left and right arrow keys for example, but not up and down or paging keys. | |
virtual | ~Element () |
Public Attributes | |
int | input_width_ |
std::string | label_ |
std::string | name_ |
std::string | value_ |
Protected Attributes | |
Dialog * | dialog_ |
Friends | |
class | Dialog |
An input element in a Dialog. This is an abstract base class from which you can derive -- although there are some builtins (Ok,string, etc). The popup() function will handle some keys and some will be sent to the element's handle_key method. The draw() method may be invoked multiples times within the popup() function call.
To add Elements to a dialog, do this: Dialog d("title"); d += new ElementType(initializer); d += new ElementType(initializer); d += new ElementType(initializer); To allow user's to edit, then do this: if(! d.popup() ) { iterate over the elements in d and extract the names and updated values for your use. use begin(), and end() to get iterators to the elements }
The popup() function draws the labels and the dialog title. The element is responsible for drawing its input area -- but not violate the input_width_ which may not be the same as what is specified during the element's construction.
the popup() function handles keyboard input and distributes some keys to the element's handle_key function: data keys and left and right arrows but no other keys -- except key_dc.
Definition at line 1126 of file cursorwindow.h.
Element | ( | std::string const & | name, | |
std::string const & | label, | |||
int | width = 0 | |||
) |
Definition at line 1178 of file cursorwindow.h.
virtual ~Element | ( | ) | [virtual] |
Definition at line 1186 of file cursorwindow.h.
virtual void draw_input_area | ( | viewport * | v, | |
bool | highlighted | |||
) | [pure virtual] |
Draw the input area of this field in the specified viewport. The cursor will already be positioned for you. Do not draw more than 'input_width_' characters. If the highlighted flag is passed in, the field is active, otherwise it is not.
Implemented in Ok, and String.
virtual void handle_key | ( | viewport * | v, | |
int | key | |||
) | [pure virtual] |
friend class Dialog [friend] |
Definition at line 1169 of file cursorwindow.h.
Definition at line 1166 of file cursorwindow.h.
int input_width_ |
Definition at line 1176 of file cursorwindow.h.
std::string label_ |
Definition at line 1174 of file cursorwindow.h.
std::string name_ |
Definition at line 1173 of file cursorwindow.h.
std::string value_ |
Definition at line 1175 of file cursorwindow.h.