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

CSBorder Class Reference

#include <CSBorder.h>

Inheritance diagram for CSBorder:

CSRoundedBorder

Public Member Functions

virtual std::string getType ()
virtual ~CSBorder ()
virtual void paint (SDL_Surface *destination, SDL_Rect *parentViewport)
virtual void setType (int type)
virtual void setState (int state)
virtual int getTotalWidth ()
virtual int getTotalHeight ()
virtual int getSizeSouth ()
virtual int getSizeNorth ()
virtual int getSizeEast ()
virtual int getSizeWest ()

Static Public Member Functions

CSBordergetBorder (int type)

Static Public Attributes

const char * CLASS = "CSBorder"

Protected Member Functions

 CSBorder ()

Protected Attributes

int mType
int mState
int mBorderOuterEdgeWidth
int mBorderInnerEdgeWidth
int mBorderInterEdgeWidth
int mShadeBright
int mShadeBrighter
int mShadeDark
int mShadeDarker

Constructor & Destructor Documentation

CSBorder::CSBorder  )  [protected]
 

Definition at line 13 of file CSBorder.cpp.

References BORDER_STATE_DEFAULT, LOG_ENTER, LOG_EXIT, mBorderInnerEdgeWidth, mBorderInterEdgeWidth, mBorderOuterEdgeWidth, and mState.

Referenced by getBorder().

00014 {
00015     static char *functionName="CSBorder";
00016     LOG_ENTER 
00017     mBorderOuterEdgeWidth = 0;
00018     mBorderInnerEdgeWidth = 0;
00019     mBorderInterEdgeWidth = 0;
00020     mState = BORDER_STATE_DEFAULT;
00021     LOG_EXIT
00022 }

virtual CSBorder::~CSBorder  )  [inline, virtual]
 

Definition at line 51 of file CSBorder.h.

00051 {}


Member Function Documentation

virtual std::string CSBorder::getType  )  [inline, virtual]
 

Reimplemented in CSRoundedBorder.

Definition at line 50 of file CSBorder.h.

References CLASS.

00050 {return (std::string) CLASS;}

CSBorder * CSBorder::getBorder int  type  )  [static]
 

Reimplemented in CSRoundedBorder.

Definition at line 363 of file CSBorder.cpp.

References BORDER_TYPE_NONE, CSBorder(), mBorderInnerEdgeWidth, mBorderInterEdgeWidth, mBorderOuterEdgeWidth, and mType.

Referenced by CSLAF::getBorderInternal(), and CSListbox::rebuildElement().

00364 {
00365     CSBorder *border = new CSBorder(); 
00366     border->mType = type;
00367     if (border->mType == BORDER_TYPE_NONE)
00368     {
00369         border->mBorderOuterEdgeWidth = 0;
00370         border->mBorderInnerEdgeWidth = 0;
00371         border->mBorderInterEdgeWidth = 0;
00372     }
00373     else
00374     {
00375         border->mBorderOuterEdgeWidth = 1;
00376         border->mBorderInnerEdgeWidth = 1;
00377         border->mBorderInterEdgeWidth = 2;
00378     }
00379     return border;
00380 }

Here is the call graph for this function:

void CSBorder::paint SDL_Surface *  destination,
SDL_Rect *  parentViewport
[virtual]
 

Reimplemented in CSRoundedBorder.

Definition at line 24 of file CSBorder.cpp.

References BORDER_STATE_HOVERING, BORDER_STATE_PRESSED, BORDER_STATE_VISIBLE, BORDER_TYPE_DOUBLE, BORDER_TYPE_HOVER, BORDER_TYPE_INTER, BORDER_TYPE_NONE, BORDER_TYPE_SINGLE_COLOR, BORDER_TYPE_UP, COLOR, CSHelper::colorPercent(), CSLAF::getBorderDefaultBrightestColor(), CSLAF::getCurrentLAF(), mBorderInnerEdgeWidth, mBorderInterEdgeWidth, mBorderOuterEdgeWidth, mShadeBright, mShadeBrighter, mShadeDark, mShadeDarker, and mState.

Referenced by CSListbox::paint(), and CSGrafikElement::paintBorder().

