00001 #ifdef WIN32
00002 #pragma warning(disable : 4786 )
00003 #endif
00004
00005 #include "CSGrafikElement.h"
00006 #include "CSArea.h"
00007 #include "CSPicture.h"
00008 #include "CSLAF.h"
00009 #include "CSHelper.h"
00010
00011 const char *CSArea::CLASS = "CSArea";
00012 const char *CSRoundedArea::CLASS = "CSRoundedArea";
00013 const char *CSGradientArea::CLASS = "CSGradientArea";
00014 const char *CSPictureArea::CLASS = "CSPictureArea";
00015
00016
00017
00018
00019 CSArea::CSArea()
00020 {
00021 static char *functionName="CSArea";
00022 LOG_ENTER
00023 mColor = 0;
00024 LOG_EXIT
00025 }
00026
00027 void CSArea::paint(SDL_Surface *destination, SDL_Rect *area)
00028 {
00029 static char *functionName="paint";
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 SDL_FillRect(destination, area, mColor);
00044 }
00045
00046 CSRoundedArea::CSRoundedArea()
00047 {
00048 static char *functionName="CSRoundedArea";
00049 LOG_ENTER
00050 mCorner = 4;
00051 LOG_EXIT
00052 }
00053
00054 void CSRoundedArea::paint(SDL_Surface *destination, SDL_Rect *area)
00055 {
00056 static char *functionName="paint";
00057 SDLMain::DrawRoundRectFill(destination, area->x, area->y, area->w, area->h, mColor, mCorner);
00058 }
00059
00060 CSGradientArea::CSGradientArea()
00061 {
00062 static char *functionName="CSRoundedArea";
00063 LOG_ENTER
00064 mType = TYPE_HORIZONTAL;
00065 mSecondColor = 0;
00066 LOG_EXIT
00067 }
00068
00069 void CSGradientArea::paint(SDL_Surface *destination, SDL_Rect *area)
00070 {
00071 static char *functionName="paint";
00072 if (mType == TYPE_HORIZONTAL)
00073 {
00074 SDLMain::horizgradient(destination, *area, mColor, mSecondColor, 255);
00075 return;
00076 }
00077 SDLMain::vertgradient(destination, *area, mColor, mSecondColor, 255);
00078 }
00079
00080 CSPictureArea::CSPictureArea()
00081 {
00082 static char *functionName="CSRoundedArea";
00083 LOG_ENTER
00084 mStretched = true;
00085 mCentered = true;
00086 mPicture = 0;
00087 LOG_EXIT
00088 }
00089
00090 void CSPictureArea::paint(SDL_Surface *destination, SDL_Rect *area)
00091 {
00092 static char *functionName="paint";
00093 if (mPicture == 0)
00094 {
00095 SDL_FillRect(destination, area, mColor);
00096 }
00097 if (mStretched)
00098 {
00099 SDL_Surface *pic = mPicture->getScaledPicture(area->w, area->h);
00100 if (pic)
00101 {
00102 if (SDL_BlitSurface(pic, 0, destination, area)< 0)
00103 {
00104 SDLMain::shutdown((std::string)"BlitSurface error: " + SDL_GetError(), 1);
00105 }
00106
00107 return;
00108 }
00109 }
00110 if (mCentered)
00111 {
00112 int x = area->w/2 - mPicture->getWidth()/2;
00113 int y = area->h - mPicture->getHeight()/2;
00114 mPicture->display(destination, x, y);
00115 return;
00116 }
00117 mPicture->display(destination, area->x, area->y);
00118 }