Empirical
Classes | Namespaces | Functions
Widget.h File Reference

Widgets maintain individual components on a web page and link to Elements. More...

#include <string>
#include "../base/vector.h"
#include "../tools/mem_track.h"
#include "events.h"
#include "Font.h"
#include "init.h"
#include "WidgetExtras.h"

Go to the source code of this file.

Classes

class  emp::web::internal::WidgetCommand
 Base class for command-objects that can be fed into widgets. More...
 
class  emp::web::Widget
 Widget is effectively a smart pointer to a WidgetInfo object, plus some basic accessors. More...
 
class  emp::web::internal::WidgetInfo
 
class  emp::web::internal::WidgetFacet< RETURN_TYPE >
 WidgetFacet is a template that provides accessors into Widget with a derived return type. More...
 

Namespaces

 emp
 If we are in emscripten, make sure to include the header.
 
 emp::web
 
 emp::web::internal
 

Functions

static size_t emp::web::internal::NextWidgetNum (bool inc_num=true)
 Quick method for generating unique Widget ID numbers when not otherwise specified. More...
 
static std::string emp::web::internal::NextWidgetID ()
 Quick method for generating unique string IDs for Widgets. More...
 

Detailed Description

Widgets maintain individual components on a web page and link to Elements.

Note
This file is part of Empirical, https://github.com/devosoft/Empirical
Date
2015-2017

Each HTML Widget has all of its details stored in a WidgetInfo object; Multiple Widgets can be attached to the same WidgetInfo, simplifying the usage. All the library user needs to worry about is the Widget object itself; the WidgetInfo will be managed behind the scenes.

WidgetInfo contains the basic information for all Widgets Widget is a generic base class, with a shared pointer to WidgetInfo WidgetFacet is a template that allows Set* methods to return derived return-type.

In other files, Widgets will be used to define specific elements. ELEMENTInfo maintains information about the specific widget (derived from WidgetInfo) ELEMENT interfaces to ELEMENTInfo so multiple elements use same core; derived from WidgetFacet

Library users should not need to access Widgets directly, only specific derived types.

Tips for using widgets:

  1. If you are about to make a lot of changes at once, run Freeze(), make the changes, and then run Activate() again. Freeze prevents widgets from being updated immediately.
  2. Trust the Widget to handle all of the manipulation behind the scenes