00025 {
00026     static char *functionName="paint";
00027     CSLAF *laf = CSLAF::getCurrentLAF(); 
00028     int type = mType;
00029     if ((!(mState & BORDER_STATE_VISIBLE)) || (type == BORDER_TYPE_NONE))
00030     {
00031         return;
00032     }
00033 
00034     mShadeBrighter = CSHelper::colorPercent(laf->getBorderDefaultBrightestColor(), 100);
00035     mShadeBright = CSHelper::colorPercent(laf->getBorderDefaultBrightestColor(), 70);
00036     mShadeDark = CSHelper::colorPercent(laf->getBorderDefaultBrightestColor(), 50);
00037     mShadeDarker = CSHelper::colorPercent(laf->getBorderDefaultBrightestColor(), 20);
00038 
00039     // if type up
00040     if (type & BORDER_TYPE_UP)
00041     {
00042         // and pressed
00043         if (mState & BORDER_STATE_PRESSED)
00044         {
00045             // draw pressed border
00046             type = type & (~BORDER_TYPE_UP);
00047         }
00048         else
00049         {
00050             // if hovering enabled 
00051             if (mState & BORDER_STATE_HOVERING)
00052             {
00053                 // and hovering happens
00054                 if (type & BORDER_TYPE_HOVER)
00055                 {
00056                     // draw on hovering Type up
00057                     type = type | BORDER_TYPE_UP;
00058                 }
00059                 else
00060                 {
00061                     // if overing enabeld and not hovering, draw nothing
00062                     return;
00063                     //type = type & (~BORDER_TYPE_UP);
00064                 }
00065             }
00066             else // if hovering disabled
00067             {
00068                 // and not pressed, than draw border up on pressed
00069                 type = type | BORDER_TYPE_UP;
00070             }
00071         }
00072     }
00073     else
00074     {
00075     }
00076 
00077 
00078     SDL_Rect copy;
00079     int o = 0;
00080     if (type & BORDER_TYPE_UP)
00081     {
00082         if (mBorderOuterEdgeWidth)
00083         {
00084             SDL_Rect a = *area;
00085             a.x += o;
00086             a.y += o;
00087             a.h = mBorderOuterEdgeWidth;
00088             a.w = a.w - 2*o;
00089             if (a.w > 60000) a.w = 0;
00090             if (mType & BORDER_TYPE_SINGLE_COLOR)
00091             {
00092                 copy = a;
00093                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeDarker));
00094                 a.y = area->h+area->y - (mBorderOuterEdgeWidth+o);
00095                 copy = a;
00096                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeDarker));
00097             }
00098             else
00099             {
00100                 copy = a;
00101                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeBrighter));
00102                 a.y = area->h+area->y - (mBorderOuterEdgeWidth+o);
00103                 copy = a;
00104                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeDarker));
00105             }
00106 
00107             a = *area;
00108             a.x += o;
00109             a.y += o;
00110             a.w = mBorderOuterEdgeWidth;
00111             a.h = a.h - 2*o;
00112             if (a.h > 60000) a.h = 0;
00113             if (mType & BORDER_TYPE_SINGLE_COLOR)
00114             {
00115                 copy = a;
00116                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeDarker));
00117                 a.x = area->w+area->x - (mBorderOuterEdgeWidth +o);
00118                 copy = a;
00119                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeDarker));
00120             }
00121             else
00122             {
00123                 copy = a;
00124                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeDarker));
00125                 a.x = area->w+area->x - (mBorderOuterEdgeWidth +o);
00126                 copy = a;
00127                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeBrighter));
00128             }
00129         }   
00130         o+=mBorderOuterEdgeWidth;
00131         if (type & BORDER_TYPE_DOUBLE)
00132         {
00133 
00134             if (mBorderInnerEdgeWidth)
00135             {
00136                 SDL_Rect a = *area;
00137                 a.x += o;
00138                 a.y += o;
00139                 a.h = mBorderInnerEdgeWidth;
00140                 a.w = a.w - 2*o;
00141                 if (a.w > 60000) a.w = 0;
00142                 if (mType & BORDER_TYPE_SINGLE_COLOR)
00143                 {
00144                     copy = a;
00145                     SDL_FillRect(destination, &copy, COLOR(destination, mShadeDark));
00146                     a.y = area->h+area->y - (mBorderInnerEdgeWidth+o);
00147                     copy = a;
00148                     SDL_FillRect(destination, &copy, COLOR(destination, mShadeDark));
00149                 }
00150                 else
00151                 {
00152                     copy = a;
00153                     SDL_FillRect(destination, &copy, COLOR(destination, mShadeBright));
00154                     a.y = area->h+area->y - (mBorderInnerEdgeWidth+o);
00155                     copy = a;
00156                     SDL_FillRect(destination, &copy, COLOR(destination, mShadeDark));
00157                 }
00158 
00159                 a = *area;
00160                 a.x += o;
00161                 a.y += o;
00162                 a.w = mBorderInnerEdgeWidth;
00163                 a.h = a.h - 2*o;
00164                 if (a.h > 60000) a.h = 0;
00165                 if (mType & BORDER_TYPE_SINGLE_COLOR)
00166                 {
00167                     copy = a;
00168                     SDL_FillRect(destination, &copy, COLOR(destination, mShadeDark));
00169                     a.x = area->w+area->x - (mBorderInnerEdgeWidth +o);
00170                     copy = a;
00171                     SDL_FillRect(destination, &copy, COLOR(destination, mShadeDark));
00172                 }
00173                 else
00174                 {
00175                     copy = a;
00176                     SDL_FillRect(destination, &copy, COLOR(destination, mShadeDark));
00177                     a.x = area->w+area->x - (mBorderInnerEdgeWidth +o);
00178                     copy = a;
00179                     SDL_FillRect(destination, &copy, COLOR(destination, mShadeBright));
00180                 }
00181             }   
00182         }
00183         o+=mBorderInnerEdgeWidth;
00184         if (type & BORDER_TYPE_INTER)
00185         {
00186             SDL_Rect a = *area;
00187             a.x += o + mBorderInterEdgeWidth;
00188             a.y += o + mBorderInterEdgeWidth;
00189             a.w = a.w - 2*o - (2*mBorderInterEdgeWidth);
00190             a.h = a.h - 2*o - (2*mBorderInterEdgeWidth);
00191             if (a.w > 60000) a.w = 0;
00192             if (a.h > 60000) a.h = 0;
00193             
00194             int typeSave = type;
00195             type = type - BORDER_TYPE_INTER - BORDER_TYPE_UP;
00196             paint(destination, &a);
00197             type = typeSave;
00198         }
00199     }   
00200     else // down
00201     {
00202         if (mBorderOuterEdgeWidth)
00203         {
00204             SDL_Rect a = *area;
00205             a.x += o;
00206             a.y += o;
00207             a.h = mBorderOuterEdgeWidth;
00208             a.w = a.w - 2*o;
00209             if (a.w > 60000) a.w = 0;
00210             copy = a;
00211             SDL_FillRect(destination, &copy, COLOR(destination, mShadeDarker));
00212             a.y = area->h+area->y - (mBorderOuterEdgeWidth+o);
00213             copy = a;
00214             SDL_FillRect(destination, &copy, COLOR(destination, mShadeBrighter));
00215 
00216             a = *area;
00217             a.x += o;
00218             a.y += o;
00219             a.w = mBorderOuterEdgeWidth;
00220             a.h = a.h - 2*o;
00221             if (a.h > 60000) a.h = 0;
00222             copy = a;
00223             SDL_FillRect(destination, &copy, COLOR(destination, mShadeBrighter));
00224             a.x = area->w+area->x - (mBorderOuterEdgeWidth +o);
00225             copy = a;
00226             SDL_FillRect(destination, &copy, COLOR(destination, mShadeDarker));
00227         }   
00228         o+=mBorderOuterEdgeWidth;
00229         if (type & BORDER_TYPE_DOUBLE)
00230         {
00231             if (mBorderInnerEdgeWidth)
00232             {
00233                 SDL_Rect a = *area;
00234                 a.x += o;
00235                 a.y += o;
00236                 a.h = mBorderInnerEdgeWidth;
00237                 a.w = a.w - 2*o;
00238                 if (a.w > 60000) a.w = 0;
00239                 copy = a;
00240                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeDark));
00241                 a.y = area->h+area->y - (mBorderInnerEdgeWidth+o);
00242                 copy = a;
00243                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeBright));
00244 
00245                 a = *area;
00246                 a.x += o;
00247                 a.y += o;
00248                 a.w = mBorderInnerEdgeWidth;
00249                 a.h = a.h - 2*o;
00250                 if (a.h > 60000) a.h = 0;
00251                 copy = a;
00252                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeBright));
00253                 a.x = area->w+area->x - (mBorderInnerEdgeWidth +o);
00254                 copy = a;
00255                 SDL_FillRect(destination, &copy, COLOR(destination, mShadeDark));
00256             }
00257         }
00258         if (type & BORDER_TYPE_INTER)
00259         {
00260             SDL_Rect a = *area;
00261             a.x += o + mBorderInterEdgeWidth;
00262             a.y += o + mBorderInterEdgeWidth;
00263             a.w = a.w - 2*o - (2*mBorderInterEdgeWidth);
00264             a.h = a.h - 2*o - (2*mBorderInterEdgeWidth);
00265             if (a.w > 60000) a.w = 0;
00266             if (a.h > 60000) a.h = 0;
00267 
00268             int typeSave = type;
00269             type = type - BORDER_TYPE_INTER - BORDER_TYPE_UP;
00270             paint(destination, &a);
00271             type = typeSave;
00272         }
00273         o+=mBorderInnerEdgeWidth;
00274     }
00275 }

