Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages | Examples

fgl::XUIBuilder Class Reference
[FGX dynamic GUI builder from XML file]

#include <fgx.h>

List of all members.


Detailed Description

This class is intended for creating, loading, saving and building of XUI files. It is container of top level widgets (FGWindow). All objects, widgets (aka Window) and its childrens (aka buttons) are identified by ID (const char*) only.
Note:
Each object in the system *MUST* have unique ID.
Your basic FGX program will look something like this:
    The file: 'some_widgets.xui'

    <?xml version="1.0" standalone="yes" ?>
    <xui>
        <widget id="id1" label="Yet another window" x="400" w="400" h="600" persistent="1" resize="1">
            <text label="A text label" x="32" y="32" foreground="000000" background="FFFFFF" />
        </widget>
    </xui>

    int main(int argc, char** argv)
    {
        FGApp app(2, argc, argv, APP_ALL);
        XUIBuilder ui;

        if (ui.LoadGUI("some_widgets.xui"))
        {
            ui.ConnectSignal("CloseApp", __CloseApplication);
            ui.Show("MyWindow");
            app.Run();
        }
        return 0;
    }


Public Member Functions

 XUIBuilder ()
bool LoadGUI (const char *fname, const char *widget=0)
bool SaveGUI (const char *fname)
void Show (const char *widget=0)
FGWindowGetWidget (const char *id)
XUIComponentFindObject (const char *widget_id, const char *component_id)
void AddWidget (const XUIWindow &widget)
bool DeleteWidget (const char *id)
bool SetData (const char *widget_id, const char *component_id, const char data[], int size)
bool SetData (const char *widget_id, const char *component_id, const int)
bool SetData (const char *widget_id, const char *component_id, const double)

Static Protected Member Functions

static void CloseApplication (CallBack cb, void *)
static void CloseWindow (CallBack cb, void *)

Protected Attributes

WidgetList widgets


Constructor & Destructor Documentation

fgl::XUIBuilder::XUIBuilder  ) 
 

Creates an object with empty list of widgets. You must create this one prior to work with XUI files. There is no reason to build more than one object of this type at the time. This object registers some built-in signal handlers when invoked first time.

  • "__CloseWindow" - you can use this signal name to close window itself.
  • "__CloseApplication" - you can use this signal name to terminate application.


Member Function Documentation

void fgl::XUIBuilder::AddWidget const XUIWindow widget  ) 
 

Insert a copy of Widget at the end of list of objects.

Note:
There are not any test to multiple adding.

bool fgl::XUIBuilder::DeleteWidget const char *  id  ) 
 

Removes copy of Widget with this ID from the list of object.

Note:
if Widget is shown then will be closed first (WindowClose() is called).

XUIComponent * fgl::XUIBuilder::FindObject const char *  widget_id,
const char *  component_id
 

Find concrete Component (e.g. button) in concrete Widget.

Parameters:
widget_id ID of Widget to contains Component
component_id ID of Component to find
Returns:
0 or component if found

FGWindow * fgl::XUIBuilder::GetWidget const char *  id  ) 
 

Find Widget with this ID.

Parameters:
id unique id of Widget to find.
Returns:
Widget pointer (aka FGWindow pointer) if succes or 0.

bool fgl::XUIBuilder::LoadGUI const char *  fname,
const char *  widget = 0
 

Loads the widget from XUI document (or its part only) into XUIBuilder object. If object already contains some data, the new one are merged at the end. Load & Save XUI document are fully reversible.

Parameters:
fname file name
widget if nonzero, loads widget with this ID from XUI file only
Returns:
true if success

bool fgl::XUIBuilder::SaveGUI const char *  fname  ) 
 

Saves the whole object as XUI document. Load & Save XUI document are fully reversible.

Parameters:
fname file name
Returns:
true if success

bool fgl::XUIBuilder::SetData const char *  widget_id,
const char *  component_id,
const   double
 

Set some data to the concrete Component.

Parameters:
widget_id ID of Widget to contains Component
component_id ID of Component to set.
value value to set
Returns:
true if succes

bool fgl::XUIBuilder::SetData const char *  widget_id,
const char *  component_id,
const   int
 

Set some data to the concrete Component (e.g. integer to Slider).

Parameters:
widget_id ID of Widget to contains Component
component_id ID of Component to set.
value value to set
Returns:
true if succes

bool fgl::XUIBuilder::SetData const char *  widget_id,
const char *  component_id,
const char  data[],
int  size
 

Set some data to the concrete Component (e.g. string to EditBox).

Parameters:
widget_id ID of Widget to contains Component
component_id ID of Component to set.
data string to set
size size of string
Returns:
true if succes

void fgl::XUIBuilder::Show const char *  widget = 0  ) 
 

Shows one or all widgets.

Parameters:
widget show widget with this ID only


Generated on Wed Feb 9 11:31:55 2005 for OpenGUI by  doxygen 1.4.0