1 | #include <cstdio> |
---|
2 | #include <cstring> |
---|
3 | #include <cstdlib> |
---|
4 | |
---|
5 | #include <arbdb.h> |
---|
6 | #include <aw_root.hxx> |
---|
7 | #include <aw_window.hxx> |
---|
8 | |
---|
9 | #include <ed4_extern.hxx> |
---|
10 | |
---|
11 | #include "ed4_class.hxx" |
---|
12 | #include "ed4_tools.hxx" |
---|
13 | |
---|
14 | int ED4_window::no_of_windows = 0; // static variable has to be initialized only once |
---|
15 | |
---|
16 | void ED4_window::reset_all_for_new_config() |
---|
17 | { |
---|
18 | horizontal_fl = NULL; |
---|
19 | vertical_fl = NULL; |
---|
20 | |
---|
21 | scrolled_rect.scroll_top = NULL; |
---|
22 | scrolled_rect.scroll_bottom = NULL; |
---|
23 | scrolled_rect.scroll_left = NULL; |
---|
24 | scrolled_rect.scroll_right = NULL; |
---|
25 | |
---|
26 | scrolled_rect.world_x = 0; |
---|
27 | scrolled_rect.world_y = 0; |
---|
28 | scrolled_rect.width = 0; |
---|
29 | scrolled_rect.height = 0; |
---|
30 | |
---|
31 | slider_pos_horizontal = 0; |
---|
32 | slider_pos_vertical = 0; |
---|
33 | |
---|
34 | coords.top_area_x = 0; |
---|
35 | coords.top_area_y = 0; |
---|
36 | coords.top_area_height = 0; |
---|
37 | |
---|
38 | coords.middle_area_x = 0; |
---|
39 | coords.middle_area_y = 0; |
---|
40 | |
---|
41 | coords.window_width = 0; |
---|
42 | coords.window_height = 0; |
---|
43 | |
---|
44 | coords.window_upper_clip_point = 0; |
---|
45 | coords.window_lower_clip_point = 0; |
---|
46 | coords.window_left_clip_point = 0; |
---|
47 | coords.window_right_clip_point = 0; |
---|
48 | |
---|
49 | ED4_ROOT->aw_root->awar(awar_path_for_cursor)->write_int(0); |
---|
50 | ED4_ROOT->aw_root->awar(awar_path_for_Ecoli)->write_int(0); |
---|
51 | ED4_ROOT->aw_root->awar(awar_path_for_basePos)->write_int(0); |
---|
52 | ED4_ROOT->aw_root->awar(awar_path_for_IUPAC)->write_string(ED4_IUPAC_EMPTY); |
---|
53 | ED4_ROOT->aw_root->awar(awar_path_for_helixNr)->write_string(""); |
---|
54 | |
---|
55 | if (next) next->reset_all_for_new_config(); |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | void ED4_window::update_window_coords() |
---|
60 | { |
---|
61 | AW_pos x,y; |
---|
62 | AW_rectangle area_size; |
---|
63 | |
---|
64 | ED4_ROOT->top_area_man->calc_world_coords( &x, &y ); |
---|
65 | |
---|
66 | coords.top_area_x = (long) x; |
---|
67 | coords.top_area_y = (long) y; |
---|
68 | coords.top_area_height = (long) ED4_ROOT->top_area_man->extension.size[HEIGHT]; |
---|
69 | |
---|
70 | ED4_ROOT->middle_area_man->calc_world_coords( &x, &y ); |
---|
71 | |
---|
72 | coords.middle_area_x = (long) x; |
---|
73 | coords.middle_area_y = (long) y; |
---|
74 | |
---|
75 | aww->_get_area_size (AW_MIDDLE_AREA, &area_size); |
---|
76 | |
---|
77 | coords.window_width = area_size.r; |
---|
78 | coords.window_height = area_size.b; |
---|
79 | |
---|
80 | // world coordinates |
---|
81 | coords.window_upper_clip_point = coords.middle_area_y + aww->slider_pos_vertical; //coordinate of upper clipping point of middle area |
---|
82 | coords.window_lower_clip_point = coords.window_upper_clip_point + coords.window_height - coords.middle_area_y; |
---|
83 | |
---|
84 | if (ED4_ROOT->scroll_links.link_for_hor_slider) { |
---|
85 | ED4_ROOT->scroll_links.link_for_hor_slider->calc_world_coords( &x, &y ); |
---|
86 | coords.window_left_clip_point = (long) x + aww->slider_pos_horizontal; |
---|
87 | coords.window_right_clip_point = coords.window_left_clip_point + coords.window_width - (long) x; |
---|
88 | } |
---|
89 | |
---|
90 | #if defined(DEBUG) && 0 |
---|
91 | printf("left %d right %d (xdiff=%d) upper %d lower %d (ydiff=%d) width=%d height=%d\n", |
---|
92 | coords.window_left_clip_point, |
---|
93 | coords.window_right_clip_point, |
---|
94 | coords.window_right_clip_point-coords.window_left_clip_point, |
---|
95 | coords.window_upper_clip_point, |
---|
96 | coords.window_lower_clip_point, |
---|
97 | coords.window_lower_clip_point-coords.window_upper_clip_point, |
---|
98 | coords.window_width, |
---|
99 | coords.window_height); |
---|
100 | #endif |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | |
---|
105 | ED4_folding_line* ED4_window::insert_folding_line( AW_pos world_x, |
---|
106 | AW_pos world_y, |
---|
107 | AW_pos length, |
---|
108 | AW_pos dimension, |
---|
109 | ED4_base *link, |
---|
110 | ED4_properties prop ) |
---|
111 | { |
---|
112 | ED4_folding_line *fl, *current_fl, *previous_fl = NULL; |
---|
113 | AW_pos x, y; |
---|
114 | int rel_pos; |
---|
115 | |
---|
116 | fl = new ED4_folding_line; |
---|
117 | fl->link = link; |
---|
118 | |
---|
119 | if ( link != NULL ) { |
---|
120 | link->update_info.linked_to_folding_line = 1; |
---|
121 | link->calc_world_coords( &x, &y ); |
---|
122 | fl->world_pos[X_POS] = x; |
---|
123 | fl->world_pos[Y_POS] = y; |
---|
124 | |
---|
125 | if ( prop == ED4_P_VERTICAL ) { |
---|
126 | fl->length = link->extension.size[HEIGHT]; |
---|
127 | } |
---|
128 | else { |
---|
129 | fl->length = link->extension.size[WIDTH]; |
---|
130 | } |
---|
131 | } |
---|
132 | else |
---|
133 | { |
---|
134 | fl->world_pos[X_POS] = world_x; |
---|
135 | fl->world_pos[Y_POS] = world_y; |
---|
136 | fl->length = length; |
---|
137 | } |
---|
138 | |
---|
139 | fl->dimension = dimension; |
---|
140 | |
---|
141 | if ( prop == ED4_P_VERTICAL ) { |
---|
142 | fl->window_pos[X_POS] = fl->world_pos[X_POS] - dimension; |
---|
143 | fl->window_pos[Y_POS] = fl->world_pos[Y_POS]; |
---|
144 | |
---|
145 | if ( (current_fl = vertical_fl) == NULL ) { |
---|
146 | vertical_fl = fl; |
---|
147 | return ( fl ); |
---|
148 | } |
---|
149 | |
---|
150 | rel_pos = X_POS; |
---|
151 | } |
---|
152 | else { |
---|
153 | if ( prop == ED4_P_HORIZONTAL ) { |
---|
154 | fl->window_pos[Y_POS] = fl->world_pos[Y_POS] - dimension; |
---|
155 | fl->window_pos[X_POS] = fl->world_pos[X_POS]; |
---|
156 | |
---|
157 | if ( (current_fl = horizontal_fl) == NULL ) { |
---|
158 | horizontal_fl = fl; |
---|
159 | return ( fl ); |
---|
160 | } |
---|
161 | |
---|
162 | rel_pos = Y_POS; |
---|
163 | } |
---|
164 | else { |
---|
165 | return ( NULL ); |
---|
166 | } |
---|
167 | } |
---|
168 | |
---|
169 | while ( (current_fl != NULL) && (current_fl->world_pos[rel_pos] <= fl->world_pos[rel_pos]) ) { |
---|
170 | previous_fl = current_fl; |
---|
171 | current_fl = current_fl->next; |
---|
172 | } |
---|
173 | |
---|
174 | if (previous_fl){ |
---|
175 | previous_fl->next = fl; |
---|
176 | } |
---|
177 | fl->next = current_fl; |
---|
178 | |
---|
179 | return ( fl ); |
---|
180 | } |
---|
181 | |
---|
182 | ED4_window *ED4_window::get_matching_ed4w(AW_window *aw) { |
---|
183 | ED4_window *window = ED4_ROOT->first_window; |
---|
184 | while (window && window->aww != aw) window = window->next; |
---|
185 | return window; |
---|
186 | } |
---|
187 | |
---|
188 | |
---|
189 | |
---|
190 | ED4_returncode ED4_window::delete_folding_line(ED4_folding_line *fl, ED4_properties prop) { |
---|
191 | AWUSE(fl); |
---|
192 | AWUSE(prop); |
---|
193 | |
---|
194 | return ( ED4_R_OK ); |
---|
195 | } |
---|
196 | |
---|
197 | ED4_returncode ED4_window::update_scrolled_rectangle( void ) |
---|
198 | { |
---|
199 | if ((scrolled_rect.scroll_top == NULL) || (scrolled_rect.scroll_bottom == NULL) || |
---|
200 | (scrolled_rect.scroll_left == NULL) || (scrolled_rect.scroll_right == NULL) ) |
---|
201 | return ED4_R_IMPOSSIBLE; |
---|
202 | |
---|
203 | AW_pos world_x = scrolled_rect.world_x; |
---|
204 | AW_pos world_y = scrolled_rect.world_y; |
---|
205 | |
---|
206 | AW_pos width = scrolled_rect.scroll_right->world_pos[X_POS] - scrolled_rect.scroll_left->world_pos[X_POS] + 1; |
---|
207 | AW_pos height = scrolled_rect.scroll_bottom->world_pos[Y_POS] - scrolled_rect.scroll_top->world_pos[Y_POS] + 1; |
---|
208 | |
---|
209 | // calculate possibly new world coordinates and extensions of existing links |
---|
210 | { |
---|
211 | AW_pos dummy; |
---|
212 | if ( scrolled_rect.x_link != NULL ) scrolled_rect.x_link->calc_world_coords( &world_x, &dummy ); |
---|
213 | if ( scrolled_rect.y_link != NULL ) scrolled_rect.y_link->calc_world_coords( &dummy, &world_y ); |
---|
214 | } |
---|
215 | |
---|
216 | if ( scrolled_rect.width_link != NULL ) width = scrolled_rect.width_link->extension.size[WIDTH]; |
---|
217 | if ( scrolled_rect.height_link != NULL ) height = scrolled_rect.height_link->extension.size[HEIGHT]; |
---|
218 | |
---|
219 | // set new world and window coordinates |
---|
220 | scrolled_rect.scroll_top->world_pos[X_POS] = world_x; |
---|
221 | scrolled_rect.scroll_top->world_pos[Y_POS] = world_y; |
---|
222 | scrolled_rect.scroll_top->window_pos[X_POS] = world_x; |
---|
223 | scrolled_rect.scroll_top->window_pos[Y_POS] = world_y; |
---|
224 | |
---|
225 | if ( scrolled_rect.scroll_top->length != INFINITE ) scrolled_rect.scroll_top->length = width; |
---|
226 | |
---|
227 | scrolled_rect.scroll_bottom->world_pos[X_POS] = world_x; |
---|
228 | scrolled_rect.scroll_bottom->world_pos[Y_POS] = world_y + height - 1; |
---|
229 | |
---|
230 | if ( scrolled_rect.scroll_bottom->length != INFINITE ) scrolled_rect.scroll_bottom->length = width; |
---|
231 | |
---|
232 | scrolled_rect.scroll_left->world_pos[X_POS] = world_x; |
---|
233 | scrolled_rect.scroll_left->world_pos[Y_POS] = world_y; |
---|
234 | scrolled_rect.scroll_left->window_pos[X_POS] = world_x; |
---|
235 | scrolled_rect.scroll_left->window_pos[Y_POS] = world_y; |
---|
236 | |
---|
237 | if ( scrolled_rect.scroll_left->length != INFINITE ) scrolled_rect.scroll_left->length = height; |
---|
238 | |
---|
239 | scrolled_rect.scroll_right->world_pos[X_POS] = world_x + width - 1; |
---|
240 | scrolled_rect.scroll_right->world_pos[Y_POS] = world_y; |
---|
241 | |
---|
242 | if ( scrolled_rect.scroll_right->length != INFINITE ) scrolled_rect.scroll_right->length = height; |
---|
243 | |
---|
244 | scrolled_rect.world_x = world_x; |
---|
245 | scrolled_rect.world_y = world_y; |
---|
246 | scrolled_rect.width = width; |
---|
247 | scrolled_rect.height = height; |
---|
248 | |
---|
249 | // update window scrollbars |
---|
250 | AW_world rect = { 0, height-1, 0, width-1 }; |
---|
251 | set_scrollbar_indents(); |
---|
252 | aww->tell_scrolled_picture_size(rect); |
---|
253 | aww->calculate_scrollbars(); |
---|
254 | |
---|
255 | AW_rectangle area_size; |
---|
256 | { |
---|
257 | int delta = aww->slider_pos_horizontal - slider_pos_horizontal; // update dimension and window position of folding lines at |
---|
258 | scrolled_rect.scroll_left->dimension += delta; // the borders of scrolled rectangle |
---|
259 | delta = aww->slider_pos_vertical - slider_pos_vertical; |
---|
260 | scrolled_rect.scroll_top->dimension += delta; |
---|
261 | ED4_ROOT->get_device()->get_area_size( &area_size ); |
---|
262 | } |
---|
263 | |
---|
264 | if ( scrolled_rect.height_link != NULL ) slider_pos_vertical = aww->slider_pos_vertical; |
---|
265 | if ( scrolled_rect.width_link != NULL ) slider_pos_horizontal = aww->slider_pos_horizontal; |
---|
266 | |
---|
267 | |
---|
268 | AW_pos dim; |
---|
269 | if ((world_y + height - 1) > area_size.b) { // our world doesn't fit vertically in our window |
---|
270 | // determine dimension of bottom folding line |
---|
271 | dim = (world_y + height - 1) - area_size.b; |
---|
272 | scrolled_rect.scroll_bottom->dimension = max(0, int(dim - scrolled_rect.scroll_top->dimension)); |
---|
273 | } |
---|
274 | else { |
---|
275 | dim = 0; |
---|
276 | scrolled_rect.scroll_bottom->dimension = 0; |
---|
277 | scrolled_rect.scroll_top->dimension = 0; |
---|
278 | } |
---|
279 | |
---|
280 | scrolled_rect.scroll_bottom->window_pos[Y_POS] = world_y + height - 1 - dim; |
---|
281 | scrolled_rect.scroll_bottom->window_pos[X_POS] = world_x; |
---|
282 | |
---|
283 | if ((world_x + width - 1) > area_size.r) { // our world doesn't fit horizontally in our window => |
---|
284 | // determine dimension of right folding line |
---|
285 | dim = (world_x + width - 1) - area_size.r; |
---|
286 | scrolled_rect.scroll_right->dimension = max(0, int(dim - scrolled_rect.scroll_left->dimension)); |
---|
287 | } |
---|
288 | else { |
---|
289 | dim = 0; |
---|
290 | scrolled_rect.scroll_right->dimension = 0; |
---|
291 | scrolled_rect.scroll_left->dimension = 0; |
---|
292 | } |
---|
293 | |
---|
294 | scrolled_rect.scroll_right->window_pos[X_POS] = world_x + width - 1 - dim; |
---|
295 | scrolled_rect.scroll_right->window_pos[Y_POS] = world_y; |
---|
296 | |
---|
297 | update_window_coords(); |
---|
298 | |
---|
299 | return ED4_R_OK; |
---|
300 | } |
---|
301 | |
---|
302 | ED4_returncode ED4_window::set_scrolled_rectangle( AW_pos world_x, AW_pos world_y, AW_pos width, AW_pos height, |
---|
303 | ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link ) |
---|
304 | { |
---|
305 | AW_pos x, y, dim; |
---|
306 | AW_rectangle area_size; |
---|
307 | |
---|
308 | // first of all remove existing scrolled rectangle |
---|
309 | if (scrolled_rect.scroll_top != NULL) delete_folding_line(scrolled_rect.scroll_top, ED4_P_HORIZONTAL); |
---|
310 | if (scrolled_rect.scroll_bottom != NULL) delete_folding_line(scrolled_rect.scroll_bottom, ED4_P_HORIZONTAL); |
---|
311 | if (scrolled_rect.scroll_left != NULL) delete_folding_line(scrolled_rect.scroll_left, ED4_P_VERTICAL); |
---|
312 | if (scrolled_rect.scroll_right != NULL) delete_folding_line(scrolled_rect.scroll_right, ED4_P_VERTICAL); |
---|
313 | |
---|
314 | if ( x_link != NULL ) { |
---|
315 | x_link->update_info.linked_to_scrolled_rectangle = 1; |
---|
316 | x_link->calc_world_coords( &x, &y ); |
---|
317 | world_x = x; |
---|
318 | } |
---|
319 | |
---|
320 | if ( y_link != NULL ) { |
---|
321 | y_link->update_info.linked_to_scrolled_rectangle = 1; |
---|
322 | y_link->calc_world_coords( &x, &y ); |
---|
323 | world_y = y; |
---|
324 | } |
---|
325 | |
---|
326 | if ( width_link != NULL ) { |
---|
327 | width_link->update_info.linked_to_scrolled_rectangle = 1; |
---|
328 | width = width_link->extension.size[WIDTH]; |
---|
329 | } |
---|
330 | |
---|
331 | if ( height_link != NULL ) { |
---|
332 | height_link->update_info.linked_to_scrolled_rectangle = 1; |
---|
333 | height = height_link->extension.size[HEIGHT]; |
---|
334 | } |
---|
335 | |
---|
336 | ED4_ROOT->get_device()->get_area_size( &area_size ); |
---|
337 | |
---|
338 | if ((area_size.r <= world_x) || (area_size.b <= world_y)) { |
---|
339 | return ED4_R_IMPOSSIBLE; |
---|
340 | } |
---|
341 | |
---|
342 | scrolled_rect.scroll_top = insert_folding_line( world_x, world_y, INFINITE, 0, NULL, ED4_P_HORIZONTAL ); |
---|
343 | scrolled_rect.scroll_left = insert_folding_line( world_x, world_y, INFINITE, 0, NULL, ED4_P_VERTICAL ); |
---|
344 | |
---|
345 | dim = 0; |
---|
346 | if ((world_y + height - 1) > area_size.b) dim = (world_y + height - 1) - area_size.b; |
---|
347 | |
---|
348 | scrolled_rect.scroll_bottom = insert_folding_line( world_x, (world_y + height - 1), INFINITE, dim, NULL, ED4_P_HORIZONTAL ); |
---|
349 | |
---|
350 | dim = 0; |
---|
351 | if ((world_x + width - 1) > area_size.r) dim = (world_x + width - 1) - area_size.r; |
---|
352 | |
---|
353 | scrolled_rect.scroll_right = insert_folding_line( (world_x + width - 1), world_y, INFINITE, dim, NULL, ED4_P_VERTICAL ); |
---|
354 | scrolled_rect.x_link = x_link; |
---|
355 | scrolled_rect.y_link = y_link; |
---|
356 | scrolled_rect.width_link = width_link; |
---|
357 | scrolled_rect.height_link = height_link; |
---|
358 | scrolled_rect.world_x = world_x; |
---|
359 | scrolled_rect.world_y = world_y; |
---|
360 | scrolled_rect.width = width; |
---|
361 | scrolled_rect.height = height; |
---|
362 | |
---|
363 | return ED4_R_OK; |
---|
364 | } |
---|
365 | |
---|
366 | static inline void clear_and_update_rectangle(AW_pos x1, AW_pos y1, AW_pos x2, AW_pos y2) |
---|
367 | // clears and updates any range of the screen (in win coordinates) |
---|
368 | // clipping range should be set correctly |
---|
369 | { |
---|
370 | AW_rectangle rect; |
---|
371 | |
---|
372 | rect.t = int(y1); |
---|
373 | rect.b = int(y2); |
---|
374 | rect.l = int(x1); |
---|
375 | rect.r = int(x2); |
---|
376 | ED4_set_clipping_rectangle(&rect); |
---|
377 | |
---|
378 | #if defined(DEBUG) && 0 |
---|
379 | static int toggle = 0; |
---|
380 | ED4_ROOT->get_device()->box(ED4_G_COLOR_2+toggle, x1, y1, x2-x1+1, y2-y1+1, (AW_bitset)-1, 0, 0); // fill range with color (for testing) |
---|
381 | toggle = (toggle+1)&7; |
---|
382 | #else |
---|
383 | ED4_ROOT->get_device()->clear_part(x1, y1, x2-x1+1, y2-y1+1, (AW_bitset)-1); |
---|
384 | #endif |
---|
385 | |
---|
386 | ED4_ROOT->main_manager->to_manager()->Show(1,1); |
---|
387 | } |
---|
388 | |
---|
389 | static inline void move_and_update_rectangle(AW_pos x1, AW_pos y1, AW_pos x2, AW_pos y2, int dx, int dy) |
---|
390 | // x1/y1=upper-left-corner (win coordinates) |
---|
391 | // x2/y2=lower-right-corner |
---|
392 | // dx/dy=movement |
---|
393 | { |
---|
394 | AW_pos fx = dx<0 ? x1-dx : x1; // move from position .. |
---|
395 | AW_pos fy = dy<0 ? y1-dy : y1; |
---|
396 | AW_pos tx = dx>0 ? x1+dx : x1; // ..to position .. |
---|
397 | AW_pos ty = dy>0 ? y1+dy : y1; |
---|
398 | int xs = int(x2-x1-abs(dx)); // ..size |
---|
399 | int ys = int(y2-y1-abs(dy)); |
---|
400 | |
---|
401 | { |
---|
402 | AW_rectangle rect; |
---|
403 | rect.t = int(ty); |
---|
404 | rect.b = int(ty+ys-1); |
---|
405 | rect.l = int(tx); |
---|
406 | rect.r = int(tx+xs-1); |
---|
407 | ED4_set_clipping_rectangle(&rect); |
---|
408 | } |
---|
409 | |
---|
410 | AW_device *device = ED4_ROOT->get_device(); |
---|
411 | device->move_region(fx, fy, xs, ys, tx, ty); |
---|
412 | |
---|
413 | if (dy<0) { // scroll to the top |
---|
414 | device->set_top_font_overlap(1); |
---|
415 | clear_and_update_rectangle(x1, y2+dy, x2, y2); |
---|
416 | device->set_top_font_overlap(0); |
---|
417 | } |
---|
418 | else if (dy>0) { // scroll to the bottom |
---|
419 | device->set_bottom_font_overlap(1); |
---|
420 | clear_and_update_rectangle(x1, y1, x2, y1+dy); |
---|
421 | device->set_bottom_font_overlap(0); |
---|
422 | } |
---|
423 | |
---|
424 | int char_width = ED4_ROOT->font_group.get_max_width() * 2; |
---|
425 | if (dx<0) { // scroll left |
---|
426 | device->set_left_font_overlap(1); |
---|
427 | clear_and_update_rectangle(x2+dx-char_width, y1, x2, y2); |
---|
428 | device->set_left_font_overlap(0); |
---|
429 | } |
---|
430 | else if (dx>0) { // scroll right |
---|
431 | device->set_right_font_overlap(1); |
---|
432 | clear_and_update_rectangle(x1, y1, x1+dx+char_width, y2); |
---|
433 | device->set_right_font_overlap(0); |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | static 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 |
---|
438 | { |
---|
439 | AW_rectangle rect; |
---|
440 | rect.t = int(y1); |
---|
441 | rect.b = int(y2); |
---|
442 | rect.l = int(x1); |
---|
443 | rect.r = int(x2); |
---|
444 | |
---|
445 | ED4_set_clipping_rectangle(&rect); |
---|
446 | clear_and_update_rectangle(x1, y1, x2, y2); |
---|
447 | } |
---|
448 | |
---|
449 | |
---|
450 | ED4_returncode ED4_window::scroll_rectangle( int dx, int dy ) |
---|
451 | { |
---|
452 | int skip_move; |
---|
453 | |
---|
454 | if (!dx && !dy) return ED4_R_OK; // scroll not |
---|
455 | |
---|
456 | AW_pos left_x = scrolled_rect.scroll_left->window_pos[X_POS]; |
---|
457 | AW_pos top_y = scrolled_rect.scroll_top->window_pos[Y_POS]; |
---|
458 | AW_pos right_x = scrolled_rect.scroll_right->window_pos[X_POS]; |
---|
459 | AW_pos bottom_y = scrolled_rect.scroll_bottom->window_pos[Y_POS]; |
---|
460 | |
---|
461 | // e4_assert((scrolled_rect.scroll_left->dimension-dx)>=0); // if any of these asserts fails, dx or dy is set wrong |
---|
462 | // e4_assert((scrolled_rect.scroll_right->dimension+dx)>=0); |
---|
463 | // e4_assert((scrolled_rect.scroll_top->dimension-dy)>=0); |
---|
464 | // e4_assert((scrolled_rect.scroll_bottom->dimension+dy)>=0); |
---|
465 | |
---|
466 | scrolled_rect.scroll_left->dimension -= dx; |
---|
467 | scrolled_rect.scroll_top->dimension -= dy; |
---|
468 | scrolled_rect.scroll_right->dimension += dx; |
---|
469 | scrolled_rect.scroll_bottom->dimension += dy; |
---|
470 | |
---|
471 | skip_move = (ABS(int(dy)) > (bottom_y - top_y - 20)) || (ABS(int(dx)) > (right_x - left_x - 20)); |
---|
472 | |
---|
473 | AW_pos leftmost_x = coords.middle_area_x; |
---|
474 | AW_pos toptop_y = coords.top_area_y; |
---|
475 | AW_pos topbottom_y = toptop_y + coords.top_area_height - 1; |
---|
476 | |
---|
477 | ED4_ROOT->get_device()->push_clip_scale(); |
---|
478 | |
---|
479 | // main area |
---|
480 | |
---|
481 | if (skip_move) update_rectangle(left_x, top_y, right_x, bottom_y); // main area |
---|
482 | else move_and_update_rectangle(left_x, top_y, right_x, bottom_y, int(dx), int(dy)); // main area |
---|
483 | |
---|
484 | // name area (scroll only vertically) |
---|
485 | |
---|
486 | if (dy) { |
---|
487 | if (skip_move) update_rectangle(leftmost_x, top_y, left_x, bottom_y); |
---|
488 | else move_and_update_rectangle(leftmost_x, top_y, left_x, bottom_y, 0, int(dy)); |
---|
489 | } |
---|
490 | |
---|
491 | // top area (scroll only horizontally) |
---|
492 | |
---|
493 | if (dx) { |
---|
494 | if (skip_move) update_rectangle(left_x, toptop_y, right_x, topbottom_y); |
---|
495 | else move_and_update_rectangle(left_x, toptop_y, right_x, topbottom_y, int(dx), 0); |
---|
496 | } |
---|
497 | |
---|
498 | ED4_ROOT->get_device()->pop_clip_scale(); |
---|
499 | |
---|
500 | return ( ED4_R_OK ); |
---|
501 | } |
---|
502 | |
---|
503 | ED4_returncode ED4_window::set_scrollbar_indents( void ) { |
---|
504 | int indent_y, indent_x; |
---|
505 | |
---|
506 | if ((scrolled_rect.scroll_top == NULL) || |
---|
507 | (scrolled_rect.scroll_bottom == NULL) || |
---|
508 | (scrolled_rect.scroll_left == NULL) || |
---|
509 | (scrolled_rect.scroll_right == NULL) ) |
---|
510 | return ( ED4_R_IMPOSSIBLE ); |
---|
511 | |
---|
512 | indent_y = (int) scrolled_rect.world_y + SLIDER_OFFSET; |
---|
513 | aww->set_vertical_scrollbar_top_indent( indent_y ); |
---|
514 | indent_x = (int) scrolled_rect.world_x + SLIDER_OFFSET; |
---|
515 | aww->set_horizontal_scrollbar_left_indent( indent_x ); |
---|
516 | |
---|
517 | return ( ED4_R_OK ); |
---|
518 | } |
---|
519 | |
---|
520 | |
---|
521 | void ED4_window::delete_window( ED4_window *window) //delete from window list |
---|
522 | { |
---|
523 | ED4_window *temp, *temp2; |
---|
524 | |
---|
525 | if (window == ED4_ROOT->first_window) { |
---|
526 | temp = ED4_ROOT->first_window; //delete temp afterwards |
---|
527 | ED4_ROOT->first_window = ED4_ROOT->first_window->next; |
---|
528 | |
---|
529 | if (no_of_windows > 1) { |
---|
530 | ED4_ROOT->use_first_window(); |
---|
531 | } |
---|
532 | } |
---|
533 | else { |
---|
534 | temp = temp2 = ED4_ROOT->first_window; |
---|
535 | |
---|
536 | while (temp != window) { |
---|
537 | temp2 = temp; |
---|
538 | temp = temp->next; |
---|
539 | } |
---|
540 | |
---|
541 | temp2->next = temp->next; |
---|
542 | |
---|
543 | ED4_ROOT->use_window(temp2); |
---|
544 | } |
---|
545 | |
---|
546 | ED4_ROOT->aw_root->awar(temp->awar_path_for_cursor)->write_int(0); // save in database |
---|
547 | ED4_ROOT->aw_root->awar(temp->awar_path_for_Ecoli)->write_int(0); |
---|
548 | ED4_ROOT->aw_root->awar(temp->awar_path_for_basePos)->write_int(0); |
---|
549 | ED4_ROOT->aw_root->awar(temp->awar_path_for_IUPAC)->write_string(ED4_IUPAC_EMPTY); |
---|
550 | ED4_ROOT->aw_root->awar(temp->awar_path_for_helixNr)->write_string(""); |
---|
551 | delete temp; |
---|
552 | } |
---|
553 | |
---|
554 | |
---|
555 | ED4_window *ED4_window::insert_window( AW_window *new_aww ) |
---|
556 | { |
---|
557 | ED4_window *last,*temp; |
---|
558 | |
---|
559 | temp = ED4_ROOT->first_window; //append at end of window list |
---|
560 | last = temp; |
---|
561 | while (temp) { |
---|
562 | last = temp; |
---|
563 | temp = temp->next; |
---|
564 | } |
---|
565 | |
---|
566 | temp = new ED4_window ( new_aww ); |
---|
567 | |
---|
568 | if (!ED4_ROOT->first_window) { //this is the first window |
---|
569 | ED4_ROOT->first_window = temp; |
---|
570 | } |
---|
571 | else if ( last != NULL) { |
---|
572 | last->next = temp; |
---|
573 | } |
---|
574 | |
---|
575 | // treat devices |
---|
576 | new_aww->set_expose_callback(AW_MIDDLE_AREA, ED4_expose_cb, 0, 0); |
---|
577 | new_aww->set_resize_callback(AW_MIDDLE_AREA, ED4_resize_cb, 0, 0); |
---|
578 | new_aww->set_input_callback (AW_MIDDLE_AREA, ED4_input_cb, 0, 0); |
---|
579 | new_aww->set_motion_callback(AW_MIDDLE_AREA, ED4_motion_cb, 0, 0); |
---|
580 | |
---|
581 | new_aww->set_horizontal_change_callback(ED4_horizontal_change_cb, 0, 0); |
---|
582 | new_aww->set_vertical_change_callback (ED4_vertical_change_cb, 0, 0); |
---|
583 | |
---|
584 | ED4_ROOT->use_window(temp); |
---|
585 | ED4_ROOT->temp_gc = ED4_G_STANDARD; |
---|
586 | |
---|
587 | return temp; |
---|
588 | } |
---|
589 | |
---|
590 | ED4_window::ED4_window( AW_window *window ) |
---|
591 | { |
---|
592 | aww = window; |
---|
593 | next = 0; |
---|
594 | slider_pos_horizontal = 0; |
---|
595 | slider_pos_vertical = 0; |
---|
596 | horizontal_fl = 0; |
---|
597 | vertical_fl = 0; |
---|
598 | |
---|
599 | scrolled_rect.clear(); |
---|
600 | id = ++no_of_windows; |
---|
601 | coords.clear(); |
---|
602 | is_hidden = false; |
---|
603 | |
---|
604 | sprintf(awar_path_for_cursor, AWAR_EDIT_SEQ_POSITION, id); |
---|
605 | ED4_ROOT->aw_root->awar_int(awar_path_for_cursor,0,AW_ROOT_DEFAULT)->set_minmax(0,MAX_POSSIBLE_SEQ_LENGTH); |
---|
606 | |
---|
607 | sprintf(awar_path_for_Ecoli, AWAR_EDIT_ECOLI_POSITION, id); |
---|
608 | ED4_ROOT->aw_root->awar_int(awar_path_for_Ecoli,0,AW_ROOT_DEFAULT)->set_minmax(0,MAX_POSSIBLE_SEQ_LENGTH); |
---|
609 | |
---|
610 | sprintf(awar_path_for_basePos, AWAR_EDIT_BASE_POSITION, id); |
---|
611 | ED4_ROOT->aw_root->awar_int(awar_path_for_basePos,0,AW_ROOT_DEFAULT)->set_minmax(0,MAX_POSSIBLE_SEQ_LENGTH); |
---|
612 | |
---|
613 | sprintf(awar_path_for_IUPAC, AWAR_EDIT_IUPAC, id); |
---|
614 | ED4_ROOT->aw_root->awar_string(awar_path_for_IUPAC,ED4_IUPAC_EMPTY,AW_ROOT_DEFAULT); |
---|
615 | |
---|
616 | sprintf(awar_path_for_helixNr, AWAR_EDIT_HELIXNR, id); |
---|
617 | ED4_ROOT->aw_root->awar_string(awar_path_for_helixNr, "", AW_ROOT_DEFAULT); // ->set_minmax(-MAX_POSSIBLE_SEQ_LENGTH,MAX_POSSIBLE_SEQ_LENGTH); |
---|
618 | } |
---|
619 | |
---|
620 | |
---|
621 | ED4_window::~ED4_window() |
---|
622 | { |
---|
623 | delete aww; |
---|
624 | delete horizontal_fl; // be careful, don't delete links to hierarchy in folding lines!!! |
---|
625 | delete vertical_fl; |
---|
626 | |
---|
627 | no_of_windows --; |
---|
628 | } |
---|
629 | |
---|