Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

AppPrefs Class Reference

Manages the application preferences. More...

#include <appprefs.hpp>

Collaboration diagram for AppPrefs:

Collaboration graph
[legend]
List of all members.

Public Member Functions

wxString getConfigKey (const int key) const
 Gets the key of the preference in the configuration file.

bool read (const int key, wxSize &s) const
 Reads a wxSize value from the key.

bool read (const int key, wxPoint &p) const
 Reads a wxPoint value from the key.

bool read (const int key, wxRect &r) const
 Reads a wxRect value from the key.

bool read (const int key, bool &b) const
 Reads a boolean value from the key.

bool read (const int key, double &d) const
 Reads a double value from the key.

bool read (const int key, long &l) const
 Reads a long integer value from the key.

bool read (const int key, wxString &str) const
 Reads a string from the key.

bool readBool (const int key, const bool def=false) const
 Reads a boolean value from the key.

double readDouble (const int key, const double def=-1.0) const
 Reads a double value from the key.

long readLong (const int key, const long def=-1L) const
 Reads a long integer value from the key.

wxPoint readPoint (const int key, const wxPoint &def=wxPoint(0, 0)) const
 Reads a wxPoint value from the key.

wxRect readRect (const int key, const wxRect &def=wxRect(0, 0, 0, 0)) const
 Reads a wxRect value from the key.

wxSize readSize (const int key, const wxSize &def=wxSize(0, 0)) const
 Reads a wxSize value from the key.

wxString readString (const int key, const wxString &def=wxEmptyString) const
 Reads a string from the key.

bool write (const int key, const wxSize &s)
 Write a wxSize value in the preference given by the key.

bool write (const int key, const wxPoint &p)
 Write a wxPoint value in the preference given by the key.

bool write (const int key, const wxRect &r)
 Write a wxRect value in the preference given by the key.

bool write (const int key, const bool b)
 Write a boolean value in the preference given by the key.

bool write (const int key, const double d)
 Write a double value in the preference given by the key.

bool write (const int key, const long l)
 Write a long integer value in the preference given by the key.

bool write (const int key, const wxString &str)
 Write a string in the preference given by the key.


Static Public Member Functions

void cleanupGlobal ()
 Cleans up the global instance.

AppPrefsget ()
 Gets a pointer on the global preferences.

wxString getConfigPathName ()
 Gets the full path of the file which contains the application's preferences.

wxRect getDefaultMainWindowRect ()
 Gets the default rects of the main window.

wxString getLanguagesPathName ()
 Gets the full path of the file which contains the application's languages settings.

wxString getUserDocumentsDirName ()
 Gets the directory where the user stores its documents.


Protected Member Functions

 AppPrefs (const AppPrefs &source)
 Copy constructor.

 AppPrefs ()
 Default constructor.

void clone (const AppPrefs &source)
 Clones the source instance in this instance.

void init ()
 Inits the instance.

AppPrefsoperator= (const AppPrefs &source)
 Assignment operator.


Static Protected Member Functions

wxString getConfigDir ()
 Gets the full name of the directory where the preferences of the application are stored.

wxString getConfigDirName ()
 Gets the name of the directory which contains the application's preferences.

wxString getConfigFileName ()
 Gets the name of the file which contains the application's preferences.

wxString getLanguagesFileName ()
 Gets the name of the file which contains the application's languages settings.

AppPrefsset (AppPrefs *pAppPrefs)
 Sets the global preferences.


Protected Attributes

HashPrefs prefs
 Hashmap that contains the data of preferences.


Static Protected Attributes

wxString configDir
 Full name of the directory which contains the application's preferences.

wxString configFileName
 Name of the file which contains the application preferences.

AppPrefsglobal = NULL
 Global preferences.


Detailed Description

Manages the application preferences.

You can't create directly an instance of this class. In order to get one, use the method get(). Use the method cleanupGlobal() at the end of the program to clean up the memory.

Don't use the method get() (and more generally don't create an instance of AppPrefs) before setting a correct global configuration file (see wxConfig in the wxWidgets documentation).

