]> git.mxchange.org Git - flightgear.git/blob - src/GUI/new_gui.hxx
6baf15b8222861f2a484bd9a6d791e82720c4728
[flightgear.git] / src / GUI / new_gui.hxx
1 // new_gui.hxx - XML-configurable GUI subsystem.
2
3 #ifndef __NEW_GUI_HXX
4 #define __NEW_GUI_HXX 1
5
6 #ifndef __cplusplus
7 # error This library requires C++
8 #endif
9
10 #include <plib/pu.h>
11
12 #include <simgear/compiler.h>   // for SG_USING_STD
13 #include <simgear/misc/props.hxx>
14
15 #include <vector>
16 SG_USING_STD(vector);
17
18 #include <map>
19 SG_USING_STD(map);
20
21 #include <Main/fgfs.hxx>
22
23
24 class GUIWidget;
25
26
27 /**
28  * User data attached to a GUI object.
29  */
30 struct GUIData
31 {
32     GUIData (GUIWidget * w, const char * a);
33     GUIWidget * widget;
34     string command;
35 };
36
37
38 /**
39  * Top-level GUI widget.
40  */
41 class GUIWidget
42 {
43 public:
44     GUIWidget (SGPropertyNode_ptr props);
45     virtual ~GUIWidget ();
46
47     virtual void action (const string &command);
48
49 private:
50     GUIWidget (const GUIWidget &); // just for safety
51     void display (SGPropertyNode_ptr props);
52     virtual void updateProperties ();
53     virtual void applyProperties ();
54     puObject * makeObject (SGPropertyNode * props,
55                            int parentWidth, int parentHeight);
56     void setupObject (puObject * object, SGPropertyNode * props);
57     void setupGroup (puGroup * group, SGPropertyNode * props,
58                      int width, int height, bool makeFrame = false);
59
60     puObject * _object;
61     vector<GUIData> _actions;
62     struct PropertyObject {
63         PropertyObject (puObject * object, SGPropertyNode_ptr node);
64         puObject * object;
65         SGPropertyNode_ptr node;
66     };
67     vector<PropertyObject> _propertyObjects;
68 };
69
70
71 class NewGUI : public FGSubsystem
72 {
73 public:
74
75     NewGUI ();
76     virtual ~NewGUI ();
77     virtual void init ();
78     virtual void update (double delta_time_sec);
79     virtual void display (const string &name);
80
81 private:
82
83     void readDir (const char * path);
84
85     map<string,SGPropertyNode_ptr> _widgets;
86
87 };
88
89 #endif // __NEW_GUI_HXX
90
91 // end of new_gui.hxx