00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llnamebox.h"
00035
00036 #include "llerror.h"
00037 #include "llfontgl.h"
00038 #include "llui.h"
00039 #include "llviewercontrol.h"
00040 #include "lluuid.h"
00041
00042 #include "llcachename.h"
00043 #include "llagent.h"
00044
00045
00046 std::set<LLNameBox*> LLNameBox::sInstances;
00047
00048
00049 LLNameBox::LLNameBox(const std::string& name, const LLRect& rect, const LLUUID& name_id, BOOL is_group, const LLFontGL* font, BOOL mouse_opaque)
00050 : LLTextBox(name, rect, "(retrieving)", font, mouse_opaque),
00051 mNameID(name_id)
00052 {
00053 LLNameBox::sInstances.insert(this);
00054 if(!name_id.isNull())
00055 {
00056 setNameID(name_id, is_group);
00057 }
00058 else
00059 {
00060 setText(LLString::null);
00061 }
00062 }
00063
00064 LLNameBox::~LLNameBox()
00065 {
00066 LLNameBox::sInstances.erase(this);
00067 }
00068
00069 void LLNameBox::setNameID(const LLUUID& name_id, BOOL is_group)
00070 {
00071 mNameID = name_id;
00072
00073 std::string name;
00074
00075 if (!is_group)
00076 {
00077 gCacheName->getFullName(name_id, name);
00078 }
00079 else
00080 {
00081 gCacheName->getGroupName(name_id, name);
00082 }
00083
00084 setText(name);
00085 }
00086
00087 void LLNameBox::refresh(const LLUUID& id, const char* firstname,
00088 const char* lastname, BOOL is_group)
00089 {
00090 if (id == mNameID)
00091 {
00092 LLString name;
00093
00094 name.assign(firstname);
00095 if (!is_group)
00096 {
00097 name.append(1, ' ');
00098 name.append(lastname);
00099 }
00100
00101 setText(name);
00102 }
00103 }
00104
00105 void LLNameBox::refreshAll(const LLUUID& id, const char* firstname,
00106 const char* lastname, BOOL is_group)
00107 {
00108 std::set<LLNameBox*>::iterator it;
00109 for (it = LLNameBox::sInstances.begin();
00110 it != LLNameBox::sInstances.end();
00111 ++it)
00112 {
00113 LLNameBox* box = *it;
00114 box->refresh(id, firstname, lastname, is_group);
00115 }
00116 }