PageRenderTime 122ms CodeModel.GetById 80ms app.highlight 37ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llscrolllistcell.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 226 lines | 151 code | 32 blank | 43 comment | 0 complexity | f5f19cc97a832336fb1955b67c20e825 MD5 | raw file
  1/** 
  2 * @file llscrolllistcell.h
  3 * @brief Scroll lists are composed of rows (items), each of which 
  4 * contains columns (cells).
  5 *
  6 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#ifndef LLSCROLLLISTCELL_H
 29#define LLSCROLLLISTCELL_H
 30
 31#include "llfontgl.h"		// HAlign
 32#include "llpointer.h"		// LLPointer<>
 33#include "lluistring.h"
 34#include "v4color.h"
 35#include "llui.h"
 36
 37class LLCheckBoxCtrl;
 38class LLSD;
 39class LLUIImage;
 40
 41/*
 42 * Represents a cell in a scrollable table.
 43 *
 44 * Sub-classes must return height and other properties 
 45 * though width accessors are implemented by the base class.
 46 * It is therefore important for sub-class constructors to call
 47 * setWidth() with realistic values.
 48 */
 49class LLScrollListCell
 50{
 51public:
 52	struct Params : public LLInitParam::Block<Params>
 53	{
 54		Optional<std::string>		type,
 55									column;
 56
 57		Optional<S32>				width;
 58		Optional<bool>				enabled,
 59									visible;
 60
 61		Optional<void*>				userdata;
 62		Optional<LLSD>				value;
 63		Optional<std::string>		tool_tip;
 64
 65		Optional<const LLFontGL*>	font;
 66		Optional<LLColor4>			font_color;
 67		Optional<LLFontGL::HAlign>	font_halign;
 68
 69		Optional<LLColor4>			color;
 70
 71		Params()
 72		:	type("type", "text"),
 73			column("column"),
 74			width("width"),
 75			enabled("enabled", true),
 76			visible("visible", true),
 77			value("value"),
 78			tool_tip("tool_tip", ""),
 79			font("font", LLFontGL::getFontSansSerifSmall()),
 80			font_color("font_color", LLColor4::black),
 81			color("color", LLColor4::white),
 82			font_halign("halign", LLFontGL::LEFT)
 83		{
 84			addSynonym(column, "name");
 85			addSynonym(font_color, "font-color");
 86		}
 87	};
 88
 89	static LLScrollListCell* create(const Params&);
 90
 91	LLScrollListCell(const LLScrollListCell::Params&);
 92	virtual ~LLScrollListCell() {};
 93
 94	virtual void			draw(const LLColor4& color, const LLColor4& highlight_color) const {};		// truncate to given width, if possible
 95	virtual S32				getWidth() const {return mWidth;}
 96	virtual S32				getContentWidth() const { return 0; }
 97	virtual S32				getHeight() const { return 0; }
 98	virtual const LLSD		getValue() const;
 99	virtual void			setValue(const LLSD& value) { }
100	virtual const std::string &getToolTip() const { return mToolTip; }
101	virtual void			setToolTip(const std::string &str) { mToolTip = str; }
102	virtual BOOL			getVisible() const { return TRUE; }
103	virtual void			setWidth(S32 width) { mWidth = width; }
104	virtual void			highlightText(S32 offset, S32 num_chars) {}
105	virtual BOOL			isText() const { return FALSE; }
106	virtual BOOL			needsToolTip() const { return ! mToolTip.empty(); }
107	virtual void			setColor(const LLColor4&) {}
108	virtual void			onCommit() {};
109
110	virtual BOOL			handleClick() { return FALSE; }
111	virtual	void			setEnabled(BOOL enable) { }
112
113private:
114	S32 mWidth;
115	std::string mToolTip;
116};
117
118class LLScrollListSpacer : public LLScrollListCell
119{
120public:
121	LLScrollListSpacer(const LLScrollListCell::Params& p) : LLScrollListCell(p) {}
122	/*virtual*/ ~LLScrollListSpacer() {};
123	/*virtual*/ void			draw(const LLColor4& color, const LLColor4& highlight_color) const {}
124};
125
126/*
127 * Cell displaying a text label.
128 */
129class LLScrollListText : public LLScrollListCell
130{
131public:
132	LLScrollListText(const LLScrollListCell::Params&);
133	/*virtual*/ ~LLScrollListText();
134
135	/*virtual*/ void    draw(const LLColor4& color, const LLColor4& highlight_color) const;
136	/*virtual*/ S32		getContentWidth() const;
137	/*virtual*/ S32		getHeight() const;
138	/*virtual*/ void	setValue(const LLSD& value);
139	/*virtual*/ const LLSD getValue() const;
140	/*virtual*/ BOOL	getVisible() const;
141	/*virtual*/ void	highlightText(S32 offset, S32 num_chars);
142
143	/*virtual*/ void	setColor(const LLColor4&);
144	/*virtual*/ BOOL	isText() const;
145	/*virtual*/ const std::string &	getToolTip() const;
146	/*virtual*/ BOOL	needsToolTip() const;
147
148	S32				getTextWidth() const { return mTextWidth;}
149	void			setTextWidth(S32 value) { mTextWidth = value;} 
150	virtual void	setWidth(S32 width) { LLScrollListCell::setWidth(width); mTextWidth = width; }
151
152	void			setText(const LLStringExplicit& text);
153	void			setFontStyle(const U8 font_style);
154
155private:
156	LLUIString		mText;
157	S32				mTextWidth;
158	const LLFontGL*	mFont;
159	LLColor4		mColor;
160	U8				mUseColor;
161	LLFontGL::HAlign mFontAlignment;
162	BOOL			mVisible;
163	S32				mHighlightCount;
164	S32				mHighlightOffset;
165
166	LLPointer<LLUIImage> mRoundedRectImage;
167
168	static U32 sCount;
169};
170
171/*
172 * Cell displaying an image.
173 */
174class LLScrollListIcon : public LLScrollListCell
175{
176public:
177	LLScrollListIcon(const LLScrollListCell::Params& p);
178	/*virtual*/ ~LLScrollListIcon();
179	/*virtual*/ void	draw(const LLColor4& color, const LLColor4& highlight_color) const;
180	/*virtual*/ S32		getWidth() const;
181	/*virtual*/ S32		getHeight() const;
182	/*virtual*/ const LLSD		getValue() const;
183	/*virtual*/ void	setColor(const LLColor4&);
184	/*virtual*/ void	setValue(const LLSD& value);
185
186private:
187	LLPointer<LLUIImage>	mIcon;
188	LLColor4				mColor;
189	LLFontGL::HAlign		mAlignment;
190};
191
192/*
193 * An interactive cell containing a check box.
194 */
195class LLScrollListCheck : public LLScrollListCell
196{
197public:
198	LLScrollListCheck( const LLScrollListCell::Params&);
199	/*virtual*/ ~LLScrollListCheck();
200	/*virtual*/ void	draw(const LLColor4& color, const LLColor4& highlight_color) const;
201	/*virtual*/ S32		getHeight() const			{ return 0; } 
202	/*virtual*/ const LLSD	getValue() const;
203	/*virtual*/ void	setValue(const LLSD& value);
204	/*virtual*/ void	onCommit();
205
206	/*virtual*/ BOOL	handleClick();
207	/*virtual*/ void	setEnabled(BOOL enable);
208
209	LLCheckBoxCtrl*	getCheckBox()				{ return mCheckBox; }
210
211private:
212	LLCheckBoxCtrl* mCheckBox;
213};
214
215class LLScrollListDate : public LLScrollListText
216{
217public:
218	LLScrollListDate( const LLScrollListCell::Params& p );
219	virtual void	setValue(const LLSD& value);
220	virtual const LLSD getValue() const;
221
222private:
223	LLDate		mDate;
224};
225
226#endif