Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb::TBWidgetsReader Class Reference

TBWidgetsReader parse a resource file (or buffer) into a TBNode tree, and turns it into a hierarchy of widgets. More...

#include <tb_widgets_reader.h>

Public Member Functions

bool AddFactory (TBWidgetFactory *wf)
 Add a widget factory. More...
 
void RemoveFactory (TBWidgetFactory *wf)
 
bool LoadFile (TBWidget *target, const TBStr &filename)
 
bool LoadFormatted (TBWidget *target, const char *format,...) TB_POST_FORMAT(3
 
bool bool LoadData (TBWidget *target, const char *data)
 
bool LoadData (TBWidget *target, const char *data, int data_len)
 
void LoadNodeTree (TBWidget *target, TBNode *node)
 
bool DumpFile (TBWidget *source, const TBStr &filename)
 
bool DumpData (TBWidget *source, TBStr &data)
 

Static Public Member Functions

static TBWidgetsReaderCreate ()
 
static void SetIDFromNode (TBID &id, TBNode *node)
 Set the id from the given node. More...
 

Detailed Description

TBWidgetsReader parse a resource file (or buffer) into a TBNode tree, and turns it into a hierarchy of widgets.

It can create all types of widgets that have a registered factory (TBWidgetFactory). All core widgets have a factory by default, and you can also add your own.

Values may be looked up from any existing TBNodeRefTree using the syntax "@treename>noderequest". If treename is left out, the request will be looked up in the same node tree. In addition to this, strings will be looked up from the global TBLanguage by using the syntax "@stringid"

Branches may be included or not depending on the value of a TBNodeRefTree node, using "@if @treename>noderequest" and optionally a following "@else".

Branches may be included from TBNodeRefTree using "@include @treename>noderequest", or included from nodes specified previosly in the same tree using "@include noderequest".

Files can be included by using the syntax "@file filename".

Each factory may have its own set of properties, but a set of generic properties is always supported on all widgets. Those are:

Resource name: TBWidget property: Values:

id TBWidget::m_id TBID (string or int) group-id TBWidget::m_group_id TBID (string or int) value TBWidget::SetValue integer data TBWidget::m_data integer is-group-root TBWidget::SetIsGroupRoot boolean is-focusable TBWidget::SetIsFocusable boolean want-long-click TBWidget::SetWantLongClick boolean ignore-input TBWidget::SetIgnoreInput boolean opacity TBWidget::SetOpacity float (0 - 1) text TBWidget::SetText string connection TBWidget::Connect string axis TBWidget::SetAxis x or y gravity TBWidget::SetGravity string (combination of left, top, right, bottom, or all) visibility TBWidget::SetVisibility string (visible, invisible, gone) state TBWidget::SetState string (disabled) skin TBWidget::SetSkinBg TBID (string or int) rect TBWidget::SetRect 4 integers (x, y, width, height) lp>width TBWidget::SetLayoutParams dimension lp>min-width TBWidget::SetLayoutParams dimension lp>max-width TBWidget::SetLayoutParams dimension lp>pref-width TBWidget::SetLayoutParams dimension lp>height TBWidget::SetLayoutParams dimension lp>min-height TBWidget::SetLayoutParams dimension lp>max-height TBWidget::SetLayoutParams dimension lp>pref-height TBWidget::SetLayoutParams dimension autofocus The TBWidget will be focused automatically the first time its TBWindow is activated. font>name Font name font>size Font size

Member Function Documentation

bool tb::TBWidgetsReader::AddFactory ( TBWidgetFactory wf)
inline

Add a widget factory.

Does not take ownership of the factory. The easiest way to add factories for custom widget types, is using the TB_WIDGET_FACTORY macro that automatically register it during startup.

void tb::TBWidgetsReader::SetIDFromNode ( TBID id,
TBNode node 
)
static

Set the id from the given node.


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