]> git.mxchange.org Git - flightgear.git/blob - src/GUI/dialog.hxx
Tie the bool property /sim/menubar/visibility to hide and reveal the
[flightgear.git] / src / GUI / dialog.hxx
1 // dialog.hxx - XML-configurable dialog box.
2
3 #ifndef __DIALOG_HXX
4 #define __DIALOG_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 class FGDialog;
19 class FGBinding;
20
21
22 /**
23  * PUI userdata describing a GUI object.
24  */
25 struct GUIInfo
26 {
27     GUIInfo (FGDialog * w);
28     virtual ~GUIInfo ();
29     
30     FGDialog * widget;
31     vector <FGBinding *> bindings;
32 };
33
34
35 /**
36  * Top-level GUI widget.
37  */
38 class FGDialog
39 {
40 public:
41
42
43     /**
44      * Construct a new GUI widget configured by a property tree.
45      */
46     FGDialog (SGPropertyNode_ptr props);
47
48
49     /**
50      * Destructor.
51      */
52     virtual ~FGDialog ();
53
54
55     /**
56      * Update the values of all GUI objects with a specific name.
57      *
58      * This method copies from the property to the GUI object.
59      *
60      * @param objectName The name of the GUI object(s) to update.
61      *        Use the empty name for all unnamed objects.
62      */
63     virtual void updateValue (const char * objectName);
64
65
66     /**
67      * Apply the values of all GUI objects with a specific name.
68      *
69      * This method copies from the GUI object to the property.
70      *
71      * @param objectName The name of the GUI object(s) to update.
72      *        Use the empty name for all unnamed objects.
73      */
74     virtual void applyValue (const char * objectName);
75
76
77     /**
78      * Update the values of all GUI objects.
79      *
80      * This method copies from the properties to the GUI objects.
81      */
82     virtual void updateValues ();
83
84
85     /**
86      * Apply the values of all GUI objects.
87      *
88      * This method copies from the GUI objects to the properties.
89      */
90     virtual void applyValues ();
91
92
93 private:
94     FGDialog (const FGDialog &); // just for safety
95
96     void display (SGPropertyNode_ptr props);
97     puObject * makeObject (SGPropertyNode * props,
98                            int parentWidth, int parentHeight);
99     void setupObject (puObject * object, SGPropertyNode * props);
100     void setupGroup (puGroup * group, SGPropertyNode * props,
101                      int width, int height, bool makeFrame = false);
102
103     puObject * _object;
104     vector<GUIInfo *> _info;
105     struct PropertyObject {
106         PropertyObject (const char * name,
107                         puObject * object,
108                         SGPropertyNode_ptr node);
109         string name;
110         puObject * object;
111         SGPropertyNode_ptr node;
112     };
113     vector<PropertyObject *> _propertyObjects;
114 };
115
116 #endif // __DIALOG_HXX