FlightGear next
dialog.hxx
Go to the documentation of this file.
1// dialog.hxx - XML-configured dialog box.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include <cstdint>
7#include <string>
8
9#include <simgear/props/propsfwd.hxx>
10#include <simgear/structure/SGWeakReferenced.hxx>
11
20class FGDialog : public SGWeakReferenced
21{
22public:
23
24
25
29 virtual ~FGDialog ();
30
31
42 virtual void updateValues(const std::string& objectName = "") = 0;
43
44
55 virtual void applyValues(const std::string& objectName = "") = 0;
56
57
61 virtual void update () = 0;
62
63 virtual const char *getName() { return ""; }
64 virtual void bringToFront() {}
65
71 virtual void close() = 0;
72
74 Window, // regular window with titlebar
75 ModalDialog, // dialog (probably without a title-bar)
76 MessageBox // for alerts, yes/no choices, progress bars, etc
77 };
78
80 Resizable = 1 << 0,
81 Closeable = 1 << 1,
82 ButtonBox = 1 << 2
83 };
84
86 bool isFlagSet(WindowFlags f) const;
87
88 virtual void runCallback(const std::string& name, SGPropertyNode_ptr args = {}) = 0;
89
96 std::string translationDomain() const noexcept;
103 void setTranslationDomain(std::string domain) noexcept;
104
105protected:
119 FGDialog(SGPropertyNode* props, std::string translationDomain = "core");
120
121private:
122 void updateFlagFromProperty(WindowFlags f, SGPropertyNode* props, const std::string& name);
123
125 std::string _translationDomain;
126 const WindowStyle _windowStyle;
127 uint32_t _flags = 0;
128};
An XML-configured dialog box.
Definition dialog.hxx:21
virtual void close()=0
Close the dialog.
FGDialog(SGPropertyNode *props, std::string translationDomain="core")
Construct a new GUI widget configured by a property tree.
Definition dialog.cxx:45
@ MessageBox
Definition dialog.hxx:76
@ ModalDialog
Definition dialog.hxx:75
std::string translationDomain() const noexcept
Return the translation domain of the dialog.
Definition dialog.cxx:61
virtual void update()=0
Update state.
virtual void applyValues(const std::string &objectName="")=0
Apply the values of all GUI objects with a specific name, or all if an empty name is given (default)
virtual void bringToFront()
Definition dialog.hxx:64
virtual const char * getName()
Definition dialog.hxx:63
void setTranslationDomain(std::string domain) noexcept
Set the translation domain of the dialog.
Definition dialog.cxx:66
bool isFlagSet(WindowFlags f) const
Definition dialog.cxx:93
WindowStyle windowStyle() const
Definition dialog.cxx:88
virtual ~FGDialog()
Destructor.
virtual void updateValues(const std::string &objectName="")=0
Update the values of all GUI objects with a specific name, or all if an empty name is given (default)...
virtual void runCallback(const std::string &name, SGPropertyNode_ptr args={})=0
@ Closeable
Definition dialog.hxx:81
@ Resizable
Definition dialog.hxx:80
@ ButtonBox
Definition dialog.hxx:82
const char * name