PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llurlmatch.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 105 lines | 40 code | 18 blank | 47 comment | 0 complexity | edd8fa01c382d645eee58aedac136c4c MD5 | raw file
  1/** 
  2 * @file llurlmatch.h
  3 * @author Martin Reddy
  4 * @brief Specifies a matched Url in a string, as returned by LLUrlRegistry
  5 *
  6 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#ifndef LL_LLURLMATCH_H
 29#define LL_LLURLMATCH_H
 30
 31//#include "linden_common.h"
 32
 33#include <string>
 34#include <vector>
 35#include "llstyle.h"
 36
 37///
 38/// LLUrlMatch describes a single Url that was matched within a string by 
 39/// the LLUrlRegistry::findUrl() method. It includes the actual Url that
 40/// was matched along with its first/last character offset in the string.
 41/// An alternate label is also provided for creating a hyperlink, as well
 42/// as tooltip/status text, an icon, and a XUI file for a context menu
 43/// that can be used in a popup for a Url (e.g., Open, Copy URL, etc.)
 44///
 45class LLUrlMatch
 46{
 47public:
 48	LLUrlMatch();
 49
 50	/// return true if this object does not contain a valid Url match yet
 51	bool empty() const { return mUrl.empty(); }
 52
 53	/// return the offset in the string for the first character of the Url
 54	U32 getStart() const { return mStart; }
 55
 56	/// return the offset in the string for the last character of the Url
 57	U32 getEnd() const { return mEnd; }
 58
 59	/// return the Url that has been matched in the input string
 60	std::string getUrl() const { return mUrl; }
 61
 62	/// return a label that can be used for the display of this Url
 63	std::string getLabel() const { return mLabel; }
 64
 65	/// return a message that could be displayed in a tooltip or status bar
 66	std::string getTooltip() const { return mTooltip; }
 67
 68	/// return the filename for an icon that can be displayed next to this Url
 69	std::string getIcon() const { return mIcon; }
 70
 71	/// Return the color to render the displayed text
 72	LLStyle::Params getStyle() const { return mStyle; }
 73
 74	/// Return the name of a XUI file containing the context menu items
 75	std::string getMenuName() const { return mMenuName; }
 76
 77	/// return the SL location that this Url describes, or "" if none.
 78	std::string getLocation() const { return mLocation; }
 79
 80	/// Should this link text be underlined only when mouse is hovered over it?
 81	bool underlineOnHoverOnly() const { return mUnderlineOnHoverOnly; }
 82
 83	/// Change the contents of this match object (used by LLUrlRegistry)
 84	void setValues(U32 start, U32 end, const std::string &url, const std::string &label,
 85	               const std::string &tooltip, const std::string &icon,
 86				   const LLStyle::Params& style, const std::string &menu, 
 87				   const std::string &location, const LLUUID& id,
 88				   bool underline_on_hover_only = false );
 89
 90	const LLUUID& getID() const { return mID; }
 91private:
 92	U32         mStart;
 93	U32         mEnd;
 94	std::string mUrl;
 95	std::string mLabel;
 96	std::string mTooltip;
 97	std::string mIcon;
 98	std::string mMenuName;
 99	std::string mLocation;
100	LLUUID		mID;
101	LLStyle::Params mStyle;
102	bool		mUnderlineOnHoverOnly;
103};
104
105#endif