Here is the call graph for this function:

virtual void CSBorder::setType int  type  )  [inline, virtual]
 

Definition at line 54 of file CSBorder.h.

00054 {mType = type;}

virtual void CSBorder::setState int  state  )  [inline, virtual]
 

Definition at line 55 of file CSBorder.h.

References mState.

Referenced by CSLAF::getBorderInternal(), and CSListbox::paint().

00055 {mState = state;}

int CSBorder::getTotalWidth  )  [virtual]
 

Definition at line 277 of file CSBorder.cpp.

References getSizeEast(), and getSizeWest().

Referenced by CSLayoutManager::getBorderWidth(), CSGrafikElement::init(), CSCombobox::layoutSetupCombobox(), CSListbox::layoutSetupListbox(), CSMessageBox::layoutSetupMessageBox(), CSTextarea::layoutSetupTextarea(), CSTextfield::layoutSetupTextfield(), CSCheckBox::paint(), and CSTextfield::reactOnMessageTextField().

00278 {
00279     return getSizeEast() + getSizeWest();
00280 }

Here is the call graph for this function:

int CSBorder::getTotalHeight  )  [virtual]
 

Definition at line 282 of file CSBorder.cpp.

References getSizeNorth(), and getSizeSouth().

Referenced by CSLayoutManager::getBorderHeight(), CSGrafikElement::init(), CSCheckBox::layoutSetupCheckBox(), CSCombobox::layoutSetupCombobox(), CSListbox::layoutSetupListbox(), CSMessageBox::layoutSetupMessageBox(), CSTextarea::layoutSetupTextarea(), and CSTextfield::layoutSetupTextfield().

