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         setFollows(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 LLStatBar *LLStatView::addStat(const LLString& name, LLStat *statp)
00071 {
00072         LLStatBar *stat_barp;
00073         LLRect r;
00074 
00075 //      if (getStatBar(name))
00076 //      {
00077 //              llinfos << "LLStatView::addStat - Stat already exists!" << llendl
00078 //              return NULL;
00079 //      }
00080 
00081         mNumStatBars++;
00082 
00083         stat_barp = new LLStatBar(name, r);
00084         stat_barp->mStatp = statp;
00085 
00086         stat_barp->setVisible(mDisplayChildren);
00087         addChildAtEnd(stat_barp);
00088         mStatBars.push_back(stat_barp);
00089 
00090         // Rearrange all child bars.
00091         reshape(getRect().getWidth(), getRect().getHeight());
00092         return stat_barp;
00093 }
00094 
00095 LLStatBar *LLStatView::getStatBar(const LLString& name)
00096 {
00097         sb_vector_t::iterator iter;
00098         for(iter = mStatBars.begin(); iter != mStatBars.end(); ++iter)
00099         {
00100                 LLStatBar *stat_barp = *iter;
00101                 if (stat_barp->getLabel() == name)
00102                 {
00103                         return stat_barp;
00104                 }
00105         }
00106 
00107         // Not found!
00108         return NULL;
00109 }

Generated on Fri May 16 08:34:02 2008 for SecondLife by  doxygen 1.5.5