Use the methods read and write to get and set the values of the preferences.

Definition at line 227 of file appprefs.hpp.


Constructor & Destructor Documentation

AppPrefs::AppPrefs  )  [protected]
 

Default constructor.

Definition at line 967 of file appprefs.cpp.

References init().

Referenced by get().

AppPrefs::AppPrefs const AppPrefs source  )  [protected]
 

Copy constructor.

Parameters:
source Source instance.

Definition at line 1106 of file appprefs.cpp.

References clone().


Member Function Documentation

void AppPrefs::cleanupGlobal  )  [static]
 

Cleans up the global instance.

Use the delete operator to delete the memory taken by the global instance of AppPrefs.

It is safe to call this static method if no global preferences have been set.

Definition at line 1596 of file appprefs.cpp.

References set().

Referenced by CkSumsApp::CleanUpAppResources().

void AppPrefs::clone const AppPrefs source  )  [protected]
 

Clones the source instance in this instance.

Parameters:
source Source instance.

Definition at line 1093 of file appprefs.cpp.

References clone(), and prefs.

Referenced by AppPrefs(), clone(), and operator=().

AppPrefs * AppPrefs::get  )  [static]
 

Gets a pointer on the global preferences.

If no global instance of the class AppPrefs exists, a new instance is created.

Returns:
A pointer on the global preferences.

Definition at line 1561 of file appprefs.cpp.

References AppPrefs(), and global.

Referenced by dlgMultiCheck::btnCancelClick(), dlgBatchCreation::btnCancelClick(), ChecksumsListView::check(), dlgMultiCheck::checkChecksumsFiles(), dlgMultiCheck::checkFile(), frmSums::closeAfterInitFromCmdLine(), frmSums::createControls(), dlgNewFile::createControls(), dlgConfigure::createControls(), dlgBatchCreation::dlgBatchCreation(), dlgConfigure::dlgConfigure(), dlgMultiCheck::dlgMultiCheck(), frmSums::FrameClose(), dlgResultsProgress::getColour(), dlgConfigure::getSFVGeneratorIdentifierConfigKey(), ChecksumFileCalculator::initBufferSize(), frmSums::initializeFromCmdLine(), CkSumsApp::InitLocale(), frmSums::itmFileNewClick(), frmSums::itmFileOpenClick(), frmSums::itmFileSaveAsClick(), frmSums::itmToolsConfigureClick(), frmSums::itmToolsShowStatusbarClick(), frmSums::itmToolsShowToolbarClick(), ChecksumsListView::openChecksumFile(), SFVFile::read(), MD5File::read(), frmSums::saveChecksumFile(), ChecksumsListView::setChecksum(), Languages::setLocale(), SumListCompareFnct(), SFVFile::write(), and MD5File::write().

wxString AppPrefs::getConfigDir  )  [static, protected]
 

Gets the full name of the directory where the preferences of the application are stored.

Returns:
A string that contains the directory where the preferences of the application are stored.

Definition at line 1611 of file appprefs.cpp.

References addPathSeparatorAtEnd(), configDir, dirExists(), getConfigDirName(), and getConfigFileName().

Referenced by getConfigPathName().

wxString AppPrefs::getConfigDirName  )  [static, protected]
 

Gets the name of the directory which contains the application's preferences.

Returns:
A string that contains the name of the directory which contains the application's preferences.

Definition at line 1715 of file appprefs.cpp.

References APP_NAME.

Referenced by getConfigDir().

wxString AppPrefs::getConfigFileName  )  [static, protected]
 

Gets the name of the file which contains the application's preferences.

Returns:
A string that contains the name of the file which contains the application's preferences.

Definition at line 1685 of file appprefs.cpp.

References APP_NAME, and configFileName.

Referenced by getConfigDir(), and getConfigPathName().

wxString AppPrefs::getConfigKey const int  key  )  const
 

Gets the key of the preference in the configuration file.

Parameters:
key The key whose configuration key in the configuration file is to be returned.
Returns:
The key of the preference in the configuration file or an empty string if there is no key.

