1 | #ifndef ED4_defs |
---|
2 | #define ED4_defs |
---|
3 | |
---|
4 | |
---|
5 | //needed prototype classes |
---|
6 | class ED4_root; |
---|
7 | class ED4_database; |
---|
8 | |
---|
9 | #ifndef HAVE_BOOL |
---|
10 | typedef char bool; |
---|
11 | #endif |
---|
12 | |
---|
13 | typedef const char ED4_ERROR; |
---|
14 | typedef int ED4_COORDINATE; |
---|
15 | |
---|
16 | typedef enum ad_edit_modus { |
---|
17 | AD_ALIGN, // add & remove of . possible (default) |
---|
18 | AD_NOWRITE, // no edits allowed |
---|
19 | AD_NOWRITE_IF_COMPRESSED, |
---|
20 | AD_REPLACE, // all edits (overwrite) |
---|
21 | AD_INSERT // all edits (insert) |
---|
22 | } ED4_EDITMODI; |
---|
23 | |
---|
24 | |
---|
25 | //global variables |
---|
26 | extern GBDATA *gb_main; |
---|
27 | extern ED4_root *ED4_ROOT; |
---|
28 | extern ED4_database *main_db; |
---|
29 | |
---|
30 | extern int TERMINALHEIGHT; // this variable replaces the define |
---|
31 | extern int MAXLETTERDESCENT; // Important for drawing text on the screen |
---|
32 | extern int MAXSEQUENCECHARACTERLENGTH; // greatest # of characters in a sequence string terminal |
---|
33 | extern int MAXSPECIESWIDTH; |
---|
34 | extern int MAXINFOWIDTH; |
---|
35 | extern int MAXCHARWIDTH; |
---|
36 | extern int MARGIN; // sets margin for cursor moves in characters |
---|
37 | extern long ED4_counter; |
---|
38 | extern long all_found; // nr of species which haven't been found |
---|
39 | extern long species_read; // nr of species read; important during loading |
---|
40 | extern void *not_found_message; |
---|
41 | extern long max_seq_terminal_length; // global maximum of sequence terminal length |
---|
42 | extern ED4_EDITMODI awar_edit_modus; |
---|
43 | extern long awar_edit_direction; |
---|
44 | extern bool move_cursor; //only needed for editing in consensus |
---|
45 | extern bool DRAW; |
---|
46 | extern bool last_window_reached; //only needed for refreshing all windows |
---|
47 | |
---|
48 | extern double status_add_count; //only needed for loading configuration |
---|
49 | extern double status_total_count; |
---|
50 | extern bool loading; |
---|
51 | //extern long last_used_timestamp; // time of last timed callback |
---|
52 | |
---|
53 | // globally used defines and flags |
---|
54 | |
---|
55 | #define INFINITE -1 |
---|
56 | #define SLIDER_OFFSET 5 |
---|
57 | //#define HALFCURSORWIDTH 3 |
---|
58 | |
---|
59 | // these are recommended for accessing ED4_extension: |
---|
60 | #define X_POS 0 |
---|
61 | #define Y_POS 1 |
---|
62 | #define WIDTH 0 |
---|
63 | #define HEIGHT 1 |
---|
64 | |
---|
65 | // size of some display elements: |
---|
66 | #define BRACKETWIDTH 10 |
---|
67 | #define SPACERHEIGHT 5 |
---|
68 | #define SPACERNOCONSENSUSHEIGHT 15 // height of spacer at top of group (used if consensus is hidden and group is folded) |
---|
69 | #define SEQUENCEINFOSIZE 50 |
---|
70 | #define TREETERMINALSIZE 100 |
---|
71 | |
---|
72 | #define COLUMN_STAT_ROW_HEIGHT(font_height) (2.2*(font_height)) // each row contains 2 sub-rows (plus some xtra space) |
---|
73 | #define COLUMN_STAT_ROWS 4 |
---|
74 | |
---|
75 | #define MAXCHARTABLE 256 // Maximum of Consensustable |
---|
76 | //#define MAXBASESTABLE 7 |
---|
77 | #define MAXWINDOWS 5 |
---|
78 | #define MINSPECFORSTATWIN 200 |
---|
79 | |
---|
80 | #define AWAR_EDIT_MODE "tmp/edit4/edit_mode" |
---|
81 | #define AWAR_INSERT_MODE "tmp/edit4/insert_mode" |
---|
82 | #define AWAR_EDIT_DIRECTION "tmp/edit4/edit_direction" |
---|
83 | #define AWAR_EDIT_SECURITY_LEVEL "tmp/edit4/security_level" |
---|
84 | #define AWAR_EDIT_SECURITY_LEVEL_ALIGN "tmp/edit4/security_level_align" |
---|
85 | #define AWAR_EDIT_SECURITY_LEVEL_CHANGE "tmp/edit4/security_level_change" |
---|
86 | #define AWAR_EDIT_CONFIGURATION "tmp/edit4/configuration" |
---|
87 | |
---|
88 | #define AWAR_EDIT_SEQ_POSITION "tmp/edit4/jump_to_position%d" // used to create ED4_window.awar_path_for_cursor[] |
---|
89 | #define AWAR_EDIT_ECOLI_POSITION "tmp/edit4/cursor_ref_ecoli%d" // used to create ED4_window.awar_path_for_Ecoli[] |
---|
90 | #define AWAR_EDIT_BASE_POSITION "tmp/edit4/cursor_to_basepos%d" // used to create ED4_window.awar_path_for_basePos[] |
---|
91 | #define AWAR_EDIT_IUPAC "tmp/edit4/iupac%d" // used to create ED4_window.awar_path_for_IUPAC[] |
---|
92 | #define AWAR_EDIT_HELIXNR "tmp/edit4/helixnr%d" // used to create ED4_window.awar_path_for_helixNr[] |
---|
93 | |
---|
94 | #define AWAR_FIELD_CHOSEN "tmp/edit4/field_chosen" // used for field selection box |
---|
95 | |
---|
96 | #define AWAR_EDIT_TITLE_MODE "edit4/title_mode" |
---|
97 | #define AWAR_EDIT_HELIX_SPACING "edit4/helix_spacing" |
---|
98 | |
---|
99 | #define CHARACTEROFFSET 5 // spacer-width left of text-terminal |
---|
100 | #define CONSENSUS "Consensusfunktion" |
---|
101 | |
---|
102 | #define ED4_index long |
---|
103 | |
---|
104 | inline int max(int x, int y) { return x>y ? x : y; } |
---|
105 | inline int min(int x, int y) { return x<y ? x : y; } |
---|
106 | inline int ABS(int x) { return x<0 ? -x : x; } |
---|
107 | |
---|
108 | #define ED4_SCROLL_OVERLAP 20 // 15 Pixels overlap |
---|
109 | |
---|
110 | #define ED4_G_FIRST_FONT ED4_G_STANDARD // ED4_G_SEQUENCES |
---|
111 | #define ED4_G_LAST_FONT ED4_G_HELIX |
---|
112 | |
---|
113 | typedef enum |
---|
114 | { |
---|
115 | ED4_G_STANDARD, |
---|
116 | |
---|
117 | ED4_G_SEQUENCES, |
---|
118 | ED4_G_HELIX, |
---|
119 | |
---|
120 | ED4_G_COLOR_2, |
---|
121 | ED4_G_COLOR_3, |
---|
122 | ED4_G_COLOR_4, |
---|
123 | ED4_G_COLOR_5, |
---|
124 | ED4_G_COLOR_6, |
---|
125 | ED4_G_COLOR_7, |
---|
126 | ED4_G_COLOR_8, |
---|
127 | ED4_G_COLOR_9, |
---|
128 | |
---|
129 | ED4_G_CBACK_0, // Ranges for column statitics |
---|
130 | ED4_G_CBACK_1, |
---|
131 | ED4_G_CBACK_2, |
---|
132 | ED4_G_CBACK_3, |
---|
133 | ED4_G_CBACK_4, |
---|
134 | ED4_G_CBACK_5, |
---|
135 | ED4_G_CBACK_6, |
---|
136 | ED4_G_CBACK_7, |
---|
137 | ED4_G_CBACK_8, |
---|
138 | ED4_G_CBACK_9, |
---|
139 | |
---|
140 | ED4_G_SBACK_0, // Background for search |
---|
141 | ED4_G_SBACK_1, |
---|
142 | ED4_G_SBACK_2, |
---|
143 | ED4_G_SBACK_3, |
---|
144 | ED4_G_SBACK_4, |
---|
145 | ED4_G_SBACK_5, |
---|
146 | ED4_G_SBACK_6, |
---|
147 | ED4_G_SBACK_7, |
---|
148 | ED4_G_SBACK_8, |
---|
149 | ED4_G_MBACK, // Mismatches |
---|
150 | |
---|
151 | ED4_G_CURSOR, // Color of cursor |
---|
152 | ED4_G_MARKED, // Background for marked species |
---|
153 | ED4_G_SELECTED, // Background for selected species |
---|
154 | |
---|
155 | ED4_G_DRAG // must be last |
---|
156 | } ED4_gc; |
---|
157 | |
---|
158 | typedef enum |
---|
159 | { |
---|
160 | ED4_L_NO_LEVEL = 0x0, |
---|
161 | ED4_L_ROOT = 0x1, |
---|
162 | ED4_L_DEVICE = 0x2, |
---|
163 | ED4_L_AREA = 0x4, |
---|
164 | ED4_L_MULTI_SPECIES = 0x8, |
---|
165 | ED4_L_SPECIES = 0x10, |
---|
166 | ED4_L_MULTI_SEQUENCE = 0x20, |
---|
167 | ED4_L_SEQUENCE = 0x40, |
---|
168 | ED4_L_TREE = 0x80, |
---|
169 | ED4_L_SPECIES_NAME = 0x100, |
---|
170 | ED4_L_SEQUENCE_INFO = 0x200, //evtl. aendern fuer Name-Manager und group-manager |
---|
171 | ED4_L_SEQUENCE_STRING = 0x400, |
---|
172 | ED4_L_SPACER = 0x800, |
---|
173 | ED4_L_LINE = 0x1000, |
---|
174 | ED4_L_MULTI_NAME = 0x2000, |
---|
175 | ED4_L_NAME_MANAGER = 0x4000, |
---|
176 | ED4_L_GROUP = 0x8000, |
---|
177 | ED4_L_BRACKET = 0x10000, |
---|
178 | ED4_L_PURE_TEXT = 0x20000, |
---|
179 | ED4_L_COL_STAT = 0x40000 |
---|
180 | } ED4_level; |
---|
181 | |
---|
182 | |
---|
183 | |
---|
184 | typedef enum |
---|
185 | { |
---|
186 | ED4_D_SPECIES, |
---|
187 | ED4_D_EXTENDED |
---|
188 | } ED4_datamode; |
---|
189 | |
---|
190 | |
---|
191 | typedef enum |
---|
192 | { |
---|
193 | ED4_M_NO_MOVE = 0, |
---|
194 | ED4_M_HORIZONTAL = 1, |
---|
195 | ED4_M_VERTICAL = 2, |
---|
196 | ED4_M_FREE = 4 |
---|
197 | } ED4_movemode; |
---|
198 | |
---|
199 | typedef enum |
---|
200 | { |
---|
201 | ED4_R_OK = 0, |
---|
202 | ED4_R_WARNING = 1, |
---|
203 | ED4_R_IMPOSSIBLE = 2, |
---|
204 | ED4_R_ERROR = 4, |
---|
205 | ED4_R_BREAK = 8, |
---|
206 | ED4_R_DESASTER = 16, |
---|
207 | // ED4_R_REMOVE = 32, |
---|
208 | // ED4_R_LEAVE = 64, |
---|
209 | // ED4_R_ADD = 128, |
---|
210 | // ED4_R_REMOVE_ALL = 256, |
---|
211 | ED4_R_ALL = 0x7fffffff |
---|
212 | } ED4_returncode; |
---|
213 | |
---|
214 | typedef enum |
---|
215 | { |
---|
216 | ED4_A_TOP_AREA, |
---|
217 | ED4_A_MIDDLE_AREA, |
---|
218 | ED4_A_BOTTOM_AREA, |
---|
219 | ED4_A_ERROR |
---|
220 | } ED4_AREA_LEVEL; |
---|
221 | |
---|
222 | typedef enum |
---|
223 | { |
---|
224 | ED4_B_LEFT_BUTTON = 1, |
---|
225 | ED4_B_MIDDLE_BUTTON = 2, |
---|
226 | ED4_B_RIGHT_BUTTON = 3 |
---|
227 | } ED4_mouse_buttons; |
---|
228 | |
---|
229 | typedef enum |
---|
230 | { |
---|
231 | ED4_P_NO_PROP = 0, |
---|
232 | ED4_P_IS_MANAGER = 1, |
---|
233 | ED4_P_IS_TERMINAL = 2, |
---|
234 | ED4_P_HORIZONTAL = 4, |
---|
235 | ED4_P_VERTICAL = 8, |
---|
236 | ED4_P_TMP = 16, |
---|
237 | ED4_P_SELECTABLE = 32, |
---|
238 | ED4_P_DRAGABLE = 64, |
---|
239 | ED4_P_MOVABLE = 128, |
---|
240 | ED4_P_IS_HANDLE = 256, |
---|
241 | ED4_P_CURSOR_ALLOWED = 512, |
---|
242 | // ED4_P_SCROLL_HORIZONTAL = 1024, |
---|
243 | // ED4_P_SCROLL_VERTICAL = 2048, |
---|
244 | ED4_P_IS_FOLDED = 4096, // Flag whether group is folded or not |
---|
245 | ED4_P_CONSENSUS_RELEVANT= 8192, |
---|
246 | ED4_P_ALL = 0x7fffffff |
---|
247 | } ED4_properties; |
---|
248 | |
---|
249 | typedef enum |
---|
250 | { |
---|
251 | ED4_C_UP, |
---|
252 | ED4_C_DOWN, |
---|
253 | ED4_C_LEFT, |
---|
254 | ED4_C_RIGHT, |
---|
255 | ED4_C_NONE |
---|
256 | } ED4_cursor_move; |
---|
257 | |
---|
258 | typedef enum |
---|
259 | { |
---|
260 | ED4_U_UP = 0, |
---|
261 | ED4_U_UP_DOWN |
---|
262 | } ED4_update_flag; |
---|
263 | |
---|
264 | typedef enum |
---|
265 | { |
---|
266 | ED4_B_BORDER, |
---|
267 | ED4_B_INDENT, |
---|
268 | ED4_B_BOTTOM_AREA |
---|
269 | } ED4_border_flag; |
---|
270 | |
---|
271 | typedef enum |
---|
272 | { |
---|
273 | ED4_K_ADD, |
---|
274 | ED4_K_SUB |
---|
275 | } ED4_consensus; |
---|
276 | |
---|
277 | typedef enum |
---|
278 | { |
---|
279 | ED4_A_DEFAULT, |
---|
280 | ED4_A_CONTAINER |
---|
281 | } ED4_alignment; |
---|
282 | |
---|
283 | |
---|
284 | typedef enum |
---|
285 | { |
---|
286 | ED4_D_VERTICAL, |
---|
287 | ED4_D_HORIZONTAL, |
---|
288 | ED4_D_ALL_DIRECTION, |
---|
289 | ED4_D_VERTICAL_ALL |
---|
290 | } ED4_direction; |
---|
291 | |
---|
292 | |
---|
293 | class ED4_base; |
---|
294 | class ED4_terminal; |
---|
295 | |
---|
296 | struct ED4_move_info |
---|
297 | { |
---|
298 | ED4_base *object; // object to be moved |
---|
299 | AW_pos end_x, end_y; // position to move to |
---|
300 | ED4_movemode mode; // move mode |
---|
301 | ED4_level preferred_parent; // level to move to |
---|
302 | }; |
---|
303 | |
---|
304 | struct ED4_selection_entry |
---|
305 | { |
---|
306 | AW_pos drag_off_x, drag_off_y; |
---|
307 | AW_pos drag_old_x, drag_old_y; |
---|
308 | AW_pos actual_width, actual_height; |
---|
309 | int old_event_y; |
---|
310 | ED4_terminal *object; |
---|
311 | }; |
---|
312 | |
---|
313 | |
---|
314 | |
---|
315 | struct ED4_extension // contains info about graphical properties |
---|
316 | { |
---|
317 | AW_pos position[2]; // upper left corner (pos_x, pos_y) in relation to parent |
---|
318 | // !!! WARNING: This is a hack!!! Every time you change 'position' you HAVE TO call ED4_base::touch_world_cache() !!! |
---|
319 | |
---|
320 | AW_pos size[2]; // width and height |
---|
321 | ED4_index y_folded; // remember old position of consensus when folding group |
---|
322 | }; |
---|
323 | |
---|
324 | struct ED4_scroll_picture |
---|
325 | { |
---|
326 | bool scroll; |
---|
327 | long old_x; |
---|
328 | long old_y; |
---|
329 | }; |
---|
330 | |
---|
331 | |
---|
332 | struct ED4_work_info |
---|
333 | { |
---|
334 | AW_event event; |
---|
335 | GBDATA *gb_data; |
---|
336 | char *string; // pointer to consensus; only if editing the consensus |
---|
337 | long char_position; // screen position after cursor |
---|
338 | |
---|
339 | int direction; // contains direction of editing (-1 left, +1 right ) |
---|
340 | ED4_EDITMODI mode; |
---|
341 | |
---|
342 | bool is_sequence; // ==1 -> special handling for sequences |
---|
343 | bool cannot_handle; // if TRUE than cannot edit |
---|
344 | bool center_cursor; // if true => cursor gets centered horizontally |
---|
345 | bool refresh_needed; |
---|
346 | |
---|
347 | long out_seq_position; // sequence position (after editing) |
---|
348 | |
---|
349 | char *out_string; // nur falls new malloc |
---|
350 | char *error; |
---|
351 | |
---|
352 | int repeat_count; // only for keystrokes: contains # of times key should be repeated |
---|
353 | }; |
---|
354 | |
---|
355 | |
---|
356 | struct ED4_update_info // if you add new elements, please ensure to initialize them in ED4_base::ED4_base() |
---|
357 | { |
---|
358 | unsigned int resize:1; |
---|
359 | unsigned int refresh:1; |
---|
360 | unsigned int clear_at_refresh:1; |
---|
361 | unsigned int linked_to_folding_line:1; |
---|
362 | unsigned int linked_to_scrolled_rectangle:1; |
---|
363 | unsigned int refresh_horizontal_scrolling:1; |
---|
364 | unsigned int refresh_vertical_scrolling:1; |
---|
365 | unsigned int delete_requested:1; |
---|
366 | |
---|
367 | void set_clear_at_refresh(int value) { |
---|
368 | clear_at_refresh = value; |
---|
369 | } |
---|
370 | void set_refresh(int value) { |
---|
371 | refresh = value; |
---|
372 | } |
---|
373 | void set_resize(int value) { |
---|
374 | resize = value; |
---|
375 | } |
---|
376 | }; |
---|
377 | |
---|
378 | struct ED4_coords |
---|
379 | { |
---|
380 | long top_area_x, |
---|
381 | top_area_y, |
---|
382 | top_area_height, |
---|
383 | |
---|
384 | middle_area_x, |
---|
385 | middle_area_y, |
---|
386 | |
---|
387 | window_width, //of whole window (top and middle area and ... ) |
---|
388 | window_height, //of whole window (top and middle area and ... ) |
---|
389 | |
---|
390 | window_upper_clip_point, //absolute coordinate of upper visible clipping point in middle area |
---|
391 | window_lower_clip_point, //absolute coordinate of lower visible clipping point in middle area |
---|
392 | window_left_clip_point, //absolute coordinate of left visible clipping point in top and middle area |
---|
393 | window_right_clip_point; //absolute coordinate of right visible clipping point in top and middle area |
---|
394 | |
---|
395 | void clear() { |
---|
396 | top_area_x = 0; |
---|
397 | top_area_y = 0; |
---|
398 | top_area_height = 0; |
---|
399 | |
---|
400 | middle_area_x = 0; |
---|
401 | middle_area_y = 0; |
---|
402 | |
---|
403 | window_width = 0; |
---|
404 | window_height = 0; |
---|
405 | |
---|
406 | window_upper_clip_point = 0; |
---|
407 | window_lower_clip_point = 0; |
---|
408 | window_left_clip_point = 0; |
---|
409 | window_right_clip_point = 0; |
---|
410 | } |
---|
411 | }; |
---|
412 | |
---|
413 | |
---|
414 | #endif |
---|