source: tags/svn.1.5.4/EDIT4/ED4_window.cxx

Last change on this file was 7668, checked in by westram, 14 years ago
  • merge from dev [7578] [7579] [7580] [7581] [7582] [7585] [7587] [7588] [7589] [7592] [7593] [7594] [7595] [7596] [7597] [7598] [7599] [7601] [7602] [7603] [7604] [7605] [7606] [7607] [7608] [7609] [7610] [7611] [7613] [7615] [7616] [7618]
    • ARB canvas printing
      • generate xfigs with 1200 dpi (was 80)
      • DRYed canvas_to_xfig vs canvas_to_printer
      • tracked down a bug in fig2dev causing wrong prints (added a workaround plus toggle to disable it)
      • paint invisible to printer (as white dots)
        • print two invisible dots which enclose the area calculated by size-device (→ fig2dev centers correctly)
      • fixed magnification
        • replaced hardcoded border with a relative border around the overall figure and a relative non-printable page-border
        • use these borders for xfig-export and printing (previously only used in xfig-export)
        • rewrote overlap calculation
      • dialog
        • missing macro-id for 'Fit on'
        • provide paper sizes and pass them to fig2dev
        • display resulting output-size of figure in print dialog
        • added quick-fit buttons several page count
        • added 'lock to pages'
    • refactorings
      • AWT_canvas
      • AWT_graphic
      • AWT_graphic_exports
      • AWT_nonDB_graphic
      • AW_device_size
    • canvas draw function
      • line styles (AW_DOTTED, AW_DASHED)
      • changed line_width to short (assert line_width is > 0)
      • fix missing final pixel on lines/boxes
      • fix width/height of XFillRectangle
      • changed cap_style + join_style
      • changed code drawing boxes with fixed pixel width (due to correct lines/boxes)
        • added AW_device::rtransform_pixelsize().
    • rewrote IRS display
      • uses double instead of int
      • scroll closed groups inside top-folding-area until they are completely scrolled out of main-area
      • draw one thick line for folding-separator
        • do only draw on print device, if printing screen-only
      • group frame/box
        • draw dotted frame on unfolded groups
        • frame/box size represents depth and size of subtree (as in dendrogram)
      • condensed display
      • draw text on size device
    • enhanced AW_device_size
      • tracks size info separately for scalable and unscalable gfx-elements
      • reset() sets clipping to a BIG area on size device to avoid clipping (size should NEVER EVER be clipped)
      • AW_device
        • recalc_size() uses unscalable overlap caused by text at borders of graphic to dynamically set some extra padding
        • replaced ALL default paddings by constant value (10 pixel)
        • when a zoom-reset is done now, ARB correctly fits the graphic AND the text into the viewport
    • unit tests (tree display)
      • use monospaced font (makes faked font-limits more accurate)
      • changed zoom/area calculation
      • draw 2 boxes (one around gfx-text, another around gfx+text)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.1 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : ED4_window.cxx                                    //
