PageRenderTime 362ms CodeModel.GetById 348ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llcheckboxctrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 127 lines | 62 code | 29 blank | 36 comment | 0 complexity | a4d99d9f73c95c4b6f64390874d79cc1 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llcheckboxctrl.h
  3. * @brief LLCheckBoxCtrl base class
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLCHECKBOXCTRL_H
  27. #define LL_LLCHECKBOXCTRL_H
  28. #include "lluictrl.h"
  29. #include "llbutton.h"
  30. #include "lltextbox.h"
  31. #include "v4color.h"
  32. //
  33. // Constants
  34. //
  35. const BOOL RADIO_STYLE = TRUE;
  36. const BOOL CHECK_STYLE = FALSE;
  37. //
  38. // Classes
  39. //
  40. class LLFontGL;
  41. class LLViewBorder;
  42. class LLCheckBoxCtrl
  43. : public LLUICtrl
  44. {
  45. public:
  46. struct Params
  47. : public LLInitParam::Block<Params, LLUICtrl::Params>
  48. {
  49. Optional<bool> initial_value; // override LLUICtrl initial_value
  50. Optional<LLTextBox::Params> label_text;
  51. Optional<LLButton::Params> check_button;
  52. Ignored radio_style;
  53. Params();
  54. };
  55. virtual ~LLCheckBoxCtrl();
  56. protected:
  57. LLCheckBoxCtrl(const Params&);
  58. friend class LLUICtrlFactory;
  59. public:
  60. // LLView interface
  61. virtual void setEnabled( BOOL b );
  62. virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
  63. // LLUICtrl interface
  64. virtual void setValue(const LLSD& value );
  65. virtual LLSD getValue() const;
  66. BOOL get() { return (BOOL)getValue().asBoolean(); }
  67. void set(BOOL value) { setValue(value); }
  68. virtual void setTentative(BOOL b);
  69. virtual BOOL getTentative() const;
  70. virtual BOOL setLabelArg( const std::string& key, const LLStringExplicit& text );
  71. virtual void clear();
  72. virtual void onCommit();
  73. // LLCheckBoxCtrl interface
  74. virtual BOOL toggle() { return mButton->toggleState(); } // returns new state
  75. void setEnabledColor( const LLColor4 &color ) { mTextEnabledColor = color; }
  76. void setDisabledColor( const LLColor4 &color ) { mTextDisabledColor = color; }
  77. void setLabel( const LLStringExplicit& label );
  78. std::string getLabel() const;
  79. void setFont( const LLFontGL* font ) { mFont = font; }
  80. const LLFontGL* getFont() { return mFont; }
  81. virtual void setControlName(const std::string& control_name, LLView* context);
  82. void onButtonPress(const LLSD& data);
  83. virtual BOOL isDirty() const; // Returns TRUE if the user has modified this control.
  84. virtual void resetDirty(); // Clear dirty state
  85. protected:
  86. // note: value is stored in toggle state of button
  87. LLButton* mButton;
  88. LLTextBox* mLabel;
  89. const LLFontGL* mFont;
  90. LLUIColor mTextEnabledColor;
  91. LLUIColor mTextDisabledColor;
  92. };
  93. // Build time optimization, generate once in .cpp file
  94. #ifndef LLCHECKBOXCTRL_CPP
  95. extern template class LLCheckBoxCtrl* LLView::getChild<class LLCheckBoxCtrl>(
  96. const std::string& name, BOOL recurse) const;
  97. #endif
  98. #endif // LL_LLCHECKBOXCTRL_H