PageRenderTime 389ms CodeModel.GetById 230ms app.highlight 8ms RepoModel.GetById 149ms app.codeStats 0ms

/indra/newview/llviewchildren.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 98 lines | 56 code | 14 blank | 28 comment | 4 complexity | 4b9ca7b3327cfd7d9ae0e19c95efd2c8 MD5 | raw file
 1/** 
 2 * @file llviewchildren.cpp
 3 * @brief LLViewChildren class implementation
 4 *
 5 * $LicenseInfo:firstyear=2006&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#include "llviewerprecompiledheaders.h"
28
29#include "llviewchildren.h"
30
31#include "lluictrlfactory.h"
32
33// viewer includes
34#include "llbutton.h"
35#include "lliconctrl.h"
36#include "lltextbox.h"
37#include "lluuid.h"
38#include "llpanel.h"
39#include "llviewercontrol.h"
40
41
42// *NOTE: Do not use mParent reference in the constructor, since it is
43// potentially not fully constructud.
44LLViewChildren::LLViewChildren(LLPanel& parent)
45	: mParent(parent)
46{
47}
48
49
50void LLViewChildren::show(const std::string& id, bool visible)
51{
52	mParent.getChildView(id)->setVisible(visible);
53}
54
55void LLViewChildren::enable(const std::string& id, bool enabled)
56{
57	mParent.getChildView(id)->setEnabled(enabled);
58}
59
60void LLViewChildren::setText(
61	const std::string& id, const std::string& text, bool visible)
62{
63	LLTextBox* child = mParent.getChild<LLTextBox>(id);
64	if (child)
65	{
66		child->setVisible(visible);
67		child->setText(text);
68	}
69}
70
71void LLViewChildren::setBadge(const std::string& id, Badge badge, bool visible)
72{
73	LLIconCtrl* child = mParent.getChild<LLIconCtrl>(id);
74	if (child)
75	{
76		child->setVisible(visible);
77		switch (badge)
78		{
79			default:
80			case BADGE_OK:		child->setValue(std::string("badge_ok.j2c"));	break;
81			case BADGE_NOTE:	child->setValue(std::string("badge_note.j2c"));	break;
82			case BADGE_WARN:	child->setValue(std::string("badge_warn.j2c"));	break;
83			case BADGE_ERROR:	child->setValue(std::string("badge_error.j2c"));	break;
84		}
85	}
86}
87
88void LLViewChildren::setAction(const std::string& id,
89	void(*function)(void*), void* value)
90{
91	LLButton* button = mParent.getChild<LLButton>(id);
92	if (button)
93	{
94		button->setClickedCallback(function, value);
95	}
96}
97
98