diff options
Diffstat (limited to 'indra/llui/lltimectrl.h')
-rw-r--r-- | indra/llui/lltimectrl.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/indra/llui/lltimectrl.h b/indra/llui/lltimectrl.h new file mode 100644 index 0000000000..81d4477da4 --- /dev/null +++ b/indra/llui/lltimectrl.h @@ -0,0 +1,125 @@ +/** + * @file lltimectrl.h + * @brief Time control + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LLTIMECTRL_H_ +#define LLTIMECTRL_H_ + +#include "stdtypes.h" +#include "llbutton.h" +#include "v4color.h" +#include "llrect.h" + +class LLLineEditor; + +class LLTimeCtrl +: public LLUICtrl +{ +public: + struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> + { + Optional<S32> label_width; + Optional<bool> allow_text_entry; + + Optional<LLUIColor> text_enabled_color; + Optional<LLUIColor> text_disabled_color; + + Optional<LLButton::Params> up_button; + Optional<LLButton::Params> down_button; + + Params(); + }; +protected: + LLTimeCtrl(const Params&); + friend class LLUICtrlFactory; + + U32 getHours() const { return mHours; } + U32 getMinutes() const { return mMinutes; } + +private: + + enum EDayPeriod + { + AM, + PM + }; + + enum EEditingPart + { + HOURS, + MINUTES, + DAYPART, + NONE + }; + + virtual void onFocusLost(); + virtual BOOL handleKeyHere(KEY key, MASK mask); + + void onUpBtn(); + void onDownBtn(); + + void onTextEntry(LLLineEditor* line_editor); + + void validateHours(const LLWString& wstr); + void validateMinutes(const LLWString& wstr); + bool isTimeStringValid(const LLWString& wstr); + + bool isPMAMStringValid(const LLWString& wstr); + bool isHoursStringValid(const LLWString& wstr); + bool isMinutesStringValid(const LLWString& wstr); + + LLWString getHoursWString(const LLWString& wstr); + LLWString getMinutesWString(const LLWString& wstr); + + void increaseMinutes(); + void increaseHours(); + + void decreaseMinutes(); + void decreaseHours(); + + void switchDayPeriod(); + + void buildTimeString(); + + EEditingPart getEditingPart(); + + class LLTextBox* mLabelBox; + + class LLLineEditor* mEditor; + LLUIColor mTextEnabledColor; + LLUIColor mTextDisabledColor; + + class LLButton* mUpBtn; + class LLButton* mDownBtn; + + U32 mHours; + U32 mMinutes; + EDayPeriod mCurrentDayPeriod; + + std::string mTimeString; + + BOOL mAllowEdit; +}; +#endif /* LLTIMECTRL_H_ */ |