00001 #ifndef FILE_SELECT_H_INCLUDED
00002 #define FILE_SELECT_H_INCLUDED
00003
00004 #include "std/support.H"
00005 #include "std/config.H"
00006
00007
00008
00009
00010
00011 class FileSelect
00012 {
00013 public :
00014
00015 enum icon_t {
00016 NO_ICON = -1,
00017 LOAD_ICON = 0,
00018 SAVE_ICON,
00019 DISC_ICON,
00020 JOT_ICON,
00021 ICON_NUM
00022 };
00023
00024 enum action_t {
00025 OK_ACTION = 0,
00026 CANCEL_ACTION
00027 };
00028
00029
00030 public :
00031
00032 typedef void (*file_cb_t) (void *,int,int,str_ptr,str_ptr);
00033
00034 protected:
00035
00036
00037 public :
00038
00039
00040 protected:
00041
00042
00043 str_ptr _title;
00044 str_ptr _action;
00045 icon_t _icon;
00046 str_ptr _path;
00047 str_ptr _file;
00048 int _filter;
00049 str_list _filters;
00050
00051
00052 public :
00053 FileSelect() : _title(""), _action("OK"), _icon(NO_ICON), _path(Config::JOT_ROOT()), _file("")
00054 {
00055 _filter = 0;
00056 _filters += "*";
00057 }
00058 virtual ~FileSelect() {}
00059
00060
00061
00062 virtual bool set_title(Cstr_ptr &s) { if (is_displaying()) return false; _title = s; return true; }
00063 virtual bool set_action(Cstr_ptr &s) { if (is_displaying()) return false; _action = s; return true; }
00064 virtual bool set_icon(icon_t i) { if (is_displaying()) return false; _icon = i; return true; }
00065 virtual bool set_path(Cstr_ptr &s) { if (is_displaying()) return false; _path = s; return true; }
00066 virtual bool set_file(Cstr_ptr &s) { if (is_displaying()) return false; _file = s; return true; }
00067 virtual bool set_filter(Cstr_ptr &s) { if (is_displaying()) return false; add_filter(s); _filter = _filters.get_index(s); return true; }
00068 virtual bool add_filter(Cstr_ptr &s) { if (is_displaying()) return false; _filters.add_uniquely(s); return true; }
00069
00070 virtual bool clear_title() { if (is_displaying()) return false; _title = ""; return true; }
00071 virtual bool clear_action() { if (is_displaying()) return false; _action = "OK"; return true; }
00072 virtual bool clear_icon() { if (is_displaying()) return false; _icon = NO_ICON; return true; }
00073 virtual bool clear_path() { if (is_displaying()) return false; _path = Config::JOT_ROOT(); return true; }
00074 virtual bool clear_file() { if (is_displaying()) return false; _file = ""; return true; }
00075 virtual bool clear_filter() { if (is_displaying()) return false; set_filter("*"); return true; }
00076 virtual bool clear_filters() { if (is_displaying()) return false; _filters.clear(); set_filter("*"); return true; }
00077
00078 virtual str_ptr get_title() { return _title; }
00079 virtual str_ptr get_action() { return _action; }
00080 virtual icon_t get_icon() { return _icon; }
00081 virtual str_ptr get_path() { return _path; }
00082 virtual str_ptr get_file() { return _file; }
00083 virtual str_ptr get_filter() { return _filters[_filter]; }
00084 virtual str_list get_filters() { return _filters; }
00085
00086
00087 public:
00088 virtual bool is_displaying() = 0;
00089 virtual bool display(bool blocking, file_cb_t cb, void *vp, int idx) = 0;
00090 protected:
00091 virtual bool undisplay(int button, str_ptr path, str_ptr file) = 0;
00092
00093 };
00094
00095 #endif