Empirical
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
emp::web::Widget Class Reference

Widget is effectively a smart pointer to a WidgetInfo object, plus some basic accessors. More...

#include <Widget.h>

Inheritance diagram for emp::web::Widget:
emp::web::internal::WidgetFacet< RETURN_TYPE > emp::web::internal::WidgetFacet< Button > emp::web::internal::WidgetFacet< Canvas > emp::web::internal::WidgetFacet< D3Visualization > emp::web::internal::WidgetFacet< Div > emp::web::internal::WidgetFacet< FileInput > emp::web::internal::WidgetFacet< Image > emp::web::internal::WidgetFacet< Selector > emp::web::internal::WidgetFacet< TableWidget > emp::web::internal::WidgetFacet< Text > emp::web::internal::WidgetFacet< TextArea >

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)
 
Widgetoperator= (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...
 
WidgetFind (const std::string &test_name)
 Look up previously created elements, by type. More...
 
WidgetAddDependant (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 >
WidgetForwardAppend (FWD_TYPE &&arg)
 If an Append doesn't work with current class, forward it to the parent and try there. More...
 
WidgetSetInfo (WidgetInfo *in_info)
 Set the information associated with this widget. More...
 
WidgetInfooperator-> ()
 Internally, we can treat a Widget as a pointer to its WidgetInfo. More...
 

Static Protected Member Functions

static WidgetInfoInfo (const Widget &w)
 Give derived classes the ability to access widget info. More...
 

Protected Attributes

WidgetInfoinfo
 Information associated with this widget. More...
 

Static Protected Attributes

static const std::string no_name = "(none)"
 Default name for un-initialized widgets. More...
 

Detailed Description

Widget is effectively a smart pointer to a WidgetInfo object, plus some basic accessors.

Member Typedef Documentation

Member Enumeration Documentation

Four activity states for any widget: INACTIVE - Not be in DOM at all. WAITING - Will become active once the page finishes loading. FROZEN - Part of DOM, but not updating on the screen. ACTIVE - Fully active; changes are reflected as they happen.

Enumerator
INACTIVE 
WAITING 
FROZEN 
ACTIVE 

Constructor & Destructor Documentation

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)
emp::web::Widget::Widget ( const Widget in)
inline
emp::web::Widget::~Widget ( )
virtual

Member Function Documentation

void emp::web::Widget::Activate ( )

Make this widget live, so changes occur immediately (once document is ready)

Widget & emp::web::Widget::AddDependant ( const Widget w)

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?

void emp::web::Widget::Deactivate ( bool  top_level = true)
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.

template<typename FWD_TYPE >
Widget& emp::web::Widget::ForwardAppend ( FWD_TYPE &&  arg)
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.

std::string emp::web::Widget::GetAttr ( const std::string &  setting)
virtual

Retrieve a specific attribute associated with this Widget.

std::string emp::web::Widget::GetCSS ( const std::string &  setting)
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.

bool emp::web::Widget::HasAttr ( const std::string &  setting)
virtual

Determine is an attribute has been set on this Widget.

bool emp::web::Widget::HasCSS ( const std::string &  setting)
virtual

Determine is a CSS trait has been set on this Widget.

static WidgetInfo* emp::web::Widget::Info ( const Widget w)
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::IsButton ( ) const

Is this Widget a Button?

bool emp::web::Widget::IsCanvas ( ) const

Is this Widget a Canvas?

bool emp::web::Widget::IsDiv ( ) const

Is this Widget a Div?

bool emp::web::Widget::IsFrozen ( ) const

Test if the activity state of this widget is currently FROZEN.

bool emp::web::Widget::IsImage ( ) const

Is this Widget an Image?

bool emp::web::Widget::IsInactive ( ) const

Test if the activity state of this widget is currently INACTIVE.

bool emp::web::Widget::IsNull ( ) const
inline

Test if this widget is valid.

bool emp::web::Widget::IsSelector ( ) const

Is this Widget a Selector?

bool emp::web::Widget::IsTable ( ) const

Is this Widget a Table?

bool emp::web::Widget::IsText ( ) const

Is this Widget a Text?

bool emp::web::Widget::IsWaiting ( ) const

Test if the activity state of this widget is currently WAITING.

emp::web::Widget::operator bool ( ) const
inline

Conver Widget to bool (I.e., is this Widget active?)

bool emp::web::Widget::operator!= ( const Widget in) const
inline

Are two Widgets refering to differnt HTML objects?

WidgetInfo* emp::web::Widget::operator-> ( )
inlineprotected

Internally, we can treat a Widget as a pointer to its WidgetInfo.

template<typename IN_TYPE >
Widget emp::web::Widget::operator<< ( IN_TYPE &&  in_val)
Widget& emp::web::Widget::operator= ( const Widget in)
inline
bool emp::web::Widget::operator== ( const Widget in) const
inline

Are two Widgets refering to the same HTML object?

virtual void emp::web::Widget::PrepareAppend ( )
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.

Widget & emp::web::Widget::SetInfo ( WidgetInfo in_info)
protected

Set the information associated with this widget.

bool emp::web::Widget::ToggleActive ( )

Doggle between Active and Deactivated.

Member Data Documentation

WidgetInfo* emp::web::Widget::info
protected

Information associated with this widget.

const std::string emp::web::Widget::no_name = "(none)"
staticprotected

Default name for un-initialized widgets.


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