PageRenderTime 27ms CodeModel.GetById 12ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_LLURLMATCH_H
  28. #define LL_LLURLMATCH_H
  29. //#include "linden_common.h"
  30. #include <string>
  31. #include <vector>
  32. #include "llstyle.h"
  33. ///
  34. /// LLUrlMatch describes a single Url that was matched within a string by
  35. /// the LLUrlRegistry::findUrl() method. It includes the actual Url that
  36. /// was matched along with its first/last character offset in the string.
  37. /// An alternate label is also provided for creating a hyperlink, as well
  38. /// as tooltip/status text, an icon, and a XUI file for a context menu
  39. /// that can be used in a popup for a Url (e.g., Open, Copy URL, etc.)
  40. ///
  41. class LLUrlMatch
  42. {
  43. public:
  44. LLUrlMatch();
  45. /// return true if this object does not contain a valid Url match yet
  46. bool empty() const { return mUrl.empty(); }
  47. /// return the offset in the string for the first character of the Url
  48. U32 getStart() const { return mStart; }
  49. /// return the offset in the string for the last character of the Url
  50. U32 getEnd() const { return mEnd; }
  51. /// return the Url that has been matched in the input string
  52. std::string getUrl() const { return mUrl; }
  53. /// return a label that can be used for the display of this Url
  54. std::string getLabel() const { return mLabel; }
  55. /// return a message that could be displayed in a tooltip or status bar
  56. std::string getTooltip() const { return mTooltip; }
  57. /// return the filename for an icon that can be displayed next to this Url
  58. std::string getIcon() const { return mIcon; }
  59. /// Return the color to render the displayed text
  60. LLStyle::Params getStyle() const { return mStyle; }
  61. /// Return the name of a XUI file containing the context menu items
  62. std::string getMenuName() const { return mMenuName; }
  63. /// return the SL location that this Url describes, or "" if none.
  64. std::string getLocation() const { return mLocation; }
  65. /// Should this link text be underlined only when mouse is hovered over it?
  66. bool underlineOnHoverOnly() const { return mUnderlineOnHoverOnly; }
  67. /// Change the contents of this match object (used by LLUrlRegistry)
  68. void setValues(U32 start, U32 end, const std::string &url, const std::string &label,
  69. const std::string &tooltip, const std::string &icon,
  70. const LLStyle::Params& style, const std::string &menu,
  71. const std::string &location, const LLUUID& id,
  72. bool underline_on_hover_only = false );
  73. const LLUUID& getID() const { return mID; }
  74. private:
  75. U32 mStart;
  76. U32 mEnd;
  77. std::string mUrl;
  78. std::string mLabel;
  79. std::string mTooltip;
  80. std::string mIcon;
  81. std::string mMenuName;
  82. std::string mLocation;
  83. LLUUID mID;
  84. LLStyle::Params mStyle;
  85. bool mUnderlineOnHoverOnly;
  86. };
  87. #endif