Empirical
|
Widget is effectively a smart pointer to a WidgetInfo object, plus some basic accessors. More...
#include <Widget.h>
Public Member Functions | |
Widget (const std::string &id) | |
When Widgets are first created, they should be provided with an ID. More... | |
Widget (WidgetInfo *in_info=nullptr) | |
Widget (const Widget &in) | |
Widget & | operator= (const Widget &in) |
virtual | ~Widget () |
bool | IsNull () const |
Test if this widget is valid. More... | |
std::string | InfoTypeName () const |
Some debugging helpers... More... | |
bool | IsInactive () const |
Test if the activity state of this widget is currently INACTIVE. More... | |
bool | IsWaiting () const |
Test if the activity state of this widget is currently WAITING. More... | |
bool | IsFrozen () const |
Test if the activity state of this widget is currently FROZEN. More... | |
bool | IsActive () const |
Test if the activity state of this widget is currently ACTIVE. More... | |
bool | AppendOK () const |
Is it okay to add more internal Widgets into this one? More... | |
void | PreventAppend () |
Disallow further appending to this Widget. More... | |
bool | IsButton () const |
Is this Widget a Button? More... | |
bool | IsCanvas () const |
Is this Widget a Canvas? More... | |
bool | IsImage () const |
Is this Widget an Image? More... | |
bool | IsSelector () const |
Is this Widget a Selector? More... | |
bool | IsDiv () const |
Is this Widget a Div? More... | |
bool | IsTable () const |
Is this Widget a Table? More... | |
bool | IsText () const |
Is this Widget a Text? More... | |
const std::string & | GetID () const |
What is the HTML string ID for this Widget? More... | |
virtual std::string | GetCSS (const std::string &setting) |
virtual bool | HasCSS (const std::string &setting) |
Determine is a CSS trait has been set on this Widget. More... | |
virtual std::string | GetAttr (const std::string &setting) |
Retrieve a specific attribute associated with this Widget. More... | |
virtual bool | HasAttr (const std::string &setting) |
Determine is an attribute has been set on this Widget. More... | |
bool | operator== (const Widget &in) const |
Are two Widgets refering to the same HTML object? More... | |
bool | operator!= (const Widget &in) const |
Are two Widgets refering to differnt HTML objects? More... | |
operator bool () const | |
Conver Widget to bool (I.e., is this Widget active?) More... | |
double | GetXPos () |
Get the X-position of this Widget within its parent. More... | |
double | GetYPos () |
Get the Y-position of this Widget within its parent. More... | |
double | GetWidth () |
Get the width of this Widget on screen. More... | |
double | GetHeight () |
Get the height of this Widget on screen. More... | |
double | GetInnerWidth () |
Get the width of this Widget not including padding. More... | |
double | GetInnerHeight () |
Get the height of this Widget not including padding. More... | |
double | GetOuterWidth () |
Get the width of this Widget including all padding. More... | |
double | GetOuterHeight () |
Get the height of this Widget including all padding. More... | |
void | Activate () |
Make this widget live, so changes occur immediately (once document is ready) More... | |
void | Freeze () |
Record changes internally, but keep static screen until Activate() is called. More... | |
virtual void | Deactivate (bool top_level=true) |
bool | ToggleActive () |
Doggle between Active and Deactivated. More... | |
void | Redraw () |
Clear and redraw the current widget on the screen. More... | |
Widget & | Find (const std::string &test_name) |
Look up previously created elements, by type. More... | |
Widget & | AddDependant (const Widget &w) |
Add a dependant to this Widget that should be redrawn when it is. More... | |
virtual void | PrepareAppend () |
Setup << operator to redirect to Append; option preparation can be overridden. More... | |
template<typename IN_TYPE > | |
Widget | operator<< (IN_TYPE &&in_val) |
std::string | GetInfoType () const |
Debug... More... | |
Protected Types | |
enum | ActivityState { INACTIVE, WAITING, FROZEN, ACTIVE } |
using | WidgetInfo = internal::WidgetInfo |
Protected Member Functions | |
template<typename FWD_TYPE > | |
Widget & | ForwardAppend (FWD_TYPE &&arg) |
If an Append doesn't work with current class, forward it to the parent and try there. More... | |
Widget & | SetInfo (WidgetInfo *in_info) |
Set the information associated with this widget. More... | |
WidgetInfo * | operator-> () |
Internally, we can treat a Widget as a pointer to its WidgetInfo. More... | |
Static Protected Member Functions | |
static WidgetInfo * | Info (const Widget &w) |
Give derived classes the ability to access widget info. More... | |
Protected Attributes | |
WidgetInfo * | info |
Information associated with this widget. More... | |
Static Protected Attributes | |
static const std::string | no_name = "(none)" |
Default name for un-initialized widgets. More... | |
Widget is effectively a smart pointer to a WidgetInfo object, plus some basic accessors.
|
protected |
|
protected |
emp::web::Widget::Widget | ( | const std::string & | id | ) |
When Widgets are first created, they should be provided with an ID.
emp::web::Widget::Widget | ( | WidgetInfo * | in_info = nullptr | ) |
|
inline |
|
virtual |
void emp::web::Widget::Activate | ( | ) |
Make this widget live, so changes occur immediately (once document is ready)
Add a dependant to this Widget that should be redrawn when it is.
bool emp::web::Widget::AppendOK | ( | ) | const |
Is it okay to add more internal Widgets into this one?
|
virtual |
Record changes internally and REMOVE from screen until Activate is called. (Argument is for recursive, internal use only.)
Reimplemented in emp::web::Div.
Widget& emp::web::Widget::Find | ( | const std::string & | test_name | ) |
Look up previously created elements, by type.
|
protected |
If an Append doesn't work with current class, forward it to the parent and try there.
void emp::web::Widget::Freeze | ( | ) |
Record changes internally, but keep static screen until Activate() is called.
|
virtual |
Retrieve a specific attribute associated with this Widget.
|
virtual |
Retrieve a specific CSS trait associated with this Widget. Note: CSS-related options may be overridden in derived classes that have multiple styles.
Reimplemented in emp::web::TableWidget, emp::web::TableCell, emp::web::TableCol, emp::web::TableColGroup, emp::web::TableRowGroup, and emp::web::TableRow.
double emp::web::Widget::GetHeight | ( | ) |
Get the height of this Widget on screen.
const std::string & emp::web::Widget::GetID | ( | ) | const |
What is the HTML string ID for this Widget?
std::string emp::web::Widget::GetInfoType | ( | ) | const |
Debug...
double emp::web::Widget::GetInnerHeight | ( | ) |
Get the height of this Widget not including padding.
double emp::web::Widget::GetInnerWidth | ( | ) |
Get the width of this Widget not including padding.
double emp::web::Widget::GetOuterHeight | ( | ) |
Get the height of this Widget including all padding.
double emp::web::Widget::GetOuterWidth | ( | ) |
Get the width of this Widget including all padding.
double emp::web::Widget::GetWidth | ( | ) |
Get the width of this Widget on screen.
double emp::web::Widget::GetXPos | ( | ) |
Get the X-position of this Widget within its parent.
double emp::web::Widget::GetYPos | ( | ) |
Get the Y-position of this Widget within its parent.
|
virtual |
Determine is an attribute has been set on this Widget.
|
virtual |
Determine is a CSS trait has been set on this Widget.
|
inlinestaticprotected |
Give derived classes the ability to access widget info.
std::string emp::web::Widget::InfoTypeName | ( | ) | const |
Some debugging helpers...
bool emp::web::Widget::IsActive | ( | ) | const |
Test if the activity state of this widget is currently ACTIVE.
bool emp::web::Widget::IsFrozen | ( | ) | const |
Test if the activity state of this widget is currently FROZEN.
bool emp::web::Widget::IsInactive | ( | ) | const |
Test if the activity state of this widget is currently INACTIVE.
|
inline |
Test if this widget is valid.
bool emp::web::Widget::IsWaiting | ( | ) | const |
Test if the activity state of this widget is currently WAITING.
|
inline |
|
inline |
Are two Widgets refering to differnt HTML objects?
|
inlineprotected |
Internally, we can treat a Widget as a pointer to its WidgetInfo.
Widget emp::web::Widget::operator<< | ( | IN_TYPE && | in_val | ) |
|
inline |
Are two Widgets refering to the same HTML object?
|
inlinevirtual |
Setup << operator to redirect to Append; option preparation can be overridden.
Reimplemented in emp::web::TableWidget.
void emp::web::Widget::PreventAppend | ( | ) |
Disallow further appending to this Widget.
void emp::web::Widget::Redraw | ( | ) |
Clear and redraw the current widget on the screen.
|
protected |
Set the information associated with this widget.
bool emp::web::Widget::ToggleActive | ( | ) |
Doggle between Active and Deactivated.
|
protected |
Information associated with this widget.
|
staticprotected |
Default name for un-initialized widgets.