aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/lliconctrl.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/lliconctrl.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/lliconctrl.cpp')
-rw-r--r--linden/indra/llui/lliconctrl.cpp158
1 files changed, 158 insertions, 0 deletions
diff --git a/linden/indra/llui/lliconctrl.cpp b/linden/indra/llui/lliconctrl.cpp
new file mode 100644
index 0000000..7dbd2bf
--- /dev/null
+++ b/linden/indra/llui/lliconctrl.cpp
@@ -0,0 +1,158 @@
1/**
2 * @file lliconctrl.cpp
3 * @brief LLIconCtrl base 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 "lliconctrl.h"
31
32// Linden library includes
33
34// Project includes
35#include "llcontrol.h"
36#include "llui.h"
37#include "lluictrlfactory.h"
38
39const F32 RESOLUTION_BUMP = 1.f;
40
41LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLUUID &image_id)
42: LLUICtrl(name,
43 rect,
44 FALSE, // mouse opaque
45 NULL, NULL,
46 FOLLOWS_LEFT | FOLLOWS_TOP),
47 mColor( LLColor4::white ),
48 mImageName("")
49{
50 setImage( image_id );
51 setTabStop(FALSE);
52}
53
54LLIconCtrl::LLIconCtrl(const LLString& name, const LLRect &rect, const LLString &image_name)
55: LLUICtrl(name,
56 rect,
57 FALSE, // mouse opaque
58 NULL, NULL,
59 FOLLOWS_LEFT | FOLLOWS_TOP),
60 mColor( LLColor4::white ),
61 mImageName(image_name)
62{
63 LLUUID image_id;
64 image_id.set(LLUI::sAssetsGroup->getString( image_name ));
65 setImage( image_id );
66 setTabStop(FALSE);
67}
68
69
70LLIconCtrl::~LLIconCtrl()
71{
72 mImagep = NULL;
73}
74
75
76void LLIconCtrl::setImage(const LLUUID &image_id)
77{
78 mImageID = image_id;
79 mImagep = LLUI::sImageProvider->getUIImageByID(image_id);
80}
81
82
83void LLIconCtrl::draw()
84{
85 if( getVisible() )
86 {
87 // Border
88 BOOL has_image = !mImageID.isNull();
89
90 if( has_image )
91 {
92 if( mImagep.notNull() )
93 {
94 gl_draw_scaled_image(0, 0,
95 mRect.getWidth(), mRect.getHeight(),
96 mImagep,
97 mColor );
98 }
99 }
100
101 LLUICtrl::draw();
102 }
103}
104
105// virtual
106void LLIconCtrl::setValue(const LLSD& value )
107{
108 setImage(value.asUUID());
109}
110
111// virtual
112LLSD LLIconCtrl::getValue() const
113{
114 LLSD ret = getImage();
115 return ret;
116}
117
118// virtual
119LLXMLNodePtr LLIconCtrl::getXML(bool save_children) const
120{
121 LLXMLNodePtr node = LLUICtrl::getXML();
122
123 if (mImageName != "")
124 {
125 node->createChild("image_name", TRUE)->setStringValue(mImageName);
126 }
127
128 node->createChild("color", TRUE)->setFloatValue(4, mColor.mV);
129
130 return node;
131}
132
133LLView* LLIconCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory)
134{
135 LLString name("icon");
136 node->getAttributeString("name", name);
137
138 LLRect rect;
139 createRect(node, rect, parent, LLRect());
140
141 LLUUID image_id;
142 if (node->hasAttribute("image_name"))
143 {
144 LLString image_name;
145 node->getAttributeString("image_name", image_name);
146 image_id.set(LLUI::sAssetsGroup->getString( image_name ));
147 }
148
149 LLColor4 color(LLColor4::white);
150 LLUICtrlFactory::getAttributeColor(node,"color", color);
151
152 LLIconCtrl* icon = new LLIconCtrl(name, rect, image_id);
153 icon->setColor(color);
154
155 icon->initFromXML(node, parent);
156
157 return icon;
158}