00283 {
00284     return getSizeSouth() + getSizeNorth();
00285 }

Here is the call graph for this function:

int CSBorder::getSizeSouth  )  [virtual]
 

Definition at line 287 of file CSBorder.cpp.

References BORDER_TYPE_DOUBLE, BORDER_TYPE_INTER, BORDER_TYPE_NONE, mBorderInnerEdgeWidth, mBorderInterEdgeWidth, and mBorderOuterEdgeWidth.

Referenced by getTotalHeight().

00288 {
00289     int size = 0;
00290     if (mType == BORDER_TYPE_NONE)
00291     {
00292         return 0;
00293     }
00294     if (mType & BORDER_TYPE_INTER)
00295     {
00296         size += mBorderInterEdgeWidth;
00297     }
00298     if (mType & BORDER_TYPE_DOUBLE)
00299     {
00300         size += mBorderInnerEdgeWidth;
00301     }
00302     size += mBorderOuterEdgeWidth;
00303     return size;
00304 }

int CSBorder::getSizeNorth  )  [virtual]
 

Definition at line 306 of file CSBorder.cpp.

References BORDER_TYPE_DOUBLE, BORDER_TYPE_INTER, BORDER_TYPE_NONE, mBorderInnerEdgeWidth, mBorderInterEdgeWidth, and mBorderOuterEdgeWidth.

Referenced by CSLayoutManager::buildArea(), getTotalHeight(), CSGrafikElement::init(), CSTextfield::paint(), CSCombobox::paint(), CSCheckBox::paint(), and CSListbox::setGrafikCursor().

