aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llstyle.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llui/llstyle.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llui/llstyle.cpp')
-rw-r--r--linden/indra/llui/llstyle.cpp242
1 files changed, 242 insertions, 0 deletions
diff --git a/linden/indra/llui/llstyle.cpp b/linden/indra/llui/llstyle.cpp
new file mode 100644
index 0000000..aaacb46
--- /dev/null
+++ b/linden/indra/llui/llstyle.cpp
@@ -0,0 +1,242 @@
1/**
2 * @file llstyle.cpp
3 * @brief Text style class
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "linden_common.h"
29
30#include "llstyle.h"
31#include "llstring.h"
32#include "llui.h"
33
34//#include "llviewerimagelist.h"
35
36LLStyle::LLStyle()
37{
38 init(TRUE, LLColor4(0,0,0,1),"");
39}
40
41LLStyle::LLStyle(const LLStyle &style)
42{
43 if (this != &style)
44 {
45 init(style.isVisible(),style.getColor(),style.getFontString());
46 if (style.isLink())
47 {
48 setLinkHREF(style.getLinkHREF());
49 }
50 mItalic = style.mItalic;
51 mBold = style.mBold;
52 mUnderline = style.mUnderline;
53 mDropShadow = style.mDropShadow;
54 mImageHeight = style.mImageHeight;
55 mImageWidth = style.mImageWidth;
56 mImagep = style.mImagep;
57 mIsEmbeddedItem = style.mIsEmbeddedItem;
58 }
59 else
60 {
61 init(TRUE, LLColor4(0,0,0,1),"");
62 }
63}
64
65LLStyle::LLStyle(BOOL is_visible, const LLColor4 &color, const LLString& font_name)
66{
67 init(is_visible, color, font_name);
68}
69
70LLStyle::~LLStyle()
71{
72 free();
73}
74
75void LLStyle::init(BOOL is_visible, const LLColor4 &color, const LLString& font_name)
76{
77 mVisible = is_visible;
78 mColor = color;
79 setFontName(font_name);
80 setLinkHREF("");
81 mItalic = FALSE;
82 mBold = FALSE;
83 mUnderline = FALSE;
84 mDropShadow = FALSE;
85 mImageHeight = 0;
86 mImageWidth = 0;
87 mIsEmbeddedItem = FALSE;
88}
89
90void LLStyle::free()
91{
92}
93
94LLFONT_ID LLStyle::getFontID() const
95{
96 return mFontID;
97}
98
99// Copy assignment
100LLStyle &LLStyle::operator=(const LLStyle &rhs)
101{
102 if (this != &rhs)
103 {
104 setVisible(rhs.isVisible());
105 setColor(rhs.getColor());
106 this->mFontName = rhs.getFontString();
107 this->mLink = rhs.getLinkHREF();
108 mImagep = rhs.mImagep;
109 mImageHeight = rhs.mImageHeight;
110 mImageWidth = rhs.mImageWidth;
111 mItalic = rhs.mItalic;
112 mBold = rhs.mBold;
113 mUnderline = rhs.mUnderline;
114 mDropShadow = rhs.mUnderline;
115 mIsEmbeddedItem = rhs.mIsEmbeddedItem;
116 }
117
118 return *this;
119}
120
121// Compare
122bool LLStyle::operator==(const LLStyle &rhs) const
123{
124 if ((mVisible != rhs.isVisible())
125 || (mColor != rhs.getColor())
126 || (mFontName != rhs.getFontString())
127 || (mLink != rhs.getLinkHREF())
128 || (mImagep != rhs.mImagep)
129 || (mImageHeight != rhs.mImageHeight)
130 || (mImageWidth != rhs.mImageWidth)
131 || (mItalic != rhs.mItalic)
132 || (mBold != rhs.mBold)
133 || (mUnderline != rhs.mUnderline)
134 || (mDropShadow != rhs.mDropShadow)
135 || (mIsEmbeddedItem != rhs.mIsEmbeddedItem)
136 )
137 {
138 return FALSE;
139 }
140 return TRUE;
141}
142
143bool LLStyle::operator!=(const LLStyle& rhs) const
144{
145 return !(*this == rhs);
146}
147
148
149const LLColor4& LLStyle::getColor() const
150{
151 return(mColor);
152}
153
154void LLStyle::setColor(const LLColor4 &color)
155{
156 mColor = color;
157}
158
159const LLString& LLStyle::getFontString() const
160{
161 return mFontName;
162}
163
164void LLStyle::setFontName(const LLString& fontname)
165{
166 mFontName = fontname;
167
168 LLString fontname_lc = fontname;
169 LLString::toLower(fontname_lc);
170
171 mFontID = LLFONT_OCRA; // default
172
173 if ((fontname_lc == "sansserif") || (fontname_lc == "sans-serif"))
174 {
175 mFontID = LLFONT_SANSSERIF;
176 }
177 else if ((fontname_lc == "serif"))
178 {
179 mFontID = LLFONT_SMALL;
180 }
181 else if ((fontname_lc == "sansserifbig"))
182 {
183 mFontID = LLFONT_SANSSERIF_BIG;
184 }
185 else if (fontname_lc == "small")
186 {
187 mFontID = LLFONT_SANSSERIF_SMALL;
188 }
189}
190
191const LLString& LLStyle::getLinkHREF() const
192{
193 return mLink;
194}
195
196void LLStyle::setLinkHREF(const LLString& href)
197{
198 mLink = href;
199}
200
201BOOL LLStyle::isLink() const
202{
203 return mLink.size();
204}
205
206BOOL LLStyle::isVisible() const
207{
208 return mVisible;
209}
210
211void LLStyle::setVisible(BOOL is_visible)
212{
213 mVisible = is_visible;
214}
215
216LLImageGL *LLStyle::getImage() const
217{
218 return mImagep;
219}
220
221void LLStyle::setImage(const LLString& src)
222{
223 if (src.size() < UUID_STR_LENGTH - 1)
224 {
225 return;
226 }
227 else
228 {
229 mImagep = LLUI::sImageProvider->getUIImageByID(LLUUID(src));
230 }
231}
232
233BOOL LLStyle::isImage() const
234{
235 return ((mImageWidth != 0) && (mImageHeight != 0));
236}
237
238void LLStyle::setImageSize(S32 width, S32 height)
239{
240 mImageWidth = width;
241 mImageHeight = height;
242}