source: branches/species/DIST/di_view_matrix.hxx

Last change on this file was 19613, checked in by westram, 2 months ago
  • reintegrates 'lib' into 'trunk'
    • replace dynamic library AWT by several static libraries: APP, ARB_SPEC, MASKS, CANVAS, MAPKEY, GUI_TK
    • now also check wrong library dependencies for untested units (only4me)
  • adds: log:branches/lib@19578:19612
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1// =============================================================== //
2//                                                                 //
3//   File      : di_view_matrix.hxx                                //
4//   Purpose   : matrix display                                    //
5//                                                                 //
6//   Institute of Microbiology (Technical University Munich)       //
7//   http://www.arb-home.de/                                       //
8//                                                                 //
9// =============================================================== //
10
11#ifndef DI_VIEW_MATRIX_HXX
12#define DI_VIEW_MATRIX_HXX
13
14#ifndef AW_WINDOW_HXX
15#include <aw_window.hxx>
16#endif
17#ifndef DI_MATR_HXX
18#include "di_matr.hxx"
19#endif
20
21enum DI_gc {
22    DI_G_STANDARD,
23    DI_G_NAMES,
24    DI_G_RULER,
25    DI_G_RULER_DISPLAY,
26    DI_G_BELOW_DIST,
27    DI_G_ABOVE_DIST,
28    DI_G_LAST                   // must be last
29};
30
31class MatrixDisplay {
32    GBDATA *gb_main;
33
34    int screen_width;             // dimensions of main screen
35    int screen_height;
36
37    int cell_width;               // width and height of one cell
38    int cell_height;
39
40    int cell_paddx;               // padding between cells
41    int cell_paddy;
42
43    bool leadZero;                // show leading zero
44    int  digits;                  // digits after '.'
45    char format_string[50];       // for digits
46
47    int horiz_page_start;         // number of first element in this page
48    int vert_page_start;
49
50    int vert_last_view_start;     // last value of scrollbars
51    int horiz_last_view_start;
52
53    int total_cells_horiz;
54    int total_cells_vert;
55
56    int horiz_page_size;          // page size in cells (how many cells per page,
57    int vert_page_size;           // vertical and horizontal)
58
59    int off_dx;                   // offset values for scrollable area
60    int off_dy;
61
62    double min_view_dist;         // m[i][j]<min_view_dist -> ascii ; else small slider
63    double max_view_dist;         // m[i][j]>max_view_dist -> ascii ; else small slider
64
65    void set_scrollbar_steps(long width, long hight, long xinc, long yinc);
66    void scroll_to(int sxpos, int sypos);
67
68public:
69    enum UpdateFlag { // bits
70        NEED_NOTHING = 0,
71        NEED_CLEAR   = 1,
72        NEED_RESIZE  = 2,
73        NEED_SETUP   = 4,
74    };
75private:
76    UpdateFlag beforeUpdate;
77
78    void setup();
79    void adapt_to_canvas_size();                                 // call after resize main window
80    void draw();
81
82    enum LastAutoPop { UNKNOWN, UP, DOWN };
83    LastAutoPop lastautopop;
84
85    bool autopop(bool show) {
86        // handle automatic hide/show of matrix view
87        // - avoid popup if was not auto-hidden
88        if (!awm) return false;
89        if (!show) {
90            if (awm->is_shown()) {
91                awm->hide(); lastautopop = DOWN;
92            }
93        }
94        else if (!awm->is_shown() && lastautopop == DOWN) {
95            awm->show(); lastautopop = UP;
96        }
97        return awm->is_shown();
98    }
99
100public:
101    AW_window *awm;
102    AW_device *device;          // device to draw in
103
104    MatrixDisplay(GBDATA *gb_main_) :
105        gb_main(gb_main_),
106        screen_width(0),
107        screen_height(0),
108        cell_width(0),
109        cell_height(0),
110        cell_paddx(0),
111        cell_paddy(0),
112        leadZero(false),
113        digits(0),
114        horiz_page_start(0),
115        vert_page_start(0),
116        vert_last_view_start(0),
117        horiz_last_view_start(0),
118        total_cells_horiz(0),
119        total_cells_vert(0),
120        horiz_page_size(0),
121        vert_page_size(0),
122        off_dx(0),
123        off_dy(0),
124        min_view_dist(0.0),
125        max_view_dist(0.0),
126        beforeUpdate(NEED_SETUP),
127        lastautopop(UNKNOWN),
128        awm(NULp),
129        device(NULp)
130    {}
131
132    DI_MATRIX *get_matrix() { return GLOBAL_MATRIX.get(); }
133
134    bool willShow() {
135        if (!awm) return false;
136        return awm->is_shown() || lastautopop == DOWN;
137    }
138
139    void monitor_vertical_scroll_cb(AW_window *);   // vertical and horizontal
140    void monitor_horizontal_scroll_cb(AW_window *); // scrollbar movements
141
142    void mark(UpdateFlag needed) { beforeUpdate = UpdateFlag(beforeUpdate|needed); }
143
144    void update_display() {
145        if (beforeUpdate&NEED_SETUP) setup();
146        if (beforeUpdate&NEED_RESIZE) adapt_to_canvas_size();
147        draw();
148        beforeUpdate = NEED_NOTHING;
149    }
150
151    // ******************** real public section *******************
152    void set_slider_min(double d) { min_view_dist = d; };
153    void set_slider_max(double d) { max_view_dist = d; };
154
155    void handle_move(AW_event& event);
156    void scroll_cells(int cells_x, int cells_y);
157};
158
159AW_window *DI_create_view_matrix_window(AW_root *awr, MatrixDisplay *disp, save_matrix_params *sparam);
160
161
162#else
163#error di_view_matrix.hxx included twice
164#endif // DI_VIEW_MATRIX_HXX
Note: See TracBrowser for help on using the repository browser.