Changeset 31
- Timestamp:
- 04/11/06 14:53:06 (2 years ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
src/IMainView.h (modified) (1 diff)
-
src/MainPter.cxx (modified) (2 diffs)
-
src/MainPter.h (modified) (1 diff)
-
tests/DumbDocument.cxx (modified) (1 diff)
-
tests/DumbMainView.cxx (modified) (1 diff)
-
tests/DumbMainView.h (modified) (1 diff)
-
tests/MainPterTest.cxx (modified) (1 diff)
-
tests/MainPterTest.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/IMainView.h
r29 r31 48 48 virtual void setGoToPageText (const gchar *text) = 0; 49 49 virtual const gchar *getGoToPageText (void) = 0; 50 virtual void getPageViewSize (gint *width, gint *height) = 0; 50 51 virtual void setTitle (const gchar *title) = 0; 51 52 -
trunk/src/MainPter.cxx
r30 r31 306 306 307 307 /// 308 /// @brief The "Zoom Fit Best" was activated. 309 /// 310 void 311 MainPter::zoomFitActivated (void) 312 { 313 g_assert ( NULL != m_Document && "Tried to zoom fit a NULL document."); 314 315 gint width; 316 gint height; 317 getView ().getPageViewSize (&width, &height); 318 m_Document->zoomToFit (width, height); 319 showPage (); 320 } 321 322 /// 323 /// @brief The "Zoom In" was activated. 324 /// 325 void 326 MainPter::zoomInActivated (void) 327 { 328 g_assert ( NULL != m_Document && "Tried to zoom in a NULL document."); 329 330 m_Document->zoomIn (); 331 showPage (); 332 } 333 334 /// 335 /// @brief The "Zoom Out" was activated. 336 /// 337 void 338 MainPter::zoomOutActivated (void) 339 { 340 g_assert ( NULL != m_Document && "Tried to zoom out a NULL document."); 341 342 m_Document->zoomOut (); 343 showPage (); 344 } 345 346 /// 347 /// @brief The "Zoom Fit Width" was activated. 348 /// 349 void 350 MainPter::zoomWidthActivated (void) 351 { 352 g_assert ( NULL != m_Document && "Tried to zoom width a NULL document."); 353 354 gint width; 355 gint height; 356 getView ().getPageViewSize (&width, &height); 357 m_Document->zoomToWidth (width); 358 showPage (); 359 } 360 361 /// 308 362 /// @brief Shows the current page. 309 363 /// … … 332 386 view.sensitiveGoToLastPage (m_Document->getNumPages() > currentPage); 333 387 view.sensitiveGoToNextPage (m_Document->getNumPages() > currentPage); 388 // And the zoom sentitivity. 389 view.sensitiveZoomIn (m_Document->canZoomIn ()); 390 view.sensitiveZoomOut (m_Document->canZoomOut ()); 334 391 335 392 DocumentPage *page = m_Document->renderPage (); -
trunk/src/MainPter.h
r30 r31 40 40 void rotateLeftActivated (void); 41 41 void rotateRightActivated (void); 42 void zoomFitActivated (void); 43 void zoomInActivated (void); 44 void zoomOutActivated (void); 45 void zoomWidthActivated (void); 42 46 43 47 protected: -
trunk/tests/DumbDocument.cxx
r30 r31 74 74 DumbDocument::getPageSize (gdouble *width, gdouble *height) 75 75 { 76 *width = 100; 77 *height = 250; 76 if ( 0 == getRotation () || 270 == getRotation () ) 77 { 78 *width = 100; 79 *height = 250; 80 } 81 else 82 { 83 *width = 250; 84 *height = 100; 85 } 78 86 } 79 87 -
trunk/tests/DumbMainView.cxx
r29 r31 145 145 146 146 void 147 DumbMainView::getPageViewSize (gint *width, gint *height) 148 { 149 *width = 75; 150 *height = 50; 151 } 152 153 void 147 154 DumbMainView::setTitle (const gchar *title) 148 155 { -
trunk/tests/DumbMainView.h
r29 r31 40 40 void sensitiveZoomWidth (gboolean sensitive); 41 41 const gchar *getGoToPageText (void); 42 void getPageViewSize (gint *width, gint *height); 42 43 void setTotalPages (gint pages); 43 44 void setGoToPageText (const char *text); -
trunk/tests/MainPterTest.cxx
r30 r31 425 425 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 426 426 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 427 CPPUNIT_ASSERT_EQUAL ( m_Document->getRotation (), 0);427 CPPUNIT_ASSERT_EQUAL (0, m_Document->getRotation ()); 428 428 429 429 m_MainPter->rotateRightActivated (); 430 430 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 431 431 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 432 CPPUNIT_ASSERT_EQUAL ( m_Document->getRotation (), 90);432 CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ()); 433 433 434 434 m_MainPter->rotateLeftActivated (); 435 435 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 436 436 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 437 CPPUNIT_ASSERT_EQUAL (m_Document->getRotation (), 0); 438 } 437 CPPUNIT_ASSERT_EQUAL (0, m_Document->getRotation ()); 438 } 439 440 /// 441 /// @brief Tests page's zoom. 442 /// 443 /// The DumbDocument has a fixed size of 100x250 pixels and the DumbMainView 444 /// has a fixed pageView of 75x50. We will make sure that getting to the max 445 /// ZoomIn unsensitives the ZoomIn button. The same for the ZoomOut. 446 /// 447 /// Then will test Zoom Fit and Zoom Width with two different rotations. 448 /// 449 void 450 MainPterTest::pageZoom () 451 { 452 m_View->setOpenFileName ("/tmp/test.pdf"); 453 m_MainPter->openFileActivated (); 454 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 455 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 456 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0f, m_Document->getZoom (), 0.0001f); 457 458 m_MainPter->zoomInActivated (); 459 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 460 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 461 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.2f, m_Document->getZoom (), 0.0001f); 462 463 m_MainPter->zoomOutActivated (); 464 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 465 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 466 CPPUNIT_ASSERT_EQUAL (1.0f, m_Document->getZoom ()); 467 468 CPPUNIT_ASSERT (m_View->isSensitiveZoomIn ()); 469 CPPUNIT_ASSERT (m_View->isSensitiveZoomOut ()); 470 // Make sure we go to the last zoom level. 471 for (int count = 0 ; count < 20 ; count++) 472 { 473 m_MainPter->zoomInActivated (); 474 } 475 CPPUNIT_ASSERT (!m_View->isSensitiveZoomIn ()); 476 CPPUNIT_ASSERT (m_View->isSensitiveZoomOut ()); 477 for (int count = 0 ; count < 40 ; count ++) 478 { 479 m_MainPter->zoomOutActivated (); 480 } 481 CPPUNIT_ASSERT (m_View->isSensitiveZoomIn ()); 482 CPPUNIT_ASSERT (!m_View->isSensitiveZoomOut ()); 483 484 // OK, now try to zoom width. Since rotation is 0 485 // the zoom level should be 50/250 = 0.2 486 m_MainPter->zoomFitActivated (); 487 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 488 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 489 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.2f, m_Document->getZoom (), 0.0001f); 490 // For the width it should be 75/100 = 0.75 491 m_MainPter->zoomWidthActivated (); 492 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 493 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 494 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.75f, m_Document->getZoom (), 0.0001f); 495 496 // Now rotate and try again. 497 m_MainPter->rotateRightActivated (); 498 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 499 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 500 CPPUNIT_ASSERT_EQUAL (90, m_Document->getRotation ()); 501 502 // Since rotation is now 90 the zoom level should be 75/250 = 0.3 503 m_MainPter->zoomFitActivated (); 504 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3f, m_Document->getZoom (), 0.0001f); 505 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 506 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 507 // For the width it should be 75/250 = 0.3 also. 508 m_MainPter->zoomWidthActivated (); 509 CPPUNIT_ASSERT_DOUBLES_EQUAL (0.3f, m_Document->getZoom (), 0.0001f); 510 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 511 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 512 } -
trunk/tests/MainPterTest.h
r30 r31 35 35 CPPUNIT_TEST (pageNavigation); 36 36 CPPUNIT_TEST (pageRotate); 37 CPPUNIT_TEST (pageZoom); 37 38 CPPUNIT_TEST_SUITE_END(); 38 39 … … 50 51 void pageNavigation (void); 51 52 void pageRotate (void); 53 void pageZoom (void); 52 54 53 55 private:
