llfloaterevent.cpp

Go to the documentation of this file.
00001 
00025 #include "llviewerprecompiledheaders.h"
00026 
00027 #include "llfloaterevent.h"
00028 
00029 // viewer project includes
00030 #include "llcommandhandler.h"
00031 #include "llpanelevent.h"
00032 #include "llvieweruictrlfactory.h"
00033 
00034 // linden library includes
00035 #include "lluuid.h"
00036 
00038 // LLFloaterEventInfo
00039 
00040 //-----------------------------------------------------------------------------
00041 // Globals
00042 //-----------------------------------------------------------------------------
00043 
00044 LLMap< U32, LLFloaterEventInfo* > gEventInfoInstances;
00045 
00046 class LLEventHandler : public LLCommandHandler
00047 {
00048 public:
00049         LLEventHandler() : LLCommandHandler("event") { }
00050         bool handle(const std::vector<std::string>& tokens)
00051         {
00052                 if (tokens.size() < 2)
00053                 {
00054                         return false;
00055                 }
00056                 U32 event_id = atoi(tokens[0].c_str());
00057                 if (tokens[1] == "about")
00058                 {
00059                         LLFloaterEventInfo::show(event_id);
00060                         return true;
00061                 }
00062                 return false;
00063         }
00064 };
00065 LLEventHandler gEventHandler;
00066 
00067 LLFloaterEventInfo::LLFloaterEventInfo(const std::string& name, const U32 event_id)
00068 :       LLFloater(name),
00069         mEventID( event_id )
00070 {
00071 
00072         mFactoryMap["event_details_panel"] = LLCallbackMap(LLFloaterEventInfo::createEventDetail, this);
00073         gUICtrlFactory->buildFloater(this, "floater_preview_event.xml", &getFactoryMap());
00074         gEventInfoInstances.addData(event_id, this);
00075 }
00076 
00077 LLFloaterEventInfo::~LLFloaterEventInfo()
00078 {
00079         // child views automatically deleted
00080         gEventInfoInstances.removeData(mEventID);
00081 }
00082 
00083 void LLFloaterEventInfo::displayEventInfo(const U32 event_id)
00084 {
00085         mPanelEventp->setEventID(event_id);
00086         this->setFrontmost(true);
00087 }
00088 
00089 // static
00090 void* LLFloaterEventInfo::createEventDetail(void* userdata)
00091 {
00092         LLFloaterEventInfo *self = (LLFloaterEventInfo*)userdata;
00093         self->mPanelEventp = new LLPanelEvent();
00094         gUICtrlFactory->buildPanel(self->mPanelEventp, "panel_event.xml");
00095 
00096         return self->mPanelEventp;
00097 }
00098 
00099 // static
00100 LLFloaterEventInfo* LLFloaterEventInfo::show(const U32 event_id)
00101 {
00102         LLFloaterEventInfo *floater;
00103         if (gEventInfoInstances.checkData(event_id))
00104         {
00105                 // ...bring that window to front
00106                 floater = gEventInfoInstances.getData(event_id);
00107                 floater->open();        /*Flawfinder: ignore*/
00108                 floater->setFrontmost(true);
00109         }
00110         else
00111         {
00112                 floater =  new LLFloaterEventInfo("eventinfo", event_id );
00113                 floater->center();
00114                 floater->open();        /*Flawfinder: ignore*/
00115                 floater->displayEventInfo(event_id);
00116                 floater->setFrontmost(true);
00117         }
00118 
00119         return floater;
00120 }

Generated on Thu Jul 1 06:08:33 2010 for Second Life Viewer by  doxygen 1.4.7