Changeset 104
- Timestamp:
- 04/21/06 05:47:55 (2 years ago)
- Files:
-
- trunk/src/MainPter.cxx (modified) (6 diffs)
- trunk/src/MainPter.h (modified) (1 diff)
- trunk/tests/DumbDocument.cxx (modified) (1 diff)
- trunk/tests/MainPterTest.cxx (modified) (1 diff)
- trunk/tests/MainPterTest.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/MainPter.cxx
r103 r104 362 362 363 363 m_Document->rotateLeft (); 364 365 Config &config = Config::getConfig (); 366 if ( config.zoomToWidth () ) 367 { 368 zoomWidth (); 369 } 370 else if ( config.zoomToFit () ) 371 { 372 zoomFit (); 373 } 364 374 showPage (); 365 375 } … … 374 384 375 385 m_Document->rotateRight (); 386 387 Config &config = Config::getConfig (); 388 if ( config.zoomToWidth () ) 389 { 390 zoomWidth (); 391 } 392 else if ( config.zoomToFit () ) 393 { 394 zoomFit (); 395 } 376 396 showPage (); 377 397 } … … 410 430 Config::getConfig().setShowToolbar (show); 411 431 getView ().showToolbar (show); 432 } 433 434 /// 435 /// @brief Performs the "Zoom Fit Best". 436 /// 437 /// Gets the width of the current page view and then calls the zoom to fit 438 /// function from document. 439 /// 440 void 441 MainPter::zoomFit () 442 { 443 gint width; 444 gint height; 445 getView ().getPageViewSize (&width, &height); 446 m_Document->zoomToFit (width, height); 412 447 } 413 448 … … 429 464 if ( active ) 430 465 { 431 gint width; 432 gint height; 433 view.getPageViewSize (&width, &height); 434 m_Document->zoomToFit (width, height); 466 zoomFit (); 435 467 showPage (); 436 468 } … … 475 507 m_Document->zoomOut (); 476 508 showPage (); 509 } 510 511 /// 512 /// @brief Performs the "Zoom Fit Width". 513 /// 514 /// Gets the width of the current page view and then calls the zoom to width 515 /// function from document. 516 /// 517 void 518 MainPter::zoomWidth () 519 { 520 gint width; 521 gint height; 522 getView ().getPageViewSize (&width, &height); 523 m_Document->zoomToWidth (width); 477 524 } 478 525 … … 494 541 if ( active ) 495 542 { 496 gint width; 497 gint height; 498 view.getPageViewSize (&width, &height); 499 m_Document->zoomToWidth (width); 543 zoomWidth (); 500 544 showPage (); 501 545 } trunk/src/MainPter.h
r103 r104 72 72 DocumentPage *m_DocumentPage; 73 73 IMainView *m_View; 74 75 void zoomFit (void); 76 void zoomWidth (void); 74 77 }; 75 78 } trunk/tests/DumbDocument.cxx
r66 r104 77 77 DumbDocument::getPageSize (gdouble *width, gdouble *height) 78 78 { 79 if ( 0 == getRotation () || 270 == getRotation () ) 79 if ( 90 == getRotation () || 270 == getRotation () ) 80 { 81 *width = 250; 82 *height = 100; 83 } 84 else 80 85 { 81 86 *width = 100; 82 87 *height = 250; 83 }84 else85 {86 *width = 250;87 *height = 100;88 88 } 89 89 } trunk/tests/MainPterTest.cxx
r103 r104 676 676 } 677 677 678 /// 679 /// @brief Checks rotation and zoom. 680 /// 681 /// This tests that rotation while the zoom to width or zoom to 682 /// fit are activated also changed the zoom level. 683 /// 684 void 685 MainPterTest::pageZoomAndRotate () 686 { 687 m_View->setOpenFileName ("/tmp/test.pdf"); 688 m_MainPter->openFileActivated (); 689 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 690 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, m_Document->getZoom (), 0.0001); 691 692 // The document is 100x250 and the page view 75x50. 693 // ZoomToWidth 75/100 = 0.75 694 m_MainPter->zoomWidthActivated (TRUE); 695 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75, m_Document->getZoom (), 0.0001); 696 // Rotate left. 75/250 = 0.3 697 m_MainPter->rotateLeftActivated (); 698 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 699 m_MainPter->rotateRightActivated (); 700 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75, m_Document->getZoom (), 0.0001); 701 m_MainPter->rotateRightActivated (); 702 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 703 m_MainPter->rotateLeftActivated (); 704 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75, m_Document->getZoom (), 0.0001); 705 706 // Now try the same with zoom to fit. 707 // 50/250 = 0.2 708 m_MainPter->zoomFitActivated (TRUE); 709 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.2, m_Document->getZoom (), 0.0001); 710 // Rotate left, 75/250 = 0.3 711 m_MainPter->rotateLeftActivated (); 712 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 713 m_MainPter->rotateRightActivated (); 714 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.2, m_Document->getZoom (), 0.0001); 715 m_MainPter->rotateRightActivated (); 716 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3, m_Document->getZoom (), 0.0001); 717 m_MainPter->rotateLeftActivated (); 718 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.2, m_Document->getZoom (), 0.0001); 719 } 678 720 679 721 /// trunk/tests/MainPterTest.h
r102 r104 40 40 CPPUNIT_TEST (pageZoomWidth); 41 41 CPPUNIT_TEST (pageZoomFit); 42 CPPUNIT_TEST (pageZoomAndRotate); 42 43 CPPUNIT_TEST (reloadNormal); 43 44 CPPUNIT_TEST (reloadEncrypted); … … 65 66 void pageZoomWidth (void); 66 67 void pageZoomFit (void); 68 void pageZoomAndRotate (void); 67 69 void reloadNormal (void); 68 70 void reloadEncrypted (void);
