StanfordCPPLib
Public Types | Static Public Member Functions | List of all members
GOptionPane Class Reference

This class provides static methods that pop up graphical input/output dialog boxes on the screen. More...

#include "goptionpane.h"

Public Types

enum  ConfirmResult { CONFIRM_CANCEL = -1, CONFIRM_NO = 0, CONFIRM_YES = 1, CONFIRM_OK = 2 }
 The various results that can be returned from some option dialogs. More...
 
enum  ConfirmType { CONFIRM_YES_NO = 0, CONFIRM_YES_NO_CANCEL = 1, CONFIRM_OK_CANCEL = 2 }
 Types used by showConfirmDialog, representing the three kinds of confirmation dialogs: Yes/No, Yes/No/Cancel, or OK/Cancel. More...
 
enum  MessageType { MESSAGE_ERROR = 0, MESSAGE_INFORMATION = 1, MESSAGE_PLAIN = -1, MESSAGE_WARNING = 2, MESSAGE_QUESTION = 3, MESSAGE_ABOUT = 4 }
 Types used by showMessageDialog, representing the various kinds of message dialogs. More...
 

Static Public Member Functions

static ConfirmResult showConfirmDialog(string message, string title="", ConfirmType type=CONFIRM_YES_NO)
 Pops up a yes/no confirmation box. More...
 
static ConfirmResult showConfirmDialog(GWindow *parent, string message, string title="", ConfirmType type=CONFIRM_YES_NO)
 Pops up a yes/no confirmation box. More...
 
static ConfirmResult showConfirmDialog(QWidget* parent, string message, string title="", ConfirmType type=CONFIRM_YES_NO)
 Pops up a yes/no confirmation box. More...
 
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. More...
 