00307 {
00308     int size = 0;
00309     if (mType == BORDER_TYPE_NONE)
00310     {
00311         return 0;
00312     }
00313     if (mType & BORDER_TYPE_INTER)
00314     {
00315         size += mBorderInterEdgeWidth;
00316     }
00317     if (mType & BORDER_TYPE_DOUBLE)
00318     {
00319         size += mBorderInnerEdgeWidth;
00320     }
00321     size += mBorderOuterEdgeWidth;
00322     return size;
00323 }

int CSBorder::getSizeEast  )  [virtual]
 

Definition at line 325 of file CSBorder.cpp.

References BORDER_TYPE_DOUBLE, BORDER_TYPE_INTER, BORDER_TYPE_NONE, mBorderInnerEdgeWidth, mBorderInterEdgeWidth, and mBorderOuterEdgeWidth.

Referenced by getTotalWidth().

00326 {
00327     int size = 0;
00328     if (mType == BORDER_TYPE_NONE)
00329     {
00330         return 0;
00331     }
00332     if (mType & BORDER_TYPE_INTER)
00333     {
00334         size += mBorderInterEdgeWidth;
00335     }
00336     if (mType & BORDER_TYPE_DOUBLE)
00337     {
00338         size += mBorderInnerEdgeWidth;
00339     }
00340     size += mBorderOuterEdgeWidth;
00341     return size;
00342 }

int CSBorder::getSizeWest  )  [virtual]
 

Definition at line 344 of file CSBorder.cpp.

References BORDER_TYPE_DOUBLE, BORDER_TYPE_INTER, BORDER_TYPE_NONE, mBorderInnerEdgeWidth, mBorderInterEdgeWidth, and mBorderOuterEdgeWidth.

Referenced by CSLayoutManager::buildArea(), getTotalWidth(), CSGrafikElement::init(), CSTextfield::paint(), CSCombobox::paint(), CSCheckBox::paint(), CSCombobox::reactOnMessageCombobox(), and CSListbox::setGrafikCursor().

00345 {
00346     int size = 0;
00347     if (mType == BORDER_TYPE_NONE)
00348     {
00349         return 0;
00350     }
00351     if (mType & BORDER_TYPE_INTER)
00352     {
00353         size += mBorderInterEdgeWidth;
00354     }
00355     if (mType & BORDER_TYPE_DOUBLE)
00356     {
00357         size += mBorderInnerEdgeWidth;
00358     }
00359     size += mBorderOuterEdgeWidth;
00360     return size;
00361 }


Field Documentation

int CSBorder::mType [protected]
 

Definition at line 36 of file CSBorder.h.

Referenced by CSRoundedBorder::getBorder(), and getBorder().

int CSBorder::mState [protected]
 

Definition at line 37 of file CSBorder.h.

Referenced by CSBorder(), paint(), and setState().

int CSBorder::mBorderOuterEdgeWidth [protected]
 

Definition at line 38 of file CSBorder.h.

Referenced by CSBorder(), CSRoundedBorder::getBorder(), getBorder(), getSizeEast(), getSizeNorth(), getSizeSouth(), getSizeWest(), and paint().

int CSBorder::mBorderInnerEdgeWidth [protected]
 

Definition at line 39 of file CSBorder.h.

Referenced by CSBorder(), CSRoundedBorder::getBorder(), getBorder(), getSizeEast(), getSizeNorth(), getSizeSouth(), getSizeWest(), and paint().

int CSBorder::mBorderInterEdgeWidth [protected]
 

Definition at line 40 of file CSBorder.h.

Referenced by CSBorder(), CSRoundedBorder::getBorder(), getBorder(), getSizeEast(), getSizeNorth(), getSizeSouth(), getSizeWest(), and paint().

int CSBorder::mShadeBright [protected]
 

Definition at line 42 of file CSBorder.h.

Referenced by paint().

int CSBorder::mShadeBrighter [protected]
 

Definition at line 43 of file CSBorder.h.

Referenced by paint().

int CSBorder::mShadeDark [protected]
 

Definition at line 44 of file CSBorder.h.

Referenced by paint().

int CSBorder::mShadeDarker [protected]
 

Definition at line 45 of file CSBorder.h.

Referenced by paint().

const char * CSBorder::CLASS = "CSBorder" [static]
 

Reimplemented in CSRoundedBorder.

Definition at line 10 of file CSBorder.cpp.

Referenced by getType().


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