PageRenderTime 52ms CodeModel.GetById 15ms app.highlight 32ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lllocationinputctrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 196 lines | 130 code | 22 blank | 44 comment | 0 complexity | 11d60917263fac4285c6b457520e9a4e MD5 | raw file
  1/** 
  2 * @file lllocationinputctrl.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 LL_LLLOCATIONINPUTCTRL_H
 28#define LL_LLLOCATIONINPUTCTRL_H
 29
 30#include "llcombobox.h"
 31#include "lliconctrl.h"		// Params
 32#include "lltextbox.h"		// Params
 33#include "lllocationhistory.h"
 34
 35class LLLandmark;
 36
 37// internals
 38class LLAddLandmarkObserver;
 39class LLRemoveLandmarkObserver;
 40class LLParcelChangeObserver;
 41class LLMenuGL;
 42class LLTeleportHistoryItem;
 43
 44/**
 45 * Location input control.
 46 * 
 47 * @see LLNavigationBar
 48 */
 49class LLLocationInputCtrl
 50:	public LLComboBox
 51{
 52	LOG_CLASS(LLLocationInputCtrl);
 53	friend class LLAddLandmarkObserver;
 54	friend class LLRemoveLandmarkObserver;
 55	friend class LLParcelChangeObserver;
 56
 57public:
 58	struct Params 
 59	:	public LLInitParam::Block<Params, LLComboBox::Params>
 60	{
 61		Optional<LLUIImage*>				icon_maturity_general,
 62											icon_maturity_adult,
 63											icon_maturity_moderate,
 64											add_landmark_image_enabled,
 65											add_landmark_image_disabled,
 66											add_landmark_image_hover,
 67											add_landmark_image_selected;
 68		Optional<std::string>				maturity_help_topic;
 69		Optional<S32>						icon_hpad,
 70											add_landmark_hpad;
 71		Optional<LLButton::Params>			maturity_button,
 72											add_landmark_button,
 73											for_sale_button,
 74											info_button;
 75		Optional<LLIconCtrl::Params>		voice_icon,
 76											fly_icon,
 77											push_icon,
 78											build_icon,
 79											scripts_icon,
 80											damage_icon,
 81											see_avatars_icon;
 82		Optional<LLTextBox::Params>			damage_text;
 83		Params();
 84	};
 85
 86	// LLView interface
 87	/*virtual*/ void		setEnabled(BOOL enabled);
 88	/*virtual*/ BOOL		handleToolTip(S32 x, S32 y, MASK mask);
 89	/*virtual*/ BOOL		handleKeyHere(KEY key, MASK mask);
 90	/*virtual*/ void		onFocusReceived();
 91	/*virtual*/ void		onFocusLost();
 92	/*virtual*/ void		draw();
 93	/*virtual*/ void		reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
 94	//========================================================================
 95
 96	// LLUICtrl interface
 97	/*virtual*/ void		setFocus(BOOL b);
 98	//========================================================================
 99
100	// LLComboBox interface
101	void					hideList();
102	void					onTextEntry(LLLineEditor* line_editor);
103	//========================================================================
104
105	LLLineEditor*			getTextEntry() const { return mTextEntry; }
106	void					handleLoginComplete();
107
108private:
109
110	enum EParcelIcon
111	{
112		VOICE_ICON = 0,
113		FLY_ICON,			// 1
114		PUSH_ICON,			// 2
115		BUILD_ICON,			// 3
116		SCRIPTS_ICON,		// 4
117		DAMAGE_ICON,		// 5
118		SEE_AVATARS_ICON,   // 6
119		ICON_COUNT			// 7 total
120	};
121
122	friend class LLUICtrlFactory;
123	LLLocationInputCtrl(const Params&);
124	virtual ~LLLocationInputCtrl();
125
126	void					focusTextEntry();
127	/**
128	 * Changes the "Add landmark" button image
129	 * depending on whether current parcel has been landmarked.
130	 */
131	void					enableAddLandmarkButton(bool val);
132	void					refresh();
133	void					refreshLocation();
134	void					refreshParcelIcons();
135	// Refresh the value in the health percentage text field
136	void					refreshHealth();
137	void					refreshMaturityButton();
138	void					positionMaturityButton();
139	
140	void					rebuildLocationHistory(const std::string& filter = LLStringUtil::null);
141	bool 					findTeleportItemsByTitle(const LLTeleportHistoryItem& item, const std::string& filter);
142	void					setText(const LLStringExplicit& text);
143	void					updateAddLandmarkButton();
144	void 					updateAddLandmarkTooltip();
145	void 					updateContextMenu();
146	void					updateWidgetlayout();
147	void					changeLocationPresentation();
148
149	void					onInfoButtonClicked();
150	void					onLocationHistoryChanged(LLLocationHistory::EChangeType event);
151	void					onLocationPrearrange(const LLSD& data);
152	void 					onTextEditorRightClicked(S32 x, S32 y, MASK mask);
153	void					onLandmarkLoaded(LLLandmark* lm);
154	void					onForSaleButtonClicked();
155	void					onAddLandmarkButtonClicked();
156	void					onAgentParcelChange();
157	void					onMaturityButtonClicked();
158	// callbacks
159	bool					onLocationContextMenuItemEnabled(const LLSD& userdata);
160	void 					onLocationContextMenuItemClicked(const LLSD& userdata);
161	void					onParcelIconClick(EParcelIcon icon);
162
163	LLMenuGL*				mLocationContextMenu;
164	LLButton*				mAddLandmarkBtn;
165	LLButton*				mForSaleBtn;
166	LLButton*				mInfoBtn;
167	S32						mIconHPad;			// pad between all icons
168	S32						mAddLandmarkHPad;	// pad to left of landmark star
169
170	LLButton*	mMaturityButton;
171	LLIconCtrl*	mParcelIcon[ICON_COUNT];
172	LLTextBox* mDamageText;
173
174	LLAddLandmarkObserver*		mAddLandmarkObserver;
175	LLRemoveLandmarkObserver*	mRemoveLandmarkObserver;
176	LLParcelChangeObserver*		mParcelChangeObserver;
177
178	boost::signals2::connection	mCoordinatesControlConnection;
179	boost::signals2::connection	mParcelPropertiesControlConnection;
180	boost::signals2::connection	mParcelMgrConnection;
181	boost::signals2::connection	mLocationHistoryConnection;
182	LLUIImage* mLandmarkImageOn;
183	LLUIImage* mLandmarkImageOff;
184	LLPointer<LLUIImage> mIconMaturityGeneral;
185	LLPointer<LLUIImage> mIconMaturityAdult;
186	LLPointer<LLUIImage> mIconMaturityModerate;
187
188	std::string mAddLandmarkTooltip;
189	std::string mEditLandmarkTooltip;
190	// this field holds a human-readable form of the location string, it is needed to be able to compare copy-pated value and real location
191	std::string mHumanReadableLocation;
192	bool isHumanReadableLocationVisible;
193	std::string mMaturityHelpTopic;
194};
195
196#endif