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

/indra/llui/llsearcheditor.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 96 lines | 47 code | 14 blank | 35 comment | 1 complexity | 1e2ee0a47a2052498bea8ad8541a9ecc MD5 | raw file
 1/** 
 2 * @file llsearcheditor.h
 3 * @brief Text editor widget that represents a search operation
 4 *
 5 * Features: 
 6 *		Text entry of a single line (text, delete, left and right arrow, insert, return).
 7 *		Callbacks either on every keystroke or just on the return key.
 8 *		Focus (allow multiple text entry widgets)
 9 *		Clipboard (cut, copy, and paste)
10 *		Horizontal scrolling to allow strings longer than widget size allows 
11 *		Pre-validation (limit which keys can be used)
12 *		Optional line history so previous entries can be recalled by CTRL UP/DOWN
13 *
14 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
15 * Second Life Viewer Source Code
16 * Copyright (C) 2010, Linden Research, Inc.
17 * 
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Lesser General Public
20 * License as published by the Free Software Foundation;
21 * version 2.1 of the License only.
22 * 
23 * This library is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26 * Lesser General Public License for more details.
27 * 
28 * You should have received a copy of the GNU Lesser General Public
29 * License along with this library; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
31 * 
32 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
33 * $/LicenseInfo$
34 */
35
36#ifndef LL_SEARCHEDITOR_H
37#define LL_SEARCHEDITOR_H
38
39#include "lllineeditor.h"
40#include "llbutton.h"
41
42class LLSearchEditor : public LLUICtrl
43{
44public:
45	struct Params : public LLInitParam::Block<Params, LLLineEditor::Params>
46	{
47		Optional<LLButton::Params>	search_button, 
48									clear_button;
49		Optional<bool>				search_button_visible, 
50									clear_button_visible;
51		Optional<commit_callback_t> keystroke_callback;
52
53		Params()
54		:	search_button("search_button"),
55			search_button_visible("search_button_visible"),
56			clear_button("clear_button"), 
57			clear_button_visible("clear_button_visible")
58		{}
59	};
60
61	void setCommitOnFocusLost(BOOL b)	{ if (mSearchEditor) mSearchEditor->setCommitOnFocusLost(b); }
62
63protected:
64	LLSearchEditor(const Params&);
65	friend class LLUICtrlFactory;
66
67public:
68	virtual ~LLSearchEditor() {}
69
70	/*virtual*/ void	draw();
71
72	void setText(const LLStringExplicit &new_text) { mSearchEditor->setText(new_text); }
73	const std::string& getText() const		{ return mSearchEditor->getText(); }
74
75	// LLUICtrl interface
76	virtual void	setValue(const LLSD& value );
77	virtual LLSD	getValue() const;
78	virtual BOOL	setTextArg( const std::string& key, const LLStringExplicit& text );
79	virtual BOOL	setLabelArg( const std::string& key, const LLStringExplicit& text );
80	virtual void	setLabel( const LLStringExplicit &new_label );
81	virtual void	clear();
82	virtual void	setFocus( BOOL b );
83
84	void			setKeystrokeCallback( commit_callback_t cb ) { mKeystrokeCallback = cb; }
85
86protected:
87	void onClearButtonClick(const LLSD& data);
88	virtual void handleKeystroke();
89
90	commit_callback_t mKeystrokeCallback;
91	LLLineEditor* mSearchEditor;
92	LLButton* mSearchButton;
93	LLButton* mClearButton;
94};
95
96#endif  // LL_SEARCHEDITOR_H