SGL
goptionpane.h
1 /*
2  * File: goptionpane.h
3  * -------------------
4  *
5  * @author Marty Stepp
6  * @version 2021/04/03
7  * - removed dependency on custom collections
8  * @version 2018/09/23
9  * - renamed enum constants to avoid name collisions (may break some client code)
10  * @version 2018/09/08
11  * - added doc comments for new documentation generation
12  * @version 2018/08/23
13  * - renamed to goptionpane.h to replace Java version
14  * @version 2018/06/28
15  * - initial version
16  */
17 
18 
19 #ifndef _goptionpane_h
20 #define _goptionpane_h
21 
22 #include <string>
23 #include <vector>
24 
25 #include "ginteractor.h"
26 
27 // forward declaration
28 class GWindow;
29 
34 class GOptionPane {
35 public:
40  enum ConfirmType {
44  };
45 
52  CONFIRM_CANCEL = -1, // for yes/no/cancel dialogs
53  CONFIRM_NO = 0, // 0 so that 'no' is 'falsey'
54  CONFIRM_YES = 1, // 1 so that 'yes' is 'truthy'
55  CONFIRM_OK = 2 // for ok/cancel dialogs
56  };
57 
63  enum MessageType {
70  };
71 
78  static ConfirmResult showConfirmDialog(const string& message,
79  const string& title = "",
81 
89  const string& message,
90  const string& title = "",
92 
99  static ConfirmResult showConfirmDialog(QWidget* parent,
100  const string& message,
101  const string& title = "",
102  ConfirmType type = CONFIRM_YES_NO);
103 
110  static string showInputDialog(const string& message,
111  const string& title = "",
112  const string& initialValue = "");
113 
120  static string showInputDialog(GWindow* parent,
121  const string& message,
122  const string& title = "",
123  const string& initialValue = "");
124 
131  static string showInputDialog(QWidget* parent,
132  const string& message,
133  const string& title = "",
134  const string& initialValue = "");
135 
144  static void showMessageDialog(const string& message,
145  const string& title = "",
146  MessageType type = MESSAGE_PLAIN);
147 
156  static void showMessageDialog(GWindow* parent,
157  const string& message,
158  const string& title = "",
159  MessageType type = MESSAGE_PLAIN);
160 
169  static void showMessageDialog(QWidget* parent,
170  const string& message,
171  const string& title = "",
172  MessageType type = MESSAGE_PLAIN);
173 
181  static string showOptionDialog(const string& message,
182  const std::vector<string>& options,
183  const string& title = "",
184  const string& initiallySelected = "");
185 
193  static string showOptionDialog(GWindow* parent,
194  const string& message,
195  const std::vector<string>& options,
196  const string& title = "",
197  const string& initiallySelected = "");
198 
206  static string showOptionDialog(QWidget* parent,
207  const string& message,
208  const std::vector<string>& options,
209  const string& title = "",
210  const string& initiallySelected = "");
211 
216  static void showTextFileDialog(const string& fileText,
217  const string& title = "",
218  int rows = -1, int cols = -1);
219 
224  static void showTextFileDialog(GWindow* parent,
225  const string& fileText,
226  const string& title = "",
227  int rows = -1, int cols = -1);
228 
233  static void showTextFileDialog(QWidget* parent,
234  const string& fileText,
235  const string& title = "",
236  int rows = -1, int cols = -1);
237 
238 private:
244  GOptionPane();
245 
250  enum InternalResult {
251  INTERNAL_CANCEL_OPTION = 2,
252  INTERNAL_CLOSED_OPTION = -1,
253  INTERNAL_NO_OPTION = 1,
254  INTERNAL_OK_OPTION = 0,
255  INTERNAL_YES_OPTION = 0
256  };
257 };
258 
259 #endif // _goptionpane_h
static string showInputDialog(string message, string title="", string initialValue="")
Pops up an input box with a text field where the user can type a response, which is returned...
Definition: goptionpane.cpp:102
Definition: goptionpane.h:55
static ConfirmResult showConfirmDialog(string message, string title="", ConfirmType type=CONFIRM_YES_NO)
Pops up a yes/no confirmation box.
Definition: goptionpane.cpp:43
static string showOptionDialog(string message, const std::vector< string > &options, string title="", string initiallySelected="")
Shows a general input box with a set of buttons from which the user may choose one option...
Definition: goptionpane.cpp:173
Definition: goptionpane.h:52
Definition: goptionpane.h:41
Definition: goptionpane.h:65
Definition: goptionpane.h:68
static void showMessageDialog(string message, string title="", MessageType type=MESSAGE_PLAIN)
Displays an output message dialog to the user.
Definition: goptionpane.cpp:131
Definition: goptionpane.h:64
ConfirmResult
The various results that can be returned from some option dialogs.
Definition: goptionpane.h:51
ConfirmType
Types used by showConfirmDialog, representing the three kinds of confirmation dialogs: Yes/No...
Definition: goptionpane.h:40
This class provides static methods that pop up graphical input/output dialog boxes on the screen...
Definition: goptionpane.h:34
static void showTextFileDialog(string fileText, string title="", int rows=-1, int cols=-1)
Displays the given text in a scrolling monospaced text area.
Definition: goptionpane.cpp:268
Definition: goptionpane.h:69
This class represents a graphics window that supports simple graphics.
Definition: gwindow.h:98
Definition: goptionpane.h:66
MessageType
Types used by showMessageDialog, representing the various kinds of message dialogs.
Definition: goptionpane.h:63
Definition: goptionpane.h:43
Definition: goptionpane.h:67
Definition: goptionpane.h:42
Definition: goptionpane.h:54
Definition: goptionpane.h:53