llstatview.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * @file llstatview.cpp
  3. * @brief Container for all statistics info.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "linden_common.h"
  33. #include "llstatview.h"
  34. #include "llgl.h"
  35. LLStatView::LLStatView(const std::string& name,
  36. const std::string& label,
  37. const std::string& setting,
  38. const LLRect& rect)
  39. : LLContainerView(name, rect),
  40. mNumStatBars(0),
  41. mSetting(setting)
  42. {
  43. setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
  44. setLabel(label);
  45. bool open = false;
  46. if (mSetting.length() > 0 && LLUI::sConfigGroup)
  47. {
  48. open = LLUI::sConfigGroup->getBool(mSetting.c_str());
  49. }
  50. setDisplayChildren(open);
  51. }
  52. //virtual
  53. LLStatView::~LLStatView()
  54. {
  55. // Children all cleaned up by default view destructor.
  56. if (mSetting.length() > 0)
  57. {
  58. bool open = getDisplayChildren();
  59. if (LLUI::sConfigGroup)
  60. {
  61. LLUI::sConfigGroup->setBool(mSetting.c_str(), open);
  62. }
  63. }
  64. }
  65. LLStatBar* LLStatView::addStat(const std::string& name,
  66. LLStat* statp,
  67. const std::string& setting,
  68. bool default_bar,
  69. bool default_history)
  70. {
  71. LLStatBar* stat_barp;
  72. LLRect r;
  73. #if 0
  74. if (getStatBar(name))
  75. {
  76. llwarns << "Stat " << name << " already exists!" << llendl;
  77. return NULL;
  78. }
  79. #endif
  80. ++mNumStatBars;
  81. stat_barp = new LLStatBar(name, r, setting, default_bar, default_history);
  82. stat_barp->mStatp = statp;
  83. stat_barp->setVisible(mDisplayChildren);
  84. addChildAtEnd(stat_barp);
  85. mStatBars.push_back(stat_barp);
  86. // Rearrange all child bars.
  87. reshape(getRect().getWidth(), getRect().getHeight());
  88. return stat_barp;
  89. }
  90. LLStatView* LLStatView::addStatView(const std::string& name,
  91. const std::string& label,
  92. const std::string& setting,
  93. const LLRect& rect)
  94. {
  95. LLStatView* statview = new LLStatView(name, label, setting, rect);
  96. statview->setVisible(mDisplayChildren);
  97. addChildAtEnd(statview);
  98. return statview;
  99. }
  100. LLStatBar* LLStatView::getStatBar(const std::string& name)
  101. {
  102. for (sb_vector_t::iterator iter = mStatBars.begin(), end = mStatBars.end();
  103. iter != end; ++iter)
  104. {
  105. LLStatBar* stat_barp = *iter;
  106. if (stat_barp->getLabel() == name)
  107. {
  108. return stat_barp;
  109. }
  110. }
  111. // Not found !
  112. return NULL;
  113. }