static string showInputDialog(GWindow *parent, 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. More...
 
static string showInputDialog(QWidget* parent, 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. More...
 
static void showMessageDialog(string message, string title="", MessageType type=MESSAGE_PLAIN)
 Displays an output message dialog to the user. More...
 
static void showMessageDialog(GWindow *parent, string message, string title="", MessageType type=MESSAGE_PLAIN)
 Displays an output message dialog to the user. More...
 
static void showMessageDialog(QWidget* parent, string message, string title="", MessageType type=MESSAGE_PLAIN)
 Displays an output message dialog to the user. More...
 
static string showOptionDialog(string message, const 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. More...
 
static string showOptionDialog(GWindow *parent, string message, const 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. More...
 
static string showOptionDialog(QWidget* parent, string message, const 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. More...
 
static void showTextFileDialog(string fileText, string title="", int rows=-1, int cols=-1)
 Displays the given text in a scrolling monospaced text area. More...
 
static void showTextFileDialog(GWindow *parent, string fileText, string title="", int rows=-1, int cols=-1)
 Displays the given text in a scrolling monospaced text area. More...
 
static void showTextFileDialog(QWidget* parent, string fileText, string title="", int rows=-1, int cols=-1)
 Displays the given text in a scrolling monospaced text area. More...
 

Detailed Description

This class provides static methods that pop up graphical input/output dialog boxes on the screen.

Member Enumeration Documentation

◆ ConfirmResult

The various results that can be returned from some option dialogs.

Note that NO has the value 0 and YES/OK have nonzero values, so you can use a ConfirmResult in a boolean context.

Enumerator
CONFIRM_CANCEL 
CONFIRM_NO 
CONFIRM_YES 
CONFIRM_OK 

◆ ConfirmType

Types used by showConfirmDialog, representing the three kinds of confirmation dialogs: Yes/No, Yes/No/Cancel, or OK/Cancel.

Enumerator
CONFIRM_YES_NO 
CONFIRM_YES_NO_CANCEL 
CONFIRM_OK_CANCEL 

◆ MessageType

Types used by showMessageDialog, representing the various kinds of message dialogs.

The type often slightly varies the dialog's appearance, such as changing its icons or font.

Enumerator
MESSAGE_ERROR 
MESSAGE_INFORMATION 
MESSAGE_PLAIN 
MESSAGE_WARNING 
MESSAGE_QUESTION 
MESSAGE_ABOUT 

Member Function Documentation

◆ showConfirmDialog() [1/3]

GOptionPane::ConfirmResult showConfirmDialog ( string   message,
string   title = "",
ConfirmType  type = CONFIRM_YES_NO 
)
static

Pops up a yes/no confirmation box.

Once the user clicks a button to close the box, one of the GOptionPaneResult enumeration constants is returned. The caller can supply an optional window title; if none is passed, a default is used.

◆ showConfirmDialog() [2/3]

GOptionPane::ConfirmResult showConfirmDialog ( GWindow parent,
string   message,
string   title = "",
ConfirmType  type = CONFIRM_YES_NO 
)
static

Pops up a yes/no confirmation box.

Once the user clicks a button to close the box, one of the GOptionPaneResult enumeration constants is returned. The caller can supply an optional window title; if none is passed, a default is used.

◆ showConfirmDialog() [3/3]

GOptionPane::ConfirmResult showConfirmDialog ( QWidget*   parent,
string   message,
string   title = "",
ConfirmType  type = CONFIRM_YES_NO 
)
static

Pops up a yes/no confirmation box.

Once the user clicks a button to close the box, one of the GOptionPaneResult enumeration constants is returned. The caller can supply an optional window title; if none is passed, a default is used.

◆ showInputDialog() [1/3]

string showInputDialog ( string   message,
string   title = "",
string   initialValue = "" 
)
static

Pops up an input box with a text field where the user can type a response, which is returned.

The caller can supply an optional window title; if none is passed, a default is used. If the user cancels the box, an empty string is returned.

◆ showInputDialog() [2/3]

string showInputDialog ( GWindow parent,
string   message,
string   title = "",
string   initialValue = "" 
)
static

Pops up an input box with a text field where the user can type a response, which is returned.

The caller can supply an optional window title; if none is passed, a default is used. If the user cancels the box, an empty string is returned.

◆ showInputDialog() [3/3]

string showInputDialog ( QWidget*   parent,
string   message,
string   title = "",
string   initialValue = "" 
)
static

Pops up an input box with a text field where the user can type a response, which is returned.

The caller can supply an optional window title; if none is passed, a default is used. If the user cancels the box, an empty string is returned.

◆ showMessageDialog() [1/3]

void showMessageDialog ( string   message,
string   title = "",
MessageType  type = MESSAGE_PLAIN 
)
static

Displays an output message dialog to the user.

The user must click the 'OK' button to close the dialog. The caller can supply an optional window title; if none is passed, a default is used. The optional 'type' parameter must be one of PLAIN_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, or QUESTION_MESSAGE; this slightly affects the dialog's appearance. The default is PLAIN_MESSAGE.

◆ showMessageDialog() [2/3]

void showMessageDialog ( GWindow parent,
string   message,
string   title = "",
MessageType  type = MESSAGE_PLAIN 
)
static

Displays an output message dialog to the user.

The user must click the 'OK' button to close the dialog. The caller can supply an optional window title; if none is passed, a default is used. The optional 'type' parameter must be one of PLAIN_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, or QUESTION_MESSAGE; this slightly affects the dialog's appearance. The default is PLAIN_MESSAGE.

◆ showMessageDialog() [3/3]

void showMessageDialog ( QWidget*   parent,
string   message,
string   title = "",
MessageType  type = MESSAGE_PLAIN 
)
static

Displays an output message dialog to the user.

The user must click the 'OK' button to close the dialog. The caller can supply an optional window title; if none is passed, a default is used. The optional 'type' parameter must be one of PLAIN_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, or QUESTION_MESSAGE; this slightly affects the dialog's appearance. The default is PLAIN_MESSAGE.

◆ showOptionDialog() [1/3]

string showOptionDialog ( string   message,
const Vector< string > &  options,
string   title = "",
string   initiallySelected = "" 
)
static

Shows a general input box with a set of buttons from which the user may choose one option.

The button the user clicks is returned as a string. If the user cancels the box, an empty string is returned. The caller can supply an optional window title; if none is passed, a default is used. The caller can supply an optional initially selected value from the list.

◆ showOptionDialog() [2/3]

string showOptionDialog ( GWindow parent,
string   message,
const Vector< string > &  options,
string   title = "",
string   initiallySelected = "" 
)
static

Shows a general input box with a set of buttons from which the user may choose one option.

The button the user clicks is returned as a string. If the user cancels the box, an empty string is returned. The caller can supply an optional window title; if none is passed, a default is used. The caller can supply an optional initially selected value from the list.

◆ showOptionDialog() [3/3]

string showOptionDialog ( QWidget*   parent,
string   message,
const Vector< string > &  options,
string   title = "",
string   initiallySelected = "" 
)
static

Shows a general input box with a set of buttons from which the user may choose one option.

The button the user clicks is returned as a string. If the user cancels the box, an empty string is returned. The caller can supply an optional window title; if none is passed, a default is used. The caller can supply an optional initially selected value from the list.

◆ showTextFileDialog() [1/3]

void showTextFileDialog ( string   fileText,
string   title = "",
int  rows = -1,
int  cols = -1 
)
static

Displays the given text in a scrolling monospaced text area.

rows/cols parameters control size to show; set to <= 0 for a default limit.

◆ showTextFileDialog() [2/3]

void showTextFileDialog ( GWindow parent,
string   fileText,
string   title = "",
int  rows = -1,
int  cols = -1 
)
static

Displays the given text in a scrolling monospaced text area.

rows/cols parameters control size to show; set to <= 0 for a default limit.

◆ showTextFileDialog() [3/3]

void showTextFileDialog ( QWidget*   parent,
string   fileText,
string   title = "",
int  rows = -1,
int  cols = -1 
)
static

Displays the given text in a scrolling monospaced text area.

rows/cols parameters control size to show; set to <= 0 for a default limit.