Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

CSArea.cpp

Go to the documentation of this file.
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 //! \todo gradient areas, picture (background areas, strechted ord centered) rounded corner areas
00017 //! none of should be difficult!
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     // simple shading!  
00032     SDL_Rect areaCopy;
00033     for (int i= 0; i<=area->h; i++)
00034     {
00035         areaCopy = *area;
00036         areaCopy.y += i;
00037         areaCopy.h = 1;
00038         SDL_FillRect(destination, &areaCopy, CSHelper::colorPercent(mColor, 50+50*i/area->h));
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 }

Generated on Wed Jul 14 00:43:28 2004 for CSLib by doxygen 1.3.6