PageRenderTime 17ms CodeModel.GetById 1ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llcheckboxctrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 127 lines | 62 code | 29 blank | 36 comment | 0 complexity | a4d99d9f73c95c4b6f64390874d79cc1 MD5 | raw file
  1/** 
  2 * @file llcheckboxctrl.h
  3 * @brief LLCheckBoxCtrl base class
  4 *
  5 * $LicenseInfo:firstyear=2001&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_LLCHECKBOXCTRL_H
 28#define LL_LLCHECKBOXCTRL_H
 29
 30#include "lluictrl.h"
 31#include "llbutton.h"
 32#include "lltextbox.h"
 33#include "v4color.h"
 34
 35//
 36// Constants
 37//
 38
 39const BOOL	RADIO_STYLE = TRUE;
 40const BOOL	CHECK_STYLE = FALSE;
 41
 42//
 43// Classes
 44//
 45class LLFontGL;
 46class LLViewBorder;
 47
 48class LLCheckBoxCtrl
 49: public LLUICtrl
 50{
 51public:
 52	struct Params 
 53	:	public LLInitParam::Block<Params, LLUICtrl::Params>
 54	{
 55		Optional<bool>			initial_value;	// override LLUICtrl initial_value
 56
 57		Optional<LLTextBox::Params> label_text;
 58		Optional<LLButton::Params> check_button;
 59
 60		Ignored					radio_style;
 61
 62		Params();
 63	};
 64
 65	virtual ~LLCheckBoxCtrl();
 66
 67protected:
 68	LLCheckBoxCtrl(const Params&);
 69	friend class LLUICtrlFactory;
 70
 71public:
 72	// LLView interface
 73
 74	virtual void		setEnabled( BOOL b );
 75
 76	virtual void		reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
 77
 78	// LLUICtrl interface
 79	virtual void		setValue(const LLSD& value );
 80	virtual LLSD		getValue() const;
 81			BOOL		get() { return (BOOL)getValue().asBoolean(); }
 82			void		set(BOOL value) { setValue(value); }
 83
 84	virtual void		setTentative(BOOL b);
 85	virtual BOOL		getTentative() const;
 86
 87	virtual BOOL		setLabelArg( const std::string& key, const LLStringExplicit& text );
 88
 89	virtual void		clear();
 90	virtual void		onCommit();
 91
 92	// LLCheckBoxCtrl interface
 93	virtual BOOL		toggle()				{ return mButton->toggleState(); }		// returns new state
 94
 95	void				setEnabledColor( const LLColor4 &color ) { mTextEnabledColor = color; }
 96	void				setDisabledColor( const LLColor4 &color ) { mTextDisabledColor = color; }
 97
 98	void				setLabel( const LLStringExplicit& label );
 99	std::string			getLabel() const;
100
101	void				setFont( const LLFontGL* font ) { mFont = font; }
102	const LLFontGL*		getFont() { return mFont; }
103	
104	virtual void		setControlName(const std::string& control_name, LLView* context);
105
106	void				onButtonPress(const LLSD& data);
107
108	virtual BOOL		isDirty()	const;		// Returns TRUE if the user has modified this control.
109	virtual void		resetDirty();			// Clear dirty state
110
111protected:
112	// note: value is stored in toggle state of button
113	LLButton*		mButton;
114	LLTextBox*		mLabel;
115	const LLFontGL* mFont;
116
117	LLUIColor		mTextEnabledColor;
118	LLUIColor		mTextDisabledColor;
119};
120
121// Build time optimization, generate once in .cpp file
122#ifndef LLCHECKBOXCTRL_CPP
123extern template class LLCheckBoxCtrl* LLView::getChild<class LLCheckBoxCtrl>(
124	const std::string& name, BOOL recurse) const;
125#endif
126
127#endif  // LL_LLCHECKBOXCTRL_H