Definition at line 1134 of file appprefs.cpp.

References getConfigKey(), and prefs.

Referenced by getConfigKey(), and dlgConfigure::getSFVGeneratorIdentifierConfigKey().

wxString AppPrefs::getConfigPathName  )  [static]
 

Gets the full path of the file which contains the application's preferences.

Returns:
A string that contains the full path name of the file which contains the application's preferences.

Definition at line 1728 of file appprefs.cpp.

References addPathSeparatorAtEnd(), getConfigDir(), and getConfigFileName().

wxRect AppPrefs::getDefaultMainWindowRect  )  [static]
 

Gets the default rects of the main window.

Returns:
The default rects of the main window.

Definition at line 1785 of file appprefs.cpp.

Referenced by frmSums::createControls(), and init().

wxString AppPrefs::getLanguagesFileName  )  [static, protected]
 

Gets the name of the file which contains the application's languages settings.

Returns:
A string that contains the name of the file which contains the application's languages settings.

Definition at line 1702 of file appprefs.cpp.

Referenced by getLanguagesPathName().

wxString AppPrefs::getLanguagesPathName  )  [static]
 

Gets the full path of the file which contains the application's languages settings.

Returns:
A string that contains the full path name of the file which contains the application's languages settings.

Definition at line 1742 of file appprefs.cpp.

References getLanguagesFileName().

wxString AppPrefs::getUserDocumentsDirName  )  [static]
 

Gets the directory where the user stores its documents.

This method looks for the HOME environment variable. On Windows only it looks for the My Documents directory.

Returns:
The directory where the user stores its documents or an empty string if this directory cannot be found.

Definition at line 1811 of file appprefs.cpp.

Referenced by dlgFilesSelector::btnAddClick(), dlgFilesSelector::btnBrowseClick(), dlgAddMatchFiles::btnBrowseClick(), dlgFilesSelector::getLastDirectoryAndFilter(), and dlgAddMatchFiles::getLastDirectoryAndFilter().

void AppPrefs::init  )  [protected]
 

Inits the instance.

This method creates the preferences that will be valid and associates to them an unique integer key.

The preferences values are read from the configuration file if it's available, else default values are used.

Definition at line 983 of file appprefs.cpp.

References getDefaultMainWindowRect(), and prefs.

Referenced by AppPrefs().

AppPrefs & AppPrefs::operator= const AppPrefs source  )  [protected]
 

Assignment operator.

Parameters:
source Source instance.

Definition at line 1118 of file appprefs.cpp.

References clone(), and operator=().

Referenced by operator=().

bool AppPrefs::read const int  key,
wxSize &  s
const
 

Reads a wxSize value from the key.

Parameters:
key The key whose associated value is to be returned.
s The wxSize in which the value will be stored.
Returns:
true if the value was read, false otherwise. If the key was not found, r is not changed.

Definition at line 1389 of file appprefs.cpp.

References prefs, and read().

bool AppPrefs::read const int  key,
wxPoint &  p
const
 

Reads a wxPoint value from the key.

Parameters:
key The key whose associated value is to be returned.
p The wxPoint in which the value will be stored.
Returns:
true if the value was read, false otherwise. If the key was not found, r is not changed.

Definition at line 1350 of file appprefs.cpp.

References prefs, and read().

bool AppPrefs::read const int  key,
wxRect &  r
const
 

Reads a wxRect value from the key.

Parameters:
key The key whose associated value is to be returned.
r The wxRect in which the value will be stored.
Returns:
true if the value was read, false otherwise. If the key was not found, r is not changed.

Definition at line 1311 of file appprefs.cpp.

References prefs, and read().

bool AppPrefs::read const int  key,
bool &  b
const
 

Reads a boolean value from the key.

Parameters:
key The key whose associated value is to be returned.
b The boolean in which the value will be stored.
Returns:
true if the value was read, false otherwise. If the key was not found, b is not changed.

Definition at line 1272 of file appprefs.cpp.

References prefs, and read().

bool AppPrefs::read const int  key,
double &  d
const
 

