00001 #ifndef __CNativeImage__ 00002 #define __CNativeImage__ 00003 00004 #include <MathTools/CDimension.hpp> 00005 #include <MathTools/CRect.hpp> 00006 #include "../Windowing/SWindowHandle.hpp" 00007 #include "../Basics/CColour.hpp" 00008 #include "SGraphicsHandle.hpp" 00009 00010 // =========================================================================== 00011 00012 using Exponent::MathTools::CDimension; 00013 using Exponent::MathTools::CRect; 00014 using Exponent::GUI::Windowing::SWindowHandle; 00015 using Exponent::GUI::Basics::CColour; 00016 using Exponent::GUI::Graphics::SGraphicsHandle; 00017 00018 // =========================================================================== 00019 00020 namespace Exponent 00021 { 00022 namespace GUI 00023 { 00024 namespace Graphics 00025 { 00046 class CNativeImage 00047 { 00048 public: 00049 00053 CNativeImage(); 00054 00058 virtual ~CNativeImage(); 00059 00060 // =========================================================================== 00061 00066 SGraphicsHandle *getGraphicsHandle() { return &m_graphicsHandle; } 00067 00072 SWindowHandle *getWindowHandle() const { return m_windowHandle; } 00073 00075 #ifdef WIN32 00076 00081 HDC getParentContext() const { return m_parentHDC; } 00083 #endif 00084 00086 // =========================================================================== 00087 00089 #ifdef WIN32 00090 00097 void initialise(SWindowHandle *windowHandle, HDC drawContext, const CDimension &area); 00099 #else 00100 00106 void initialise(SWindowHandle *windowHandle, const CDimension &area); 00108 #endif 00109 00114 void uninitialise(); 00115 00116 // =========================================================================== 00117 00122 void copyTo(CNativeImage *image); 00123 00128 void copyFrom(CNativeImage *image); 00129 00137 void alphaBlendTo(CNativeImage *image, const CRect &where, const CRect &toHere, const double alpha); 00138 00139 // =========================================================================== 00140 00145 void setBackgroundColour(const CColour &colour) { m_backgroundColour = colour; } 00146 00151 const CColour &getBackgroundColour() const { return m_backgroundColour; } 00152 00157 const CDimension &getDimensions() const { return m_area; } 00158 00159 // =========================================================================== 00160 00161 protected: 00162 00163 // =========================================================================== 00164 00168 void createNativeImage(); 00169 00173 void destroyNativeImage(); 00174 00175 // =========================================================================== 00176 00178 #ifdef WIN32 00179 00180 HDC m_parentHDC; 00182 #endif 00183 00185 SGraphicsHandle m_graphicsHandle; 00186 SWindowHandle *m_windowHandle; 00187 CDimension m_area; 00188 CColour m_backgroundColour; 00189 bool m_initialised; 00190 }; 00191 } 00192 } 00193 } 00194 #endif // End of CNativeImage.hpp