FlightGear next
FGPUICompatDialog.hxx
Go to the documentation of this file.
1// SPDX-FileName: FGPUICompatDialog.hxx
2// SPDX-FileComment: XML dialog class without using PUI
3// SPDX-FileCopyrightText: Copyright (C) 2022 James Turner
4// SPDX-License-Identifier: GPL-2.0-or-later
5
6#pragma once
7
8#include <cstdint>
9
10#include "dialog.hxx"
11#include "simgear/math/SGRect.hxx"
12
13
14#include <simgear/misc/sg_path.hxx>
15#include <simgear/nasal/cppbind/NasalHash.hxx>
16#include <simgear/nasal/cppbind/NasalObject.hxx>
17#include <simgear/props/condition.hxx>
18#include <simgear/props/props.hxx>
19
20
21class NewGUI;
22class FGColor;
23
24class PUICompatObject;
25using PUICompatObjectRef = SGSharedPtr<PUICompatObject>;
26
36{
37public:
38 static void setupGhost(nasal::Hash& compatModule);
39
53 FGPUICompatDialog(SGPropertyNode* props,
54 std::string translationDomain = "core");
55
56
60 virtual ~FGPUICompatDialog();
61
62
73 virtual void updateValues(const std::string& objectName = "");
74
75
86 virtual void applyValues(const std::string& objectName = "");
87
88 bool init();
89
93 void update() override;
94
98 void relayout();
99
100
102 {
103 _needsRelayout = true;
104 }
105
106 virtual const char* getName();
107 virtual void bringToFront();
108
109 std::string nameString() const;
110 std::string nasalModule() const;
111
112 SGRectd geometry() const;
113
114 double getX() const;
115 double getY() const;
116 double width() const;
117 double height() const;
118
119 void close() override;
120
121 std::string title() const;
122 void setTitle(const std::string& s);
123
124 const std::string& windowType() const
125 {
126 return _windowType;
127 }
128
136 uint32_t uiVersion() const
137 {
138 return _uiVersion;
139 }
140
145 PUICompatObjectRef widgetByName(const std::string& name) const;
146
147 void runCallback(const std::string& name, SGPropertyNode_ptr args) override;
148
149private:
150 friend naRef f_makeDialogPeer(const nasal::CallContext& ctx);
151 friend naRef f_dialogRootObject(FGPUICompatDialog& dialog, naContext c);
152
153 // Show the dialog.
154 void display(SGPropertyNode* props);
155
156 void requestClose();
157
158 // return key code number for keystring
159 int getKeyCode(const char* keystring);
160
161 // The source xml tree, so that we can pass data back, such as the
162 // last position.
163 SGPropertyNode_ptr _props;
164
165 bool _needsRelayout;
166 SGRectd _geometry = SGRectd{0.0, 0.0, 0.0, 0.0};
167
168 // Nasal module.
169 std::string _module;
170 SGPropertyNode_ptr _nasal_close;
171
172 class DialogPeer;
173
174 SGSharedPtr<DialogPeer> _peer;
175
176 std::string _windowType;
177 std::string _name;
178 PUICompatObjectRef _root;
179 std::string _title;
180 uint32_t _uiVersion = 0;
181};
SGSharedPtr< PUICompatObject > PUICompatObjectRef
FGDialog(SGPropertyNode *props, std::string translationDomain="core")
Construct a new GUI widget configured by a property tree.
Definition dialog.cxx:45
std::string translationDomain() const noexcept
Return the translation domain of the dialog.
Definition dialog.cxx:61
An XML-configured dialog box.
std::string nasalModule() const
void runCallback(const std::string &name, SGPropertyNode_ptr args) override
virtual const char * getName()
std::string nameString() const
friend naRef f_dialogRootObject(FGPUICompatDialog &dialog, naContext c)
const std::string & windowType() const
void update() override
Update state.
static void setupGhost(nasal::Hash &compatModule)
SGRectd geometry() const
std::string title() const
void setTitle(const std::string &s)
virtual void bringToFront()
FGPUICompatDialog(SGPropertyNode *props, std::string translationDomain="core")
Construct a new GUI widget configured by a property tree.
void relayout()
Recompute the dialog's layout.
friend naRef f_makeDialogPeer(const nasal::CallContext &ctx)
void close() override
Close the dialog.
uint32_t uiVersion() const
return the UI XML syntax version used by this dialog.
PUICompatObjectRef widgetByName(const std::string &name) const
find the dialog widget with the specified name, or nullptr.
virtual void applyValues(const std::string &objectName="")
Apply the values of all GUI objects with a specific name, or all if an empty name is given (default).
virtual ~FGPUICompatDialog()
Destructor.
virtual void updateValues(const std::string &objectName="")
Update the values of all GUI objects with a specific name, or all if an empty name is given (default)...
XML-configured GUI subsystem.
Definition new_gui.hxx:31
const char * name