The base class of all GUI elements. More...
#include <glv_core.h>
Classes | |
struct | TraversalAction |
An action to be called when traversing the node tree. More... | |
Public Member Functions | |
View (space_t left, space_t top, space_t width, space_t height, drawCallback cb=0) | |
View (const Rect &rect=Rect(200, 200), Place::t anchor=Place::TL, drawCallback cb=0) | |
virtual const char * | className () const |
Get class name. | |
virtual void | onAnimate (double dsec, GLV &g) |
Animation callback. | |
virtual void | onDraw (GLV &g) |
Drawing callback. | |
virtual bool | onEvent (Event::t e, GLV &g) |
Event callback to be called after those in callback list. | |
virtual void | onResize (space_t dx, space_t dy) |
Resize callback. | |
virtual void | onDataModelSync () |
Update internal values if different from attached model variables. | |
void | add (View &child) |
Add a child view to myself, and update linked lists. | |
void | add (View *child) |
Add a child view to myself, and update linked lists. | |
void | makeLastSibling () |
Put self at end of sibling chain. | |
void | remove () |
Remove myself from the parent view, and update linked lists. | |
void | traverseDepth (TraversalAction &action) |
Traverse tree depth-first applying an action at each node. | |
View & | operator<< (View &newChild) |
Add a child view to myself. | |
StyleColor & | colors () const |
Get style colors. | |
const std::string & | descriptor () const |
Get descriptor. | |
int | enabled (Property::t v) const |
Returns whether a property is set. | |
Font & | font () |
Get font. | |
bool | hasCallback (Event::t e, eventCallback cb) const |
Returns whether a particular callback has been registered. | |
bool | hasCallbacks (Event::t e) const |
Returns whether there are callback(s) registered for a particular event. | |
const std::string & | name () const |
Get name. | |
int | numCallbacks (Event::t e) const |
Returns number of registered callbacks. | |
const View * | posAbs (space_t &al, space_t &at) const |
Computes absolute left-top position. Returns topmost parent view. | |
void | printDescendents () const |
Print tree of descendent Views to stdout. | |
bool | showing () const |
Returns whether View is being shown. | |
Style & | style () const |
Get style object. | |
const View * | toAbs (space_t &x, space_t &y) const |
Converts relative View x-y coordinates to absolute. Returns topmost parent view. | |
int | visible () const |
Returns model value(s) as string. | |
View & | anchor (space_t mx, space_t my) |
Set translation factors relative to parent resize amount. | |
View & | anchor (Place::t parentPlace) |
Set translation factors relative to parent resize amount. | |
void | addCallback (Event::t type, eventCallback cb) |
Push an event callback onto the back of the event callbacks list. | |
View & | disable (Property::t p) |
Disable property flag(s). | |
View & | enable (Property::t p) |
Enable property flag(s). | |
View & | property (Property::t p, bool v) |
Set property flag(s) to a specfic value. | |
View & | toggle (Property::t p) |
Toggle property flag(s). | |
View & | bringToFront () |
Brings to front of parent View. | |
View & | cloneStyle () |
Creates own copy of current style. | |
void | constrainWithinParent () |
Force to remain in parent. | |
View * | findTarget (space_t &x, space_t &y) |
Returns View under these absolute coordinates or 0 if none. | |
void | fit () |
Fit geometry so all children are visible. | |
void | focused (bool b) |
Set whether I'm focused. | |
void | move (space_t x, space_t y) |
Translate constraining within parent. | |
void | on (Event::t e, eventCallback cb=0) |
Set first callback for a specific event type. | |
void | removeCallback (Event::t e, eventCallback cb) |
Remove a callback for a given event (if found). | |
void | removeAllCallbacks (Event::t e) |
Detach all callbacks for a given event. | |
View & | descriptor (const std::string &v) |
Set descriptor, e.g. tooltip text. | |
View & | name (const std::string &v) |
Set identifier string. | |
View & | pos (Place::t p, space_t x, space_t y) |
Position a specific place at point (x,y). | |
View & | pos (Place::t p) |
Position a specific place at point (0,0). | |
View & | stretch (space_t mx, space_t my) |
Set parent resize stretch factors. | |
View & | style (Style *style) |
Set pointer to style. | |
View & | maximize () |
Matches geometry to parent. | |
View & | restore () |
Undoes maximization. | |
void | rectifyGeometry () |
Correct geometry for proper display. | |
Public Attributes | |
View * | parent |
My parent view. | |
View * | child |
My first child (next to be drawn). | |
View * | sibling |
My next sibling view (drawn after all my children). | |
std::map< Event::t, eventCallbackList > | callbackLists |
Map of event callback sequences. | |
drawCallback | draw |
Drawing callback. |
The base class of all GUI elements.
glv::View::View | ( | space_t | left, | |
space_t | top, | |||
space_t | width, | |||
space_t | height, | |||
drawCallback | cb = 0 | |||
) |
[in] | left | Initial left edge position |
[in] | top | Initial top edge position |
[in] | width | Initial width |
[in] | height | Initial height |
[in] | cb | Drawing callback |
glv::View::View | ( | const Rect & | rect = Rect(200, 200) , |
|
Place::t | anchor = Place::TL , |
|||
drawCallback | cb = 0 | |||
) |
[in] | rect | Rect geometry of View |
[in] | anchor | Anchor place |
[in] | cb | Drawing callback |
void glv::View::addCallback | ( | Event::t | type, | |
eventCallback | cb | |||
) |
Push an event callback onto the back of the event callbacks list.
If the event callback already exists in the list, then it will be not be added. If multiple callbacks are registered for the same event type, then two types of prioritization take place. First, callbacks on the front of the list get called first. Second, if a callback returns false (for bubbling), then it cancels execution of any subsequent callbacks in the list.
View * glv::View::findTarget | ( | space_t & | x, | |
space_t & | y | |||
) |
Returns View under these absolute coordinates or 0 if none.
The coordinates are modified to be relative to the returned View's.
View & glv::View::name | ( | const std::string & | v | ) |
Set identifier string.
The name should follow the same conventions as identifiers in C. I.e., it can be any string of letters, digits, and underscores, not beginning with a digit. If the argument is not a valid identifier, then the name will not be set.
int glv::View::visible | ( | ) | const [inline] |
Returns model value(s) as string.
Returns whether View visibility flag is set