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

CSIcon.cpp

Go to the documentation of this file.
00001 #ifdef WIN32
00002 #pragma warning(disable : 4786 )
00003 #endif
00004 
00005 #include "CSIcon.h"
00006 #include "CSFont.h"
00007 #include "CSDesktop.h"
00008 #include "CSLAF.h"
00009 
00010 const char *CSIcon::CLASS = "CSIcon";
00011 const char *CSPictureIcon::CLASS = "CSPictureIcon";
00012 const char *CSTextIcon::CLASS = "CSTextIcon";
00013 
00014 CSPictureIcon::~CSPictureIcon()
00015 {
00016     static char *functionName="~CSPictureIcon";
00017     LOG_ENTER 
00018     mEnabledPicture = 0;
00019     mDisabledPicture = 0;
00020     LOG_EXIT
00021 }
00022 
00023 bool CSPictureIcon::initIcon(CSPicture *picture)
00024 {
00025     static char *functionName="initIcon";
00026     LOG_ENTER 
00027     mEnabledPicture = picture;
00028     mDisabledPicture = picture;
00029     if (mEnabledPicture && mDisabledPicture)
00030     {
00031         init(mEnabledPicture->getMaxY(), mEnabledPicture->getMaxX());
00032     }
00033     else
00034     {
00035         LOG_EXIT
00036         return false;
00037     }
00038     LOG_EXIT
00039     return true;
00040 }
00041 
00042 bool CSPictureIcon::initIcon(std::string enabledPictureFile, std::string disabledPictureFile)
00043 {
00044     static char *functionName="initIcon";
00045     LOG_ENTER 
00046     mEnabledPicture = CSPictureLoader::INSTANCE.load(enabledPictureFile);
00047     mDisabledPicture = CSPictureLoader::INSTANCE.load(disabledPictureFile);
00048     if (mEnabledPicture && mDisabledPicture)
00049     {
00050         if ((mEnabledPicture->getHeight() != mDisabledPicture->getHeight()) || (mEnabledPicture->getWidth() != mDisabledPicture->getWidth()))
00051         {
00052             LOG_EXIT
00053             return false;
00054         }
00055         init(mEnabledPicture->getHeight(), mEnabledPicture->getWidth());
00056     }
00057     else
00058     {
00059         LOG_EXIT
00060         return false;
00061     }
00062     LOG_EXIT
00063     return true;
00064 }
00065 
00066 //! \todo display picture is allways on screen! -> must change!
00067 void CSPictureIcon::paint(SDL_Surface *destination, SDL_Rect *parentViewport)
00068 {
00069     static char *functionName="paint";
00070     int state = getState();
00071     if (state == ICON_STATE_ENABLED)
00072     {
00073         setEnabled(true);
00074         mEnabledPicture->display(getElementArea().x + parentViewport->x, getElementArea().y + parentViewport->y);
00075     }
00076     if (state == ICON_STATE_DISABLED)
00077     {
00078         setEnabled(false);
00079         mDisabledPicture->display(getElementArea().x + parentViewport->x, getElementArea().y + parentViewport->y);
00080     }
00081 }
00082 
00083 void CSPictureIcon::layoutSetupPictureIcon() 
00084 {
00085     if (mEnabledPicture)
00086     {
00087         mMinHeight = mHeight = mEnabledPicture->getHeight();
00088         mMinWidth = mWidth = mEnabledPicture->getWidth();
00089     }
00090 }
00091 
00092 /*************************************************************************************************************/
00093 /*************************************************************************************************************/
00094 /*************************************************************************************************************/
00095 
00096 CSTextIcon::~CSTextIcon() 
00097 {
00098     static char *functionName="~CSTextIcon";
00099     LOG_ENTER 
00100     LOG_EXIT
00101 }
00102 
00103 bool CSTextIcon::initIcon(const std::string &text)
00104 {
00105     static char *functionName="initIcon";
00106     LOG_ENTER 
00107     mText = text;
00108     init(getFont()->getHeight(), getFont()->getWidth(mText.c_str()));
00109     LOG_EXIT
00110     return true;
00111 }
00112 
00113 void CSTextIcon::paint(SDL_Surface *destination, SDL_Rect *parentViewport)
00114 {
00115     static char *functionName="paint";
00116     int state = getState();
00117 
00118     if (state == ICON_STATE_ENABLED)
00119     {
00120         setEnabled(true);
00121     }
00122     if (state == ICON_STATE_DISABLED)
00123     {
00124         setEnabled(false);
00125     }
00126     putString(destination, parentViewport, getX(), getY(), getTextColor(), mText.c_str());
00127 }
00128 
00129 void CSTextIcon::layoutSetupTextIcon()
00130 {
00131     static char *functionName="layoutSetupTextIcon";
00132     LOG_ENTER 
00133     mMinHeight = mHeight = getFont()->getHeight();
00134     mMinWidth = mWidth = getFont()->getWidth(mText.c_str());
00135     LOG_EXIT
00136 }
00137 

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