/indra/newview/llstylemap.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 83 lines · 47 code · 8 blank · 28 comment · 10 complexity · 793eaed71a200a6573d9a920fe1fc23b MD5 · raw file

  1. /**
  2. * @file llstylemap.cpp
  3. * @brief LLStyleMap class implementation
  4. *
  5. * $LicenseInfo:firstyear=2002&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. #include "llviewerprecompiledheaders.h"
  27. #include "llstylemap.h"
  28. #include "llstring.h"
  29. #include "llui.h"
  30. #include "llslurl.h"
  31. #include "llviewercontrol.h"
  32. #include "llagent.h"
  33. const LLStyle::Params &LLStyleMap::lookupAgent(const LLUUID &source)
  34. {
  35. // Find this style in the map or add it if not. This map holds links to residents' profiles.
  36. if (mMap.find(source) == mMap.end())
  37. {
  38. LLStyle::Params style_params;
  39. if (source != LLUUID::null)
  40. {
  41. style_params.color.control = "HTMLLinkColor";
  42. style_params.readonly_color.control = "HTMLLinkColor";
  43. style_params.link_href = LLSLURL("agent", source, "inspect").getSLURLString();
  44. }
  45. mMap[source] = style_params;
  46. }
  47. return mMap[source];
  48. }
  49. // This is similar to lookupAgent for any generic URL encoded style.
  50. const LLStyle::Params &LLStyleMap::lookup(const LLUUID& id, const std::string& link)
  51. {
  52. // Find this style in the map or add it if not.
  53. style_map_t::iterator iter = mMap.find(id);
  54. if (iter == mMap.end())
  55. {
  56. LLStyle::Params style_params;
  57. if (id != LLUUID::null && !link.empty())
  58. {
  59. style_params.color.control = "HTMLLinkColor";
  60. style_params.readonly_color.control = "HTMLLinkColor";
  61. style_params.link_href = link;
  62. }
  63. else
  64. {
  65. style_params.color = LLColor4::white;
  66. style_params.readonly_color = LLColor4::white;
  67. }
  68. mMap[id] = style_params;
  69. }
  70. else
  71. {
  72. iter->second.link_href = link;
  73. }
  74. return mMap[id];
  75. }