Image Component Library (ICL)
Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
icl::qt::DynamicGUI Class Reference

Special GUI implementation that allows for defining the GUI layout in an XML-file. More...

#include <DynamicGUI.h>

Inheritance diagram for icl::qt::DynamicGUI:
icl::qt::GUI icl::utils::Uncopyable

Classes

class  Node
 internal xml-parsing node class More...
 

Public Types

typedef utils::SmartPtr< NodeNodePtr
 typedef for node-pointers More...
 
typedef Node ParseTree
 A tree is simply the root-node. More...
 
typedef utils::SmartPtr< ParseTreeParseTreePtr
 pointer typedef More...
 
- Public Types inherited from icl::qt::GUI
typedef utils::Function< GUIWidget *, const GUIDefinition & > CreatorFunction
 registered widget type creator function More...
 
typedef utils::Function< void > Callback
 simple callback, that can be registered at GUI components More...
 
typedef utils::Function< void, const std::string & > ComplexCallback
 complex callback type that can be registered at GUI components More...
 

Public Member Functions

 DynamicGUI (const std::string &cfgFileName="", QWidget *parent=0)
 creates a new DynamicGUI instance from a given XML-description filename More...
 
 ~DynamicGUI ()
 Destructor. More...
 
void initialize (const std::string &cfgXMLString)
 intialize DynamicGUI instance from given XML-string More...
 
void load (const std::string &cfgFileName)
 intialize DynamicGUI instance from given XML-file More...
 
void release ()
 internally releases everything More...
 
ParseTreePtr getParseTree ()
 returns the internal parse-tree representation More...
 
- Public Member Functions inherited from icl::qt::GUI
 GUI (QWidget *parent=0)
 Default constructor, creates a vbox GUI Component. More...
 
 GUI (const GUIComponent &component, QWidget *parent=0)
 creates a GUI from a givne GUIComponent More...
 
 GUI (const GUI &gui, QWidget *parent=0)
 copy constructor More...
 
GUIoperator= (const GUI &other)
 gui-copy operator More...
 
virtual ~GUI ()
 Destructor. More...
 
virtual GUIoperator<< (const GUIComponent &component)
 adds a new GUI component More...
 
virtual GUIoperator<< (const GUI &g)
 stream operator to add new other GUIs More...
 
template<class T >
T & allocValue (const std::string &id, const T &val=T())
 wraps the data-stores allocValue function More...
 
template<class T >
void release (const std::string &id)
 wraps the datastores release function More...
 
template<class T >
T & get (const std::string &id, bool typeCheck=true)
 
DataStore::Data operator[] (const std::string &key)
 returns a Data instance from the datastore More...
 
template<class T >
std::vector< T > collect (const std::vector< std::string > &keys)
 collects data from different components at once More...
 
virtual bool isVisible () const
 returns whether this gui is actually visible More...
 
virtual void create ()
 internally creates everything More...
 
virtual void show ()
 internally creates everything (and makes the gui visible) More...
 
virtual void hide ()
 make this gui invisible (nothing more) More...
 
virtual void switchVisibility ()
 if widget is visible, this hides the widget, otherwise the widget is shown More...
 
GUIWidgetgetRootWidget ()
 returns the root widget of the gui (only avialable after create() or show()) More...
 
void lockData ()
 internally locks the datastore More...
 
void unlockData ()
 internally unlocks the data store More...
 
void waitForCreation ()
 waits for the gui to be created completely More...
 
const DataStoregetDataStore () const
 returns the GUI internal dataStore More...
 
void registerCallback (const Callback &cb, const std::string &handleNamesList, char listDelim=',')
 registers a callback function on each component More...
 
void registerCallback (const ComplexCallback &cb, const std::string &handleNamesList, char listDelim=',')
 registeres a complex callback at a given GUI component More...
 
void removeCallbacks (const std::string &handleNamesList, char listDelim=',')
 removes all callbacks from components More...
 
bool isDummy () const
 returns whether this GUI is a dummy GUI More...
 
bool hasBeenCreated () const
 returns whether this GUI has been created or not More...
 
std::string createXMLDescription () const
 creates a hierarchical xml-description of the GUI Layout More...
 

Private Member Functions

void initInternal (pugi::xml_node &root)
 internally used initialization method More...
 

Static Private Member Functions

static void traverse_tree (const pugi::xml_node &n, int level, utils::SmartPtr< DynamicGUI::Node > target)
 internal tree-traversal method More...
 
static void create_gui (Node &n)
 internal GUI-creation method More...
 

Private Attributes

Data * m_data
 internal data pointer More...
 

Friends

