00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "CATPicture.h"
00016
00017
00018
00019
00020
00021
00022
00023
00024 CATPicture::CATPicture(const CATString& element,
00025 const CATString& rootDir)
00026 : CATControl(element, rootDir)
00027 {
00028 fBackgroundColor = CATColor(0,0,255);
00029 fValue = 0.0f;
00030 }
00031
00032
00033
00034 bool CATPicture::IsFocusable() const
00035 {
00036 return false;
00037 }
00038
00039
00040
00041 CATPicture::~CATPicture()
00042 {
00043
00044 }
00045
00046
00047
00048
00049
00050
00051 void CATPicture::Draw(CATImage* image, const CATRect& dirtyRect)
00052 {
00053 if (this->IsVisible() == false)
00054 {
00055 return;
00056 }
00057
00058
00059 CATRect imgRect(0,0,image->Width(), image->Height());
00060 CATASSERT(imgRect.Inside(dirtyRect), "Update rect is outside of img rect!");
00061
00062
00063 CATRect drawRect;
00064 bool drawn = false;
00065
00066 CATResult result = CAT_SUCCESS;
00067
00068
00069 if (this->fRect.Intersect(dirtyRect, &drawRect))
00070 {
00071 if (fImage)
00072 {
00073 if ((fImage->Width() == fRect.Width()) &&
00074 (fImage->Height() == fRect.Height()))
00075 {
00076 CATRect ourRect = drawRect;
00077 ourRect.Offset(-fRect.left, -fRect.top);
00078
00079
00080 result = image->Overlay(fImage,drawRect.left,drawRect.top,ourRect.left,ourRect.top,drawRect.Width(),drawRect.Height());
00081 }
00082 else
00083 {
00084
00085
00086 CATInt32 yPos = drawRect.top;
00087 CATInt32 totalHeight = drawRect.Height();
00088 CATInt32 offsetY = (yPos - fRect.top) % fImage->Height();
00089
00090 while (totalHeight > 0)
00091 {
00092 CATInt32 xPos = drawRect.left;
00093 CATInt32 copyHeight = CATMin(fImage->Height() - offsetY, totalHeight);
00094 CATInt32 totalWidth = drawRect.Width();
00095 CATInt32 offsetX = (xPos - fRect.left) % fImage->Width();
00096
00097 while (totalWidth > 0)
00098 {
00099 CATInt32 copyWidth = CATMin(fImage->Width() - offsetX, totalWidth);
00100 result = image->Overlay(fImage,xPos,yPos,offsetX,offsetY,copyWidth,copyHeight);
00101 xPos += copyWidth;
00102 totalWidth -= copyWidth;
00103 offsetX = 0;
00104 }
00105
00106 offsetY = 0;
00107 yPos += copyHeight;
00108 totalHeight -= copyHeight;
00109 }
00110 }
00111 }
00112 else
00113 {
00114
00115 result = image->FillRect(drawRect,this->fBackgroundColor);
00116 }
00117 }
00118 }
00119