Reads a double value from the key.

Parameters:
key The key whose associated value is to be returned.
d The double in which the value will be stored.
Returns:
true if the value was read, false otherwise. If the key was not found, d is not changed.

Definition at line 1233 of file appprefs.cpp.

References prefs, and read().

bool AppPrefs::read const int  key,
long &  l
const
 

Reads a long integer value from the key.

Parameters:
key The key whose associated value is to be returned.
l The long integer in which the value will be stored.
Returns:
true if the value was read, false otherwise. If the key was not found, l is not changed.

Definition at line 1194 of file appprefs.cpp.

References prefs, and read().

bool AppPrefs::read const int  key,
wxString &  str
const
 

Reads a string from the key.

Parameters:
key The key whose associated value is to be returned.
str The string in which the value will be stored.
Returns:
true if the value was read, false otherwise. If the key was not found, str is not changed.

Definition at line 1155 of file appprefs.cpp.

References prefs, and read().

Referenced by read(), readBool(), readDouble(), readLong(), readPoint(), readRect(), readSize(), and readString().

bool AppPrefs::readBool const int  key,
const bool  def = false
const
 

Reads a boolean value from the key.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 1291 of file appprefs.cpp.

References read(), and readBool().

Referenced by ChecksumsListView::check(), dlgMultiCheck::checkChecksumsFiles(), dlgMultiCheck::checkFile(), frmSums::closeAfterInitFromCmdLine(), frmSums::createControls(), dlgConfigure::createControls(), frmSums::FrameClose(), frmSums::initializeFromCmdLine(), ChecksumsListView::openChecksumFile(), readBool(), frmSums::saveChecksumFile(), ChecksumsListView::setChecksum(), SumListCompareFnct(), SFVFile::write(), and MD5File::write().

double AppPrefs::readDouble const int  key,
const double  def = -1.0
const
 

Reads a double value from the key.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 1252 of file appprefs.cpp.

References read(), and readDouble().

Referenced by readDouble().

long AppPrefs::readLong const int  key,
const long  def = -1L
const
 

Reads a long integer value from the key.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 1213 of file appprefs.cpp.

References read(), and readLong().

Referenced by frmSums::closeAfterInitFromCmdLine(), frmSums::createControls(), dlgNewFile::createControls(), dlgConfigure::createControls(), dlgResultsProgress::getColour(), ChecksumFileCalculator::initBufferSize(), frmSums::initializeFromCmdLine(), SFVFile::read(), MD5File::read(), readLong(), SFVFile::write(), and MD5File::write().

wxPoint AppPrefs::readPoint const int  key,
const wxPoint &  def = wxPoint(0, 0)
const
 

Reads a wxPoint value from the key.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 1369 of file appprefs.cpp.

References read(), and readPoint().

Referenced by frmSums::createControls(), and readPoint().

wxRect AppPrefs::readRect const int  key,
const wxRect &  def = wxRect(0, 0, 0, 0)
const
 

Reads a wxRect value from the key.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 1330 of file appprefs.cpp.

References read(), and readRect().

Referenced by readRect().

wxSize AppPrefs::readSize const int  key,
const wxSize &  def = wxSize(0, 0)
const
 

Reads a wxSize value from the key.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 1408 of file appprefs.cpp.

References read(), and readSize().

Referenced by frmSums::createControls(), dlgBatchCreation::dlgBatchCreation(), dlgConfigure::dlgConfigure(), dlgMultiCheck::dlgMultiCheck(), and readSize().

wxString AppPrefs::readString const int  key,
const wxString &  def = wxEmptyString
const
 

Reads a string from the key.

Parameters:
key The key whose associated value is to be returned.
def The default value to return if the value can't be read.
Returns:
The value corresponding to the key or the default value if the value hasn't been read successfully.

Definition at line 1174 of file appprefs.cpp.

References read(), and readString().

Referenced by dlgNewFile::createControls(), dlgConfigure::createControls(), CkSumsApp::InitLocale(), frmSums::itmFileOpenClick(), frmSums::itmFileSaveAsClick(), readString(), Languages::setLocale(), and SFVFile::write().

