preferences.h
上传用户:psq1974
上传日期:2007-01-06
资源大小:1195k
文件大小:2k
- /* Copyright (C) 1998, 1999 State University of New York at Stony Brook
- Author: Andrew V. Shuvalov ( andrew@ecsl.cs.sunysb.edu )
- Software license is located in file "COPYING"
- */
- #ifndef _preferences_h_
- #define _preferences_h_
- #include <gtk--.h>
- class Session;
- /** parent abstract class to store configuration parameter
- */
- class BaseConfigItem {
- protected:
- void init_base( const char *des, const char *k );
- public:
- string descr;
- string key;
- BaseConfigItem() {}
- virtual void init
- ( GDBM_FILE dbf, const char *des, const char *k, const char *def,
- Session *ses ) = 0;
- virtual void update( const string &newval ) = 0;
- virtual void load( GDBM_FILE dbf ) = 0;
- virtual void store( GDBM_FILE dbf ) = 0;
- virtual const string &str() const = 0;
- };
- /**
- */
- class ConfigItemStr : public BaseConfigItem {
- string value;
- public:
- void init( GDBM_FILE dbf, const char *des, const char *k, const char *def,
- Session *ses );
- void update( const string &newval );
- void load( GDBM_FILE dbf );
- void store( GDBM_FILE dbf );
-
- const string &str() const;
- const char *c_str() const { return value.c_str(); }
- };
- /**
- */
- class ConfigItemInt : public BaseConfigItem {
- int value;
- string strrepr;
- public:
- void init( GDBM_FILE dbf, const char *des, const char *k, const char *def,
- Session *ses );
- void update( const string &newval );
- void load( GDBM_FILE dbf );
- void store( GDBM_FILE dbf );
-
- const string &str() const { return strrepr; }
- operator int() const { return value; }
- void fix();
- };
- /** edit preferences
- */
- class PrefWindow : public Gtk_Window {
- /** reference to Session */
- Session &session;
- Gtk_VBox *profList;
- vector< Gtk_Entry * > entries;
- public:
- static const int topWindowInitSizeX = 700;
- static const int topWindowInitSizeY = 400;
- public:
- PrefWindow( Session &session );
- void add_config_items();
- void update_from_screen();
- void callback_select_list_item( gpointer entry );
- void callback_save();
- void callback_ok();
- void callback_cancel();
- };
- #endif // _preferences_h_