Changeset 8353
- Timestamp:
- 02/02/12 11:45:41 (4 months ago)
- Location:
- branches/e4fix/EDIT4
- Files:
-
- 3 modified
-
ED4_root.cxx (modified) (1 diff)
-
ED4_window.cxx (modified) (2 diffs)
-
ed4_class.hxx (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/e4fix/EDIT4/ED4_root.cxx
r8346 r8353 46 46 47 47 ED4_WinContext ED4_WinContext::current_context; 48 49 void ED4_folding_line::warn_illegal_dimension() { 50 #if defined(DEBUG) 51 if (dimension<0.0) { 52 // e4_assert(0); // crashes gdb when called from scrollbar callback - so instead only dump backtrace 53 const char *msg = GBS_global_string("illegal dimension %f\n", dimension); 54 GBK_dump_backtrace(stderr, msg); 55 } 56 #endif 57 } 48 58 49 59 void ED4_WinContext::warn_missing_context() const { -
branches/e4fix/EDIT4/ED4_window.cxx
r8306 r8353 142 142 } 143 143 144 ED4_returncode ED4_window::update_scrolled_rectangle() { 145 if (!scrolled_rect.exists()) 146 return ED4_R_IMPOSSIBLE; 147 148 AW::Rectangle srect = scrolled_rect.get_world_rect(); 149 scrolled_rect.set_rect_and_update_folding_line_positions(srect); 150 151 { 152 // update dimension and window position of folding lines at the borders of scrolled rectangle 153 154 int dx = aww->slider_pos_horizontal - slider_pos_horizontal; 155 int dy = aww->slider_pos_vertical - slider_pos_vertical; 156 157 scrolled_rect.add_to_top_left_dimension(dx, dy); 158 } 159 160 if (scrolled_rect.is_linked()) { 161 slider_pos_vertical = aww->slider_pos_vertical; 162 slider_pos_horizontal = aww->slider_pos_horizontal; 163 } 164 165 const AW_screen_area& area_size = get_device()->get_area_size(); 166 scrolled_rect.calc_bottomRight_folding_dimensions(area_size.r, area_size.b); 167 168 update_window_coords(); 169 170 // update window scrollbars 171 AW_world rect = { 0, srect.height()-1, 0, srect.width()-1 }; 172 set_scrollbar_indents(); 173 aww->tell_scrolled_picture_size(rect); 174 aww->calculate_scrollbars(); 175 176 return ED4_R_OK; 144 void ED4_window::update_scrolled_rectangle() { 145 if (scrolled_rect.exists()) { 146 e4_assert(scrolled_rect.is_linked()); 147 148 AW::Rectangle srect = scrolled_rect.get_world_rect(); 149 scrolled_rect.set_rect_and_update_folding_line_positions(srect); 150 151 // if slider positions stored in AW_window and ED4_window differ, 152 // we correct folding line dimensions: 153 154 { 155 // update dimension and window position of folding lines at the borders of scrolled rectangle 156 int dx = aww->slider_pos_horizontal - slider_pos_horizontal; 157 int dy = aww->slider_pos_vertical - slider_pos_vertical; 158 159 scrolled_rect.add_to_top_left_dimension(dx, dy); 160 } 161 162 const AW_screen_area& area_size = get_device()->get_area_size(); 163 scrolled_rect.calc_bottomRight_folding_dimensions(area_size.r, area_size.b); 164 165 update_window_coords(); // @@@ do at end of this function? (since it uses aww-slider_pos_horizontal, 166 // which might get modified by calculate_scrollbars below); 167 168 // update window scrollbars 169 AW_world rect = { 0, srect.height(), 0, srect.width() }; 170 set_scrollbar_indents(); 171 aww->tell_scrolled_picture_size(rect); 172 aww->calculate_scrollbars(); 173 174 check_valid_scrollbar_values(); // test that AW_window slider positions and folding line dimensions are in sync 175 } 176 177 // store synced slider positions in ED4_window 178 slider_pos_vertical = aww->slider_pos_vertical; 179 slider_pos_horizontal = aww->slider_pos_horizontal; 177 180 } 178 181 … … 336 339 } 337 340 338 ED4_returncode ED4_window::set_scrollbar_indents() { 339 if (!scrolled_rect.exists()) return ED4_R_IMPOSSIBLE; 340 341 AW::Rectangle rect = scrolled_rect.get_window_rect(); 342 aww->set_vertical_scrollbar_top_indent(rect.top() + SLIDER_OFFSET); 343 aww->set_horizontal_scrollbar_left_indent(rect.left() + SLIDER_OFFSET); 344 345 return ED4_R_OK; 341 void ED4_window::set_scrollbar_indents() { 342 if (scrolled_rect.exists()) { 343 AW::Rectangle rect = scrolled_rect.get_window_rect(); 344 aww->set_vertical_scrollbar_top_indent(rect.top() + SLIDER_OFFSET); 345 aww->set_horizontal_scrollbar_left_indent(rect.left() + SLIDER_OFFSET); 346 } 346 347 } 347 348 -
branches/e4fix/EDIT4/ed4_class.hxx
r8347 r8353 319 319 const ED4_folding_line *get_next() const { return next; } 320 320 321 void set_dimension(AW_pos dim) { dimension = dim; } 322 void add_to_dimension(AW_pos offset) { dimension += offset; } 321 void warn_illegal_dimension(); 322 323 void set_dimension(AW_pos dim) { dimension = dim; warn_illegal_dimension(); } 324 void add_to_dimension(AW_pos offset) { dimension += offset; warn_illegal_dimension(); } 323 325 324 326 void set_pos(AW_pos p) { pos = p; } … … 426 428 } 427 429 430 AW_pos top_dim() const { return scroll_top->get_dimension(); } 431 AW_pos left_dim() const { return scroll_left->get_dimension(); } 428 432 429 433 bool exists() const { return scroll_top && scroll_bottom && scroll_left && scroll_right; } … … 481 485 482 486 void calc_bottomRight_folding_dimensions(int area_width, int area_height) { 487 area_width -= SLIDER_OFFSET; 488 area_height -= SLIDER_OFFSET; 489 483 490 AW_pos dim; 484 491 if (bottom() > area_height) { // our world doesn't fit vertically in our window … … 493 500 } 494 501 495 // e4_assert(scroll_top->dimension >= 0); // @@@ reactivate when refresh is fixed (or better move into set_dimension)496 // e4_assert(scroll_bottom->dimension >= 0);497 502 e4_assert(dim == (scroll_top->get_dimension()+scroll_bottom->get_dimension())); 498 scroll_bottom->set_pos(world.bottom()-dim );503 scroll_bottom->set_pos(world.bottom()-dim+SLIDER_OFFSET); 499 504 500 505 if (right()>area_width) { // our world doesn't fit horizontally in our window … … 509 514 } 510 515 511 // e4_assert(scroll_left->dimension >= 0); // @@@ reactivate when refresh is fixed (or better move into set_dimension)512 // e4_assert(scroll_right->dimension >= 0);513 516 e4_assert(dim == (scroll_left->get_dimension()+scroll_right->get_dimension())); 514 scroll_right->set_pos(world.right()-dim );517 scroll_right->set_pos(world.right()-dim+SLIDER_OFFSET); 515 518 516 519 folding_dimensions_calculated = true; … … 538 541 init_folding_lines(); 539 542 } 540 541 543 }; 542 544 … … 705 707 class ED4_window : public ED4_foldable, virtual ED4_WinContextFree { // derived from Noncopyable 706 708 ED4_window(const ED4_window&); // copy-constructor not allowed 709 710 void set_scrollbar_indents(); 711 707 712 public: 708 713 AW_window *aww; // Points to Window … … 735 740 736 741 // functions concerned the scrolled area 737 ED4_returncode update_scrolled_rectangle(); 738 ED4_returncode set_scrollbar_indents(); 739 ED4_returncode scroll_rectangle(int dx, int dy); 740 ED4_returncode set_scrolled_rectangle(ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link); 742 void update_scrolled_rectangle(); 743 ED4_returncode scroll_rectangle(int dx, int dy); 744 ED4_returncode set_scrolled_rectangle(ED4_base *x_link, ED4_base *y_link, ED4_base *width_link, ED4_base *height_link); 745 746 bool scrollbars_and_scrolledRect_inSync() const { 747 // Scrolling in EDIT4 window uses redundant data 748 // - dimension of folding lines 749 // - slider positions in AW_window and ED4_window 750 // This function checks whether they are in sync. 751 752 bool inSync = 753 (scrolled_rect.top_dim() == aww->slider_pos_vertical) && 754 (scrolled_rect.left_dim() == aww->slider_pos_horizontal); 755 756 #if defined(DEBUG) 757 if (!inSync) { 758 fputs("scrollbars not in sync with scrolled_rect:\n", stderr); 759 fprintf(stderr, " aww->slider_pos_vertical =%i scrolled_rect->top_dim() =%f\n", aww->slider_pos_vertical, scrolled_rect.top_dim()); 760 fprintf(stderr, " aww->slider_pos_horizontal=%i scrolled_rect->left_dim()=%f\n", aww->slider_pos_horizontal, scrolled_rect.left_dim()); 761 } 762 #endif 763 764 return inSync; 765 } 766 767 void check_valid_scrollbar_values() { e4_assert(scrollbars_and_scrolledRect_inSync()); } 741 768 742 769 bool shows_xpos(int x) const { return x >= coords.window_left_clip_point && x <= coords.window_right_clip_point; }
