KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dlg_rotateimage.cc 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * dlg_rotateimage.cc - part of KimageShop^WKrayon^WChalk
  3. *
  4. * Copyright (c) 2004 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #include <config.h>
  21. #include <math.h>
  22. #include <iostream>
  23. using namespace std;
  24. #include <tqgroupbox.h>
  25. #include <tqradiobutton.h>
  26. #include <tqcheckbox.h>
  27. #include <tqlabel.h>
  28. #include <klocale.h>
  29. #include <knuminput.h>
  30. #include <kdebug.h>
  31. #include "dlg_rotateimage.h"
  32. #include "wdg_rotateimage.h"
  33. DlgRotateImage::DlgRotateImage( TQWidget * parent,
  34. const char * name)
  35. : super (parent, name, true, i18n("Rotate Image"), Ok | Cancel, Ok)
  36. {
  37. m_lock = false;
  38. m_page = new WdgRotateImage(this, "rotate_image");
  39. Q_CHECK_PTR(m_page);
  40. setMainWidget(m_page);
  41. resize(m_page->sizeHint());
  42. connect(this, TQT_SIGNAL(okClicked()),
  43. this, TQT_SLOT(okClicked()));
  44. connect( m_page->doubleCustom, TQT_SIGNAL( valueChanged ( double ) ),
  45. this, TQT_SLOT( slotAngleValueChanged( double ) ) );
  46. }
  47. DlgRotateImage::~DlgRotateImage()
  48. {
  49. delete m_page;
  50. }
  51. void DlgRotateImage::slotAngleValueChanged( double )
  52. {
  53. m_page->radioCustom->setChecked(true);
  54. }
  55. void DlgRotateImage::setAngle(double angle)
  56. {
  57. if (angle == 90) {
  58. m_page->radio90->setChecked(true);
  59. }
  60. else if (angle == 180) {
  61. m_page->radio180->setChecked(true);
  62. }
  63. else if (angle == 270) {
  64. m_page->radio270->setChecked(true);
  65. }
  66. else {
  67. m_page->radioCustom->setChecked(true);
  68. m_page->doubleCustom->setValue(angle);
  69. }
  70. if (m_oldAngle != angle)
  71. resetPreview();
  72. m_oldAngle = angle;
  73. }
  74. double DlgRotateImage::angle()
  75. {
  76. double angle = 0;
  77. if (m_page->radio90->isChecked()) {
  78. angle = 90;
  79. }
  80. else if (m_page->radio180->isChecked()) {
  81. angle = 180;
  82. }
  83. else if (m_page->radio270->isChecked()) {
  84. angle = 270;
  85. }
  86. else {
  87. angle = tqRound(m_page->doubleCustom->value());
  88. }
  89. if (m_page->radioCW->isChecked()) {
  90. return angle;
  91. }
  92. else {
  93. return -angle;
  94. }
  95. }
  96. void DlgRotateImage::setDirection (enumRotationDirection direction)
  97. {
  98. if (direction == CLOCKWISE) {
  99. m_page->radioCW->setChecked(true);
  100. }
  101. else if (direction== COUNTERCLOCKWISE) {
  102. m_page->radioCCW->setChecked(true);
  103. }
  104. }
  105. enumRotationDirection DlgRotateImage::direction()
  106. {
  107. if (m_page->radioCCW->isChecked()) {
  108. return COUNTERCLOCKWISE;
  109. }
  110. else {
  111. return CLOCKWISE;
  112. }
  113. }
  114. void DlgRotateImage::okClicked()
  115. {
  116. accept();
  117. }
  118. void DlgRotateImage::resetPreview()
  119. {
  120. // Code to update preview here.
  121. }
  122. #include "dlg_rotateimage.moc"