00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#ifndef INC_APPPREFS_HPP
00026
#define INC_APPPREFS_HPP
00027
00028
00029
00030
#include <wx/wxprec.h>
00031
00032
#ifdef __BORLANDC__
00033
#pragma hdrstop
00034
#endif
00035
00036
#ifndef WX_PRECOMP
00037
00038
#include <wx/wx.h>
00039
#endif
00040
#include <wx/hashmap.h>
00041
#include <wx/config.h>
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 class PreferenceValue
00069 {
00070
protected:
00071
00072 enum PreferenceType
00073 {
00074 ptNotDefined = 0,
00075 ptLong,
00076 ptString,
00077 ptDouble,
00078 ptBoolean,
00079 ptRect,
00080 ptSize,
00081 ptPoint
00082 };
00083
00084
00085 union value_t
00086 {
00087 long*
valLong;
00088 wxString*
valString;
00089 double*
valDouble;
00090 bool*
valBool;
00091 wxRect*
valRect;
00092 wxSize*
valSize;
00093 wxPoint*
valPoint;
00094 };
00095
00096 value_t _value;
00097 PreferenceType _valueType;
00098 wxString
_cfgKey;
00099
00100
protected:
00101
00102
void clone(
const PreferenceValue& source);
00103
00104
00105
void cleanup();
00106
00107
public:
00108
00109
PreferenceValue();
00110
00111
00112
PreferenceValue(
const long value,
const wxString& cfgKey = wxEmptyString,
const bool initFromCfgFile =
true);
00113
00114
00115
PreferenceValue(
const wxString& value,
const wxString& cfgKey = wxEmptyString,
const bool initFromCfgFile =
true);
00116
00117
00118
PreferenceValue(
const double value,
const wxString& cfgKey = wxEmptyString,
const bool initFromCfgFile =
true);
00119
00120
00121
PreferenceValue(
const bool value,
const wxString& cfgKey = wxEmptyString,
const bool initFromCfgFile =
true);
00122
00123
00124
PreferenceValue(
const wxRect& value,
const wxString& cfgKey = wxEmptyString,
const bool initFromCfgFile =
true);
00125
00126
00127
PreferenceValue(
const wxPoint& value,
const wxString& cfgKey = wxEmptyString,
const bool initFromCfgFile =
true);
00128
00129
00130
PreferenceValue(
const wxSize& value,
const wxString& cfgKey = wxEmptyString,
const bool initFromCfgFile =
true);
00131
00132
00133
PreferenceValue(
const PreferenceValue& source);
00134
00135
00136
PreferenceValue&
operator=(
const PreferenceValue& source);
00137
00138
00139
~PreferenceValue();
00140
00141
00142 wxString
getConfigKey() const;
00143
00144
00145
bool get(
long& value) const;
00146
00147
00148
bool set(const
long newValue);
00149
00150
00151
bool get(wxString& value) const;
00152
00153
00154
bool set(const wxString& newValue);
00155
00156
00157
bool get(
double& value) const;
00158
00159
00160
bool set(const
double newValue);
00161
00162
00163
bool get(
bool& value) const;
00164
00165
00166
bool set(const
bool newValue);
00167
00168
00169
bool get(wxRect& value) const;
00170
00171
00172
bool set(const wxRect& newValue);
00173
00174
00175
bool get(wxPoint& value) const;
00176
00177
00178
bool set(const wxPoint& newValue);
00179
00180
00181
bool get(wxSize& value) const;
00182
00183
00184
bool set(const wxSize& newValue);
00185
00186
00187 static
bool read(const wxString& key, wxRect* r, wxConfigBase* cfg = NULL);
00188
00189
00190 static wxRect read(const wxString& key, const wxRect& def, wxConfigBase* cfg = NULL);
00191
00192
00193 static
bool read(const wxString& key, wxPoint* r, wxConfigBase* cfg = NULL);
00194
00195
00196 static wxPoint read(const wxString& key, const wxPoint& def, wxConfigBase* cfg = NULL);
00197
00198
00199 static
bool read(const wxString& key, wxSize* r, wxConfigBase* cfg = NULL);
00200
00201
00202 static wxSize read(const wxString& key, const wxSize& def, wxConfigBase* cfg = NULL);
00203 };
00204
00205
00206
00207
00208 WX_DECLARE_HASH_MAP(
int,
PreferenceValue, wxIntegerHash, wxIntegerEqual, HashPrefs);
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 class
AppPrefs
00228 {
00229
protected:
00230 HashPrefs prefs;
00231
00232
00233
void clone(
const AppPrefs& source);
00234
00235
00236
void init();
00237
00238
00239 AppPrefs();
00240
00241
00242 AppPrefs(
const AppPrefs& source);
00243
00244
00245 AppPrefs& operator=(
const AppPrefs& source);
00246
00247
public:
00248
00249 wxString
getConfigKey(
const int key)
const;
00250
00251
00252
bool read(
const int key, wxString& str)
const;
00253
00254
00255 wxString readString(
const int key,
const wxString& def = wxEmptyString)
const;
00256
00257
00258
bool read(
const int key,
long& l)
const;
00259
00260
00261
long readLong(
const int key,
const long def = -1L)
const;
00262
00263
00264
bool read(
const int key,
double& d)
const;
00265
00266
00267
double readDouble(
const int key,
const double def = -1.0)
const;
00268
00269
00270
bool read(
const int key,
bool& b)
const;
00271
00272
00273
bool readBool(
const int key,
const bool def =
false)
const;
00274
00275
00276
bool read(
const int key, wxRect& r)
const;
00277
00278
00279 wxRect readRect(
const int key,
const wxRect& def = wxRect(0, 0, 0, 0)) const;
00280
00281
00282
bool read(const
int key, wxPoint& p) const;
00283
00284
00285 wxPoint readPoint(const
int key, const wxPoint& def = wxPoint(0, 0)) const;
00286
00287
00288
bool read(const
int key, wxSize& s) const;
00289
00290
00291 wxSize readSize(const
int key, const wxSize& def = wxSize(0, 0)) const;
00292
00293
00294
bool write(const
int key, const wxString& str);
00295
00296
00297
bool write(const
int key, const
long l);
00298
00299
00300
bool write(const
int key, const
double d);
00301
00302
00303
bool write(const
int key, const
bool b);
00304
00305
00306
bool write(const
int key, const wxRect& r);
00307
00308
00309
bool write(const
int key, const wxPoint& p);
00310
00311
00312
bool write(const
int key, const wxSize& s);
00313
00314
00315 protected:
00316 static AppPrefs* global;
00317 static wxString configDir;
00318 static wxString configFileName;
00319
00320
00321 static wxString getConfigDir();
00322
00323
00324 static wxString getConfigFileName();
00325
00326
00327 static wxString getLanguagesFileName();
00328
00329
00330 static wxString getConfigDirName();
00331
00332
00333 static AppPrefs* set(AppPrefs* pAppPrefs);
00334
00335 public:
00336
00337 static AppPrefs* get();
00338
00339
00340 static
void cleanupGlobal();
00341
00342
00343 static wxString getConfigPathName();
00344
00345
00346 static wxString getLanguagesPathName();
00347
00348
00349 static wxRect getDefaultMainWindowRect();
00350
00351
00352 static wxString getUserDocumentsDirName();
00353 };
00354
00355
00356
00357
00358 enum PreferencesKeys
00359 {
00360 prGUI_MAIN_SAVE_WINDOW_POSITION = 100,
00361 prGUI_MAIN_SAVE_WINDOW_SIZE,
00362 prGUI_MAIN_WINDOW_POSITION,
00363 prGUI_MAIN_WINDOW_SIZE,
00364 prGUI_MAIN_SHOW_TOOLBAR,
00365 prGUI_MAIN_SHOW_STATUSBAR,
00366 prGUI_MAIN_SUMS_SAVECOLUMNTOSORT,
00367 prGUI_MAIN_SUMS_COLUMNTOSORT,
00368 prGUI_MAIN_SUMS_COLUMNSORTORDER,
00369 prGUI_MAIN_SUMS_SAVECOLUMNSWIDTHS,
00370 prGUI_MAIN_SUMS_COL_FILENAME_WIDTH,
00371 prGUI_MAIN_SUMS_COL_DIRECTORY_WIDTH,
00372 prGUI_MAIN_SUMS_COL_CHECKSUM_WIDTH,
00373 prGUI_MAIN_SUMS_COL_STATE_WIDTH,
00374 prGUI_MAIN_SUMS_COL_FIRST,
00375 prGUI_MAIN_SUMS_COL_SECOND,
00376 prGUI_MAIN_SUMS_COL_THIRD,
00377 prGUI_MAIN_SUMS_COL_FOURTH,
00378 prGUI_MAIN_SUMS_DIRSINABSOLUTEPATH,
00379 prGUI_MAIN_SUMS_UPPERCASE,
00380 prGUI_MAIN_SUMS_HRULES,
00381 prGUI_MAIN_SUMS_VRULES,
00382 prGUI_MAIN_LAST_DIRECTORY,
00383 prGUI_CONF_WINDOW_SIZE,
00384 prGUI_CONF_SASH_POSITION,
00385 prGUI_NEWFILE_LAST_DIRECTORY,
00386 prGUI_NEWFILE_LAST_FILETYPE,
00387 prGUI_AUTO_CHECK_ON_OPEN,
00388 prGUI_DLG_SUMUP_CHECK,
00389 prGUI_WARN_ON_INVALID_WHEN_SAVING,
00390 prGUI_CLN_VERIFY_DONT_SHOW_GUI,
00391 prGUI_CLN_APPEND_SHOW_GUI,
00392 prGUI_CLN_CREATE_SHOW_GUI,
00393 prLANGUAGE_NAME,
00394 prSFV_READ_PATH_SEPARATOR,
00395 prSFV_WRITE_GEN_AND_DATE,
00396 prSFV_IDENTIFY_AS,
00397 prSFV_WRITE_FILE_SIZE_AND_DATE,
00398 prSFV_WRITE_PATH_SEPARATOR,
00399 prSFV_WRITE_EOL,
00400 prMD5_READ_PATH_SEPARATOR,
00401 prMD5_WRITE_GEN_AND_DATE,
00402 prMD5_WRITE_FILE_SIZE_AND_DATE,
00403 prMD5_WRITE_PATH_SEPARATOR,
00404 prMD5_WRITE_EOL,
00405 prMC_WINDOW_SIZE,
00406 prMC_GLOBAL_SUMMARY,
00407 prMC_CHECKSUMS_FILE_SUMMARY,
00408 prMC_FILE_STATE,
00409 prMC_NO_CORRECT_FILE_STATE,
00410 prMC_NORMAL_COLOUR,
00411 prMC_SUCCESS_COLOUR,
00412 prMC_WARNING_COLOUR,
00413 prMC_ERROR_COLOUR,
00414 prBC_WINDOW_SIZE,
00415 prBC_OVERWRITE_WHEN_CKFILE_EXISTS,
00416 prBC_REPLACE_FILE_EXTENSION,
00417 prBC_VERBOSITY_LEVEL,
00418 prBC_NORMAL_COLOUR,
00419 prBC_SUCCESS_COLOUR,
00420 prBC_WARNING_COLOUR,
00421 prBC_ERROR_COLOUR,
00422 prENGINE_READ_BUFFER
00423 };
00424
00425
00426
00427
#endif // #define INC_APPPREFS_HPP