CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Fireworks/Core/src/FWCheckBoxIcon.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWCheckBoxIcon
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Thu Feb 19 16:25:17 CST 2009
00011 // $Id: FWCheckBoxIcon.cc,v 1.5 2010/06/18 10:17:14 yana Exp $
00012 //
00013 
00014 // system include files
00015 #include "TGPicture.h"
00016 #include "TGClient.h"
00017 #include "TSystem.h"
00018 #include <cassert>
00019 
00020 // user include files
00021 #include "Fireworks/Core/src/FWCheckBoxIcon.h"
00022 
00023 //
00024 // constants, enums and typedefs
00025 //
00026 
00027 //
00028 // static data member definitions
00029 //
00030 static
00031 const TGPicture* checkImage()
00032 {
00033    static const TGPicture* s_picture=gClient->GetPicture(FWCheckBoxIcon::coreIcondir()+"check-mark.png");
00034    return s_picture;
00035 }
00036 
00037 //
00038 // constructors and destructor
00039 //
00040 FWCheckBoxIcon::FWCheckBoxIcon(unsigned int iEdgeLength):
00041 FWBoxIconBase(iEdgeLength),
00042 m_checked(false)
00043 {
00044 }
00045 
00046 // FWCheckBoxIcon::FWCheckBoxIcon(const FWCheckBoxIcon& rhs)
00047 // {
00048 //    // do actual copying here;
00049 // }
00050 
00051 FWCheckBoxIcon::~FWCheckBoxIcon()
00052 {
00053 }
00054 
00055 //
00056 // assignment operators
00057 //
00058 // const FWCheckBoxIcon& FWCheckBoxIcon::operator=(const FWCheckBoxIcon& rhs)
00059 // {
00060 //   //An exception safe implementation is
00061 //   FWCheckBoxIcon temp(rhs);
00062 //   swap(rhs);
00063 //
00064 //   return *this;
00065 // }
00066 
00067 //
00068 // member functions
00069 //
00070 
00071 //
00072 // const member functions
00073 //
00074 void
00075 FWCheckBoxIcon::drawInsideBox(Drawable_t iID, GContext_t iContext, int iX, int iY, unsigned int iSize) const
00076 {
00077    if(m_checked) {
00078       int xOffset = (iSize - checkImage()->GetWidth()) /2;
00079       int yOffset = (iSize - checkImage()->GetHeight())/2;
00080       checkImage()->Draw(iID,iContext,iX+xOffset,iY+yOffset);
00081    }
00082 }
00083 
00084 //
00085 // static member functions
00086 //
00087 const TString& FWCheckBoxIcon::coreIcondir() {
00088    static TString path = Form("%s/src/Fireworks/Core/icons/",gSystem->Getenv("CMSSW_BASE"));
00089    if ( gSystem->AccessPathName(path.Data()) ){ // cannot find directory
00090       assert(gSystem->Getenv("CMSSW_RELEASE_BASE"));
00091       path = Form("%s/src/Fireworks/Core/icons/",gSystem->Getenv("CMSSW_RELEASE_BASE"));
00092    }
00093 
00094    return path;
00095 }