AppPrefs * AppPrefs::set AppPrefs pAppPrefs  )  [static, protected]
 

Sets the global preferences.

Parameters:
pAppPrefs A pointer on the new global preferences.
Returns:
A pointer on the old global preferences or NULL if there wasn't global preferences.

Definition at line 1578 of file appprefs.cpp.

References global, and set().

Referenced by cleanupGlobal(), and set().

bool AppPrefs::write const int  key,
const wxSize &  s
 

Write a wxSize value in the preference given by the key.

Parameters:
key The key of the preference where the value will be stored.
s The value to store.
Returns:
true if the value has been stored successfully, false otherwise.

Definition at line 1542 of file appprefs.cpp.

References prefs, and write().

bool AppPrefs::write const int  key,
const wxPoint &  p
 

Write a wxPoint value in the preference given by the key.

Parameters:
key The key of the preference where the value will be stored.
p The value to store.
Returns:
true if the value has been stored successfully, false otherwise.

Definition at line 1523 of file appprefs.cpp.

References prefs, and write().

bool AppPrefs::write const int  key,
const wxRect &  r
 

Write a wxRect value in the preference given by the key.

Parameters:
key The key of the preference where the value will be stored.
r The value to store.
Returns:
true if the value has been stored successfully, false otherwise.

Definition at line 1504 of file appprefs.cpp.

References prefs, and write().

bool AppPrefs::write const int  key,
const bool  b
 

Write a boolean value in the preference given by the key.

Parameters:
key The key of the preference where the value will be stored.
b The value to store.
Returns:
true if the value has been stored successfully, false otherwise.

Definition at line 1485 of file appprefs.cpp.

References prefs, and write().

bool AppPrefs::write const int  key,
const double  d
 

Write a double value in the preference given by the key.

Parameters:
key The key of the preference where the value will be stored.
d The value to store.
Returns:
true if the value has been stored successfully, false otherwise.

Definition at line 1466 of file appprefs.cpp.

References prefs, and write().

bool AppPrefs::write const int  key,
const long  l
 

Write a long integer value in the preference given by the key.

Parameters:
key The key of the preference where the value will be stored.
l The value to store.
Returns:
true if the value has been stored successfully, false otherwise.

Definition at line 1447 of file appprefs.cpp.

References prefs, and write().

bool AppPrefs::write const int  key,
const wxString &  str
 

Write a string in the preference given by the key.

Parameters:
key The key of the preference where the value will be stored.
str The value to store.
Returns:
true if the value has been stored successfully, false otherwise.

Definition at line 1428 of file appprefs.cpp.

References prefs, and write().

Referenced by dlgMultiCheck::btnCancelClick(), dlgBatchCreation::btnCancelClick(), frmSums::FrameClose(), frmSums::itmFileNewClick(), frmSums::itmFileOpenClick(), frmSums::itmFileSaveAsClick(), frmSums::itmToolsConfigureClick(), frmSums::itmToolsShowStatusbarClick(), frmSums::itmToolsShowToolbarClick(), and write().


Member Data Documentation

wxString AppPrefs::configDir [static, protected]
 

Full name of the directory which contains the application's preferences.

Definition at line 959 of file appprefs.cpp.

Referenced by getConfigDir().

wxString AppPrefs::configFileName [static, protected]
 

Name of the file which contains the application preferences.

Definition at line 960 of file appprefs.cpp.

Referenced by getConfigFileName().

AppPrefs * AppPrefs::global = NULL [static, protected]
 

Global preferences.

Definition at line 958 of file appprefs.cpp.

Referenced by get(), and set().

HashPrefs AppPrefs::prefs [protected]
 

Hashmap that contains the data of preferences.

Definition at line 230 of file appprefs.hpp.

Referenced by clone(), getConfigKey(), init(), read(), and write().


The documentation for this class was generated from the following files:
Generated on Sun May 30 13:38:02 2004 for wxChecksums by doxygen 1.3.7