4//   Purpose   :                                                   //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#include <ed4_extern.hxx>
12#include "ed4_class.hxx"
13#include "ed4_tools.hxx"
14#include <aw_awar.hxx>
15#include <aw_root.hxx>
16
17int ED4_window::no_of_windows = 0;                  // static variable has to be initialized only once
18
19void ED4_window::reset_all_for_new_config()
20{
21    horizontal_fl = NULL;
22    vertical_fl   = NULL;
23
24    scrolled_rect.scroll_top    = NULL;
25    scrolled_rect.scroll_bottom = NULL;
26    scrolled_rect.scroll_left   = NULL;
27    scrolled_rect.scroll_right  = NULL;
28
29    scrolled_rect.world_x = 0;
30    scrolled_rect.world_y = 0;
31    scrolled_rect.width   = 0;
32    scrolled_rect.height  = 0;
33
34    slider_pos_horizontal = 0;
35    slider_pos_vertical   = 0;
36
37    coords.top_area_x      = 0;
38    coords.top_area_y      = 0;
39    coords.top_area_height = 0;
40
41    coords.middle_area_x = 0;
42    coords.middle_area_y = 0;
43
44    coords.window_width  = 0;
45    coords.window_height = 0;
46
47    coords.window_upper_clip_point = 0;
48    coords.window_lower_clip_point = 0;
49    coords.window_left_clip_point  = 0;
50    coords.window_right_clip_point = 0;
51
52    ED4_ROOT->aw_root->awar(awar_path_for_cursor)->write_int(0);
53    ED4_ROOT->aw_root->awar(awar_path_for_Ecoli)->write_int(0);
54    ED4_ROOT->aw_root->awar(awar_path_for_basePos)->write_int(0);
55    ED4_ROOT->aw_root->awar(awar_path_for_IUPAC)->write_string(ED4_IUPAC_EMPTY);
56    ED4_ROOT->aw_root->awar(awar_path_for_helixNr)->write_string("");
57
58    if (next) next->reset_all_for_new_config();
59}
60
61
62void ED4_window::update_window_coords()
63{
64    AW_pos       x, y;
65    AW_screen_area area_size;
66
67    ED4_ROOT->top_area_man->calc_world_coords(&x, &y);
68
69    coords.top_area_x      = (long) x;
70    coords.top_area_y      = (long) y;
71    coords.top_area_height = (long) ED4_ROOT->top_area_man->extension.size[HEIGHT];
72
73    ED4_ROOT->middle_area_man->calc_world_coords(&x, &y);
74
75    coords.middle_area_x = (long) x;
76    coords.middle_area_y = (long) y;
77
78    aww->_get_area_size (AW_MIDDLE_AREA, &area_size);
79
80    coords.window_width  = area_size.r;
81    coords.window_height = area_size.b;
82
83    // world coordinates
84    coords.window_upper_clip_point = coords.middle_area_y + aww->slider_pos_vertical; // coordinate of upper clipping point of middle area
85    coords.window_lower_clip_point = coords.window_upper_clip_point + coords.window_height - coords.middle_area_y;
86
87    if (ED4_ROOT->scroll_links.link_for_hor_slider) {
88        ED4_ROOT->scroll_links.link_for_hor_slider->calc_world_coords(&x, &y);
89        coords.window_left_clip_point = (long) x + aww->slider_pos_horizontal;
90        coords.window_right_clip_point = coords.window_left_clip_point + coords.window_width - (long) x;
91    }
92
93#if defined(DEBUG) && 0
94    printf("left %d right %d (xdiff=%d) upper %d lower %d (ydiff=%d) width=%d height=%d\n",
95           coords.window_left_clip_point,
96           coords.window_right_clip_point,
97           coords.window_right_clip_point-coords.window_left_clip_point,
98           coords.window_upper_clip_point,
99           coords.window_lower_clip_point,
100           coords.window_lower_clip_point-coords.window_upper_clip_point,
101           coords.window_width,
102           coords.window_height);
103#endif
104}
105
106
107
108ED4_folding_line* ED4_window::insert_folding_line(AW_pos world_x, AW_pos world_y, AW_pos length, AW_pos dimension, ED4_base *link, ED4_properties prop) {
109    ED4_folding_line *fl = NULL;
110
111    if (prop == ED4_P_VERTICAL || prop == ED4_P_HORIZONTAL) {
112        fl = new ED4_folding_line;
113        fl->link = link;
114
115        if (link != NULL) {
116            link->update_info.linked_to_folding_line = 1;
117
118            AW_pos x, y;
119            link->calc_world_coords(&x, &y);
120
121            fl->world_pos[X_POS] = x;
122            fl->world_pos[Y_POS] = y;
123            fl->length           = link->extension.size[(prop == ED4_P_VERTICAL) ? HEIGHT : WIDTH];
124        }
125        else
126        {
127            fl->world_pos[X_POS] = world_x;
128            fl->world_pos[Y_POS] = world_y;
129            fl->length           = length;
130        }
131
132        fl->dimension = dimension;
133
134        ED4_folding_line *current_fl = NULL;
135        int               rel_pos;
136
137        if (prop == ED4_P_VERTICAL) {
138            fl->window_pos[X_POS] = fl->world_pos[X_POS] - dimension;
139            fl->window_pos[Y_POS] = fl->world_pos[Y_POS];
140
141            if (!vertical_fl) vertical_fl = fl;
142            else {
143                current_fl = vertical_fl;
144                rel_pos    = X_POS;
145            }
146        }
147        else {
148            e4_assert(prop == ED4_P_HORIZONTAL);
149            fl->window_pos[Y_POS] = fl->world_pos[Y_POS] - dimension;
150            fl->window_pos[X_POS] = fl->world_pos[X_POS];
151
152            if (!horizontal_fl) horizontal_fl = fl;
153            else {
154                current_fl = horizontal_fl;
155                rel_pos    = Y_POS;
156            }
157        }
158
159        if (current_fl) {
160            ED4_folding_line *previous_fl = NULL;
161
162            while ((current_fl != NULL) && (current_fl->world_pos[rel_pos] <= fl->world_pos[rel_pos])) {
163                previous_fl = current_fl;
164                current_fl  = current_fl->next;
165            }
166
167            if (previous_fl) previous_fl->next = fl;
168            fl->next = current_fl;
169        }
170    }
171    return fl;
172}
173
174ED4_window *ED4_window::get_matching_ed4w(AW_window *aw) {
175    ED4_window *window = ED4_ROOT->first_window;
176    while (window && window->aww != aw) window = window->next;
177    return window;
178}
179
180
181
182ED4_returncode ED4_window::delete_folding_line(ED4_folding_line */*fl*/, ED4_properties /*prop*/) {
183    return ED4_R_OK;
184}
185
186ED4_returncode ED4_window::update_scrolled_rectangle()
187{
188    if ((scrolled_rect.scroll_top == NULL) || (scrolled_rect.scroll_bottom == NULL) ||
189        (scrolled_rect.scroll_left == NULL) || (scrolled_rect.scroll_right == NULL))
190        return ED4_R_IMPOSSIBLE;
191
192    AW_pos world_x = scrolled_rect.world_x;
193    AW_pos world_y = scrolled_rect.world_y;
194
195    AW_pos width  = scrolled_rect.scroll_right->world_pos[X_POS] - scrolled_rect.scroll_left->world_pos[X_POS] + 1;
196    AW_pos height = scrolled_rect.scroll_bottom->world_pos[Y_POS] - scrolled_rect.scroll_top->world_pos[Y_POS] + 1;
197
198    // calculate possibly new world coordinates and extensions of existing links
199    {
200        AW_pos dummy;
201        if (scrolled_rect.x_link != NULL) scrolled_rect.x_link->calc_world_coords(&world_x, &dummy);
202        if (scrolled_rect.y_link != NULL) scrolled_rect.y_link->calc_world_coords(&dummy, &world_y);
203    }
204
205    if (scrolled_rect.width_link  != NULL) width  = scrolled_rect.width_link->extension.size[WIDTH];
206    if (scrolled_rect.height_link != NULL) height = scrolled_rect.height_link->extension.size[HEIGHT];
207
208    // set new world and window coordinates
209    scrolled_rect.scroll_top->world_pos[X_POS]  = world_x;
210    scrolled_rect.scroll_top->world_pos[Y_POS]  = world_y;
211    scrolled_rect.scroll_top->window_pos[X_POS] = world_x;
212    scrolled_rect.scroll_top->window_pos[Y_POS] = world_y;
213
214    if (scrolled_rect.scroll_top->length != INFINITE) scrolled_rect.scroll_top->length = width;
215
216    scrolled_rect.scroll_bottom->world_pos[X_POS] = world_x;
217    scrolled_rect.scroll_bottom->world_pos[Y_POS] = world_y + height - 1;
218
219    if (scrolled_rect.scroll_bottom->length != INFINITE) scrolled_rect.scroll_bottom->length = width;
220
221    scrolled_rect.scroll_left->world_pos[X_POS]  = world_x;
222    scrolled_rect.scroll_left->world_pos[Y_POS]  = world_y;
223    scrolled_rect.scroll_left->window_pos[X_POS] = world_x;
224    scrolled_rect.scroll_left->window_pos[Y_POS] = world_y;
225
226    if (scrolled_rect.scroll_left->length != INFINITE) scrolled_rect.scroll_left->length = height;
227
228    scrolled_rect.scroll_right->world_pos[X_POS] = world_x + width - 1;
229    scrolled_rect.scroll_right->world_pos[Y_POS] = world_y;
230
231    if (scrolled_rect.scroll_right->length != INFINITE) scrolled_rect.scroll_right->length = height;
232
233    scrolled_rect.world_x = world_x;
234    scrolled_rect.world_y = world_y;
235    scrolled_rect.width   = width;
236    scrolled_rect.height  = height;
237
238    // update window scrollbars
239    AW_world rect = { 0, height-1, 0, width-1 };
240    set_scrollbar_indents();
241    aww->tell_scrolled_picture_size(rect);
242    aww->calculate_scrollbars();
243
244    {
245        int delta = aww->slider_pos_horizontal - slider_pos_horizontal;     // update dimension and window position of folding lines at
246        scrolled_rect.scroll_left->dimension += delta;                  // the borders of scrolled rectangle
247        delta = aww->slider_pos_vertical - slider_pos_vertical;
248        scrolled_rect.scroll_top->dimension += delta;
249    }
250    const AW_screen_area& area_size = ED4_ROOT->get_device()->get_area_size();
251
252    if (scrolled_rect.height_link != NULL) slider_pos_vertical   = aww->slider_pos_vertical;
253    if (scrolled_rect.width_link  != NULL) slider_pos_horizontal = aww->slider_pos_horizontal;
254
255
256    AW_pos dim;
257    if ((world_y + height - 1) > area_size.b) { // our world doesn't fit vertically in our window
258        // determine dimension of bottom folding line
259        dim = (world_y + height - 1) - area_size.b;
260        scrolled_rect.scroll_bottom->dimension = max(0, int(dim - scrolled_rect.scroll_top->dimension));
261    }
262    else {
263        dim = 0;
264        scrolled_rect.scroll_bottom->dimension = 0;
265        scrolled_rect.scroll_top->dimension = 0;
266    }
267
268    scrolled_rect.scroll_bottom->window_pos[Y_POS] = world_y + height - 1 - dim;
269    scrolled_rect.scroll_bottom->window_pos[X_POS] = world_x;
270
271    if ((world_x + width - 1) > area_size.r) { // our world doesn't fit horizontally in our window =>
272        // determine dimension of right folding line
273        dim = (world_x + width - 1) - area_size.r;
274        scrolled_rect.scroll_right->dimension = max(0, int(dim - scrolled_rect.scroll_left->dimension));
275    }
276    else {
277        dim = 0;
278        scrolled_rect.scroll_right->dimension = 0;
279        scrolled_rect.scroll_left->dimension = 0;
280    }
281
282    scrolled_rect.scroll_right->window_pos[X_POS] = world_x + width - 1 - dim;
283    scrolled_rect.scroll_right->window_pos[Y_POS] = world_y;
284
285    update_window_coords();
286
287    return ED4_R_OK;
288}
289
290ED4_returncode ED4_window::set_scrolled_rectangle(AW_pos world_x, AW_pos world_y, AW_pos width, AW_pos height,
291                                                  ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link)
292{
293    AW_pos x, y, dim;
294
295    // first of all remove existing scrolled rectangle
296    if (scrolled_rect.scroll_top    != NULL) delete_folding_line(scrolled_rect.scroll_top,    ED4_P_HORIZONTAL);
297    if (scrolled_rect.scroll_bottom != NULL) delete_folding_line(scrolled_rect.scroll_bottom, ED4_P_HORIZONTAL);
298    if (scrolled_rect.scroll_left   != NULL) delete_folding_line(scrolled_rect.scroll_left,   ED4_P_VERTICAL);
299    if (scrolled_rect.scroll_right  != NULL) delete_folding_line(scrolled_rect.scroll_right,  ED4_P_VERTICAL);
300
301    if (x_link != NULL) {
302        x_link->update_info.linked_to_scrolled_rectangle = 1;
303        x_link->calc_world_coords(&x, &y);
304        world_x = x;
305    }
306
307    if (y_link != NULL) {
308        y_link->update_info.linked_to_scrolled_rectangle = 1;
309        y_link->calc_world_coords(&x, &y);
310        world_y = y;
311    }
312
313    if (width_link != NULL) {
314        width_link->update_info.linked_to_scrolled_rectangle = 1;
315        width = width_link->extension.size[WIDTH];
316    }
317
318    if (height_link != NULL) {
319        height_link->update_info.linked_to_scrolled_rectangle = 1;
320        height = height_link->extension.size[HEIGHT];
321    }
322
323    const AW_screen_area& area_size = ED4_ROOT->get_device()->get_area_size();
324
325    if ((area_size.r <= world_x) || (area_size.b <= world_y)) {
326        return ED4_R_IMPOSSIBLE;
327    }
328
329    scrolled_rect.scroll_top  = insert_folding_line(world_x, world_y, INFINITE, 0, NULL, ED4_P_HORIZONTAL);
330    scrolled_rect.scroll_left = insert_folding_line(world_x, world_y, INFINITE, 0, NULL, ED4_P_VERTICAL);
331
332    dim = 0;
333    if ((world_y + height - 1) > area_size.b) dim = (world_y + height - 1) - area_size.b;
334
335    scrolled_rect.scroll_bottom = insert_folding_line(world_x, (world_y + height - 1), INFINITE, dim, NULL, ED4_P_HORIZONTAL);
336
337    dim = 0;
338    if ((world_x + width - 1) > area_size.r) dim = (world_x + width - 1) - area_size.r;
339
340    scrolled_rect.scroll_right = insert_folding_line((world_x + width - 1), world_y, INFINITE, dim, NULL, ED4_P_VERTICAL);
341    scrolled_rect.x_link       = x_link;
342    scrolled_rect.y_link       = y_link;
343    scrolled_rect.width_link   = width_link;
344    scrolled_rect.height_link  = height_link;
345    scrolled_rect.world_x      = world_x;
346    scrolled_rect.world_y      = world_y;
347    scrolled_rect.width        = width;
348    scrolled_rect.height       = height;
349
350    return ED4_R_OK;
351}
352
353static inline void clear_and_update_rectangle(AW_pos x1, AW_pos y1, AW_pos x2, AW_pos y2)
354// clears and updates any range of the screen (in win coordinates)
355// clipping range should be set correctly
356{
357    AW_screen_area rect;
358
359    rect.t = int(y1);
360    rect.b = int(y2);
361    rect.l = int(x1);
362    rect.r = int(x2);
363    ED4_set_clipping_rectangle(&rect);
364
365#if defined(DEBUG) && 0
366    static int toggle = 0;
367    ED4_ROOT->get_device()->box(ED4_G_COLOR_2+toggle, x1, y1, x2-x1+1, y2-y1+1, AW_ALL_DEVICES_SCALED, 0, 0);    // fill range with color (for testing)
368    toggle = (toggle+1)&7;
369#else
370    ED4_ROOT->get_device()->clear_part(x1, y1, x2-x1+1, y2-y1+1, AW_ALL_DEVICES);
371#endif
372
373    ED4_ROOT->main_manager->to_manager()->Show(1, 1);
374}
375
376static inline void move_and_update_rectangle(AW_pos x1, AW_pos y1, AW_pos x2, AW_pos y2, int dx, int dy)
377// x1/y1=upper-left-corner (win coordinates)
378// x2/y2=lower-right-corner
379// dx/dy=movement
380{
381    AW_pos fx = dx<0 ? x1-dx : x1;  // move from position ..
382    AW_pos fy = dy<0 ? y1-dy : y1;
383    AW_pos tx = dx>0 ? x1+dx : x1;  // ..to position ..
384    AW_pos ty = dy>0 ? y1+dy : y1;
385    int xs = int(x2-x1-abs(dx));        // ..size
386    int ys = int(y2-y1-abs(dy));
387
388    {
389        AW_screen_area rect;
390        rect.t = int(ty);
391        rect.b = int(ty+ys-1);
392        rect.l = int(tx);
393        rect.r = int(tx+xs-1);
394        ED4_set_clipping_rectangle(&rect);
395    }
396
397    AW_device *device = ED4_ROOT->get_device();
398    device->move_region(fx, fy, xs, ys, tx, ty);
399
400    if (dy<0) { // scroll to the top
401        device->set_top_font_overlap(true);
402        clear_and_update_rectangle(x1, y2+dy, x2, y2);
403        device->set_top_font_overlap(false);
404    }
405    else if (dy>0) { // scroll to the bottom
406        device->set_bottom_font_overlap(true);
407        clear_and_update_rectangle(x1, y1, x2, y1+dy);
408        device->set_bottom_font_overlap(false);
409    }
410
411    int char_width = ED4_ROOT->font_group.get_max_width() * 2;
412    if (dx<0) { // scroll left
413        device->set_left_font_overlap(true);
414        clear_and_update_rectangle(x2+dx-char_width, y1, x2, y2);
415        device->set_left_font_overlap(false);
416    }
417    else if (dx>0) { // scroll right
418        device->set_right_font_overlap(true);
419        clear_and_update_rectangle(x1, y1, x1+dx+char_width, y2);
420        device->set_right_font_overlap(false);
421    }
422}
423
424static inline void update_rectangle(AW_pos x1, AW_pos y1, AW_pos x2, AW_pos y2) // x1/y1=upper-left-corner x2/y2=lower-right-corner
425{
426    AW_screen_area rect;
427    rect.t = int(y1);
428    rect.b = int(y2);
429    rect.l = int(x1);
430    rect.r = int(x2);
431
432    ED4_set_clipping_rectangle(&rect);
433    clear_and_update_rectangle(x1, y1, x2, y2);
434}
435
436
437ED4_returncode ED4_window::scroll_rectangle(int dx, int dy)
438{
439    int skip_move;
440
441    if (!dx && !dy) return ED4_R_OK; // scroll not
442
443    AW_pos left_x   = scrolled_rect.scroll_left->window_pos[X_POS];
444    AW_pos top_y    = scrolled_rect.scroll_top->window_pos[Y_POS];
445    AW_pos right_x  = scrolled_rect.scroll_right->window_pos[X_POS];
446    AW_pos bottom_y = scrolled_rect.scroll_bottom->window_pos[Y_POS];
447
448    scrolled_rect.scroll_left->dimension   -= dx;
449    scrolled_rect.scroll_top->dimension    -= dy;
450    scrolled_rect.scroll_right->dimension  += dx;
451    scrolled_rect.scroll_bottom->dimension += dy;
452
453    skip_move = (ABS(int(dy)) > (bottom_y - top_y - 20)) || (ABS(int(dx)) > (right_x - left_x - 20));
454
455    AW_pos leftmost_x = coords.middle_area_x;
456    AW_pos toptop_y = coords.top_area_y;
457    AW_pos topbottom_y = toptop_y + coords.top_area_height - 1;
458
459    ED4_ROOT->get_device()->push_clip_scale();
460
461    // main area
462
463    if (skip_move)  update_rectangle(left_x, top_y, right_x, bottom_y); // main area
464    else            move_and_update_rectangle(left_x, top_y, right_x, bottom_y, int(dx), int(dy)); // main area
465
466    // name area (scroll only vertically)
467
468    if (dy) {
469        if (skip_move)  update_rectangle(leftmost_x, top_y, left_x, bottom_y);
470        else            move_and_update_rectangle(leftmost_x, top_y, left_x, bottom_y, 0, int(dy));
471    }
472
473    // top area (scroll only horizontally)
474
475    if (dx) {
476        if (skip_move)  update_rectangle(left_x, toptop_y, right_x, topbottom_y);
477        else            move_and_update_rectangle(left_x, toptop_y, right_x, topbottom_y, int(dx), 0);
478    }
479
480    ED4_ROOT->get_device()->pop_clip_scale();
481
482    return (ED4_R_OK);
483}
484
485ED4_returncode ED4_window::set_scrollbar_indents() {
486    int indent_y, indent_x;
487
488    if ((scrolled_rect.scroll_top    == NULL) ||
489        (scrolled_rect.scroll_bottom == NULL) ||
490        (scrolled_rect.scroll_left   == NULL) ||
491        (scrolled_rect.scroll_right  == NULL))
492        return (ED4_R_IMPOSSIBLE);
493
494    indent_y = (int) scrolled_rect.world_y + SLIDER_OFFSET;
495    aww->set_vertical_scrollbar_top_indent(indent_y);
496    indent_x = (int) scrolled_rect.world_x + SLIDER_OFFSET;
497    aww->set_horizontal_scrollbar_left_indent(indent_x);
498
499    return (ED4_R_OK);
500}
501
502
503void ED4_window::delete_window(ED4_window *window)  // delete from window list
504{
505    ED4_window *temp, *temp2;
506
507    if (window == ED4_ROOT->first_window) {
508        temp = ED4_ROOT->first_window;                  // delete temp afterwards
509        ED4_ROOT->first_window = ED4_ROOT->first_window->next;
510
511        if (no_of_windows > 1) {
512            ED4_ROOT->use_first_window();
513        }
514    }
515    else {
516        temp = temp2 = ED4_ROOT->first_window;
517
518        while (temp != window) {
519            temp2 = temp;
520            temp = temp->next;
521        }
522
523        temp2->next = temp->next;
524
525        ED4_ROOT->use_window(temp2);
526    }
527
528    ED4_ROOT->aw_root->awar(temp->awar_path_for_cursor)->write_int(0);              // save in database
529    ED4_ROOT->aw_root->awar(temp->awar_path_for_Ecoli)->write_int(0);
530    ED4_ROOT->aw_root->awar(temp->awar_path_for_basePos)->write_int(0);
531    ED4_ROOT->aw_root->awar(temp->awar_path_for_IUPAC)->write_string(ED4_IUPAC_EMPTY);
532    ED4_ROOT->aw_root->awar(temp->awar_path_for_helixNr)->write_string("");
533    delete temp;
534}
535
536
537ED4_window *ED4_window::insert_window(AW_window *new_aww)
538{
539    ED4_window *last, *temp;
540
541    temp = ED4_ROOT->first_window;          // append at end of window list
542    last = temp;
543    while (temp) {
544        last = temp;
545        temp = temp->next;
546    }
547
548    temp = new ED4_window (new_aww);
549
550    if (!ED4_ROOT->first_window) {       // this is the first window
551        ED4_ROOT->first_window = temp;
552    }
553    else if (last != NULL) {
554        last->next = temp;
555    }
556
557    // treat devices
558    new_aww->set_expose_callback(AW_MIDDLE_AREA, ED4_expose_cb, 0, 0);
559    new_aww->set_resize_callback(AW_MIDDLE_AREA, ED4_resize_cb, 0, 0);
560    new_aww->set_input_callback (AW_MIDDLE_AREA, ED4_input_cb,  0, 0);
561    new_aww->set_motion_callback(AW_MIDDLE_AREA, ED4_motion_cb, 0, 0);
562
563    new_aww->set_horizontal_change_callback(ED4_horizontal_change_cb, 0, 0);
564    new_aww->set_vertical_change_callback  (ED4_vertical_change_cb,   0, 0);
565
566    ED4_ROOT->use_window(temp);
567    ED4_ROOT->temp_gc = ED4_G_STANDARD;
568
569    return temp;
570}
571
572ED4_window::ED4_window(AW_window *window)
573{
574    aww                   = window;
575    next                  = 0;
576    slider_pos_horizontal = 0;
577    slider_pos_vertical   = 0;
578    horizontal_fl         = 0;
579    vertical_fl           = 0;
580
581    scrolled_rect.clear();
582    id        = ++no_of_windows;
583    coords.clear();
584    is_hidden = false;
585
586    sprintf(awar_path_for_cursor, AWAR_EDIT_SEQ_POSITION, id);
587    ED4_ROOT->aw_root->awar_int(awar_path_for_cursor, 0, AW_ROOT_DEFAULT);
588
589    sprintf(awar_path_for_Ecoli, AWAR_EDIT_ECOLI_POSITION, id);
590    ED4_ROOT->aw_root->awar_int(awar_path_for_Ecoli, 0, AW_ROOT_DEFAULT);
591
592    sprintf(awar_path_for_basePos, AWAR_EDIT_BASE_POSITION, id);
593    ED4_ROOT->aw_root->awar_int(awar_path_for_basePos, 0, AW_ROOT_DEFAULT);
594
595    sprintf(awar_path_for_IUPAC, AWAR_EDIT_IUPAC, id);
596    ED4_ROOT->aw_root->awar_string(awar_path_for_IUPAC, ED4_IUPAC_EMPTY, AW_ROOT_DEFAULT);
597
598    sprintf(awar_path_for_helixNr, AWAR_EDIT_HELIXNR, id);
599    ED4_ROOT->aw_root->awar_string(awar_path_for_helixNr, "", AW_ROOT_DEFAULT);
600}
601
602
603ED4_window::~ED4_window()
604{
605    delete aww;
606    delete horizontal_fl;       // be careful, don't delete links to hierarchy  in folding lines!!!
607    delete vertical_fl;
608
609    no_of_windows --;
610}
611
Note: See TracBrowser for help on using the repository browser.