llviewborder.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * @file llviewborder.h
  3. * @brief A customizable decorative border. Does not interact with mouse events.
  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_LLVIEWBORDER_H
  33. #define LL_LLVIEWBORDER_H
  34. #include "llview.h"
  35. class LLViewBorder : public LLView
  36. {
  37. public:
  38. enum EBevel { BEVEL_IN, BEVEL_OUT, BEVEL_BRIGHT, BEVEL_NONE };
  39. enum EStyle { STYLE_LINE, STYLE_TEXTURE };
  40. LLViewBorder(const std::string& name,
  41. const LLRect& rect,
  42. EBevel bevel = BEVEL_OUT,
  43. EStyle style = STYLE_LINE,
  44. S32 width = 1);
  45. // LLUICtrl functionality
  46. LL_INLINE void setValue(const LLSD& val) override { setRect(LLRect(val)); }
  47. // LLView functionality
  48. LL_INLINE bool isCtrl() const override { return false; }
  49. void draw() override;
  50. const std::string& getTag() const override;
  51. LLXMLNodePtr getXML(bool save_children = true) const override;
  52. static LLView* fromXML(LLXMLNodePtr node, LLView* parent,
  53. class LLUICtrlFactory* factory);
  54. static bool getBevelFromAttribute(LLXMLNodePtr node,
  55. LLViewBorder::EBevel& bevel_style);
  56. LL_INLINE void setBorderWidth(S32 width) { mBorderWidth = width; }
  57. LL_INLINE S32 getBorderWidth() const { return mBorderWidth; }
  58. LL_INLINE void setBevel(EBevel bevel) { mBevel = bevel; }
  59. LL_INLINE EBevel getBevel() const { return mBevel; }
  60. void setColors(const LLColor4& shadow_dark,
  61. const LLColor4& highlight_light);
  62. void setColorsExtended(const LLColor4& shadow_light,
  63. const LLColor4& shadow_dark,
  64. const LLColor4& highlight_light,
  65. const LLColor4& highlight_dark);
  66. void setTexture(const class LLUUID& image_id);
  67. LL_INLINE LLColor4 getHighlightLight() { return mHighlightLight; }
  68. LL_INLINE LLColor4 getShadowDark() { return mHighlightDark; }
  69. LL_INLINE EStyle getStyle() const { return mStyle; }
  70. LL_INLINE void setKeyboardFocusHighlight(bool b) { mHasKeyboardFocus = b; }
  71. private:
  72. void drawOnePixelLines();
  73. void drawTwoPixelLines();
  74. private:
  75. LLColor4 mHighlightLight;
  76. LLColor4 mHighlightDark;
  77. LLColor4 mShadowLight;
  78. LLColor4 mShadowDark;
  79. LLColor4 mBackgroundColor;
  80. S32 mBorderWidth;
  81. LLUIImagePtr mTexture;
  82. EBevel mBevel;
  83. const EStyle mStyle;
  84. bool mHasKeyboardFocus;
  85. };
  86. #endif // LL_LLVIEWBORDER_H