CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Core/src/CmsShowHelpPopup.cc

Go to the documentation of this file.
00001 #include <stdexcept>
00002 #include <cassert>
00003 #include "TGClient.h"
00004 #include "TGHtml.h"
00005 #include "TGText.h"
00006 #include "TSystem.h"
00007 #include "Fireworks/Core/interface/CmsShowHelpPopup.h"
00008 
00009 CmsShowHelpPopup::CmsShowHelpPopup (const std::string &filename,
00010                                     const std::string &windowname,
00011                                     const TGWindow* p, UInt_t w, UInt_t h)
00012    : TGTransientFrame(gClient->GetDefaultRoot(), p, w, h),
00013      m_helpHtml(new TGHtml(this, w, h))
00014 {
00015    AddFrame(m_helpHtml, new TGLayoutHints(kLHintsTop | kLHintsLeft |
00016                                           kLHintsExpandX | kLHintsExpandY));
00017    SetWindowName(windowname.c_str());
00018    TGText text;
00019    text.Load(helpFileName(filename).c_str());
00020   
00021    static TString path = Form("%s/src/Fireworks/Core/data/",gSystem->Getenv("CMSSW_BASE"));
00022    if ( gSystem->AccessPathName(path.Data()) ){ // cannot find directory   
00023       assert(gSystem->Getenv("CMSSW_RELEASE_BASE"));
00024       path = Form("%s/src/Fireworks/Core/data/",gSystem->Getenv("CMSSW_RELEASE_BASE"));
00025    }
00026    m_helpHtml->SetBaseUri(path.Data());
00027    // printf("%s ... \n",  m_helpHtml->GetBaseUri());
00028    
00029    m_helpHtml->ParseText((char *)text.AsString().Data());
00030 
00031    MapSubwindows();
00032    m_helpHtml->Layout();
00033 }
00034 
00035 CmsShowHelpPopup::~CmsShowHelpPopup()
00036 {
00037    delete m_helpHtml;
00038 }
00039 
00040 std::string CmsShowHelpPopup::helpFileName (const std::string &filename)
00041 {
00042    const char* cmspath = gSystem->Getenv("CMSSW_BASE");
00043    if(0 == cmspath) {
00044       throw std::runtime_error("CMSSW_BASE environment variable not set");
00045    }
00046    return std::string(cmspath) + "/src/Fireworks/Core/data/" + filename;
00047 }