#include <glv_core.h>
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 void | onDraw () |
Main drawing callback. | |
virtual bool | onEvent (Event::t e, GLV &glv) |
Main event callback to be called after those in callback list. | |
virtual void | onResize (space_t dx, space_t dy) |
Resize callback. | |
virtual void | onModelSync () |
Sync self to 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. | |
View & | operator<< (View &newChild) |
Add a child view to myself. | |
StyleColor & | colors () const |
Returns my style colors. | |
int | enabled (Property::t v) const |
Returns whether a property is set. | |
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 whether View visibility flag is set. | |
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 & | name (const std::string &v) |
Set name. | |
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. | |
Static Public Member Functions | |
static void | traverseDepth (View *top, TraversalAction &action) |
Traverse tree depth-first. | |
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. | |
Classes | |
struct | TraversalAction |
An action to be called when traversing the node tree. More... |
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.