CMS 3D CMS Logo

FWCheckBoxIcon.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWCheckBoxIcon
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Feb 19 16:25:17 CST 2009
11 //
12 
13 // system include files
14 #include "TGPicture.h"
15 #include "TGClient.h"
16 #include "TSystem.h"
17 #include <cassert>
18 
19 // user include files
21 
22 //
23 // constants, enums and typedefs
24 //
25 
26 //
27 // static data member definitions
28 //
29 static const TGPicture* checkImage() {
30  static const TGPicture* s_picture = gClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "check-mark.png");
31  return s_picture;
32 }
33 
34 //
35 // constructors and destructor
36 //
37 FWCheckBoxIcon::FWCheckBoxIcon(unsigned int iEdgeLength) : FWBoxIconBase(iEdgeLength), m_checked(false) {}
38 
39 // FWCheckBoxIcon::FWCheckBoxIcon(const FWCheckBoxIcon& rhs)
40 // {
41 // // do actual copying here;
42 // }
43 
45 
46 //
47 // assignment operators
48 //
49 // const FWCheckBoxIcon& FWCheckBoxIcon::operator=(const FWCheckBoxIcon& rhs)
50 // {
51 // //An exception safe implementation is
52 // FWCheckBoxIcon temp(rhs);
53 // swap(rhs);
54 //
55 // return *this;
56 // }
57 
58 //
59 // member functions
60 //
61 
62 //
63 // const member functions
64 //
65 void FWCheckBoxIcon::drawInsideBox(Drawable_t iID, GContext_t iContext, int iX, int iY, unsigned int iSize) const {
66  if (m_checked) {
67  int xOffset = (iSize - checkImage()->GetWidth()) / 2;
68  int yOffset = (iSize - checkImage()->GetHeight()) / 2;
69  checkImage()->Draw(iID, iContext, iX + xOffset, iY + yOffset);
70  }
71 }
72 
73 //
74 // static member functions
75 //
76 const TString& FWCheckBoxIcon::coreIcondir() {
77  static TString path = Form("%s/src/Fireworks/Core/icons/", gSystem->Getenv("CMSSW_BASE"));
78  if (gSystem->AccessPathName(path.Data())) { // cannot find directory
79  assert(gSystem->Getenv("CMSSW_RELEASE_BASE"));
80  path = Form("%s/src/Fireworks/Core/icons/", gSystem->Getenv("CMSSW_RELEASE_BASE"));
81  }
82 
83  return path;
84 }
static const TString & coreIcondir()
~FWCheckBoxIcon() override
assert(be >=bs)
FWCheckBoxIcon(unsigned int iEdgeLength)
static const TGPicture * checkImage()
constexpr int16_t xOffset
void drawInsideBox(Drawable_t iID, GContext_t iContext, int iX, int iY, unsigned int iSize) const override
constexpr int16_t yOffset