/** * @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 { Optional label_width; Optional allow_text_entry; Optional text_enabled_color; Optional text_disabled_color; Optional up_button; Optional 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_ */