PageRenderTime 48ms CodeModel.GetById 35ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/lltextbox.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 84 lines | 39 code | 18 blank | 27 comment | 0 complexity | 2039764b2ddf069c168ce498cda9e8d7 MD5 | raw file
 1/** 
 2 * @file lltextbox.h
 3 * @brief A single text item display
 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_LLTEXTBOX_H
28#define LL_LLTEXTBOX_H
29
30#include "lluistring.h"
31#include "lltextbase.h"
32
33class LLTextBox :
34	public LLTextBase
35{
36public:
37	
38	// *TODO: Add callback to Params
39	typedef boost::function<void (void)> callback_t;
40	
41	struct Params : public LLInitParam::Block<Params, LLTextBase::Params>
42	{};
43
44protected:
45	LLTextBox(const Params&);
46	friend class LLUICtrlFactory;
47
48public:
49	virtual ~LLTextBox();
50
51	/*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
52	/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
53	/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
54
55	/*virtual*/ void setEnabled(BOOL enabled);
56
57	/*virtual*/ void setText( const LLStringExplicit& text, const LLStyle::Params& input_params = LLStyle::Params() );
58	
59	void			setRightAlign()							{ mHAlign = LLFontGL::RIGHT; }
60	void			setHAlign( LLFontGL::HAlign align )		{ mHAlign = align; }
61	void			setClickedCallback( boost::function<void (void*)> cb, void* userdata = NULL );
62
63	void			reshapeToFitText();
64
65	S32				getTextPixelWidth();
66	S32				getTextPixelHeight();
67
68	/*virtual*/ LLSD	getValue() const;
69	/*virtual*/ BOOL	setTextArg( const std::string& key, const LLStringExplicit& text );
70
71protected:
72	void            onUrlLabelUpdated(const std::string &url, const std::string &label);
73
74	LLUIString			mText;
75	callback_t			mClickedCallback;
76};
77
78// Build time optimization, generate once in .cpp file
79#ifndef LLTEXTBOX_CPP
80extern template class LLTextBox* LLView::getChild<class LLTextBox>(
81	const std::string& name, BOOL recurse) const;
82#endif
83
84#endif