00001
00032 #include "linden_common.h"
00033
00034 #include "llstyle.h"
00035 #include "llstring.h"
00036 #include "llui.h"
00037
00038
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 void LLStyle::init(BOOL is_visible, const LLColor4 &color, const LLString& font_name)
00075 {
00076 mVisible = is_visible;
00077 mColor = color;
00078 setFontName(font_name);
00079 setLinkHREF("");
00080 mItalic = FALSE;
00081 mBold = FALSE;
00082 mUnderline = FALSE;
00083 mDropShadow = FALSE;
00084 mImageHeight = 0;
00085 mImageWidth = 0;
00086 mIsEmbeddedItem = FALSE;
00087 }
00088
00089
00090
00091 LLStyle &LLStyle::operator=(const LLStyle &rhs)
00092 {
00093 if (this != &rhs)
00094 {
00095 setVisible(rhs.isVisible());
00096 setColor(rhs.getColor());
00097 this->mFontName = rhs.getFontString();
00098 this->mLink = rhs.getLinkHREF();
00099 mImagep = rhs.mImagep;
00100 mImageHeight = rhs.mImageHeight;
00101 mImageWidth = rhs.mImageWidth;
00102 mItalic = rhs.mItalic;
00103 mBold = rhs.mBold;
00104 mUnderline = rhs.mUnderline;
00105 mDropShadow = rhs.mUnderline;
00106 mIsEmbeddedItem = rhs.mIsEmbeddedItem;
00107 }
00108
00109 return *this;
00110 }
00111
00112
00113 void LLStyle::setFontName(const LLString& fontname)
00114 {
00115 mFontName = fontname;
00116
00117 LLString fontname_lc = fontname;
00118 LLString::toLower(fontname_lc);
00119
00120 mFontID = LLFONT_OCRA;
00121
00122 if ((fontname_lc == "sansserif") || (fontname_lc == "sans-serif"))
00123 {
00124 mFontID = LLFONT_SANSSERIF;
00125 }
00126 else if ((fontname_lc == "serif"))
00127 {
00128 mFontID = LLFONT_SMALL;
00129 }
00130 else if ((fontname_lc == "sansserifbig"))
00131 {
00132 mFontID = LLFONT_SANSSERIF_BIG;
00133 }
00134 else if (fontname_lc == "small")
00135 {
00136 mFontID = LLFONT_SANSSERIF_SMALL;
00137 }
00138 }
00139
00140
00141 void LLStyle::setLinkHREF(const LLString& href)
00142 {
00143 mLink = href;
00144 }
00145
00146 BOOL LLStyle::isLink() const
00147 {
00148 return mLink.size();
00149 }
00150
00151 BOOL LLStyle::isVisible() const
00152 {
00153 return mVisible;
00154 }
00155
00156 void LLStyle::setVisible(BOOL is_visible)
00157 {
00158 mVisible = is_visible;
00159 }
00160
00161 LLUIImagePtr LLStyle::getImage() const
00162 {
00163 return mImagep;
00164 }
00165
00166 void LLStyle::setImage(const LLUUID& src)
00167 {
00168 mImagep = LLUI::sImageProvider->getUIImageByID(src);
00169 }
00170
00171
00172 void LLStyle::setImageSize(S32 width, S32 height)
00173 {
00174 mImageWidth = width;
00175 mImageHeight = height;
00176 }