TDE graphics utilities
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.

kptoolpreviewdialog.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. Copyright (c) 2003,2004,2005 Clarence Dang <dang@kde.org>
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions
  6. are met:
  7. 1. Redistributions of source code must retain the above copyright
  8. notice, this list of conditions and the following disclaimer.
  9. 2. Redistributions in binary form must reproduce the above copyright
  10. notice, this list of conditions and the following disclaimer in the
  11. documentation and/or other materials provided with the distribution.
  12. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  13. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14. OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  18. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  19. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. */
  23. #ifndef __kp_tool_preview_dialog_h__
  24. #define __kp_tool_preview_dialog_h__
  25. #include <tqpixmap.h>
  26. #include <kdialogbase.h>
  27. class TQLabel;
  28. class TQGridLayout;
  29. class TQGroupBox;
  30. class kpDocument;
  31. class kpMainWindow;
  32. class kpResizeSignallingLabel;
  33. class kpToolPreviewDialog : public KDialogBase
  34. {
  35. Q_OBJECT
  36. public:
  37. enum Features
  38. {
  39. Dimensions = 1, Preview = 2,
  40. AllFeatures = Dimensions | Preview
  41. };
  42. // You must call slotUpdate() in your constructor
  43. kpToolPreviewDialog (Features features,
  44. bool reserveTopRow,
  45. // e.g. "Skew (Image|Selection)"
  46. const TQString &caption,
  47. // (in the Dimensions Group Box) e.g. "After Skew:"
  48. const TQString &afterActionText,
  49. bool actOnSelection,
  50. kpMainWindow *parent,
  51. const char *name = 0);
  52. virtual ~kpToolPreviewDialog ();
  53. private:
  54. void createDimensionsGroupBox ();
  55. void createPreviewGroupBox ();
  56. public:
  57. virtual bool isNoOp () const = 0;
  58. protected:
  59. kpDocument *document () const;
  60. // All widgets must have mainWidget() as their parent
  61. void addCustomWidgetToFront (TQWidget *w); // see <reserveTopRow> in ctor
  62. void addCustomWidget (TQWidget *w);
  63. void addCustomWidgetToBack (TQWidget *w)
  64. {
  65. addCustomWidget (w);
  66. }
  67. virtual TQSize newDimensions () const = 0;
  68. virtual TQPixmap transformPixmap (const TQPixmap &pixmap,
  69. int targetWidth, int targetHeight) const = 0;
  70. private:
  71. void updateDimensions ();
  72. public:
  73. static double aspectScale (int newWidth, int newHeight,
  74. int oldWidth, int oldHeight);
  75. static int scaleDimension (int dimension, double scale, int min, int max);
  76. private:
  77. void updateShrukenDocumentPixmap ();
  78. protected slots:
  79. void updatePreview ();
  80. // Call this whenever a value (e.g. an angle) changes
  81. // and the Dimensions & Preview need to be updated
  82. virtual void slotUpdate ();
  83. virtual void slotUpdateWithWaitCursor ();
  84. protected:
  85. TQString m_afterActionText;
  86. bool m_actOnSelection;
  87. kpMainWindow *m_mainWindow;
  88. int m_oldWidth, m_oldHeight;
  89. TQGroupBox *m_dimensionsGroupBox;
  90. TQLabel *m_afterTransformDimensionsLabel;
  91. TQGroupBox *m_previewGroupBox;
  92. kpResizeSignallingLabel *m_previewPixmapLabel;
  93. TQSize m_previewPixmapLabelSizeWhenUpdatedPixmap;
  94. TQPixmap m_shrunkenDocumentPixmap;
  95. TQGridLayout *m_gridLayout;
  96. int m_gridNumRows;
  97. };
  98. #endif // __kp_tool_preview_dialog_h__