| 1 | // dialog.hxx - XML-configured dialog box. |
| 2 | |
| 3 | #ifndef __DIALOG_HXX |
| 4 | #define __DIALOG_HXX 1 |
| 5 | |
| 6 | #include <string> |
| 7 | |
| 8 | #include <simgear/props/propsfwd.hxx> |
| 9 | #include <simgear/structure/SGWeakReferenced.hxx> |
| 10 | |
| 11 | /** |
| 12 | * An XML-configured dialog box. |
| 13 | * |
| 14 | * The GUI manager stores only the property tree for the dialog |
| 15 | * boxes. This class creates a PUI dialog box on demand from |
| 16 | * the properties in that tree. The manager recreates the dialog |
| 17 | * every time it needs to show it. |
| 18 | */ |
| 19 | class FGDialog : public SGWeakReferenced |
| 20 | { |
| 21 | public: |
| 22 | |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * Destructor. |
| 27 | */ |
| 28 | virtual ~FGDialog (); |
| 29 | |
| 30 | |
| 31 | /** |
| 32 | * Update the values of all GUI objects with a specific name, |
| 33 | * or all if an empty name is given (default). |
| 34 | * |
| 35 | * This method copies values from the FlightGear property tree to |
| 36 | * the GUI object(s). |
| 37 | * |
| 38 | * @param objectName The name of the GUI object(s) to update. |
| 39 | * Use the empty name for all objects. |
| 40 | */ |
| 41 | virtual void updateValues(const std::string& objectName = "") = 0; |
| 42 | |
| 43 | |
| 44 | /** |
| 45 | * Apply the values of all GUI objects with a specific name, |
| 46 | * or all if an empty name is given (default) |
| 47 | * |
| 48 | * This method copies values from the GUI object(s) to the |
| 49 | * FlightGear property tree. |
| 50 | * |
| 51 | * @param objectName The name of the GUI object(s) to update. |
| 52 | * Use the empty name for all objects. |
| 53 | */ |
| 54 | virtual void applyValues(const std::string& objectName = "") = 0; |
| 55 | |
| 56 | |
| 57 | /** |
| 58 | * Update state. Called on active dialogs before rendering. |
| 59 | */ |
| 60 | virtual void update () = 0; |
| 61 | |
| 62 | virtual const char *getName() { return ""; } |
| 63 | virtual void bringToFront() {} |
| 64 | |
| 65 | /** |
| 66 | * @brief Close the dialog. This should actually close the GUI |
| 67 | * assets associated, if you want an 'are you sure?' interaction, it |
| 68 | * needs to be handled in advance of this interaction. |
| 69 | */ |
| 70 | virtual void close() = 0; |
| 71 | |
| 72 | |
| 73 | virtual void runCallback(const std::string& name, SGPropertyNode_ptr args = {}) = 0; |
| 74 | |
| 75 | protected: |
| 76 | /** |
| 77 | * Construct a new GUI widget configured by a property tree. |
| 78 | * |
| 79 | * The configuration properties are not part of the main |
| 80 | * FlightGear property tree; the GUI manager reads them |
| 81 | * from individual configuration files. |
| 82 | * |
| 83 | * @param props A property tree describing the dialog. |
| 84 | */ |
| 85 | FGDialog (SGPropertyNode * props); |
| 86 | |
| 87 | private: |
| 88 | |
| 89 | }; |
| 90 | |
| 91 | #endif // __DIALOG_HXX |