llstyle.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * @file llstyle.h
  3. * @brief Text style class
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLSTYLE_H
  33. #define LL_LLSTYLE_H
  34. #include "llcolor4.h"
  35. #include "llfontgl.h"
  36. #include "llui.h"
  37. class LLFontGL;
  38. class LLStyle : public LLRefCount
  39. {
  40. public:
  41. LLStyle();
  42. LLStyle(const LLStyle& style);
  43. LLStyle(bool is_visible, const LLColor4& color,
  44. const std::string& font_name);
  45. protected:
  46. ~LLStyle() override = default;
  47. public:
  48. LLStyle& operator=(const LLStyle& rhs);
  49. virtual void init(bool is_visible, const LLColor4& color,
  50. const std::string& font_name);
  51. LL_INLINE virtual const LLColor4& getColor() const { return mColor; }
  52. LL_INLINE virtual void setColor(const LLColor4& color) { mColor = color; }
  53. LL_INLINE virtual bool isVisible() const { return mVisible; }
  54. LL_INLINE virtual void setVisible(bool is_visible) { mVisible = is_visible; }
  55. LL_INLINE virtual const std::string& getFontString() const { return mFontName; }
  56. virtual void setFontName(const std::string& fontname);
  57. LL_INLINE virtual LLFONT_ID getFontID() const { return mFontID; }
  58. LL_INLINE virtual const std::string& getLinkHREF() const { return mLink; }
  59. LL_INLINE virtual void setLinkHREF(const std::string& href) { mLink = href; }
  60. LL_INLINE virtual bool isLink() const { return mLink.size(); }
  61. LL_INLINE virtual LLUIImagePtr getImage() const { return mImagep; }
  62. LL_INLINE virtual void setImage(const LLUUID& src) { mImagep = LLUI::getUIImageByID(src); }
  63. LL_INLINE virtual bool isImage() const { return mImageWidth != 0 && mImageHeight != 0; }
  64. LL_INLINE virtual void setImageSize(S32 width, S32 height) { mImageWidth = width; mImageHeight = height; }
  65. LL_INLINE bool getIsEmbeddedItem() const { return mIsEmbeddedItem; }
  66. LL_INLINE void setIsEmbeddedItem(bool b) { mIsEmbeddedItem = b; }
  67. // Inlined here to make it easier to compare to member data below. - MG
  68. LL_INLINE bool operator==(const LLStyle& rhs) const
  69. {
  70. return mVisible == rhs.isVisible() && mColor == rhs.getColor() &&
  71. mFontName == rhs.getFontString() &&
  72. mLink == rhs.getLinkHREF() && mImagep == rhs.mImagep &&
  73. mImageHeight == rhs.mImageHeight &&
  74. mImageWidth == rhs.mImageWidth && mItalic == rhs.mItalic &&
  75. mBold == rhs.mBold && mUnderline == rhs.mUnderline &&
  76. mDropShadow == rhs.mDropShadow &&
  77. mIsEmbeddedItem == rhs.mIsEmbeddedItem;
  78. }
  79. LL_INLINE bool operator!=(const LLStyle& rhs) const { return !(*this == rhs); }
  80. private:
  81. // Note: the first member variable is 32 bits in order to align on 64 bits
  82. // for the next variables, counting the 32 bits counter from LLRefCount. HB
  83. LLFONT_ID mFontID;
  84. std::string mFontName;
  85. std::string mLink;
  86. LLColor4 mColor;
  87. LLUIImagePtr mImagep;
  88. public:
  89. S32 mImageWidth;
  90. S32 mImageHeight;
  91. public:
  92. bool mItalic;
  93. bool mBold;
  94. bool mUnderline;
  95. bool mDropShadow;
  96. private:
  97. bool mVisible;
  98. bool mIsEmbeddedItem;
  99. };
  100. typedef LLPointer<LLStyle> LLStyleSP;
  101. #endif // LL_LLSTYLE_H