Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:46:23

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWCheckBoxIcon
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Thu Feb 19 16:25:17 CST 2009
0011 //
0012 
0013 // system include files
0014 #include "TGPicture.h"
0015 #include "TGClient.h"
0016 #include "TSystem.h"
0017 #include <cassert>
0018 
0019 // user include files
0020 #include "Fireworks/Core/src/FWCheckBoxIcon.h"
0021 
0022 //
0023 // constants, enums and typedefs
0024 //
0025 
0026 //
0027 // static data member definitions
0028 //
0029 static const TGPicture* checkImage() {
0030   static const TGPicture* s_picture = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "check-mark.png");
0031   return s_picture;
0032 }
0033 
0034 //
0035 // constructors and destructor
0036 //
0037 FWCheckBoxIcon::FWCheckBoxIcon(unsigned int iEdgeLength) : FWBoxIconBase(iEdgeLength), m_checked(false) {}
0038 
0039 // FWCheckBoxIcon::FWCheckBoxIcon(const FWCheckBoxIcon& rhs)
0040 // {
0041 //    // do actual copying here;
0042 // }
0043 
0044 FWCheckBoxIcon::~FWCheckBoxIcon() {}
0045 
0046 //
0047 // assignment operators
0048 //
0049 // const FWCheckBoxIcon& FWCheckBoxIcon::operator=(const FWCheckBoxIcon& rhs)
0050 // {
0051 //   //An exception safe implementation is
0052 //   FWCheckBoxIcon temp(rhs);
0053 //   swap(rhs);
0054 //
0055 //   return *this;
0056 // }
0057 
0058 //
0059 // member functions
0060 //
0061 
0062 //
0063 // const member functions
0064 //
0065 void FWCheckBoxIcon::drawInsideBox(Drawable_t iID, GContext_t iContext, int iX, int iY, unsigned int iSize) const {
0066   if (m_checked) {
0067     int xOffset = (iSize - checkImage()->GetWidth()) / 2;
0068     int yOffset = (iSize - checkImage()->GetHeight()) / 2;
0069     checkImage()->Draw(iID, iContext, iX + xOffset, iY + yOffset);
0070   }
0071 }
0072 
0073 //
0074 // static member functions
0075 //
0076 const TString& FWCheckBoxIcon::coreIcondir() {
0077   static TString path = Form("%s/src/Fireworks/Core/icons/", gSystem->Getenv("CMSSW_BASE"));
0078   if (gSystem->AccessPathName(path.Data())) {  // cannot find directory
0079     assert(gSystem->Getenv("CMSSW_RELEASE_BASE"));
0080     path = Form("%s/src/Fireworks/Core/icons/", gSystem->Getenv("CMSSW_RELEASE_BASE"));
0081   }
0082 
0083   return path;
0084 }