llstyle.cpp

Go to the documentation of this file.
00001 
00032 #include "linden_common.h"
00033 
00034 #include "llstyle.h"
00035 #include "llstring.h"
00036 #include "llui.h"
00037 
00038 //#include "llviewerimagelist.h"
00039 
00040 LLStyle::LLStyle()
00041 {
00042         init(TRUE, LLColor4(0,0,0,1),"");
00043 }
00044 
00045 LLStyle::LLStyle(const LLStyle &style)
00046 {
00047         if (this != &style)
00048         {
00049                 init(style.isVisible(),style.getColor(),style.getFontString());
00050                 if (style.isLink())
00051                 {
00052                         setLinkHREF(style.getLinkHREF());
00053                 }
00054                 mItalic = style.mItalic;
00055                 mBold = style.mBold;
00056                 mUnderline = style.mUnderline;
00057                 mDropShadow = style.mDropShadow;
00058                 mImageHeight = style.mImageHeight;
00059                 mImageWidth = style.mImageWidth;
00060                 mImagep = style.mImagep;
00061                 mIsEmbeddedItem = style.mIsEmbeddedItem;
00062         }
00063         else
00064         {
00065                 init(TRUE, LLColor4(0,0,0,1),"");
00066         }
00067 }
00068 
00069 LLStyle::LLStyle(BOOL is_visible, const LLColor4 &color, const LLString& font_name)
00070 {
00071         init(is_visible, color, font_name);
00072 }
00073 
00074 LLStyle::~LLStyle()
00075 {
00076         free();
00077 }
00078 
00079 void LLStyle::init(BOOL is_visible, const LLColor4 &color, const LLString& font_name)
00080 {
00081         mVisible = is_visible;
00082         mColor = color;
00083         setFontName(font_name);
00084         setLinkHREF("");
00085         mItalic = FALSE;
00086         mBold = FALSE;
00087         mUnderline = FALSE;
00088         mDropShadow = FALSE;
00089         mImageHeight = 0;
00090         mImageWidth = 0;
00091         mIsEmbeddedItem = FALSE;
00092 }
00093 
00094 void LLStyle::free()
00095 {
00096 }
00097 
00098 LLFONT_ID LLStyle::getFontID() const
00099 {
00100         return mFontID; 
00101 }
00102 
00103 // Copy assignment
00104 LLStyle &LLStyle::operator=(const LLStyle &rhs)
00105 {
00106         if (this != &rhs)
00107         {
00108                 setVisible(rhs.isVisible());
00109                 setColor(rhs.getColor());
00110                 this->mFontName = rhs.getFontString();
00111                 this->mLink = rhs.getLinkHREF();
00112                 mImagep = rhs.mImagep;
00113                 mImageHeight = rhs.mImageHeight;
00114                 mImageWidth = rhs.mImageWidth;
00115                 mItalic = rhs.mItalic;
00116                 mBold = rhs.mBold;
00117                 mUnderline = rhs.mUnderline;
00118                 mDropShadow = rhs.mUnderline;
00119                 mIsEmbeddedItem = rhs.mIsEmbeddedItem;
00120         }
00121         
00122         return *this;
00123 }
00124 
00125 // Compare
00126 bool LLStyle::operator==(const LLStyle &rhs) const
00127 {
00128         if ((mVisible != rhs.isVisible()) 
00129                 || (mColor != rhs.getColor()) 
00130                 || (mFontName != rhs.getFontString())
00131                 || (mLink != rhs.getLinkHREF())
00132                 || (mImagep != rhs.mImagep)
00133                 || (mImageHeight != rhs.mImageHeight)
00134                 || (mImageWidth != rhs.mImageWidth)
00135                 || (mItalic != rhs.mItalic)
00136                 || (mBold != rhs.mBold)
00137                 || (mUnderline != rhs.mUnderline)
00138                 || (mDropShadow != rhs.mDropShadow)
00139                 || (mIsEmbeddedItem != rhs.mIsEmbeddedItem)
00140                 )
00141         {
00142                 return FALSE;
00143         }
00144         return TRUE;
00145 }
00146 
00147 bool LLStyle::operator!=(const LLStyle& rhs) const
00148 {
00149         return !(*this == rhs);
00150 }
00151 
00152 
00153 const LLColor4& LLStyle::getColor() const
00154 {
00155         return(mColor);
00156 }
00157 
00158 void LLStyle::setColor(const LLColor4 &color)
00159 {
00160         mColor = color;
00161 }
00162 
00163 const LLString& LLStyle::getFontString() const
00164 {
00165         return mFontName;
00166 }
00167 
00168 void LLStyle::setFontName(const LLString& fontname)
00169 {
00170         mFontName = fontname;
00171 
00172         LLString fontname_lc = fontname;
00173         LLString::toLower(fontname_lc);
00174         
00175         mFontID = LLFONT_OCRA; // default
00176         
00177         if ((fontname_lc == "sansserif") || (fontname_lc == "sans-serif"))
00178         {
00179                 mFontID = LLFONT_SANSSERIF;
00180         }
00181         else if ((fontname_lc == "serif"))
00182         {
00183                 mFontID = LLFONT_SMALL;
00184         }
00185         else if ((fontname_lc == "sansserifbig"))
00186         {
00187                 mFontID = LLFONT_SANSSERIF_BIG;
00188         }
00189         else if (fontname_lc ==  "small")
00190         {
00191                 mFontID = LLFONT_SANSSERIF_SMALL;
00192         }
00193 }
00194 
00195 const LLString& LLStyle::getLinkHREF() const
00196 {
00197         return mLink;
00198 }
00199 
00200 void LLStyle::setLinkHREF(const LLString& href)
00201 {
00202         mLink = href;
00203 }
00204 
00205 BOOL LLStyle::isLink() const
00206 {
00207         return mLink.size();
00208 }
00209 
00210 BOOL LLStyle::isVisible() const
00211 {
00212         return mVisible;
00213 }
00214 
00215 void LLStyle::setVisible(BOOL is_visible)
00216 {
00217         mVisible = is_visible;
00218 }
00219 
00220 LLImageGL *LLStyle::getImage() const
00221 {
00222         return mImagep;
00223 }
00224 
00225 void LLStyle::setImage(const LLString& src)
00226 {
00227         if (src.size() < UUID_STR_LENGTH - 1)
00228         {
00229                 return;
00230         }
00231         else
00232         {
00233                 mImagep = LLUI::sImageProvider->getUIImageByID(LLUUID(src));
00234         }
00235 }
00236 
00237 BOOL LLStyle::isImage() const
00238 {
00239         return ((mImageWidth != 0) && (mImageHeight != 0));
00240 }
00241 
00242 void LLStyle::setImageSize(S32 width, S32 height)
00243 {
00244     mImageWidth = width;
00245     mImageHeight = height;
00246 }

Generated on Thu Jul 1 06:09:14 2010 for Second Life Viewer by  doxygen 1.4.7