ARB
di_view_matrix.hxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : di_view_matrix.hxx //
4 // //
5 // Institute of Microbiology (Technical University Munich) //
6 // http://www.arb-home.de/ //
7 // //
8 // =============================================================== //
9 
10 #ifndef DI_VIEW_MATRIX_HXX
11 #define DI_VIEW_MATRIX_HXX
12 
13 #ifndef AW_WINDOW_HXX
14 #include <aw_window.hxx>
15 #endif
16 #ifndef DI_MATR_HXX
17 #include "di_matr.hxx"
18 #endif
19 
20 enum DI_gc {
27  DI_G_LAST // must be last
28 };
29 
31  int screen_width; // dimensions of main screen
32  int screen_height;
33 
34  int cell_width; // width and height of one cell
35  int cell_height;
36 
37  int cell_paddx; // padding between cells
38  int cell_paddy;
39 
40  bool leadZero; // show leading zero
41  int digits; // digits after '.'
42  char format_string[50]; // for digits
43 
44  int horiz_page_start; // number of first element in this page
45  int vert_page_start;
46 
47  int vert_last_view_start; // last value of scrollbars
48  int horiz_last_view_start;
49 
50  int total_cells_horiz;
51  int total_cells_vert;
52 
53  int horiz_page_size; // page size in cells (how many cells per page,
54  int vert_page_size; // vertical and horizontal)
55 
56  int off_dx; // offset values for scrollable area
57  int off_dy;
58 
59  double min_view_dist; // m[i][j]<min_view_dist -> ascii ; else small slider
60  double max_view_dist; // m[i][j]>max_view_dist -> ascii ; else small slider
61 
62  void set_scrollbar_steps(long width, long hight, long xinc, long yinc);
63  void scroll_to(int sxpos, int sypos);
64 
65 public:
66  enum UpdateFlag { // bits
71  };
72 private:
73  UpdateFlag beforeUpdate;
74 
75  void setup();
76  void adapt_to_canvas_size(); // call after resize main window
77  void draw();
78 
79  enum LastAutoPop { UNKNOWN, UP, DOWN };
80  LastAutoPop lastautopop;
81 
82  bool autopop(bool show) {
83  // handle automatic hide/show of matrix view
84  // - avoid popup if was not auto-hidden
85  if (!awm) return false;
86  if (!show) {
87  if (awm->is_shown()) {
88  awm->hide(); lastautopop = DOWN;
89  }
90  }
91  else if (!awm->is_shown() && lastautopop == DOWN) {
92  awm->show(); lastautopop = UP;
93  }
94  return awm->is_shown();
95  }
96 
97 public:
99  AW_device *device; // device to draw in
100 
102  : screen_width(0),
103  screen_height(0),
104  cell_width(0),
105  cell_height(0),
106  cell_paddx(0),
107  cell_paddy(0),
108  leadZero(false),
109  digits(0),
110  horiz_page_start(0),
111  vert_page_start(0),
112  vert_last_view_start(0),
113  horiz_last_view_start(0),
114  total_cells_horiz(0),
115  total_cells_vert(0),
116  horiz_page_size(0),
117  vert_page_size(0),
118  off_dx(0),
119  off_dy(0),
120  min_view_dist(0.0),
121  max_view_dist(0.0),
122  beforeUpdate(NEED_SETUP),
123  lastautopop(UNKNOWN),
124  awm(NULp),
125  device(NULp)
126  {}
127 
129 
130  bool willShow() {
131  if (!awm) return false;
132  return awm->is_shown() || lastautopop == DOWN;
133  }
134 
135  void monitor_vertical_scroll_cb(AW_window *); // vertical and horizontal
136  void monitor_horizontal_scroll_cb(AW_window *); // scrollbar movements
137 
138  void mark(UpdateFlag needed) { beforeUpdate = UpdateFlag(beforeUpdate|needed); }
139 
140  void update_display() {
141  if (beforeUpdate&NEED_SETUP) setup();
142  if (beforeUpdate&NEED_RESIZE) adapt_to_canvas_size();
143  draw();
144  beforeUpdate = NEED_NOTHING;
145  }
146 
147  // ******************** real public section *******************
148  void set_slider_min(double d) { min_view_dist = d; };
149  void set_slider_max(double d) { max_view_dist = d; };
150 
151  void handle_move(AW_event& event);
152  void scroll_cells(int cells_x, int cells_y);
153 };
154 
156 
157 
158 #else
159 #error di_view_matrix.hxx included twice
160 #endif // DI_VIEW_MATRIX_HXX
void monitor_vertical_scroll_cb(AW_window *)
void handle_move(AW_event &event)
void set_slider_min(double d)
void monitor_horizontal_scroll_cb(AW_window *)
void mark(UpdateFlag needed)
void scroll_cells(int cells_x, int cells_y)
void show()
Definition: AW_window.cxx:1658
DI_MATRIX * get()
Definition: di_matr.hxx:192
#define false
Definition: ureadseq.h:13
AW_device * device
DI_GLOBAL_MATRIX GLOBAL_MATRIX
Definition: DI_matr.cxx:64
AW_window * awm
bool is_shown() const
Definition: AW_window.cxx:1622
void hide()
Definition: AW_window.cxx:1807
#define NULp
Definition: cxxforward.h:97
DI_MATRIX * get_matrix()
AW_window * DI_create_view_matrix_window(AW_root *awr, MatrixDisplay *disp, save_matrix_params *sparam)
void set_slider_max(double d)