std::ostream & operator<< (std::ostream &s, const DynamicGUI::Node &n)
 ostream operator for the node class More...
 

Additional Inherited Members

- Static Public Member Functions inherited from icl::qt::GUI
static void register_widget_type (const std::string &tag, CreatorFunction f)
 registers a new widget type More...
 
static GUI create_gui_from_string (const std::string &definition, QWidget *parent)
 legacy creation method (use with care) More...
 
- Static Public Attributes inherited from icl::qt::GUI
static const int CELLW = 20
 cell width (all sizes are given in this unit) More...
 
static const int CELLH = 20
 cell height (all sizes are given in this unit) More...
 
- Protected Member Functions inherited from icl::qt::GUI
 GUI (const std::string &definition, QWidget *parent)
 default constructor More...
 
virtual std::string createDefinition () const
 can be overwritten in subclasses (such as ContainerGUIComponent) More...
 
- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 

Detailed Description

Special GUI implementation that allows for defining the GUI layout in an XML-file.

In some cases, it might be useful to not embed the design of the GUI layout into the c++-source code. To this end, ICL provides the DynamicGUI class, which is defined from XML that is dynamically loaded and parsed at runtime. By this, it is possible to add or re-arrange GUI components or to adapt features of these such as sizes or labels dynamically, i.e. without having to recompile the C++ application. The abstraction mechanism can also be used to implement different GUI layouts e.g. optimized for different screen resolutions.

Here is an examplary xml-definition file

  <?xml version="1.0"?>
  <hbox>
    <vbox minsize="16x12" label="a box">
      <button args="Push" minsize="10x2" handle="the button">
      <togglebutton args="Toggle,Me" minsize="10x2" handle="the t-button">
      <string args="test,20" handle="string">
      <int args="0,1000,500" handle="int">
      <checkbox args="my checkbox,toggled" handle="checkbox">
      <float args="-0.2,0.8,0.6" handle="float" label="float">
    </vbox>
    <include href="other.xml"/>
    <vsplit>
      <image minsize="16x12" label="an image" handle="image">
      <slider args="0,255,0" label="the slider" handle="s">
      <hbox>
        <image minsize="16x12" label="another image" handle="what">
        <slider args="0,255,0" label="yet another slider">
      </hbox>
    </vsplit>
    <hbox margin="20" label="box with margin">
      <image minsize="16x12" label="last image then" handle="otherimage">
      <slider args="0,255,0" label="slider slider slider">
    </hbox>
  </hbox>

As one can see, the hierarchical GUI definition syntax is generically translated to the XML-structure.

the include tag

With the include tag, (e.g. <include href="other.xml"/>) GUI files can even be included in a hierarchical fashion, but here, the user has to take care to not create infinite inclusion loops.

Member Typedef Documentation

◆ NodePtr

typedef for node-pointers

◆ ParseTree

A tree is simply the root-node.

◆ ParseTreePtr

pointer typedef

Constructor & Destructor Documentation

◆ DynamicGUI()

icl::qt::DynamicGUI::DynamicGUI ( const std::string &  cfgFileName = "",
QWidget *  parent = 0 
)

creates a new DynamicGUI instance from a given XML-description filename

if cfgFileName is "", a null GUI instance is created that can be initialized in hindsight using initialize or load

◆ ~DynamicGUI()

icl::qt::DynamicGUI::~DynamicGUI ( )

Destructor.

Member Function Documentation

◆ create_gui()

static void icl::qt::DynamicGUI::create_gui ( Node n)
staticprivate

internal GUI-creation method

◆ getParseTree()

ParseTreePtr icl::qt::DynamicGUI::getParseTree ( )

returns the internal parse-tree representation

◆ initialize()

void icl::qt::DynamicGUI::initialize ( const std::string &  cfgXMLString)

intialize DynamicGUI instance from given XML-string

here, the XML-string is already in memory

◆ initInternal()

void icl::qt::DynamicGUI::initInternal ( pugi::xml_node &  root)
private

internally used initialization method

◆ load()

void icl::qt::DynamicGUI::load ( const std::string &  cfgFileName)

intialize DynamicGUI instance from given XML-file

◆ release()

void icl::qt::DynamicGUI::release ( )

internally releases everything

◆ traverse_tree()

static void icl::qt::DynamicGUI::traverse_tree ( const pugi::xml_node &  n,
int  level,
utils::SmartPtr< DynamicGUI::Node target 
)
staticprivate

internal tree-traversal method

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  s,
const DynamicGUI::Node n 
)
friend

ostream operator for the node class

Member Data Documentation

◆ m_data

Data* icl::qt::DynamicGUI::m_data
private

internal data pointer


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