PageRenderTime 59ms CodeModel.GetById 52ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llurllineeditorctrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 92 lines | 50 code | 13 blank | 29 comment | 0 complexity | 1933c70dd34902108b5408d555c502f3 MD5 | raw file
 1/** 
 2 * @file llurllineeditorctrl.h
 3 * @brief Combobox-like location input control
 4 *
 5 * $LicenseInfo:firstyear=2009&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 LLURLLINEEDITOR_H_
28#define LLURLLINEEDITOR_H_
29
30#include "linden_common.h"
31
32#include "lllineeditor.h"
33#include "lluictrl.h"
34
35// LLURLLineEditor class performing escaping of an URL while copying or cutting the target text
36class LLURLLineEditor: public LLLineEditor {
37	LOG_CLASS( LLURLLineEditor);
38
39public:
40	// LLLineEditor overrides to do necessary escaping
41	/*virtual*/		void copy();
42	/*virtual*/ 	void cut();
43
44protected:
45	LLURLLineEditor(const Params&);
46	friend class LLUICtrlFactory;
47	friend class LLFloaterEditUI;
48
49private:
50	// util function to escape selected text and copy it to clipboard
51	void 			copyEscapedURLToClipboard();
52
53	// Helper class to do rollback if needed
54	class LLURLLineEditorRollback
55	{
56	public:
57		LLURLLineEditorRollback( LLURLLineEditor* ed )
58			:
59			mCursorPos( ed->mCursorPos ),
60			mScrollHPos( ed->mScrollHPos ),
61			mIsSelecting( ed->mIsSelecting ),
62			mSelectionStart( ed->mSelectionStart ),
63			mSelectionEnd( ed->mSelectionEnd )
64		{
65			mText = ed->getText();
66		}
67
68		void doRollback( LLURLLineEditor* ed )
69		{
70			ed->mCursorPos = mCursorPos;
71			ed->mScrollHPos = mScrollHPos;
72			ed->mIsSelecting = mIsSelecting;
73			ed->mSelectionStart = mSelectionStart;
74			ed->mSelectionEnd = mSelectionEnd;
75			ed->mText = mText;
76			ed->mPrevText = mText;
77		}
78
79		std::string getText()   { return mText; }
80
81	private:
82		std::string mText;
83		S32		mCursorPos;
84		S32		mScrollHPos;
85		BOOL	mIsSelecting;
86		S32		mSelectionStart;
87		S32		mSelectionEnd;
88	}; // end class LLURLLineEditorRollback
89
90};
91
92#endif /* LLURLLINEEDITOR_H_ */