PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/lltimectrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 131 lines | 77 code | 29 blank | 25 comment | 0 complexity | 3328ad3d09e5be7d926e4feae01d2d78 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltimectrl.h
  3. * @brief Time control
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2011, 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 LLTIMECTRL_H_
  27. #define LLTIMECTRL_H_
  28. #include "stdtypes.h"
  29. #include "llbutton.h"
  30. #include "v4color.h"
  31. #include "llrect.h"
  32. class LLLineEditor;
  33. class LLTimeCtrl
  34. : public LLUICtrl
  35. {
  36. LOG_CLASS(LLTimeCtrl);
  37. public:
  38. struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
  39. {
  40. Optional<S32> label_width;
  41. Optional<S32> snap_to;
  42. Optional<bool> allow_text_entry;
  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. F32 getTime24() const; // 0.0 - 24.0
  50. U32 getHours24() const; // 0 - 23
  51. U32 getMinutes() const; // 0 - 59
  52. void setTime24(F32 time); // 0.0 - 23.98(3)
  53. protected:
  54. LLTimeCtrl(const Params&);
  55. friend class LLUICtrlFactory;
  56. private:
  57. enum EDayPeriod
  58. {
  59. AM,
  60. PM
  61. };
  62. enum EEditingPart
  63. {
  64. HOURS,
  65. MINUTES,
  66. DAYPART,
  67. NONE
  68. };
  69. virtual void onFocusLost();
  70. virtual BOOL handleKeyHere(KEY key, MASK mask);
  71. void onUpBtn();
  72. void onDownBtn();
  73. void onTextEntry(LLLineEditor* line_editor);
  74. bool isTimeStringValid(const LLWString& wstr);
  75. void increaseMinutes();
  76. void increaseHours();
  77. void decreaseMinutes();
  78. void decreaseHours();
  79. bool isPM() const;
  80. void switchDayPeriod();
  81. void updateText();
  82. EEditingPart getEditingPart();
  83. static std::string getHoursString(const std::string& str);
  84. static std::string getMinutesString(const std::string& str);
  85. static std::string getAMPMString(const std::string& str);
  86. static bool isHoursStringValid(const std::string& str);
  87. static bool isMinutesStringValid(const std::string& str);
  88. static bool isPMAMStringValid(const std::string& str);
  89. static U32 parseHours(const std::string& str);
  90. static U32 parseMinutes(const std::string& str);
  91. static bool parseAMPM(const std::string& str);
  92. class LLTextBox* mLabelBox;
  93. class LLLineEditor* mEditor;
  94. LLUIColor mTextEnabledColor;
  95. LLUIColor mTextDisabledColor;
  96. class LLButton* mUpBtn;
  97. class LLButton* mDownBtn;
  98. U32 mTime; // minutes since midnight: 0 - 1439
  99. U32 mSnapToMin; // interval in minutes to snap to
  100. BOOL mAllowEdit;
  101. };
  102. #endif /* LLTIMECTRL_H_ */