PageRenderTime 25ms CodeModel.GetById 11ms app.highlight 11ms RepoModel.GetById 1ms 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
  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
 27#ifndef LL_LLSPINCTRL_H
 28#define LL_LLSPINCTRL_H
 29
 30
 31#include "stdtypes.h"
 32#include "llbutton.h"
 33#include "llf32uictrl.h"
 34#include "v4color.h"
 35#include "llrect.h"
 36
 37
 38class LLSpinCtrl
 39: public LLF32UICtrl
 40{
 41public:
 42	struct Params : public LLInitParam::Block<Params, LLF32UICtrl::Params>
 43	{
 44		Optional<S32> label_width;
 45		Optional<U32> decimal_digits;
 46		Optional<bool> allow_text_entry;
 47		Optional<bool> label_wrap;
 48
 49		Optional<LLUIColor> text_enabled_color;
 50		Optional<LLUIColor> text_disabled_color;
 51
 52		Optional<LLButton::Params> up_button;
 53		Optional<LLButton::Params> down_button;
 54
 55		Params();
 56	};
 57protected:
 58	LLSpinCtrl(const Params&);
 59	friend class LLUICtrlFactory;
 60public:
 61	virtual ~LLSpinCtrl() {} // Children all cleaned up by default view destructor.
 62
 63	virtual void    forceSetValue(const LLSD& value ) ;
 64	virtual void	setValue(const LLSD& value );
 65			F32		get() const { return getValueF32(); }
 66			void	set(F32 value) { setValue(value); mInitialValue = value; }
 67
 68	BOOL			isMouseHeldDown() const;
 69
 70	virtual void    setEnabled( BOOL b );
 71	virtual void	setFocus( BOOL b );
 72	virtual void	clear();
 73	virtual BOOL	isDirty() const { return( getValueF32() != mInitialValue ); }
 74	virtual void    resetDirty() { mInitialValue = getValueF32(); }
 75
 76	virtual void	setPrecision(S32 precision);
 77
 78	void			setLabel(const LLStringExplicit& label);
 79	void			setLabelColor(const LLColor4& c)			{ mTextEnabledColor = c; updateLabelColor(); }
 80	void			setDisabledLabelColor(const LLColor4& c)	{ mTextDisabledColor = c; updateLabelColor();}
 81	void			setAllowEdit(BOOL allow_edit);
 82
 83	virtual void	onTabInto();
 84
 85	virtual void	setTentative(BOOL b);			// marks value as tentative
 86	virtual void	onCommit();						// mark not tentative, then commit
 87
 88	void 			forceEditorCommit();			// for commit on external button
 89
 90	virtual BOOL	handleScrollWheel(S32 x,S32 y,S32 clicks);
 91	virtual BOOL	handleKeyHere(KEY key, MASK mask);
 92
 93	void			onEditorCommit(const LLSD& data);
 94	static void		onEditorGainFocus(LLFocusableElement* caller, void *userdata);
 95	static void		onEditorChangeFocus(LLUICtrl* caller, S32 direction, void *userdata);
 96
 97	void			onUpBtn(const LLSD& data);
 98	void			onDownBtn(const LLSD& data);
 99	
100	const LLColor4&	getEnabledTextColor() const	{ return mTextEnabledColor.get(); }
101	const LLColor4&	getDisabledTextColor() const { return mTextDisabledColor.get(); }
102
103private:
104	void			updateLabelColor();
105	void			updateEditor();
106	void			reportInvalidData();
107
108	S32				mPrecision;
109	class LLTextBox*	mLabelBox;
110
111	class LLLineEditor*	mEditor;
112	LLUIColor	mTextEnabledColor;
113	LLUIColor	mTextDisabledColor;
114
115	class LLButton*		mUpBtn;
116	class LLButton*		mDownBtn;
117
118	BOOL			mbHasBeenSet;
119	BOOL			mAllowEdit;
120};
121
122#endif  // LL_LLSPINCTRL_H