sptk2 logo
SPTK Home Page

sptk::CDialog Class Reference
[GUI Classes]

Dialog window. More...

#include <CDialog.h>

Inheritance diagram for sptk::CDialog:

sptk::CWindow sptk::CLayoutManager sptk::CWindowShape sptk::CLayoutClient sptk::CAskDialog sptk::CFileDialog sptk::CSpellChecker sptk::CInputDialog sptk::CMessageDialog sptk::CDirOpenDialog sptk::CFileOpenDialog sptk::CFileSaveDialog sptk::CEditorSpellChecker

List of all members.

Public Member Functions

 CDialog (int w, int h, const char *label=0)
 Constructor.
 ~CDialog ()
 Destructor.
virtual bool reset ()
 Resets all the controls inside the dialog tabs by calling reset() for every control.
int handle (int event)
 Own handle() method to process dialog events the special way.
bool showModal ()
 Shows modal dialog.
void alert (std::string s) const
 Shows an alert box.
void defaultButton (CButton *btn)
 Defines the default button.
virtual void database (CDatabaseDriver *db)
 Sets the database connection.
CDatabaseDriverdatabase () const
 Returns current database connection.
void table (std::string tableName)
 Defines database table to use.
std::string table () const
 Returnes used database table.
void table (CDatabaseDriver *db, std::string tableName, const std::string keyFieldName)
 Fast setup of the database connection.
void keyField (std::string keyFieldName)
 Sets the key field name for the database table.
std::string keyField () const
 Returns the key field name for the database table.
void keyValue (int val)
 Finds the database record by the value in previously defined key field.
int keyValue () const
 Returns the current database record key value.
virtual Fl_Group * newPage (const char *label, bool autoColor=false)
 Creates a new page as CGroup.
virtual Fl_Group * newScroll (const char *label, bool autoColor=false)
 Creates a new page as CScroll.
CButtonaddExtraButton (CButtonKind buttonKind, const char *label, Fl_Callback_p callback)
 Adds a user-defined button to the dialog.
uint32_t fieldCount () const
 Returns the number of controls inside the dialog with defined field names.
CControloperator[] (std::string fieldName)
 Index operator to access controls with defined field name.
void rescan ()
 Makes dialog to scan the widgets inside.
virtual void load (const CXmlNode *node) throw (CException)
 Loads the dialog controls data from XML.
virtual void save (CXmlNode *node) const
 Saves the dialog controls into XML.
CDialogModalResult modalResult () const
 Returns the modal result of the dialog.
virtual std::string className () const
 Returns widget class name (internal SPTK RTTI).

Protected Member Functions

virtual bool okPressed ()
 Ok button callback.
virtual bool cancelPressed ()
 Ok button callback.
virtual void scanControls ()
 Scans dialog controls.
virtual bool buildQueries ()
 Builds database interface queries using table(), keyField(), and control field names.
virtual bool load ()
 Loads data into dialog.
virtual bool save ()
 Saves data from dialog.

Protected Attributes

CButtonm_okButton
 Standard Ok button.
CButtonm_cancelButton
 Standard Cancel button.
CButtonm_defaultButton
 Pointer to the default button.
std::string m_tableName
 Database interface: table name.
std::string m_keyField
 Database interface: table key field name.
int m_keyValue
 Database interface: table key field value for the record to edit.
CControlList m_defaultFields
 Database interface: The list of controls for standard processing.
CControlList m_allFields
 The list of all controls (CControl-descendants).
CGroupm_buttonGroup
 The group buttons are placed on.
CDialogTabsm_pages
 The tabs.
CQuerym_selectQuery
 Database interface: The query to select a database record.
CQuerym_updateQuery
 Database interface: The query to update a database record.
CQuerym_insertQuery
 Database interface: The query to insert a new database record.
bool m_queriesBuilt
 Database interface: The flag indicating if queries are created from available controls.
bool m_controlsScanned
 Database interface: The flag indicating if available controls were scanned for field names.
CControlList m_specialProcessingControls
 Database interface: The list of the controls to exclude from standard database queries.
CDialogModalResult m_modalResult
 The result of exiting the modal mode.


Detailed Description

Dialog window.

Shows a modal window on the screen. CDialog has support for the database data exchange to edit a database record. The required SQL queries in this case are created on the fly, from the list of controls inside the dialog. Controls should have the field names defined, though. And don't forget to define a table name and key field name.


Constructor & Destructor Documentation

