gcu::Dialog Class Reference

#include <gcu/dialog.h>

Inheritance diagram for gcu::Dialog:

gcu::UIBuilder gcp::DocPropDlg gcp::HPosDlg gcp::NewFileDlg gcp::PrefsDlg gcp::ReactionPropDlg gcp::StringDlg gcp::Tools gcp::ZoomDlg gcu::PrintSetupDlg

List of all members.

Public Member Functions

 Dialog (Application *App, char const *filename, const char *windowname, char const *domainname, DialogOwner *owner=NULL, void(*extra_destroy)(gpointer)=NULL, gpointer data=NULL) throw (std::runtime_error)
virtual void Destroy ()
virtual bool Apply ()
void Help ()
GtkWindow * GetWindow ()
void Present ()
void SetTransientFor (GtkWindow *window)
void SetRealName (char const *name, DialogOwner *owner) throw (std::runtime_error)

Protected Member Functions

bool GetNumber (GtkEntry *Entry, double *x, CheckType c=NoCheck, double min=0, double max=0)

Protected Attributes

GtkWindow * dialog
Applicationm_App


Detailed Description

This class is base class for dialog boxes. It provides some basic services.

Definition at line 68 of file dialog.h.


Constructor & Destructor Documentation

gcu::Dialog::Dialog ( Application App,
char const *  filename,
const char *  windowname,
char const *  domainname,
DialogOwner owner = NULL,
void(*)(gpointer)  extra_destroy = NULL,
gpointer  data = NULL 
) throw (std::runtime_error)

Parameters:
App,: the Application which owns the dialog.
filename,: the name of the ui file which contains the description of the dialog.
windowname,: the name of the top level GtkWidget of the dialog box in the glade file. This name should be unique for the application. It is used to access the contextual help and to ensure the uniqueness of the dialog (in some cases).
domainname,: the translation domain.
owner,: the address of an owner object, might be App or a document or NULL (the default). when owner is not NULL, the dialog will be unique for it.
extra_destroy,: a callback to be called when the dialog is detroyed by calling Dialog::Destroy. Useful to perform non standard cleaning operations before calling gtk_widget_destroy. The destructor being called afterwards, it cannot access the widget.
data,: the data to be passed to extra_destroy.
If the ui file declares buttons with names "OK", "apply", "cancel" and "help", default actions will be associated with these buttons. If the Application does not provide help support, the Help button will be hidden.


Member Function Documentation

virtual bool gcu::Dialog::Apply (  )  [virtual]

Called after a click on the OK or Apply buttons. After clicking the OK button and if the method returns true, Destroy will be called to close the dialog box. A derived class should implement this method, as the default just returns true.

Returns:
true if everything worked, false if something when wrong and the dialog should not be closed.

Reimplemented in gcp::NewFileDlg, and gcp::StringDlg.

virtual void gcu::Dialog::Destroy (  )  [virtual]

Called when closing the dialog box after a click on the OK or Cancel buttons. If a child class implements this method, it should call Dialog::Destroy after performing its task or it must destroy the window. The defaut implementation calls extra_destroy and gtk_widget_destroy.

bool gcu::Dialog::GetNumber ( GtkEntry *  Entry,
double *  x,
CheckType  c = NoCheck,
double  min = 0,
double  max = 0 
) [protected]

Parameters:
Entry,: the GtkEntry from which the number should be retrieved.
x,: a pointer to the value which will be replaced by the result.
c,: the type of check to perform on the value.
min,: the minimum accepted value, if needed.
max,: the maximum accepted value, if needed.
This method retrieves the text displayed in Entry, converts it to a number and perform bounds tests if needed. If an error occurs, a message box is displayed which let the user know why the value is not correct.
Returns:
true if the value is valid, false if something went wrong.

GtkWindow* gcu::Dialog::GetWindow (  )  [inline]

/return the top level window of the dialog box.

Definition at line 121 of file dialog.h.

References dialog.

void gcu::Dialog::Help (  ) 

Displays the help corresponding to the dialog. This function is called when a click occurs on the Help button. It calls Application::OnHelp (windowname);

void gcu::Dialog::Present (  )  [inline]

Brings the dialog to top of the windows stack.

Definition at line 126 of file dialog.h.

References dialog.

void gcu::Dialog::SetRealName ( char const *  name,
DialogOwner owner 
) throw (std::runtime_error)

Parameters:
name a new name for the window.
owner the address of an dialog owner object.
Usually, the Dialog is registered using its window name as passed to the constructor. If several occurences of the same Dialog are acceptable, another unique name is needed. owner might be NULL if it has already been set in the constructor. The existence of a Dialog with the same name should be checked before calling this method, because that would throw an error.

void gcu::Dialog::SetTransientFor ( GtkWindow *  window  ) 

Parameters:
window the parent window.
Make the diaolg box transient for window.


Member Data Documentation

GtkWindow* gcu::Dialog::dialog [protected]

The associated GtkWindow instance.

Definition at line 166 of file dialog.h.

Referenced by GetWindow(), and Present().

The Application instance owning the dialog.

Definition at line 170 of file dialog.h.


The documentation for this class was generated from the following file:

Generated on Fri Sep 24 15:58:47 2010 for The Gnome Chemistry Utils by  doxygen 1.5.9