Framework for a basic dialog window with OK/Apply/Cancel actions. More...
#include <GenericDialog.h>
Public Member Functions | |
Interrogation | |
const std::string & | GetKey () const |
Get the unique key that identifies this dialog widget. | |
Window management | |
virtual void | SetWindow (GtkWidget *window) |
Mark this window widget as a modal dialog for a parent window. | |
virtual void | Raise () |
Raise this dialog window to the top of the window stack. | |
virtual void | Show (const std::string &triggerCommand) |
Make this dialog window visible and foreground. | |
virtual void | Hide () |
Hide this dialog window. | |
Callback implementation | |
virtual bool | Apply () |
Default handler for Apply logic. | |
virtual gint | CloseEventCallback (GtkWidget *widget, GdkEvent *event, gpointer callbackID) |
Callback for window-close event. | |
virtual void | FinalizeCallback (GtkWidget *widget, gpointer callbackID) |
Callback for clicking on OK/Apply/Cancel button. | |
Callback creation | |
void | CreateWindowCloseCallback () |
Register the callback for the close-window event. | |
void | CreateOkButtonCallback (GtkWidget *button) |
Register the callback for the OK button. | |
void | CreateApplyButtonCallback (GtkWidget *button) |
Register the callback for the Apply button. | |
void | CreateCancelButtonCallback (GtkWidget *button) |
Register the callback for the Cancel button. | |
Public Member Functions inherited from RefCounted | |
RefCounted () | |
Default constructor. | |
virtual | ~RefCounted () |
Virtual destructor. | |
void | IncRef () |
Increment reference count. | |
void | DecRef () |
Decrement reference count, and self-delete if count is <= 0. |
Protected Member Functions | |
Lifecycle | |
GenericDialog (const std::string &key) | |
Constructor. | |
virtual | ~GenericDialog () |
Virtual destructor. |
Protected Attributes | |
GtkWidget * | _dialog |
This dialog widget. | |
GtkWidget * | _window |
Parent window. | |
const std::string | _key |
Unique key for this dialog. | |
std::string | _triggerCommand |
Command token that most recently summoned this dialog. | |
gpointer | _okCallbackID |
Callback ID associated with an OK button; 0 if none. | |
gpointer | _applyCallbackID |
Callback ID associated with an Apply button; 0 if none. | |
gpointer | _cancelCallbackID |
Callback ID associated with a Cancel button; 0 if none. |
Private Member Functions | |
Unimplemented to prevent copy/assignment | |
GenericDialog (const GenericDialog &) | |
const GenericDialog & | operator= (const GenericDialog &) |
Framework for a basic dialog window with OK/Apply/Cancel actions.
A subclass should handle decorating/customizing the window, populating it with contained widgets, customizing the Apply logic, and registering the appropriate OK/Apply/Cancel buttons.
|
protected |
Constructor.
Create the GTK+ widget for the dialog window (not visible yet). Initialize callback IDs to zero (invalid). Note that as this is a protected method, GenericDialog objects cannot be created directly; only subclasses of GenericDialog can be created.
key | Unique key to identify this dialog widget. |
|
protectedvirtual |
Virtual destructor.
Destroy the GTK+ dialog widget (and therefore its contained widgets) if necessary.
|
virtual |
Default handler for Apply logic.
This method should be overriden by subclass implementations that need to execute some logic when OK or Apply is clicked. The return value should be the success of that logic. A successful OK will cause the window to be hidden.
Reimplemented in SetScaleDialog, GeneralFunctionDialog, and GetInfoDialog.
|
virtual |
Callback for window-close event.
widget | This dialog window widget. |
event | The event that instigated the callback. |
callbackID | Unique numerical ID for the callback. |
void GenericDialog::CreateApplyButtonCallback | ( | GtkWidget * | button | ) |
Register the callback for the Apply button.
button | The Apply button widget. |
void GenericDialog::CreateCancelButtonCallback | ( | GtkWidget * | button | ) |
Register the callback for the Cancel button.
button | The Cancel button widget. |
void GenericDialog::CreateOkButtonCallback | ( | GtkWidget * | button | ) |
Register the callback for the OK button.
button | The OK button widget. |
|
virtual |
Callback for clicking on OK/Apply/Cancel button.
widget | This dialog window widget. |
callbackID | Unique numerical ID for the callback. |
const std::string & GenericDialog::GetKey | ( | ) | const |
Get the unique key that identifies this dialog widget.
|
virtual |
Mark this window widget as a modal dialog for a parent window.
window | The parent window. |
|
virtual |
Make this dialog window visible and foreground.
triggerCommand | The command token that summoned the dialog. |