llstatview.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llstatview.h"
00035 
00036 #include "llerror.h"
00037 #include "llstatbar.h"
00038 #include "llfontgl.h"
00039 #include "llgl.h"
00040 #include "llui.h"
00041 
00042 #include "llstatbar.h"
00043 #include "llviewercontrol.h"
00044 
00045 LLStatView::LLStatView(const LLString& name, const LLString& label, const LLString& setting, const LLRect& rect)
00046         :       LLContainerView(name, rect),
00047                 mNumStatBars(0),
00048                 mSetting(setting)
00049 {
00050         mReshapeFlags = FOLLOWS_TOP | FOLLOWS_LEFT;
00051         setLabel(label);
00052         BOOL open = FALSE;
00053         if (mSetting.length() > 0)
00054         {
00055                 open = gSavedSettings.getBOOL(mSetting);
00056         }
00057         setDisplayChildren(open);               /* Flawfinder: ignore */
00058 }
00059 
00060 LLStatView::~LLStatView()
00061 {
00062         // Children all cleaned up by default view destructor.
00063         if (mSetting.length() > 0)
00064         {
00065                 BOOL open = getDisplayChildren();
00066                 gSavedSettings.setBOOL(mSetting, open);         /* Flawfinder: ignore */
00067         }
00068 }
00069 
00070 EWidgetType LLStatView::getWidgetType() const
00071 {
00072         return WIDGET_TYPE_STAT_VIEW;
00073 }
00074 
00075 LLString LLStatView::getWidgetTag() const
00076 {
00077         return LL_STAT_VIEW_TAG;
00078 }
00079 
00080 LLStatBar *LLStatView::addStat(const LLString& name, LLStat *statp)
00081 {
00082         LLStatBar *stat_barp;
00083         LLRect r;
00084 
00085 //      if (getStatBar(name))
00086 //      {
00087 //              llinfos << "LLStatView::addStat - Stat already exists!" << llendl
00088 //              return NULL;
00089 //      }
00090 
00091         mNumStatBars++;
00092 
00093         stat_barp = new LLStatBar(name, r);
00094         stat_barp->mStatp = statp;
00095 
00096         stat_barp->setVisible(mDisplayChildren);
00097         addChildAtEnd(stat_barp);
00098         mStatBars.push_back(stat_barp);
00099 
00100         // Rearrange all child bars.
00101         reshape(mRect.getWidth(), mRect.getHeight());
00102         return stat_barp;
00103 }
00104 
00105 LLStatBar *LLStatView::getStatBar(const LLString& name)
00106 {
00107         sb_vector_t::iterator iter;
00108         for(iter = mStatBars.begin(); iter != mStatBars.end(); ++iter)
00109         {
00110                 LLStatBar *stat_barp = *iter;
00111                 if (stat_barp->getLabel() == name)
00112                 {
00113                         return stat_barp;
00114                 }
00115         }
00116 
00117         // Not found!
00118         return NULL;
00119 }

Generated on Thu Jul 1 06:09:13 2010 for Second Life Viewer by  doxygen 1.4.7