tdegraphics
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.

kpselectiontransparency.h 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_selection_transparency_h__
  24. #define __kp_selection_transparency_h__
  25. #include <kpcolor.h>
  26. // This does not apply to the Text Tool. Use kpTextStyle for that.
  27. class kpSelectionTransparency
  28. {
  29. public:
  30. // Opaque selection
  31. kpSelectionTransparency ();
  32. // Selection that's transparent at pixels with <color>
  33. kpSelectionTransparency (const kpColor &transparentColor, double colorSimilarity);
  34. // If <isOpaque>, <transparentColor> is allowed to be anything
  35. // (including invalid) as the color would have no effect.
  36. // However, you are encouraged to set it as you would if !<isOpaque>,
  37. // because setTransparent(true) might be called later, after which
  38. // the <transparentColor> would suddenly become important.
  39. //
  40. // It is a similar case with <colorSimilarity>, although <colorSimilarity>
  41. // must be in-range (see kpColorSimilarityDialog).
  42. kpSelectionTransparency (bool isOpaque, const kpColor &transparentColor, double colorSimilarity);
  43. // Returns whether they are visually equivalent.
  44. // This is the same as a memcmp() except that if they are both opaque,
  45. // this function will return true regardless of the transparentColor's.
  46. bool operator== (const kpSelectionTransparency &rhs) const;
  47. bool operator!= (const kpSelectionTransparency &rhs) const;
  48. ~kpSelectionTransparency ();
  49. bool isOpaque () const;
  50. bool isTransparent () const;
  51. void setOpaque (bool yes = true);
  52. void setTransparent (bool yes = true);
  53. // If isOpaque(), transparentColor() is generally not called because
  54. // the transparent color would have no effect.
  55. kpColor transparentColor () const;
  56. void setTransparentColor (const kpColor &transparentColor);
  57. double colorSimilarity () const;
  58. void setColorSimilarity (double colorSimilarity);
  59. int processedColorSimilarity () const;
  60. private:
  61. bool m_isOpaque;
  62. kpColor m_transparentColor;
  63. double m_colorSimilarity;
  64. int m_processedColorSimilarity;
  65. };
  66. #endif // __kp_selection_transparency_h__