2002-11-08 16:33:00 +00:00
|
|
|
// new_gui.hxx - XML-configurable GUI subsystem.
|
|
|
|
|
2002-11-07 16:27:47 +00:00
|
|
|
#ifndef __NEW_GUI_HXX
|
|
|
|
#define __NEW_GUI_HXX 1
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
# error This library requires C++
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <plib/pu.h>
|
|
|
|
|
|
|
|
#include <simgear/compiler.h> // for SG_USING_STD
|
|
|
|
#include <simgear/misc/props.hxx>
|
|
|
|
|
2002-11-07 22:59:46 +00:00
|
|
|
#include <vector>
|
|
|
|
SG_USING_STD(vector);
|
|
|
|
|
2002-11-07 16:27:47 +00:00
|
|
|
#include <map>
|
|
|
|
SG_USING_STD(map);
|
|
|
|
|
|
|
|
#include <Main/fgfs.hxx>
|
|
|
|
|
|
|
|
|
2002-11-08 16:33:00 +00:00
|
|
|
class GUIWidget;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* User data attached to a GUI object.
|
|
|
|
*/
|
|
|
|
struct GUIData
|
|
|
|
{
|
|
|
|
GUIData (GUIWidget * w, const char * a);
|
|
|
|
GUIWidget * widget;
|
|
|
|
string command;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Top-level GUI widget.
|
|
|
|
*/
|
2002-11-08 15:24:14 +00:00
|
|
|
class GUIWidget
|
2002-11-07 16:27:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2002-11-08 15:24:14 +00:00
|
|
|
GUIWidget (SGPropertyNode_ptr props);
|
|
|
|
virtual ~GUIWidget ();
|
2002-11-07 16:27:47 +00:00
|
|
|
|
2002-11-08 16:33:00 +00:00
|
|
|
virtual void action (const string &command);
|
2002-11-07 22:59:46 +00:00
|
|
|
|
2002-11-07 16:27:47 +00:00
|
|
|
private:
|
2002-11-08 15:24:14 +00:00
|
|
|
GUIWidget (const GUIWidget &); // just for safety
|
2002-11-08 16:33:00 +00:00
|
|
|
void display (SGPropertyNode_ptr props);
|
|
|
|
virtual void updateProperties ();
|
|
|
|
virtual void applyProperties ();
|
2002-11-07 16:27:47 +00:00
|
|
|
puObject * makeObject (SGPropertyNode * props,
|
|
|
|
int parentWidth, int parentHeight);
|
|
|
|
void setupObject (puObject * object, SGPropertyNode * props);
|
|
|
|
void setupGroup (puGroup * group, SGPropertyNode * props,
|
|
|
|
int width, int height, bool makeFrame = false);
|
|
|
|
|
2002-11-08 15:24:14 +00:00
|
|
|
puObject * _object;
|
2002-11-08 16:33:00 +00:00
|
|
|
vector<GUIData> _actions;
|
2002-11-07 22:59:46 +00:00
|
|
|
struct PropertyObject {
|
|
|
|
PropertyObject (puObject * object, SGPropertyNode_ptr node);
|
|
|
|
puObject * object;
|
|
|
|
SGPropertyNode_ptr node;
|
|
|
|
};
|
|
|
|
vector<PropertyObject> _propertyObjects;
|
2002-11-07 16:27:47 +00:00
|
|
|
};
|
|
|
|
|
2002-11-08 15:24:14 +00:00
|
|
|
|
|
|
|
class NewGUI : public FGSubsystem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NewGUI ();
|
|
|
|
virtual ~NewGUI ();
|
|
|
|
virtual void init ();
|
|
|
|
virtual void update (double delta_time_sec);
|
|
|
|
virtual void display (const string &name);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void readDir (const char * path);
|
|
|
|
|
|
|
|
map<string,SGPropertyNode_ptr> _widgets;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2002-11-07 16:27:47 +00:00
|
|
|
#endif // __NEW_GUI_HXX
|
2002-11-08 16:33:00 +00:00
|
|
|
|
|
|
|
// end of new_gui.hxx
|