sptk::CDialog::CDialog ( int  w,
int  h,
const char *  label = 0 
)

Constructor.

Parameters:
w int, dialog width
h int, dialog height
label const char *, dialog caption


Member Function Documentation

CButton* sptk::CDialog::addExtraButton ( CButtonKind  buttonKind,
const char *  label,
Fl_Callback_p  callback 
)

Adds a user-defined button to the dialog.

User-defined buttons usually do something in the dialog without closing the dialog.

Parameters:
buttonKind CButtonKind, button type
label const char *, button label
callback Fl_Callback_p, button callback

virtual bool sptk::CDialog::buildQueries (  )  [protected, virtual]

Builds database interface queries using table(), keyField(), and control field names.

If m_queriesBuilt is already true, does nothing.

virtual bool sptk::CDialog::cancelPressed (  )  [protected, virtual]

Ok button callback.

If it returns true the dialog closes. False indicates an error and dialog stays open.

virtual void sptk::CDialog::database ( CDatabaseDriver db  )  [virtual]

Sets the database connection.

Parameters:
db CDatabaseDriver *, the database connection

void sptk::CDialog::defaultButton ( CButton btn  ) 

Defines the default button.

Parameters:
btn CButton *, button in dialog to become the default button

int sptk::CDialog::handle ( int  event  ) 

Own handle() method to process dialog events the special way.

Parameters:
event int, an FLTK event
Returns:
true if event was processed

Reimplemented from sptk::CWindow.

void sptk::CDialog::keyField ( std::string  keyFieldName  ) 

Sets the key field name for the database table.

The key field contains the unique value to find the database record.

Parameters:
keyFieldName std::string, the name of the key field in the database table

virtual void sptk::CDialog::load ( const CXmlNode node  )  throw (CException) [virtual]

Loads the dialog controls data from XML.

Parameters:
node const CXmlNode*, the XML node to load data from
See also:
CXmlNode

virtual bool sptk::CDialog::load (  )  [protected, virtual]

Loads data into dialog.

Returns true upon success. If you're overwriting this method make sure you're calling the original CDialog::load() and use the result of it.

CDialogModalResult sptk::CDialog::modalResult (  )  const [inline]

Returns the modal result of the dialog.

See also:
CDialogModalResult for more information.
Returns:
modal result

virtual Fl_Group* sptk::CDialog::newPage ( const char *  label,
bool  autoColor = false 
) [virtual]

Creates a new page as CGroup.

Parameters:
label const char *, page label
autoColor bool, if true the page color is assigned automatically
Returns:
created group

virtual Fl_Group* sptk::CDialog::newScroll ( const char *  label,
bool  autoColor = false 
) [virtual]

Creates a new page as CScroll.

Parameters:
label const char *, page label
autoColor bool, if true the page color is assigned automatically
Returns:
created group

virtual bool sptk::CDialog::okPressed (  )  [protected, virtual]

Ok button callback.

If it returns true the dialog closes. False indicates an error and dialog stays open.

Reimplemented in sptk::CDirOpenDialog, sptk::CFileOpenDialog, and sptk::CFileSaveDialog.

CControl& sptk::CDialog::operator[] ( std::string  fieldName  ) 

Index operator to access controls with defined field name.

Parameters:
fieldName std::string, the control field name

Reimplemented in sptk::CSpellChecker.

virtual void sptk::CDialog::save ( CXmlNode node  )  const [virtual]

Saves the dialog controls into XML.

Parameters:
node CXmlNode&, the XML node to save data into
See also:
CXmlNode* node

virtual bool sptk::CDialog::save (  )  [protected, virtual]

Saves data from dialog.

Returns true upon success. If you're overwriting this method make sure you're calling the original CDialog::save() and use the result of it.

virtual void sptk::CDialog::scanControls (  )  [protected, virtual]

Scans dialog controls.

If m_controlsScanned is already true, does nothing.

bool sptk::CDialog::showModal (  ) 

Shows modal dialog.

Returns:
true if Ok button was used to close the dialog

void sptk::CDialog::table ( CDatabaseDriver db,
std::string  tableName,
const std::string  keyFieldName 
)

Fast setup of the database connection.

Parameters:
db CDatabaseDriver*, the database connection
tableName std::string, the name of the database table
keyFieldName std::string, the name of the key field in the database table

void sptk::CDialog::table ( std::string  tableName  ) 

Defines database table to use.

Parameters:
tableName std::string, the name of the database table


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

Mon Mar 5 11:56:12 2012: SPTK 3.5.7