From 9ec432034dc3c45d7ce763eb02dae4cc7f6b8da8 Mon Sep 17 00:00:00 2001 From: Steven Bennetts Date: Sun, 21 Jun 2009 08:04:56 +0000 Subject: merge -r 122421-124917 viewer-2.0.0-2 -> viewer-2.0.0-3 ignore-dead-branch --- indra/llui/llscrolllistcell.h | 223 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 indra/llui/llscrolllistcell.h (limited to 'indra/llui/llscrolllistcell.h') diff --git a/indra/llui/llscrolllistcell.h b/indra/llui/llscrolllistcell.h new file mode 100644 index 0000000000..2ab13f7618 --- /dev/null +++ b/indra/llui/llscrolllistcell.h @@ -0,0 +1,223 @@ +/** + * @file llscrolllistcell.h + * @brief Scroll lists are composed of rows (items), each of which + * contains columns (cells). + * + * $LicenseInfo:firstyear=2007&license=viewergpl$ + * + * Copyright (c) 2007-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LLSCROLLLISTCELL_H +#define LLSCROLLLISTCELL_H + +#include "llfontgl.h" // HAlign +#include "llpointer.h" // LLPointer<> +#include "lluistring.h" +#include "v4color.h" +#include "llui.h" + +class LLCheckBoxCtrl; +class LLSD; +class LLUIImage; + +/* + * Represents a cell in a scrollable table. + * + * Sub-classes must return height and other properties + * though width accessors are implemented by the base class. + * It is therefore important for sub-class constructors to call + * setWidth() with realistic values. + */ +class LLScrollListCell +{ +public: + struct Params : public LLInitParam::Block + { + Optional type, + column; + + Optional width; + Optional enabled, + visible; + + Optional userdata; + Optional value; + + Optional font; + Optional font_color; + Optional font_halign; + + Optional color; + + Params() + : type("type", "text"), + column("column"), + width("width"), + enabled("enabled", true), + visible("visible", true), + value("value"), + font("font", LLFontGL::getFontSansSerifSmall()), + font_color("font_color", LLColor4::black), + color("color", LLColor4::white), + font_halign("halign", LLFontGL::LEFT) + { + addSynonym(column, "name"); + addSynonym(font_color, "font-color"); + } + }; + + static LLScrollListCell* create(const Params&); + + LLScrollListCell(const LLScrollListCell::Params&); + virtual ~LLScrollListCell() {}; + virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const = 0; // truncate to given width, if possible + virtual S32 getWidth() const {return mWidth;} + virtual S32 getContentWidth() const { return 0; } + virtual S32 getHeight() const = 0; + virtual const LLSD getValue() const; + virtual void setValue(const LLSD& value) { } + virtual BOOL getVisible() const { return TRUE; } + virtual void setWidth(S32 width) { mWidth = width; } + virtual void highlightText(S32 offset, S32 num_chars) {} + virtual BOOL isText() const = 0; + virtual void setColor(const LLColor4&) {} + virtual void onCommit() {}; + + virtual BOOL handleClick() { return FALSE; } + virtual void setEnabled(BOOL enable) { } + +private: + S32 mWidth; +}; + +class LLScrollListSpacer : public LLScrollListCell +{ +public: + LLScrollListSpacer(const LLScrollListCell::Params& p) : LLScrollListCell(p) {} + /*virtual*/ ~LLScrollListSpacer() {}; + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const {} + /*virtual*/ S32 getHeight() const { return 0; } + /*virtual*/ BOOL isText() const { return FALSE; } +}; + +/* + * Cell displaying a text label. + */ +class LLScrollListText : public LLScrollListCell +{ +public: + LLScrollListText(const LLScrollListCell::Params&); + /*virtual*/ ~LLScrollListText(); + + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ S32 getContentWidth() const; + /*virtual*/ S32 getHeight() const; + /*virtual*/ void setValue(const LLSD& value); + /*virtual*/ const LLSD getValue() const; + /*virtual*/ BOOL getVisible() const; + /*virtual*/ void highlightText(S32 offset, S32 num_chars); + + /*virtual*/ void setColor(const LLColor4&); + /*virtual*/ BOOL isText() const; + + void setText(const LLStringExplicit& text); + void setFontStyle(const U8 font_style) { mFontStyle = font_style; } + +private: + LLUIString mText; + const LLFontGL* mFont; + LLColor4 mColor; + U8 mUseColor; + U8 mFontStyle; + LLFontGL::HAlign mFontAlignment; + BOOL mVisible; + S32 mHighlightCount; + S32 mHighlightOffset; + + LLPointer mRoundedRectImage; + + static U32 sCount; +}; + +/* + * Cell displaying an image. + */ +class LLScrollListIcon : public LLScrollListCell +{ +public: + LLScrollListIcon(const LLScrollListCell::Params& p); + /*virtual*/ ~LLScrollListIcon(); + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ S32 getWidth() const; + /*virtual*/ S32 getHeight() const; + /*virtual*/ const LLSD getValue() const; + /*virtual*/ void setColor(const LLColor4&); + /*virtual*/ BOOL isText()const { return FALSE; } + /*virtual*/ void setValue(const LLSD& value); + +private: + LLPointer mIcon; + LLColor4 mColor; + LLFontGL::HAlign mAlignment; +}; + +/* + * An interactive cell containing a check box. + */ +class LLScrollListCheck : public LLScrollListCell +{ +public: + LLScrollListCheck( const LLScrollListCell::Params&); + /*virtual*/ ~LLScrollListCheck(); + /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const; + /*virtual*/ S32 getHeight() const { return 0; } + /*virtual*/ const LLSD getValue() const; + /*virtual*/ void setValue(const LLSD& value); + /*virtual*/ void onCommit(); + + /*virtual*/ BOOL handleClick(); + /*virtual*/ void setEnabled(BOOL enable); + + LLCheckBoxCtrl* getCheckBox() { return mCheckBox; } + /*virtual*/ BOOL isText() const { return FALSE; } + +private: + LLCheckBoxCtrl* mCheckBox; +}; + +class LLScrollListDate : public LLScrollListText +{ +public: + LLScrollListDate( const LLScrollListCell::Params& p ); + virtual void setValue(const LLSD& value); + virtual const LLSD getValue() const; + +private: + LLDate mDate; +}; + +#endif -- cgit v1.2.3