- Timestamp:
- 18/11/11 14:24:12 (6 months ago)
- Location:
- branches/e4fix/EDIT4
- Files:
-
- 5 modified
-
ED4_manager.cxx (modified) (3 diffs)
-
ED4_root.cxx (modified) (5 diffs)
-
ED4_window.cxx (modified) (5 diffs)
-
Makefile (modified) (1 diff)
-
ed4_class.hxx (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/e4fix/EDIT4/ED4_manager.cxx
r8201 r8227 998 998 999 999 int x1, y1, x2, y2; 1000 ED4_folding_line *flv, *flh;1001 1000 ED4_window& win = *current_ed4w(); 1002 1001 int old_last_window_reached = last_window_reached; … … 1004 1003 last_window_reached = 0; 1005 1004 x1 = area_rect.l; 1006 for ( flv = win.vertical_fl; ; flv = flv->next) {1005 for (const ED4_folding_line *flv = win.get_vertical_folding(); ; flv = flv->next) { 1007 1006 int lastColumn = 0; 1008 1007 … … 1023 1022 1024 1023 y1 = area_rect.t; 1025 for ( flh = win.horizontal_fl; ; flh = flh->next) {1024 for (const ED4_folding_line *flh = win.get_horizontal_folding(); ; flh = flh->next) { 1026 1025 int lastRow = 0; 1027 1026 -
branches/e4fix/EDIT4/ED4_root.cxx
r8202 r8227 104 104 105 105 106 void ED4_ window::win_to_world_coords(AW_pos *xPtr, AW_pos *yPtr) {106 void ED4_foldable::win_to_world_coords(AW_pos *xPtr, AW_pos *yPtr) { 107 107 // calculates transformation from window to world coordinates in a given window 108 108 const AW_pos x = *xPtr; … … 136 136 } 137 137 138 void ED4_ window::world_to_win_coords(AW_pos *xPtr, AW_pos *yPtr) {138 void ED4_foldable::world_to_win_coords(AW_pos *xPtr, AW_pos *yPtr) { 139 139 // calculates transformation from world to window coordinates in a given window 140 140 const AW_pos x = *xPtr; … … 167 167 *yPtr = temp_y; 168 168 } 169 170 // -------------------------------------------------------------------------------- 171 172 #ifdef UNIT_TESTS 173 #ifndef TEST_UNIT_H 174 #include <test_unit.h> 175 #endif 176 177 static arb_test::match_expectation correct_win2world_calculation(ED4_foldable& foldable, int xwin_org, int ywin_org, int xwrld_expd, int ywrld_expd) { 178 using namespace arb_test; 179 match_expectation precondition(all().of(that(xwrld_expd).more_or_equal(xwin_org), 180 that(ywrld_expd).more_or_equal(ywin_org))); 181 182 AW_pos xwrld_calc = xwin_org; 183 AW_pos ywrld_calc = ywin_org; 184 foldable.win_to_world_coords(&xwrld_calc, &ywrld_calc); 185 186 match_expectation win_2_world_conversion(all().of(that(xwrld_calc).equals(xwrld_expd), 187 that(ywrld_calc).equals(ywrld_expd))); 188 189 AW_pos xwin_back = xwrld_calc; 190 AW_pos ywin_back = ywrld_calc; 191 foldable.world_to_win_coords(&xwin_back, &ywin_back); 192 193 match_expectation world_back2_win_conversion(all().of(that(xwin_back).equals(xwin_org), 194 that(ywin_back).equals(ywin_org))); 195 196 return all().of(precondition, win_2_world_conversion, world_back2_win_conversion); 197 } 198 199 #define TEST_ASSERT_WIN_UNFOLDED(xwi,ywi) TEST_EXPECT(correct_win2world_calculation(foldable, xwi, ywi, xwi, ywi)) 200 #define TEST_ASSERT_WIN_WORLD_FOLDING(xwi,ywi,fx,fy) TEST_EXPECT(correct_win2world_calculation(foldable, xwi, ywi, (xwi)+(fx), (ywi)+(fy))) 201 202 #define TEST_ASSERT_WIN_WORLD_FOLDING__BROKEN(xwi,ywi,fx,fy) TEST_EXPECT__BROKEN(correct_win2world_calculation(foldable, xwi, ywi, (xwi)+(fx), (ywi)+(fy))) 203 #define TEST_ASSERT_WIN_WORLD_FOLDING__BROKENIF(when,xwi,ywi,fx,fy) TEST_EXPECT__BROKENIF(when, correct_win2world_calculation(foldable, xwi, ywi, (xwi)+(fx), (ywi)+(fy))) 204 205 void TEST_win_2_world() { 206 ED4_foldable foldable; 207 208 ED4_folding_line *hor100 = foldable.insert_folding_line(0, 100, INFINITE, 0, NULL, ED4_P_HORIZONTAL); 209 ED4_folding_line *ver200 = foldable.insert_folding_line(200, 0, INFINITE, 0, NULL, ED4_P_VERTICAL); 210 211 ED4_folding_line *hor200 = foldable.insert_folding_line(0, 200, 300, 0, NULL, ED4_P_HORIZONTAL); 212 ED4_folding_line *ver300 = foldable.insert_folding_line(300, 100, 200, 0, NULL, ED4_P_VERTICAL); 213 214 // nothing folded yet 215 216 TEST_ASSERT_WIN_UNFOLDED(100, 50); 217 TEST_ASSERT_WIN_UNFOLDED(250, 50); 218 TEST_ASSERT_WIN_UNFOLDED(400, 50); 219 220 TEST_ASSERT_WIN_UNFOLDED(100, 150); 221 TEST_ASSERT_WIN_UNFOLDED(250, 150); 222 TEST_ASSERT_WIN_UNFOLDED(400, 150); 223 224 TEST_ASSERT_WIN_UNFOLDED(100, 250); 225 TEST_ASSERT_WIN_UNFOLDED(250, 250); 226 TEST_ASSERT_WIN_UNFOLDED(400, 250); 227 228 TEST_ASSERT_WIN_UNFOLDED(100, 350); 229 TEST_ASSERT_WIN_UNFOLDED(250, 350); 230 TEST_ASSERT_WIN_UNFOLDED(400, 350); 231 232 for (int FACTOR = 1; FACTOR <= 10; FACTOR ++) { 233 TEST_ANNOTATE_ASSERT(GBS_global_string("FACTOR=%i", FACTOR)); 234 int H1 = FACTOR* 10; 235 int H2 = FACTOR* 40; 236 int V1 = FACTOR* 20; 237 int V2 = FACTOR* 80; 238 239 hor100->dimension = H1; 240 hor200->dimension = H2; 241 ver200->dimension = V1; 242 ver300->dimension = V2; 243 244 TEST_ASSERT_WIN_UNFOLDED(100, 50); // always in unfolded range 245 TEST_ASSERT_WIN_WORLD_FOLDING(250, 50, V1, 0); 246 TEST_ASSERT_WIN_WORLD_FOLDING(400, 50, V1, 0); 247 248 TEST_ASSERT_WIN_WORLD_FOLDING__BROKENIF(FACTOR >= 5, 100, 150, 0, H1); 249 TEST_ASSERT_WIN_WORLD_FOLDING__BROKENIF(FACTOR >= 3, 250, 150, V1, H1); 250 TEST_ASSERT_WIN_WORLD_FOLDING(400, 150, V1+V2, H1); 251 TEST_ASSERT_WIN_WORLD_FOLDING__BROKENIF(FACTOR >= 3, 250, 250, V1, H1+H2); 252 253 TEST_ASSERT_WIN_WORLD_FOLDING(100, 250, 0, H1+H2); 254 TEST_ASSERT_WIN_WORLD_FOLDING__BROKENIF(FACTOR >= 6, 400, 250, V1+V2, H1); 255 256 TEST_ASSERT_WIN_WORLD_FOLDING(100, 350, 0, H1+H2); 257 TEST_ASSERT_WIN_WORLD_FOLDING__BROKENIF(FACTOR >= 3, 250, 350, V1, H1+H2); 258 TEST_ASSERT_WIN_WORLD_FOLDING(400, 350, V1, H1); 259 } 260 } 261 262 #endif // UNIT_TESTS 263 264 // -------------------------------------------------------------------------------- 169 265 170 266 short ED4_root::is_primary_selection(ED4_terminal *object) … … 680 776 ED4_returncode ED4_root::get_area_rectangle(AW_screen_area *rect, AW_pos x, AW_pos y) { 681 777 // returns win-coordinates of area (defined by folding lines) which contains position x/y 682 ED4_folding_line *flv, *flh;683 778 int x1, x2, y1, y2; 684 779 const AW_screen_area& area_rect = curr_device()->get_area_size(); 685 780 686 781 x1 = area_rect.l; 687 for ( flv=curr_ed4w()->vertical_fl; ; flv = flv->next) {782 for (const ED4_folding_line *flv=curr_ed4w()->get_vertical_folding(); ; flv = flv->next) { 688 783 if (flv) { 689 784 e4_assert(flv->length==INFINITE); … … 698 793 699 794 y1 = area_rect.t; 700 for ( flh=curr_ed4w()->horizontal_fl; ; flh = flh->next) {795 for (const ED4_folding_line *flh=curr_ed4w()->get_horizontal_folding(); ; flh = flh->next) { 701 796 if (flh) { 702 797 e4_assert(flh->length==INFINITE); -
branches/e4fix/EDIT4/ED4_window.cxx
r8193 r8227 17 17 int ED4_window::no_of_windows = 0; // static variable has to be initialized only once 18 18 19 void ED4_window::reset_all_for_new_config() 20 { 21 horizontal_fl = NULL; 22 vertical_fl = NULL; 19 void ED4_window::reset_all_for_new_config() { 20 ED4_foldable::reset(); 23 21 24 22 scrolled_rect.scroll_top = NULL; … … 106 104 107 105 108 ED4_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) {106 ED4_folding_line* ED4_foldable::insert_folding_line(AW_pos world_x, AW_pos world_y, AW_pos length, AW_pos dimension, ED4_base *link, ED4_properties prop) { 109 107 ED4_folding_line *fl = NULL; 110 108 … … 180 178 181 179 182 ED4_returncode ED4_window::delete_folding_line(ED4_folding_line */*fl*/, ED4_properties /*prop*/) { 180 ED4_returncode ED4_foldable::delete_folding_line(ED4_folding_line */*fl*/, ED4_properties /*prop*/) { 181 e4_assert(0); // not implement - cause it's unused 183 182 return ED4_R_OK; 184 183 } … … 576 575 slider_pos_horizontal = 0; 577 576 slider_pos_vertical = 0; 578 horizontal_fl = 0;579 vertical_fl = 0;580 577 581 578 scrolled_rect.clear(); … … 601 598 602 599 603 ED4_window::~ED4_window() 604 { 600 ED4_window::~ED4_window() { 605 601 delete aww; 606 delete horizontal_fl; // be careful, don't delete links to hierarchy in folding lines!!!607 delete vertical_fl;608 609 602 no_of_windows --; 610 603 } -
branches/e4fix/EDIT4/Makefile
r8169 r8227 750 750 ED4_root.o: $(ARBHOME)/INCLUDE/svn_revision.h 751 751 ED4_root.o: $(ARBHOME)/INCLUDE/test_global.h 752 ED4_root.o: $(ARBHOME)/INCLUDE/test_unit.h 752 753 753 754 ED4_search.o: ed4_awars.hxx -
branches/e4fix/EDIT4/ed4_class.hxx
r8222 r8227 467 467 }; 468 468 469 470 class ED4_window : virtual Noncopyable { 469 class ED4_foldable : virtual Noncopyable { 470 ED4_folding_line *horizontal_fl; 471 ED4_folding_line *vertical_fl; 472 protected: 473 void reset() { 474 delete horizontal_fl; 475 delete vertical_fl; 476 horizontal_fl = NULL; 477 vertical_fl = NULL; 478 } 479 public: 480 481 ED4_foldable() : horizontal_fl(NULL), vertical_fl(NULL) {} 482 ~ED4_foldable() { reset(); } 483 484 const ED4_folding_line *get_horizontal_folding() { return horizontal_fl; } 485 const ED4_folding_line *get_vertical_folding() { return vertical_fl; } 486 487 void world_to_win_coords(AW_pos *x, AW_pos *y); 488 void win_to_world_coords(AW_pos *x, AW_pos *y); 489 490 ED4_folding_line *insert_folding_line(AW_pos world_x, AW_pos world_y, AW_pos length, AW_pos dimension, ED4_base *link, ED4_properties prop); 491 ED4_returncode delete_folding_line(ED4_folding_line *fl, ED4_properties prop); 492 }; 493 494 class ED4_window : public ED4_foldable { // derived from Noncopyable 471 495 ED4_window(const ED4_window&); // copy-constructor not allowed 472 496 public: … … 475 499 int slider_pos_horizontal; 476 500 int slider_pos_vertical; 477 ED4_folding_line *horizontal_fl;478 ED4_folding_line *vertical_fl;479 501 ED4_scrolled_rectangle scrolled_rect; 480 502 int id; // unique id in window-list … … 507 529 void update_window_coords(); 508 530 509 // functions concerned with folding lines510 ED4_folding_line *insert_folding_line(AW_pos world_x, AW_pos world_y, AW_pos length, AW_pos dimension, ED4_base *link, ED4_properties prop);511 ED4_returncode delete_folding_line(ED4_folding_line *fl, ED4_properties prop);512 513 // functions concerning coordinate transformation514 void world_to_win_coords(AW_pos *x, AW_pos *y);515 void win_to_world_coords(AW_pos *x, AW_pos *y);516 517 531 ED4_window(AW_window *window); 518 532 ~ED4_window();
