1 | // =========================================================== // |
---|
2 | // // |
---|
3 | // File : awt.hxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =========================================================== // |
---|
10 | |
---|
11 | #ifndef AWT_HXX |
---|
12 | #define AWT_HXX |
---|
13 | |
---|
14 | #ifndef ARB_ASSERT_H |
---|
15 | #include <arb_assert.h> |
---|
16 | #endif |
---|
17 | #define awt_assert(bed) arb_assert(bed) |
---|
18 | |
---|
19 | #ifndef AW_WINDOW_HXX |
---|
20 | #include <aw_window.hxx> |
---|
21 | #endif |
---|
22 | #ifndef ARBDB_H |
---|
23 | #include <arbdb.h> |
---|
24 | #endif |
---|
25 | |
---|
26 | // ------------------------------------------------------------ |
---|
27 | // filename related functions: |
---|
28 | |
---|
29 | char *AWT_fold_path(char *path, const char *pwd = "PWD"); |
---|
30 | char *AWT_unfold_path(const char *path, const char *pwd = "PWD"); |
---|
31 | const char *AWT_valid_path(const char *path); |
---|
32 | |
---|
33 | int AWT_is_dir(const char *path); |
---|
34 | int AWT_is_file(const char *path); |
---|
35 | int AWT_is_link(const char *path); |
---|
36 | char *AWT_extract_directory(const char *path); |
---|
37 | |
---|
38 | // ------------------------------------------------------------ |
---|
39 | |
---|
40 | // holds all stuff needed to make ad_.. functions work with species _and_ genes (and more..) |
---|
41 | |
---|
42 | typedef enum { |
---|
43 | AWT_QUERY_ITEM_SPECIES, |
---|
44 | AWT_QUERY_ITEM_GENES, |
---|
45 | AWT_QUERY_ITEM_EXPERIMENTS, |
---|
46 | |
---|
47 | AWT_QUERY_ITEM_TYPES // how many different types do we have |
---|
48 | |
---|
49 | } AWT_QUERY_ITEM_TYPE; |
---|
50 | |
---|
51 | typedef enum { |
---|
52 | AWT_QUERY_CURRENT_SPECIES, |
---|
53 | AWT_QUERY_MARKED_SPECIES, |
---|
54 | AWT_QUERY_ALL_SPECIES |
---|
55 | } AWT_QUERY_RANGE; |
---|
56 | |
---|
57 | typedef enum { |
---|
58 | AWT_QUERY_SORT_NONE = 0, |
---|
59 | |
---|
60 | // "real" criteria: |
---|
61 | AWT_QUERY_SORT_BY_1STFIELD_CONTENT = 1, // by content of first selected search field |
---|
62 | AWT_QUERY_SORT_BY_ID = 2, // by item id (not by parent) |
---|
63 | AWT_QUERY_SORT_BY_NESTED_PID = 4, // by nested parent id |
---|
64 | AWT_QUERY_SORT_BY_MARKED = 8, // marked items first |
---|
65 | AWT_QUERY_SORT_BY_HIT_DESCRIPTION = 16, // by hit description |
---|
66 | AWT_QUERY_SORT_REVERSE = 32, // revert following (may occur multiple times) |
---|
67 | |
---|
68 | } AWT_QUERY_RESULT_ORDER; |
---|
69 | |
---|
70 | #define AWT_QUERY_SORT_CRITERIA_BITS 6 // number of "real" sort criteria |
---|
71 | #define AWT_QUERY_SORT_CRITERIA_MASK ((1<<AWT_QUERY_SORT_CRITERIA_BITS)-1) |
---|
72 | |
---|
73 | struct ad_item_selector { |
---|
74 | AWT_QUERY_ITEM_TYPE type; |
---|
75 | |
---|
76 | // if user selects an item in the result list, |
---|
77 | // this callback sets the appropriate AWARs |
---|
78 | // - for species: AWAR_SPECIES_NAME is changed (item_name = 'species_name') |
---|
79 | // - for genes: AWAR_GENE_NAME and AWAR_SPECIES_NAME are changed (item_name = 'species_name/gene_name') |
---|
80 | void (*update_item_awars)(GBDATA* gb_main, AW_root *aw_root, const char *item_name); |
---|
81 | char *(*generate_item_id)(GBDATA *gb_main, GBDATA *gb_item); |
---|
82 | GBDATA *(*find_item_by_id)(GBDATA *gb_main, const char *id); |
---|
83 | AW_CB selection_list_rescan_cb; |
---|
84 | int item_name_length; // -1 means "unknown" (might be long) |
---|
85 | |
---|
86 | const char *change_key_path; |
---|
87 | const char *item_name; // "species" or "gene" or "experiment" or "organism" |
---|
88 | const char *items_name; // "species" or "genes" or "experiments" or "organisms" |
---|
89 | const char *id_field; // e.g. "name" for species, genes |
---|
90 | |
---|
91 | GBDATA *(*get_first_item_container)(GBDATA *, AW_root *, AWT_QUERY_RANGE); // AW_root may be NULL for AWT_QUERY_ALL_SPECIES and AWT_QUERY_MARKED_SPECIES |
---|
92 | GBDATA *(*get_next_item_container)(GBDATA *, AWT_QUERY_RANGE); // use same AWT_QUERY_RANGE as in get_first_item_container() |
---|
93 | |
---|
94 | GBDATA *(*get_first_item)(GBDATA *); |
---|
95 | GBDATA *(*get_next_item)(GBDATA *); |
---|
96 | |
---|
97 | GBDATA *(*get_selected_item)(GBDATA *gb_main, AW_root *aw_root); // searches the currently selected item |
---|
98 | |
---|
99 | struct ad_item_selector *parent_selector; // selector of parent item (or NULL if item has no parents) |
---|
100 | GBDATA *(*get_parent)(GBDATA *gb_item); // if 'parent_selector' is defined, this function returns the parent of the item |
---|
101 | }; |
---|
102 | |
---|
103 | char *AWT_get_item_id(GBDATA *gb_main, const ad_item_selector *sel, GBDATA *gb_item); |
---|
104 | GBDATA *AWT_get_item_with_id(GBDATA *gb_main, const ad_item_selector *sel, const char *id); |
---|
105 | |
---|
106 | extern ad_item_selector AWT_species_selector; |
---|
107 | extern ad_item_selector AWT_organism_selector; |
---|
108 | |
---|
109 | /************************************************************************** |
---|
110 | ********************* File Selection Boxes ******************* |
---|
111 | ***************************************************************************/ |
---|
112 | |
---|
113 | void awt_create_selection_box(AW_window *aws, const char *awar_prefix, const char *at_prefix = "", const char *pwd = "PWD", bool show_dir = true, bool allow_wildcards = false); |
---|
114 | /* Create a file selection box, this box needs 3 AWARS: |
---|
115 | |
---|
116 | 1. "$awar_prefix/filter" |
---|
117 | 2. "$awar_prefix/directory" |
---|
118 | 3. "$awar_prefix/file_name" |
---|
119 | |
---|
120 | (Note: The function aw_create_selection_box_awars can be used to create them) |
---|
121 | */ |
---|
122 | |
---|
123 | /* the "$awar_prefix/file_name" contains the full filename |
---|
124 | Use awt_get_selected_fullname() to read it. |
---|
125 | |
---|
126 | The items are placed at |
---|
127 | |
---|
128 | 1. "$at_prefix""filter" |
---|
129 | 2. "$at_prefix""box" |
---|
130 | 3. "$at_prefix""file_name" |
---|
131 | |
---|
132 | if show_dir== true than show directories and files |
---|
133 | else only files |
---|
134 | |
---|
135 | pwd is a 'shell enviroment variable' which indicates the base directory |
---|
136 | ( mainly PWD or ARBHOME ) */ |
---|
137 | |
---|
138 | char *awt_get_selected_fullname(AW_root *awr, const char *awar_prefix); |
---|
139 | |
---|
140 | void awt_refresh_selection_box(AW_root *awr, const char *awar_prefix); |
---|
141 | |
---|
142 | // ------------------------------- |
---|
143 | |
---|
144 | AW_window *create_save_box_for_selection_lists(AW_root *aw_root,AW_CL selid); |
---|
145 | AW_window *create_load_box_for_selection_lists(AW_root *aw_root,AW_CL selid); |
---|
146 | void create_print_box_for_selection_lists(AW_window *aw_window,AW_CL selid); |
---|
147 | /* Create a file selection box to save a selection list */ |
---|
148 | |
---|
149 | /************************************************************************** |
---|
150 | ********************* Query Box ******************* |
---|
151 | ***************************************************************************/ |
---|
152 | |
---|
153 | |
---|
154 | #define IS_QUERIED(gb_species,cbs) (cbs->select_bit & GB_read_usr_private(gb_species)) |
---|
155 | class awt_query_struct { |
---|
156 | public: |
---|
157 | awt_query_struct(void); |
---|
158 | |
---|
159 | GBDATA *gb_main; // the main database (in merge tool: source db in left query; dest db in right query) |
---|
160 | GBDATA *gb_ref; // second reference database (only used by merge tool; dest db in left query; source db in right query) |
---|
161 | bool expect_hit_in_ref_list; // merge-tool: when searching dups in fields: match only if hit exists in other DBs hitlist (true for DBII-query) |
---|
162 | AWAR species_name; // AWAR containing current species name |
---|
163 | AWAR tree_name; // AWAR containing current tree name |
---|
164 | |
---|
165 | const ad_item_selector *selector; // which kind of item do we handle? |
---|
166 | |
---|
167 | // bool query_genes; // true -> create gene query box |
---|
168 | // AWAR gene_name; // AWAR containing current gene name |
---|
169 | |
---|
170 | int select_bit; // one of 1 2 4 8 .. 128 (one for each query box) |
---|
171 | int use_menu; // put additional commands in menu |
---|
172 | |
---|
173 | const char *ere_pos_fig; // rebuild enlarge reduce |
---|
174 | const char *where_pos_fig; // current, marked or all species (used for sub-items of species) |
---|
175 | const char *by_pos_fig; // fit query dont fit, marked |
---|
176 | |
---|
177 | const char *qbox_pos_fig; // key box for queries |
---|
178 | const char *rescan_pos_fig; // rescan label |
---|
179 | const char *key_pos_fig; // the key |
---|
180 | const char *query_pos_fig; // the query |
---|
181 | |
---|
182 | |
---|
183 | const char *result_pos_fig; // the result box |
---|
184 | const char *count_pos_fig; |
---|
185 | |
---|
186 | const char *do_query_pos_fig; |
---|
187 | const char *config_pos_fig; |
---|
188 | const char *do_mark_pos_fig; |
---|
189 | const char *do_unmark_pos_fig; |
---|
190 | const char *do_delete_pos_fig; |
---|
191 | const char *do_set_pos_fig; // multi set a key |
---|
192 | const char *open_parser_pos_fig; |
---|
193 | const char *do_refresh_pos_fig; |
---|
194 | AW_CL create_view_window; // AW_window *(*create_view_window)(AW_root *aw_root) |
---|
195 | |
---|
196 | const char *info_box_pos_fig; |
---|
197 | |
---|
198 | }; |
---|
199 | |
---|
200 | struct adaqbsstruct; |
---|
201 | void awt_copy_selection_list_2_queried_species(struct adaqbsstruct *cbs, AW_selection_list *id, const char *hit_description); |
---|
202 | struct adaqbsstruct *awt_create_query_box(AW_window *aws, awt_query_struct *awtqs, const char *query_id); // create the query box |
---|
203 | /* Create the query box */ |
---|
204 | void awt_search_equal_entries(AW_window *dummy, struct adaqbsstruct *cbs, bool tokenize); |
---|
205 | long awt_count_queried_items(struct adaqbsstruct *cbs, AWT_QUERY_RANGE range); |
---|
206 | void awt_unquery_all(void *dummy, struct adaqbsstruct *cbs); |
---|
207 | |
---|
208 | AW_window *awt_create_item_colorizer(AW_root *aw_root, GBDATA *gb_main, const ad_item_selector *sel); |
---|
209 | |
---|
210 | /************************************************************************** |
---|
211 | ********************* Simple Awar Controll Procs ******************* |
---|
212 | ***************************************************************************/ |
---|
213 | |
---|
214 | void awt_set_long(AW_window *aws, AW_CL varname, AW_CL value); // set an awar |
---|
215 | void awt_set_string(AW_window *aws, AW_CL varname, AW_CL value); // set an awar |
---|
216 | |
---|
217 | /************************************************************************** |
---|
218 | ********************* Call External Editor ******************* |
---|
219 | ***************************************************************************/ |
---|
220 | |
---|
221 | typedef void (*awt_fileChanged_cb)(const char *path, bool fileWasChanged, bool editorTerminated); |
---|
222 | void AWT_edit(const char *path, awt_fileChanged_cb callback = 0, AW_window *aww = 0, GBDATA *gb_main = 0); |
---|
223 | |
---|
224 | void AWT_create_ascii_print_window(AW_root *awr, const char *text_to_print,const char *title=0); |
---|
225 | void AWT_write_file(const char *filename,const char *file); |
---|
226 | void AWT_show_file(AW_root *awr, const char *filename); |
---|
227 | |
---|
228 | enum AD_MAP_VIEWER_TYPE { |
---|
229 | ADMVT_INFO, |
---|
230 | ADMVT_WWW, |
---|
231 | ADMVT_SELECT |
---|
232 | }; |
---|
233 | void AD_map_viewer(GBDATA *gbd,AD_MAP_VIEWER_TYPE type = ADMVT_INFO); |
---|
234 | |
---|
235 | // open database viewer using input-mask-file |
---|
236 | class awt_item_type_selector; |
---|
237 | GB_ERROR AWT_initialize_input_mask(AW_root *root, GBDATA *gb_main, const awt_item_type_selector *sel, const char* mask_name, bool localMask); |
---|
238 | |
---|
239 | // ---------------------------------------- |
---|
240 | // class awt_input_mask_descriptor |
---|
241 | // ---------------------------------------- |
---|
242 | class awt_input_mask_descriptor { |
---|
243 | private: |
---|
244 | char *title; // title of the input mask |
---|
245 | char *internal_maskname; // starts with 0 for local mask and with 1 for global mask |
---|
246 | // followed by file name w/o path |
---|
247 | char *itemtypename; // name of the itemtype |
---|
248 | bool local_mask; // true if mask file was found in "~/.arb_prop/inputMasks" |
---|
249 | bool hidden; // if true, mask is NOT shown in Menus |
---|
250 | |
---|
251 | public: |
---|
252 | awt_input_mask_descriptor(const char *title_, const char *maskname_, const char *itemtypename_, bool local, bool hidden_); |
---|
253 | awt_input_mask_descriptor(const awt_input_mask_descriptor& other); |
---|
254 | virtual ~awt_input_mask_descriptor(); |
---|
255 | |
---|
256 | awt_input_mask_descriptor& operator = (const awt_input_mask_descriptor& other); |
---|
257 | |
---|
258 | const char *get_title() const { return title; } |
---|
259 | const char *get_maskname() const { return internal_maskname+1; } |
---|
260 | const char *get_internal_maskname() const { return internal_maskname; } |
---|
261 | const char *get_itemtypename() const { return itemtypename; } |
---|
262 | |
---|
263 | bool is_local_mask() const { return local_mask; } |
---|
264 | bool is_hidden() const { return hidden; } |
---|
265 | }; |
---|
266 | |
---|
267 | const awt_input_mask_descriptor *AWT_look_input_mask(int id); // id starts with 0; returns 0 if no more masks |
---|
268 | |
---|
269 | #if defined(DEBUG) |
---|
270 | // database browser : |
---|
271 | void AWT_create_db_browser_awars(AW_root *aw_root, AW_default aw_def); |
---|
272 | void AWT_announce_db_to_browser(GBDATA *gb_main, const char *description); |
---|
273 | void AWT_browser_forget_db(GBDATA *gb_main); |
---|
274 | |
---|
275 | void AWT_create_debug_menu(AW_window *awmm); |
---|
276 | #endif // DEBUG |
---|
277 | |
---|
278 | #else |
---|
279 | #error awt.hxx included twice |
---|
280 | #endif // AWT_HXX |
---|