Xfce
Foundation Classes |
|||
« Main Page | Index | |||
MessageDialogA message dialog is a dialog with an image representing the type of message (Error, Question, etc.) alongside some message text. It's simply a convenience widget; you could construct the equivalent of MessageDialog from Gtk::Dialog without too much effort, but MessageDialog saves you typing. The easiest way to do a modal message dialog is to use Gtk::Dialog::run(), though you can also pass in the Gtk::DIALOG_MODAL flag, Gtk::Dialog::run() automatically makes the dialog modal and waits for the user to respond to it. Gtk::Dialog::run() returns when any dialog button is clicked. To create a MessageDialog call one of the following constructors: MessageDialog(Window
*parent, DialogFlagsField flags); The first two constructors create
a message dialog with no message. If
you
use either of these constructors you will need to explicitly call
set_message() to set the message text.
The third constructor sets all the fields at construction, including
the
message.
The 'type' argument is the message type and can be one of the following values from the Gtk::MessageType enum:
void
set_message(const String& message); The first method sets the message
text from a String. The second method
sets the message text from a character string formatted inline using
sprintf-style formatting. For example, this is a message dialog used in
the
<demos/xfc-demo/appwindow.cc> file from the xfc-demo source code:
Gtk::MessageDialog
*dialog(Gtk::MESSAGE_INFO, Gtk::BUTTONS_CLOSE, this); To make it easy to format text in a message (changing colors, fonts, etc.), the message text can be provided in a simple markup format using the Pango text markup language (see Gtk::Label::set_markup()). To set the message using markup text call one of the following methods: void set_markup(const String&
message); To display a modal message dialog call the Gtk::Dialog::run method: int
run();
|