PageRenderTime 181ms CodeModel.GetById 11ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LLSCROLLLISTCELL_H
  28. #define LLSCROLLLISTCELL_H
  29. #include "llfontgl.h" // HAlign
  30. #include "llpointer.h" // LLPointer<>
  31. #include "lluistring.h"
  32. #include "v4color.h"
  33. #include "llui.h"
  34. class LLCheckBoxCtrl;
  35. class LLSD;
  36. class LLUIImage;
  37. /*
  38. * Represents a cell in a scrollable table.
  39. *
  40. * Sub-classes must return height and other properties
  41. * though width accessors are implemented by the base class.
  42. * It is therefore important for sub-class constructors to call
  43. * setWidth() with realistic values.
  44. */
  45. class LLScrollListCell
  46. {
  47. public:
  48. struct Params : public LLInitParam::Block<Params>
  49. {
  50. Optional<std::string> type,
  51. column;
  52. Optional<S32> width;
  53. Optional<bool> enabled,
  54. visible;
  55. Optional<void*> userdata;
  56. Optional<LLSD> value;
  57. Optional<std::string> tool_tip;
  58. Optional<const LLFontGL*> font;
  59. Optional<LLColor4> font_color;
  60. Optional<LLFontGL::HAlign> font_halign;
  61. Optional<LLColor4> color;
  62. Params()
  63. : type("type", "text"),
  64. column("column"),
  65. width("width"),
  66. enabled("enabled", true),
  67. visible("visible", true),
  68. value("value"),
  69. tool_tip("tool_tip", ""),
  70. font("font", LLFontGL::getFontSansSerifSmall()),
  71. font_color("font_color", LLColor4::black),
  72. color("color", LLColor4::white),
  73. font_halign("halign", LLFontGL::LEFT)
  74. {
  75. addSynonym(column, "name");
  76. addSynonym(font_color, "font-color");
  77. }
  78. };
  79. static LLScrollListCell* create(const Params&);
  80. LLScrollListCell(const LLScrollListCell::Params&);
  81. virtual ~LLScrollListCell() {};
  82. virtual void draw(const LLColor4& color, const LLColor4& highlight_color) const {}; // truncate to given width, if possible
  83. virtual S32 getWidth() const {return mWidth;}
  84. virtual S32 getContentWidth() const { return 0; }
  85. virtual S32 getHeight() const { return 0; }
  86. virtual const LLSD getValue() const;
  87. virtual void setValue(const LLSD& value) { }
  88. virtual const std::string &getToolTip() const { return mToolTip; }
  89. virtual void setToolTip(const std::string &str) { mToolTip = str; }
  90. virtual BOOL getVisible() const { return TRUE; }
  91. virtual void setWidth(S32 width) { mWidth = width; }
  92. virtual void highlightText(S32 offset, S32 num_chars) {}
  93. virtual BOOL isText() const { return FALSE; }
  94. virtual BOOL needsToolTip() const { return ! mToolTip.empty(); }
  95. virtual void setColor(const LLColor4&) {}
  96. virtual void onCommit() {};
  97. virtual BOOL handleClick() { return FALSE; }
  98. virtual void setEnabled(BOOL enable) { }
  99. private:
  100. S32 mWidth;
  101. std::string mToolTip;
  102. };
  103. class LLScrollListSpacer : public LLScrollListCell
  104. {
  105. public:
  106. LLScrollListSpacer(const LLScrollListCell::Params& p) : LLScrollListCell(p) {}
  107. /*virtual*/ ~LLScrollListSpacer() {};
  108. /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const {}
  109. };
  110. /*
  111. * Cell displaying a text label.
  112. */
  113. class LLScrollListText : public LLScrollListCell
  114. {
  115. public:
  116. LLScrollListText(const LLScrollListCell::Params&);
  117. /*virtual*/ ~LLScrollListText();
  118. /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
  119. /*virtual*/ S32 getContentWidth() const;
  120. /*virtual*/ S32 getHeight() const;
  121. /*virtual*/ void setValue(const LLSD& value);
  122. /*virtual*/ const LLSD getValue() const;
  123. /*virtual*/ BOOL getVisible() const;
  124. /*virtual*/ void highlightText(S32 offset, S32 num_chars);
  125. /*virtual*/ void setColor(const LLColor4&);
  126. /*virtual*/ BOOL isText() const;
  127. /*virtual*/ const std::string & getToolTip() const;
  128. /*virtual*/ BOOL needsToolTip() const;
  129. S32 getTextWidth() const { return mTextWidth;}
  130. void setTextWidth(S32 value) { mTextWidth = value;}
  131. virtual void setWidth(S32 width) { LLScrollListCell::setWidth(width); mTextWidth = width; }
  132. void setText(const LLStringExplicit& text);
  133. void setFontStyle(const U8 font_style);
  134. private:
  135. LLUIString mText;
  136. S32 mTextWidth;
  137. const LLFontGL* mFont;
  138. LLColor4 mColor;
  139. U8 mUseColor;
  140. LLFontGL::HAlign mFontAlignment;
  141. BOOL mVisible;
  142. S32 mHighlightCount;
  143. S32 mHighlightOffset;
  144. LLPointer<LLUIImage> mRoundedRectImage;
  145. static U32 sCount;
  146. };
  147. /*
  148. * Cell displaying an image.
  149. */
  150. class LLScrollListIcon : public LLScrollListCell
  151. {
  152. public:
  153. LLScrollListIcon(const LLScrollListCell::Params& p);
  154. /*virtual*/ ~LLScrollListIcon();
  155. /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
  156. /*virtual*/ S32 getWidth() const;
  157. /*virtual*/ S32 getHeight() const;
  158. /*virtual*/ const LLSD getValue() const;
  159. /*virtual*/ void setColor(const LLColor4&);
  160. /*virtual*/ void setValue(const LLSD& value);
  161. private:
  162. LLPointer<LLUIImage> mIcon;
  163. LLColor4 mColor;
  164. LLFontGL::HAlign mAlignment;
  165. };
  166. /*
  167. * An interactive cell containing a check box.
  168. */
  169. class LLScrollListCheck : public LLScrollListCell
  170. {
  171. public:
  172. LLScrollListCheck( const LLScrollListCell::Params&);
  173. /*virtual*/ ~LLScrollListCheck();
  174. /*virtual*/ void draw(const LLColor4& color, const LLColor4& highlight_color) const;
  175. /*virtual*/ S32 getHeight() const { return 0; }
  176. /*virtual*/ const LLSD getValue() const;
  177. /*virtual*/ void setValue(const LLSD& value);
  178. /*virtual*/ void onCommit();
  179. /*virtual*/ BOOL handleClick();
  180. /*virtual*/ void setEnabled(BOOL enable);
  181. LLCheckBoxCtrl* getCheckBox() { return mCheckBox; }
  182. private:
  183. LLCheckBoxCtrl* mCheckBox;
  184. };
  185. class LLScrollListDate : public LLScrollListText
  186. {
  187. public:
  188. LLScrollListDate( const LLScrollListCell::Params& p );
  189. virtual void setValue(const LLSD& value);
  190. virtual const LLSD getValue() const;
  191. private:
  192. LLDate mDate;
  193. };
  194. #endif