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-12-22 19:52:26 +00:00
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
#include <Input/input.hxx>
|
2002-11-07 16:27:47 +00:00
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
class FGMenuBar;
|
2002-11-08 16:33:00 +00:00
|
|
|
class GUIWidget;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-22 19:52:26 +00:00
|
|
|
* Information about a GUI widget.
|
2002-11-08 16:33:00 +00:00
|
|
|
*/
|
2002-12-22 19:52:26 +00:00
|
|
|
struct GUIInfo
|
2002-11-08 16:33:00 +00:00
|
|
|
{
|
2002-12-22 19:52:26 +00:00
|
|
|
GUIInfo (GUIWidget * w);
|
|
|
|
virtual ~GUIInfo ();
|
|
|
|
|
2002-11-08 16:33:00 +00:00
|
|
|
GUIWidget * widget;
|
2002-12-22 19:52:26 +00:00
|
|
|
vector <FGBinding *> bindings;
|
2002-11-08 16:33:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Top-level GUI widget.
|
|
|
|
*/
|
2002-11-08 15:24:14 +00:00
|
|
|
class GUIWidget
|
2002-11-07 16:27:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2002-12-22 19:52:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct a new GUI widget configured by a property tree.
|
|
|
|
*/
|
2002-11-08 15:24:14 +00:00
|
|
|
GUIWidget (SGPropertyNode_ptr props);
|
2002-12-22 19:52:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor.
|
|
|
|
*/
|
2002-11-08 15:24:14 +00:00
|
|
|
virtual ~GUIWidget ();
|
2002-11-07 16:27:47 +00:00
|
|
|
|
2002-12-22 19:52:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the values of all GUI objects with a specific name.
|
|
|
|
*
|
|
|
|
* This method copies from the property to the GUI object.
|
|
|
|
*
|
|
|
|
* @param objectName The name of the GUI object(s) to update.
|
|
|
|
* Use the empty name for all unnamed objects.
|
|
|
|
*/
|
|
|
|
virtual void updateValue (const char * objectName);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Apply the values of all GUI objects with a specific name.
|
|
|
|
*
|
|
|
|
* This method copies from the GUI object to the property.
|
|
|
|
*
|
|
|
|
* @param objectName The name of the GUI object(s) to update.
|
|
|
|
* Use the empty name for all unnamed objects.
|
|
|
|
*/
|
|
|
|
virtual void applyValue (const char * objectName);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the values of all GUI objects.
|
|
|
|
*
|
|
|
|
* This method copies from the properties to the GUI objects.
|
|
|
|
*/
|
|
|
|
virtual void updateValues ();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Apply the values of all GUI objects.
|
|
|
|
*
|
|
|
|
* This method copies from the GUI objects to the properties.
|
|
|
|
*/
|
|
|
|
virtual void applyValues ();
|
|
|
|
|
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-12-22 19:52:26 +00:00
|
|
|
|
2002-11-08 16:33:00 +00:00
|
|
|
void display (SGPropertyNode_ptr props);
|
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-12-22 19:52:26 +00:00
|
|
|
vector<GUIInfo *> _info;
|
2002-11-07 22:59:46 +00:00
|
|
|
struct PropertyObject {
|
2002-12-22 19:52:26 +00:00
|
|
|
PropertyObject (const char * name,
|
|
|
|
puObject * object,
|
|
|
|
SGPropertyNode_ptr node);
|
|
|
|
string name;
|
2002-11-07 22:59:46 +00:00
|
|
|
puObject * object;
|
|
|
|
SGPropertyNode_ptr node;
|
|
|
|
};
|
2002-12-22 19:52:26 +00:00
|
|
|
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);
|
|
|
|
|
2002-12-22 19:52:26 +00:00
|
|
|
virtual void setCurrentWidget (GUIWidget * widget);
|
|
|
|
virtual GUIWidget * getCurrentWidget ();
|
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
virtual FGMenuBar * getMenuBar ();
|
|
|
|
|
2002-12-22 19:52:26 +00:00
|
|
|
|
2002-11-08 15:24:14 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void readDir (const char * path);
|
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
FGMenuBar * _menubar;
|
2002-12-22 19:52:26 +00:00
|
|
|
GUIWidget * _current_widget;
|
2002-11-08 15:24:14 +00:00
|
|
|
map<string,SGPropertyNode_ptr> _widgets;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2002-12-22 19:52:26 +00:00
|
|
|
|
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
|