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.

kptemppixmap.cpp 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. #define DEBUG_KP_TEMP_PIXMAP 0
  24. #include <kptemppixmap.h>
  25. #include <kppixmapfx.h>
  26. #include <kpviewmanager.h>
  27. kpTempPixmap::kpTempPixmap (bool isBrush, RenderMode renderMode,
  28. const TQPoint &topLeft, const TQPixmap &pixmap)
  29. : m_isBrush (isBrush),
  30. m_renderMode (renderMode),
  31. m_topLeft (topLeft),
  32. m_pixmap (pixmap)
  33. {
  34. }
  35. kpTempPixmap::kpTempPixmap (const kpTempPixmap &rhs)
  36. : m_isBrush (rhs.m_isBrush),
  37. m_renderMode (rhs.m_renderMode),
  38. m_topLeft (rhs.m_topLeft),
  39. m_pixmap (rhs.m_pixmap)
  40. {
  41. }
  42. kpTempPixmap &kpTempPixmap::operator= (const kpTempPixmap &rhs)
  43. {
  44. if (this == &rhs)
  45. return *this;
  46. m_isBrush = rhs.m_isBrush;
  47. m_renderMode = rhs.m_renderMode;
  48. m_topLeft = rhs.m_topLeft;
  49. m_pixmap = rhs.m_pixmap;
  50. return *this;
  51. }
  52. kpTempPixmap::~kpTempPixmap ()
  53. {
  54. }
  55. // public
  56. bool kpTempPixmap::isBrush () const
  57. {
  58. return m_isBrush;
  59. }
  60. // public
  61. kpTempPixmap::RenderMode kpTempPixmap::renderMode () const
  62. {
  63. return m_renderMode;
  64. }
  65. // public
  66. TQPoint kpTempPixmap::topLeft () const
  67. {
  68. return m_topLeft;
  69. }
  70. // public
  71. TQPixmap kpTempPixmap::pixmap () const
  72. {
  73. return m_pixmap;
  74. }
  75. // public
  76. bool kpTempPixmap::isVisible (const kpViewManager *vm) const
  77. {
  78. return m_isBrush ? (bool) vm->viewUnderCursor () : true;
  79. }
  80. // public
  81. TQRect kpTempPixmap::rect () const
  82. {
  83. return TQRect (m_topLeft.x (), m_topLeft.y (),
  84. m_pixmap.width (), m_pixmap.height ());
  85. }
  86. // public
  87. int kpTempPixmap::width () const
  88. {
  89. return m_pixmap.width ();
  90. }
  91. // public
  92. int kpTempPixmap::height () const
  93. {
  94. return m_pixmap.height ();
  95. }
  96. // public
  97. bool kpTempPixmap::mayChangeDocumentMask () const
  98. {
  99. return (m_renderMode == SetPixmap ||
  100. m_renderMode == PaintMaskTransparentWithBrush);
  101. }
  102. // public
  103. void kpTempPixmap::paint (TQPixmap *destPixmap, const TQRect &docRect) const
  104. {
  105. #define PARAMS destPixmap, m_topLeft - docRect.topLeft (), m_pixmap
  106. switch (m_renderMode)
  107. {
  108. case SetPixmap:
  109. kpPixmapFX::setPixmapAt (PARAMS);
  110. break;
  111. case PaintPixmap:
  112. kpPixmapFX::paintPixmapAt (PARAMS);
  113. break;
  114. case PaintMaskTransparentWithBrush:
  115. kpPixmapFX::paintMaskTransparentWithBrush (PARAMS);
  116. break;
  117. }
  118. #undef PARAMS
  119. }