source: tags/ms_r17q2/EDIT4/ed4_defs.hxx

Last change on this file was 15288, checked in by westram, 8 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.8 KB
Line 
1#ifndef ED4_DEFS_HXX
2#define ED4_DEFS_HXX
3
4#ifndef AW_COLOR_GROUPS_HXX
5#include <aw_color_groups.hxx>
6#endif
7#ifndef AW_WINDOW_HXX
8#include <aw_window.hxx>
9#endif
10#ifndef AW_POSITION_HXX
11#include <aw_position.hxx>
12#endif
13#ifndef ARBDB_BASE_H
14#include <arbdb_base.h>
15#endif
16
17#if defined(DEBUG)
18// #define TRACE_REFRESH
19// #define TRACE_JUMPS
20#endif
21
22#define e4_assert(bed) arb_assert(bed)
23
24class  ED4_root;
25class  ED4_database;
26struct GBS_strstruct;
27
28typedef int ED4_COORDINATE;
29
30enum ED4_EDITMODE {
31    AD_ALIGN,   // add & remove of . possible (default)
32    AD_NOWRITE, // no edits allowed
33    AD_NOWRITE_IF_COMPRESSED,
34    AD_REPLACE, // all edits (overwrite)
35    AD_INSERT   // all edits (insert)
36};
37
38
39// global variables
40extern GBDATA   *GLOBAL_gb_main;
41extern ED4_root *ED4_ROOT;
42
43extern int INFO_TERM_TEXT_YOFFSET;
44extern int SEQ_TERM_TEXT_YOFFSET;
45
46extern int TERMINAL_HEIGHT;             // standard terminal height (sequences, name, info, etc..)
47extern int MAXSEQUENCECHARACTERLENGTH;  // greatest # of characters in a sequence string terminal
48extern int MAXNAME_WIDTH;               // max. pixel width of ED4_species_name_terminal (effective width also depends on group-nesting)
49extern int MAXINFO_WIDTH;               // pixel width used to display sequence info ("CONS", "4data", etc.)
50extern int FLAG_WIDTH;                  // pixel width used to display species flags (and its header)
51
52extern long ED4_counter;
53
54// use ED4_init_notFoundMessage and ED4_finish_and_show_notFoundMessage to
55// modify the following elements
56#define MAX_SHOWN_MISSING_SPECIES 200U              // limit no of missing species/data printed into not_found_message
57extern size_t         not_found_counter;            // nr of species which haven't been found
58extern GBS_strstruct *not_found_message;            // error message containing (some) missing/unloadable species
59
60extern long         max_seq_terminal_length;        // global maximum of sequence terminal length
61extern ED4_EDITMODE awar_edit_mode;
62extern long         awar_edit_rightward;            // 0 = leftward, 1 = rightward
63extern bool         move_cursor;                    // only needed for editing in consensus
64extern bool         DRAW;
65
66// globally used defines and flags
67
68#define INFINITE -1
69
70#if defined(ARB_MOTIF)
71#define SLIDER_OFFSET 5
72#else // ARB_GTK
73#define SLIDER_OFFSET 0
74#endif
75
76// these are recommended for accessing ED4_extension:
77#define X_POS       0
78#define Y_POS       1
79#define WIDTH       0
80#define HEIGHT      1
81
82// size of some display elements:
83#define BRACKET_WIDTH        11
84#define SPACER_HEIGHT        5
85#define SPACER_NOCONS_HEIGHT 15     // height of spacer at top of group (used if consensus is hidden and group is folded)
86#define SEQUENCE_INFO_WIDTH  50     // default width of ED4_sequence_info_terminal (overridden via ref-terminal)
87#define TREE_TERMINAL_WIDTH  100    // some default-width (used for ED4_line_terminal only; @@@ has no noteable effect)
88
89#define COLUMN_STAT_ROW_HEIGHT(font_height)     (2.2*(font_height)) // each row contains 2 sub-rows (plus some xtra space)
90#define COLUMN_STAT_ROWS            4
91
92#define MAX_POSSIBLE_SEQ_LENGTH     100000000
93
94#define MAXWINDOWS 5
95
96#define AWAR_EDIT_MODE                  "tmp/edit4/edit_mode"
97#define AWAR_INSERT_MODE                "tmp/edit4/insert_mode"
98#define AWAR_EDIT_SECURITY_LEVEL        "tmp/edit4/security_level"
99#define AWAR_EDIT_SECURITY_LEVEL_ALIGN  "tmp/edit4/security_level_align"
100#define AWAR_EDIT_SECURITY_LEVEL_CHANGE "tmp/edit4/security_level_change"
101#define AWAR_EDIT_CONFIGURATION         "tmp/edit4/configuration"
102
103#define AWAR_EDIT_SEQ_POSITION   "tmp/edit4/jump_to_position%d" // used to create ED4_window.awar_path_for_cursor[]
104#define AWAR_EDIT_ECOLI_POSITION "tmp/edit4/cursor_ref_ecoli%d" // used to create ED4_window.awar_path_for_Ecoli[]
105#define AWAR_EDIT_BASE_POSITION  "tmp/edit4/cursor_to_basepos%d" // used to create ED4_window.awar_path_for_basePos[]
106#define AWAR_EDIT_IUPAC          "tmp/edit4/iupac%d" // used to create ED4_window.awar_path_for_IUPAC[]
107#define AWAR_EDIT_HELIXNR        "tmp/edit4/helixnr%d" // used to create ED4_window.awar_path_for_helixNr[]
108
109#define AWAR_FIELD_CHOSEN "tmp/edit4/field_chosen" // used for field selection box
110
111#define AWAR_EDIT_TITLE_MODE       "edit4/title_mode"
112#define AWAR_EDIT_HELIX_SPACING    "edit4/helix_add_spacing"
113#define AWAR_EDIT_TERMINAL_SPACING "edit4/terminal_add_spacing"
114
115#define CHARACTEROFFSET 5       // spacer-width left of text-terminal
116
117#define NAME_BUFFERSIZE 100 // size of buffer used to build terminal/manager IDs
118
119typedef long ED4_index;
120
121#define ED4_SCROLL_OVERLAP 20   // 15 Pixels overlap
122
123
124enum ED4_level { // has to contain bit values
125    LEV_INVALID         = -1U,
126    LEV_NONE            = 0,
127    LEV_ROOT            = 0x1,
128    LEV_DEVICE          = 0x2,
129    LEV_AREA            = 0x4,
130    LEV_MULTI_SPECIES   = 0x8,
131    LEV_SPECIES         = 0x10,
132    LEV_MULTI_SEQUENCE  = 0x20,
133    LEV_SEQUENCE        = 0x40,
134    LEV_TREE            = 0x80,
135    LEV_SPECIES_NAME    = 0x100,
136    LEV_SEQUENCE_INFO   = 0x200,
137    LEV_SEQUENCE_STRING = 0x400,
138    LEV_ORF             = 0x800,
139    LEV_SPACER          = 0x1000,
140    LEV_LINE            = 0x2000,
141    LEV_MULTI_NAME      = 0x4000,
142    LEV_NAME_MANAGER    = 0x8000,
143    LEV_GROUP           = 0x10000,
144    LEV_ROOTGROUP       = 0x20000,
145    LEV_BRACKET         = 0x40000,
146    LEV_PURE_TEXT       = 0x80000,
147    LEV_COL_STAT        = 0x100000,
148    LEV_FLAG_HEADER     = 0x200000,
149    LEV_FLAG            = 0x400000,
150};
151
152enum ED4_datamode {
153    ED4_D_SPECIES,
154    ED4_D_EXTENDED
155};
156
157
158enum ED4_movemode {
159    ED4_M_NO_MOVE    = 0,
160    ED4_M_HORIZONTAL = 1,
161    ED4_M_VERTICAL   = 2,
162    ED4_M_FREE       = 4
163};
164
165enum ED4_returncode {
166    ED4_R_OK         = 0,
167    ED4_R_WARNING    = 1,
168    ED4_R_IMPOSSIBLE = 2,
169    ED4_R_ERROR      = 4,
170    ED4_R_BREAK      = 8,
171};
172
173enum ED4_AREA_LEVEL {
174    ED4_A_TOP_AREA,
175    ED4_A_MIDDLE_AREA,
176    ED4_A_BOTTOM_AREA,
177    ED4_A_ERROR
178};
179
180enum ED4_properties {
181    PROP_NONE               = 0,
182    PROP_IS_MANAGER         = 0x1,
183    PROP_IS_TERMINAL        = 0x2,
184    PROP_HORIZONTAL         = 0x4,
185    PROP_VERTICAL           = 0x8,
186    PROP_DYNA_RESIZE        = 0x10,              // if set => allowed to resize dynamically (static_prop => object type is capable; auto-copied to dynamic_prop)
187    PROP_SELECTABLE         = 0x20,
188    PROP_DRAGABLE           = 0x40,
189    PROP_MOVABLE            = 0x80,
190    PROP_IS_HANDLE          = 0x100,
191    PROP_CURSOR_ALLOWED     = 0x200,
192    //  PROP_               = 0x400,
193    //  PROP_               = 0x800,
194    PROP_IS_FOLDED          = 0x1000,            // Flag whether group is folded or not
195    PROP_CONSENSUS_RELEVANT = 0x2000,            // contains information relevant for consensus
196    PROP_ALIGNMENT_DATA     = 0x4000,            // contains aligned data (also SAIs)
197};
198
199enum ED4_cursor_move {
200    ED4_C_UP,
201    ED4_C_DOWN,
202    ED4_C_LEFT,
203    ED4_C_RIGHT,
204    ED4_C_NONE
205};
206
207enum ED4_update_flag {
208    ED4_U_UP = 0,
209    ED4_U_UP_DOWN
210};
211
212enum ED4_border_flag {
213    ED4_B_BORDER,
214    ED4_B_INDENT,
215    ED4_B_BOTTOM_AREA
216};
217
218enum ED4_consensus {
219    ED4_K_ADD,
220    ED4_K_SUB
221};
222
223enum ED4_aa_seq_flag {
224    ED4_AA_FRWD_1,
225    ED4_AA_FRWD_2,
226    ED4_AA_FRWD_3,
227    ED4_AA_RVRS_1,
228    ED4_AA_RVRS_2,
229    ED4_AA_RVRS_3,
230    ED4_AA_DB_FIELD
231};
232
233enum ED4_direction {
234    ED4_D_VERTICAL,
235    ED4_D_HORIZONTAL,
236    ED4_D_ALL_DIRECTION,
237};
238
239
240class ED4_base;
241class ED4_terminal;
242class ED4_species_name_terminal;
243
244struct ED4_move_info
245{
246    ED4_base     *object;                // object to be moved
247    AW_pos        end_x, end_y;          // position to move to
248    ED4_movemode  mode;                  // move mode
249    ED4_level     preferred_parent;      // level to move to
250};
251
252struct ED4_selection_entry {
253    AW_pos drag_off_x, drag_off_y;
254    AW_pos drag_old_x, drag_old_y;
255    AW_pos actual_width, actual_height;
256    int    old_event_y;
257
258    ED4_species_name_terminal *object;
259};
260
261
262
263struct ED4_extension // contains info about graphical properties
264{
265    AW_pos  position[2];        // upper left corner (pos_x, pos_y) in relation to parent
266    // !!! WARNING: This is a hack!!! Every time you change 'position' you HAVE TO call ED4_base::touch_world_cache() !!!
267
268    AW_pos    size[2];          // width and height
269    ED4_index y_folded;         // remember old position of consensus when folding group
270
271    AW::Vector get_size() const { return AW::Vector(size[WIDTH], size[HEIGHT]); }
272    AW::Vector get_parent_offset() const { return AW::Vector(position[X_POS], position[Y_POS]); }
273
274    bool set_size_does_change(int idx, AW_pos value) {
275        // returns true if changed
276        e4_assert(idx == WIDTH || idx == HEIGHT);
277        if (size[idx] != value) {
278            size[idx] = value;
279            return true;
280        }
281        return false;
282    }
283
284#if defined(IMPLEMENT_DUMP)
285    void dump(size_t indent) const;
286#endif // IMPLEMENT_DUMP
287};
288
289struct ED4_scroll_picture {
290    bool scroll;
291    long old_x;
292    long old_y;
293
294    ED4_scroll_picture() : scroll(false), old_x(0), old_y(0) {}
295};
296
297enum ED4_CursorJumpType {
298    ED4_JUMP_CENTERED,          // centers the cursor
299    ED4_JUMP_KEEP_VISIBLE,      // keeps the cursor visible (keeps a fixed margin)
300    ED4_JUMP_KEEP_POSITION,     // paint cursor at previous position
301};
302
303struct ED4_work_info
304{
305    AW_event  event;
306    GBDATA   *gb_data;
307    char     *string;           // pointer to consensus; only if editing the consensus
308    long      char_position;    // screen position after cursor
309
310    bool rightward; // contains direction of editing (0 = leftward, 1 = rightward)
311
312    ED4_EDITMODE mode;
313
314    bool    is_sequence;        // ==1 -> special handling for sequences
315    bool    cannot_handle;      // if TRUE then cannot edit
316
317    ED4_CursorJumpType cursor_jump;
318    bool    refresh_needed;
319
320    long    out_seq_position;   // sequence position (after editing)
321
322    char     *out_string;                           // nur falls new malloc
323
324    int     repeat_count;       // only for keystrokes: contains # of times key should be repeated
325
326    ED4_terminal *working_terminal; // this contains the terminal
327};
328
329
330struct ED4_update_info // if you add new elements, please ensure to initialize them in ED4_base::ED4_base()
331{
332    unsigned int resize : 1;
333    unsigned int refresh : 1;
334    unsigned int clear_at_refresh : 1;
335    unsigned int linked_to_folding_line : 1;
336    unsigned int linked_to_scrolled_rectangle : 1;
337    unsigned int refresh_horizontal_scrolling : 1;
338    unsigned int refresh_vertical_scrolling : 1;
339    unsigned int delete_requested : 1;
340    unsigned int update_requested : 1;
341
342    void set_clear_at_refresh(int value) {
343        clear_at_refresh = value;
344    }
345    void set_refresh(int value) {
346        refresh = value;
347    }
348    void set_resize(int value) {
349        resize = value;
350    }
351
352#if defined(IMPLEMENT_DUMP)
353    void dump(size_t indent) const;
354#endif // IMPLEMENT_DUMP
355};
356
357struct ED4_coords
358{
359    long top_area_x,
360        top_area_y,
361        top_area_height,
362
363        middle_area_x,
364        middle_area_y,
365
366        window_width,               // of whole window (top and middle area and ... )
367        window_height,              // of whole window (top and middle area and ... )
368
369        window_upper_clip_point,        // absolute coordinate of upper visible clipping point in middle area
370        window_lower_clip_point,        // absolute coordinate of lower visible clipping point in middle area
371        window_left_clip_point,         // absolute coordinate of left  visible clipping point in top and middle area
372        window_right_clip_point;        // absolute coordinate of right visible clipping point in top and middle area
373
374    void clear() {
375        top_area_x = 0;
376        top_area_y = 0;
377        top_area_height = 0;
378
379        middle_area_x = 0;
380        middle_area_y = 0;
381
382        window_width = 0;
383        window_height = 0;
384
385        window_upper_clip_point = 0;
386        window_lower_clip_point = 0;
387        window_left_clip_point = 0;
388        window_right_clip_point = 0;
389    }
390};
391
392#else
393#error ed4_defs.hxx included twice
394#endif
Note: See TracBrowser for help on using the repository browser.