PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llviewchildren.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 98 lines | 56 code | 14 blank | 28 comment | 4 complexity | 4b9ca7b3327cfd7d9ae0e19c95efd2c8 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llviewchildren.cpp
  3. * @brief LLViewChildren class implementation
  4. *
  5. * $LicenseInfo:firstyear=2006&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 "llviewchildren.h"
  28. #include "lluictrlfactory.h"
  29. // viewer includes
  30. #include "llbutton.h"
  31. #include "lliconctrl.h"
  32. #include "lltextbox.h"
  33. #include "lluuid.h"
  34. #include "llpanel.h"
  35. #include "llviewercontrol.h"
  36. // *NOTE: Do not use mParent reference in the constructor, since it is
  37. // potentially not fully constructud.
  38. LLViewChildren::LLViewChildren(LLPanel& parent)
  39. : mParent(parent)
  40. {
  41. }
  42. void LLViewChildren::show(const std::string& id, bool visible)
  43. {
  44. mParent.getChildView(id)->setVisible(visible);
  45. }
  46. void LLViewChildren::enable(const std::string& id, bool enabled)
  47. {
  48. mParent.getChildView(id)->setEnabled(enabled);
  49. }
  50. void LLViewChildren::setText(
  51. const std::string& id, const std::string& text, bool visible)
  52. {
  53. LLTextBox* child = mParent.getChild<LLTextBox>(id);
  54. if (child)
  55. {
  56. child->setVisible(visible);
  57. child->setText(text);
  58. }
  59. }
  60. void LLViewChildren::setBadge(const std::string& id, Badge badge, bool visible)
  61. {
  62. LLIconCtrl* child = mParent.getChild<LLIconCtrl>(id);
  63. if (child)
  64. {
  65. child->setVisible(visible);
  66. switch (badge)
  67. {
  68. default:
  69. case BADGE_OK: child->setValue(std::string("badge_ok.j2c")); break;
  70. case BADGE_NOTE: child->setValue(std::string("badge_note.j2c")); break;
  71. case BADGE_WARN: child->setValue(std::string("badge_warn.j2c")); break;
  72. case BADGE_ERROR: child->setValue(std::string("badge_error.j2c")); break;
  73. }
  74. }
  75. }
  76. void LLViewChildren::setAction(const std::string& id,
  77. void(*function)(void*), void* value)
  78. {
  79. LLButton* button = mParent.getChild<LLButton>(id);
  80. if (button)
  81. {
  82. button->setClickedCallback(function, value);
  83. }
  84. }