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.

kpdocumentsaveoptions.h 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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_DOCUMENT_SAVE_OPTIONS_H
  24. #define KP_DOCUMENT_SAVE_OPTIONS_H
  25. class TQPixmap;
  26. class TQString;
  27. class TDEConfigBase;
  28. class kpDocumentSaveOptions
  29. {
  30. public:
  31. kpDocumentSaveOptions ();
  32. kpDocumentSaveOptions (const kpDocumentSaveOptions &rhs);
  33. kpDocumentSaveOptions (TQString mimeType, int colorDepth, bool dither, int quality);
  34. virtual ~kpDocumentSaveOptions ();
  35. bool operator== (const kpDocumentSaveOptions &rhs) const;
  36. bool operator!= (const kpDocumentSaveOptions &rhs) const;
  37. kpDocumentSaveOptions &operator= (const kpDocumentSaveOptions &rhs);
  38. void printDebug (const TQString &prefix) const;
  39. TQString mimeType () const;
  40. void setMimeType (const TQString &mimeType);
  41. static TQString invalidMimeType ();
  42. static bool mimeTypeIsInvalid (const TQString &mimeType);
  43. bool mimeTypeIsInvalid () const;
  44. int colorDepth () const;
  45. void setColorDepth (int depth);
  46. static int invalidColorDepth ();
  47. static bool colorDepthIsInvalid (int colorDepth);
  48. bool colorDepthIsInvalid () const;
  49. bool dither () const;
  50. void setDither (bool dither);
  51. static int initialDither ();
  52. int quality () const;
  53. void setQuality (int quality);
  54. static int invalidQuality ();
  55. static bool qualityIsInvalid (int quality);
  56. bool qualityIsInvalid () const;
  57. // (All assume that <config>'s group has been set)
  58. // (None of them call TDEConfigBase::reparseConfig() nor TDEConfigBase::sync())
  59. static TQString defaultMimeType (TDEConfigBase *config);
  60. static void saveDefaultMimeType (TDEConfigBase *config, const TQString &mimeType);
  61. static int defaultColorDepth (TDEConfigBase *config);
  62. static void saveDefaultColorDepth (TDEConfigBase *config, int colorDepth);
  63. static int defaultDither (TDEConfigBase *config);
  64. static void saveDefaultDither (TDEConfigBase *config, bool dither);
  65. static int defaultQuality (TDEConfigBase *config);
  66. static void saveDefaultQuality (TDEConfigBase *config, int quality);
  67. static kpDocumentSaveOptions defaultDocumentSaveOptions (TDEConfigBase *config);
  68. // (returns true if it encountered a difference (and saved it to <config>))
  69. static bool saveDefaultDifferences (TDEConfigBase *config,
  70. const kpDocumentSaveOptions &oldDocInfo,
  71. const kpDocumentSaveOptions &newDocInfo);
  72. public:
  73. // (purely for informational purposes - not enforced by this class)
  74. static int mimeTypeMaximumColorDepth (const TQString &mimeType);
  75. int mimeTypeMaximumColorDepth () const;
  76. static bool mimeTypeHasConfigurableColorDepth (const TQString &mimeType);
  77. bool mimeTypeHasConfigurableColorDepth () const;
  78. static bool mimeTypeHasConfigurableQuality (const TQString &mimeType);
  79. bool mimeTypeHasConfigurableQuality () const;
  80. // TODO: checking for mask loss due to format e.g. BMP
  81. enum LossyType
  82. {
  83. LossLess = 0,
  84. // mimeTypeMaximumColorDepth() < <pixmap>.depth()
  85. MimeTypeMaximumColorDepthLow = 1,
  86. // i.e. colorDepth() < <pixmap>.depth() ||
  87. // colorDepth() < 32 && <pixmap>.mask()
  88. ColorDepthLow = 2,
  89. // i.e. mimeTypeHasConfigurableQuality()
  90. Quality = 4
  91. };
  92. // Returns whether saving <pixmap> with these options will result in
  93. // loss of information. Returned value is the bitwise OR of
  94. // LossType enum possiblities.
  95. int isLossyForSaving (const TQPixmap &pixmap) const;
  96. private:
  97. // There is no need to maintain binary compatibility at this stage.
  98. // The d-pointer is just so that you can experiment without recompiling
  99. // the kitchen sink.
  100. class kpDocumentSaveOptionsPrivate *d;
  101. };
  102. #endif // KP_DOCUMENT_SAVE_OPTIONS_H