| 1 | // ==================================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : awt_sel_boxes.hxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // // |
|---|
| 7 | // Coded by Ralf Westram (coder@reallysoft.de) in May 2005 // |
|---|
| 8 | // Copyright Department of Microbiology (Technical University Munich) // |
|---|
| 9 | // // |
|---|
| 10 | // Visit our web site at: http://www.arb-home.de/ // |
|---|
| 11 | // // |
|---|
| 12 | // ==================================================================== // |
|---|
| 13 | #ifndef AWT_SEL_BOXES_HXX |
|---|
| 14 | #define AWT_SEL_BOXES_HXX |
|---|
| 15 | |
|---|
| 16 | #ifndef _GLIBCXX_STRING |
|---|
| 17 | #include <string> |
|---|
| 18 | #endif |
|---|
| 19 | #ifndef CB_H |
|---|
| 20 | #include <cb.h> |
|---|
| 21 | #endif |
|---|
| 22 | #ifndef AW_WINDOW_HXX |
|---|
| 23 | #include <aw_window.hxx> |
|---|
| 24 | #endif |
|---|
| 25 | |
|---|
| 26 | class AP_filter; |
|---|
| 27 | class AW_DB_selection; |
|---|
| 28 | class AW_selection; |
|---|
| 29 | class AW_selection_list; |
|---|
| 30 | struct StrArray; |
|---|
| 31 | struct ConstStrArray; |
|---|
| 32 | struct CharPtrArray; |
|---|
| 33 | struct adfiltercbstruct; |
|---|
| 34 | |
|---|
| 35 | class TypedSelectionList { |
|---|
| 36 | AW_selection_list& selection_list; |
|---|
| 37 | |
|---|
| 38 | std::string content; // what is contained in the selection list ? (e.g. "probes") |
|---|
| 39 | std::string filetype_id; // shared by all selection lists with same content type; used as file-extension for save/load |
|---|
| 40 | std::string unique_id; // a unique id |
|---|
| 41 | |
|---|
| 42 | public: |
|---|
| 43 | TypedSelectionList(const char *filetype_id_, AW_selection_list *selection_list_, const char *content_, const char *unique_id_) |
|---|
| 44 | : selection_list(*selection_list_), |
|---|
| 45 | content(content_), |
|---|
| 46 | filetype_id(filetype_id_), |
|---|
| 47 | unique_id(unique_id_) |
|---|
| 48 | {} |
|---|
| 49 | |
|---|
| 50 | AW_selection_list *get_sellist() const { return &selection_list; } |
|---|
| 51 | const char *whats_contained() const { return content.c_str(); } |
|---|
| 52 | const char *get_unique_id() const { return unique_id.c_str(); } |
|---|
| 53 | const char *get_shared_id() const { return filetype_id.c_str(); } |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | typedef char *(*awt_sai_sellist_filter)(GBDATA *, AW_CL); |
|---|
| 57 | class AWT_sai_selection; |
|---|
| 58 | |
|---|
| 59 | class SAI_selection_list_spec : virtual Noncopyable { |
|---|
| 60 | char *awar_name; |
|---|
| 61 | GBDATA *gb_main; |
|---|
| 62 | |
|---|
| 63 | awt_sai_sellist_filter filter_poc; |
|---|
| 64 | AW_CL filter_cd; |
|---|
| 65 | |
|---|
| 66 | public: |
|---|
| 67 | SAI_selection_list_spec(const char *awar_name_, GBDATA *gb_main_) |
|---|
| 68 | : awar_name(strdup(awar_name_)), |
|---|
| 69 | gb_main(gb_main_), |
|---|
| 70 | filter_poc(NULL), |
|---|
| 71 | filter_cd(0) |
|---|
| 72 | {} |
|---|
| 73 | ~SAI_selection_list_spec() { free(awar_name); } |
|---|
| 74 | |
|---|
| 75 | void define_filter(awt_sai_sellist_filter filter_poc_, AW_CL filter_cd_) { |
|---|
| 76 | // Warning: do not use different filters for same awar! (wont work as expected) |
|---|
| 77 | filter_poc = filter_poc_; |
|---|
| 78 | filter_cd = filter_cd_; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | const char *get_awar_name() const { return awar_name; } |
|---|
| 82 | |
|---|
| 83 | AWT_sai_selection *create_list(AW_window *aws, bool fallback2default) const; |
|---|
| 84 | }; |
|---|
| 85 | |
|---|
| 86 | // ----------------------------------------- |
|---|
| 87 | // various database selection boxes |
|---|
| 88 | |
|---|
| 89 | AW_DB_selection *awt_create_selection_list_on_alignments(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match); |
|---|
| 90 | void awt_reconfigure_selection_list_on_alignments(AW_DB_selection *alisel, const char *ali_type_match); |
|---|
| 91 | |
|---|
| 92 | AW_DB_selection *awt_create_selection_list_on_trees(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default); |
|---|
| 93 | |
|---|
| 94 | void awt_create_selection_list_on_pt_servers(AW_window *aws, const char *varname, bool popup); |
|---|
| 95 | void awt_edit_arbtcpdat_cb(AW_window *aww, GBDATA *gb_main); |
|---|
| 96 | |
|---|
| 97 | void awt_create_selection_list_on_tables(GBDATA *gb_main, AW_window *aws, const char *varname); |
|---|
| 98 | void awt_create_selection_list_on_table_fields(GBDATA *gb_main, AW_window *aws, const char *tablename, const char *varname); |
|---|
| 99 | AW_window *AWT_create_tables_admin_window(AW_root *aw_root, GBDATA *gb_main); |
|---|
| 100 | |
|---|
| 101 | AWT_sai_selection *awt_create_selection_list_on_sai(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default, awt_sai_sellist_filter filter_poc = 0, AW_CL filter_cd = 0); |
|---|
| 102 | void awt_selection_list_on_sai_update_cb(UNFIXED, AWT_sai_selection *cbsid); |
|---|
| 103 | void awt_popup_sai_selection_list(AW_window *aww, const char *awar_name, GBDATA *gb_main); |
|---|
| 104 | void awt_create_SAI_selection_button(GBDATA *gb_main, AW_window *aws, const char *varname, awt_sai_sellist_filter filter_poc = 0, AW_CL filter_cd = 0); |
|---|
| 105 | |
|---|
| 106 | void awt_create_selection_list_on_configurations(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default); |
|---|
| 107 | char *awt_create_string_on_configurations(GBDATA *gb_main); |
|---|
| 108 | |
|---|
| 109 | // ------------------------------- |
|---|
| 110 | |
|---|
| 111 | AW_selection *awt_create_subset_selection_list(AW_window *aww, AW_selection_list *select_subset_from, const char *at_box, const char *at_add, const char *at_sort); |
|---|
| 112 | |
|---|
| 113 | // ------------------------------- |
|---|
| 114 | // generic file prompter |
|---|
| 115 | |
|---|
| 116 | AW_window *awt_create_load_box(AW_root *aw_root, |
|---|
| 117 | const char *action, |
|---|
| 118 | const char *what, |
|---|
| 119 | const char *default_directory, |
|---|
| 120 | const char *file_extension, |
|---|
| 121 | char **set_file_name_awar, |
|---|
| 122 | const WindowCallback& ok_cb, |
|---|
| 123 | const WindowCallback& abort_cb = makeWindowCallback(AW_POPDOWN), |
|---|
| 124 | const char *close_button_text = NULL); |
|---|
| 125 | |
|---|
| 126 | // ------------------------------------------ |
|---|
| 127 | // save/load selection list content |
|---|
| 128 | |
|---|
| 129 | typedef GB_ERROR (*ssl_to_storage)(const CharPtrArray& display, const CharPtrArray& value, StrArray& line); |
|---|
| 130 | typedef GB_ERROR (*ssl_from_storage)(const CharPtrArray& line, StrArray& display, StrArray& value); |
|---|
| 131 | |
|---|
| 132 | class StorableSelectionList { |
|---|
| 133 | TypedSelectionList tsl; |
|---|
| 134 | ssl_to_storage list2file; |
|---|
| 135 | ssl_from_storage file2list; |
|---|
| 136 | |
|---|
| 137 | public: |
|---|
| 138 | StorableSelectionList(const TypedSelectionList& tsl_); |
|---|
| 139 | StorableSelectionList(const TypedSelectionList& tsl_, ssl_to_storage list2file_, ssl_from_storage file2list_) |
|---|
| 140 | : tsl(tsl_), |
|---|
| 141 | list2file(list2file_), |
|---|
| 142 | file2list(file2list_) |
|---|
| 143 | {} |
|---|
| 144 | |
|---|
| 145 | const TypedSelectionList& get_typedsellist() const { return tsl; } |
|---|
| 146 | const char *get_filter() const { return tsl.get_shared_id(); } |
|---|
| 147 | |
|---|
| 148 | GB_ERROR save(const char *filename, long number_of_lines = 0) const; |
|---|
| 149 | GB_ERROR load(const char *filemask, bool append) const; |
|---|
| 150 | }; |
|---|
| 151 | |
|---|
| 152 | AW_window *create_save_box_for_selection_lists(AW_root *aw_root, const StorableSelectionList *storabsellist); |
|---|
| 153 | AW_window *create_load_box_for_selection_lists(AW_root *aw_root, const StorableSelectionList *storabsellist); |
|---|
| 154 | |
|---|
| 155 | void create_print_box_for_selection_lists(AW_window *aw_window, const TypedSelectionList *typedsellist); |
|---|
| 156 | |
|---|
| 157 | void awt_clear_selection_list_cb(AW_window *, AW_selection_list *sellist); |
|---|
| 158 | |
|---|
| 159 | #else |
|---|
| 160 | #error awt_sel_boxes.hxx included twice |
|---|
| 161 | #endif // AWT_SEL_BOXES_HXX |
|---|
| 162 | |
|---|