PageRenderTime 124ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/llspinctrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 122 lines | 71 code | 26 blank | 25 comment | 1 complexity | e7fdaf9d55f8c3bd4561c9f9b713a57f MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llspinctrl.h
  3. * @brief Typical spinner with "up" and "down" arrow buttons.
  4. *
  5. * $LicenseInfo:firstyear=2002&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_LLSPINCTRL_H
  27. #define LL_LLSPINCTRL_H
  28. #include "stdtypes.h"
  29. #include "llbutton.h"
  30. #include "llf32uictrl.h"
  31. #include "v4color.h"
  32. #include "llrect.h"
  33. class LLSpinCtrl
  34. : public LLF32UICtrl
  35. {
  36. public:
  37. struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
  38. {
  39. Optional<S32> label_width;
  40. Optional<U32> decimal_digits;
  41. Optional<bool> allow_text_entry;
  42. Optional<bool> label_wrap;
  43. Optional<LLUIColor> text_enabled_color;
  44. Optional<LLUIColor> text_disabled_color;
  45. Optional<LLButton::Params> up_button;
  46. Optional<LLButton::Params> down_button;
  47. Params();
  48. };
  49. protected:
  50. LLSpinCtrl(const Params&);
  51. friend class LLUICtrlFactory;
  52. public:
  53. virtual ~LLSpinCtrl() {} // Children all cleaned up by default view destructor.
  54. virtual void forceSetValue(const LLSD& value ) ;
  55. virtual void setValue(const LLSD& value );
  56. F32 get() const { return getValueF32(); }
  57. void set(F32 value) { setValue(value); mInitialValue = value; }
  58. BOOL isMouseHeldDown() const;
  59. virtual void setEnabled( BOOL b );
  60. virtual void setFocus( BOOL b );
  61. virtual void clear();
  62. virtual BOOL isDirty() const { return( getValueF32() != mInitialValue ); }
  63. virtual void resetDirty() { mInitialValue = getValueF32(); }
  64. virtual void setPrecision(S32 precision);
  65. void setLabel(const LLStringExplicit& label);
  66. void setLabelColor(const LLColor4& c) { mTextEnabledColor = c; updateLabelColor(); }
  67. void setDisabledLabelColor(const LLColor4& c) { mTextDisabledColor = c; updateLabelColor();}
  68. void setAllowEdit(BOOL allow_edit);
  69. virtual void onTabInto();
  70. virtual void setTentative(BOOL b); // marks value as tentative
  71. virtual void onCommit(); // mark not tentative, then commit
  72. void forceEditorCommit(); // for commit on external button
  73. virtual BOOL handleScrollWheel(S32 x,S32 y,S32 clicks);
  74. virtual BOOL handleKeyHere(KEY key, MASK mask);
  75. void onEditorCommit(const LLSD& data);
  76. static void onEditorGainFocus(LLFocusableElement* caller, void *userdata);
  77. static void onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
  78. void onUpBtn(const LLSD& data);
  79. void onDownBtn(const LLSD& data);
  80. const LLColor4& getEnabledTextColor() const { return mTextEnabledColor.get(); }
  81. const LLColor4& getDisabledTextColor() const { return mTextDisabledColor.get(); }
  82. private:
  83. void updateLabelColor();
  84. void updateEditor();
  85. void reportInvalidData();
  86. S32 mPrecision;
  87. class LLTextBox* mLabelBox;
  88. class LLLineEditor* mEditor;
  89. LLUIColor mTextEnabledColor;
  90. LLUIColor mTextDisabledColor;
  91. class LLButton* mUpBtn;
  92. class LLButton* mDownBtn;
  93. BOOL mbHasBeenSet;
  94. BOOL mAllowEdit;
  95. };
  96. #endif // LL_LLSPINCTRL_H