CMS 3D CMS Logo

FWCustomIconsButton.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWCustomIconsButton
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Oct 23 13:05:35 EDT 2008
11 //
12 
13 // system include files
14 #include <algorithm>
15 #include <cassert>
16 #include "TGPicture.h"
17 #include "TVirtualX.h"
18 // user include files
20 
21 //
22 // constants, enums and typedefs
23 //
24 
25 //
26 // static data member definitions
27 //
28 
29 //
30 // constructors and destructor
31 //
33  const TGPicture* iUpIcon,
34  const TGPicture* iDownIcon,
35  const TGPicture* iDisabledIcon,
36  const TGPicture* iBelowMouseIcon,
37  Int_t id,
38  GContext_t norm,
39  UInt_t option)
40  : TGButton(iParent, id, norm, option),
41  m_upIcon(iUpIcon),
42  m_downIcon(iDownIcon),
43  m_disabledIcon(iDisabledIcon),
44  m_belowMouseIcon(iBelowMouseIcon),
45  m_inside(false) {
46  assert(nullptr != iUpIcon);
47  assert(nullptr != iDownIcon);
48  assert(nullptr != iDisabledIcon);
49  gVirtualX->ShapeCombineMask(GetId(), 0, 0, iUpIcon->GetMask());
50  SetBackgroundPixmap(iUpIcon->GetPicture());
51  Resize(iUpIcon->GetWidth(), iUpIcon->GetHeight());
52  fTWidth = iUpIcon->GetWidth();
53  fTHeight = iUpIcon->GetHeight();
54 }
55 
56 // FWCustomIconsButton::FWCustomIconsButton(const FWCustomIconsButton& rhs)
57 // {
58 // // do actual copying here;
59 // }
60 
62 
63 //
64 // assignment operators
65 //
66 // const FWCustomIconsButton& FWCustomIconsButton::operator=(const FWCustomIconsButton& rhs)
67 // {
68 // //An exception safe implementation is
69 // FWCustomIconsButton temp(rhs);
70 // swap(rhs);
71 //
72 // return *this;
73 // }
74 
75 //
76 // member functions
77 //
78 void FWCustomIconsButton::swapIcons(const TGPicture*& iUpIcon,
79  const TGPicture*& iDownIcon,
80  const TGPicture*& iDisabledIcon) {
81  std::swap(iUpIcon, m_upIcon);
82  std::swap(iDownIcon, m_downIcon);
83  std::swap(iDisabledIcon, m_disabledIcon);
84  gVirtualX->ShapeCombineMask(GetId(), 0, 0, m_upIcon->GetMask());
85  fClient->NeedRedraw(this);
86 }
87 
88 void FWCustomIconsButton::setIcons(const TGPicture* iUpIcon,
89  const TGPicture* iDownIcon,
90  const TGPicture* iDisabledIcon,
91  const TGPicture* iBelowMouseIcon) {
92  m_upIcon = iUpIcon;
93  m_downIcon = iDownIcon;
94  m_disabledIcon = iDisabledIcon;
95  m_belowMouseIcon = iBelowMouseIcon;
96 
97  gVirtualX->ShapeCombineMask(GetId(), 0, 0, m_upIcon->GetMask());
98  fClient->NeedRedraw(this);
99 }
100 
101 //
102 // const member functions
103 //
104 
105 //______________________________________________________________________________
107  if (event->fType == kEnterNotify)
108  m_inside = true;
109  else if (event->fType == kLeaveNotify)
110  m_inside = false;
111 
112  fClient->NeedRedraw(this);
113 
114  return TGButton::HandleCrossing(event);
115 }
116 
118  //ChangeOptions(0);
119  //TGButton::DoRedraw();
120  //Stole this from TGPictureButton.
121  int x = (fWidth - fTWidth) >> 1;
122  int y = (fHeight - fTHeight) >> 1;
123 
124  switch (fState) {
125  case kButtonUp:
126  if (m_belowMouseIcon && m_inside)
127  m_belowMouseIcon->Draw(fId, fNormGC, x, y);
128  else
129  m_upIcon->Draw(fId, fNormGC, x, y);
130  break;
131  case kButtonEngaged:
132  case kButtonDown:
133  m_downIcon->Draw(fId, fNormGC, x, y);
134  break;
135  case kButtonDisabled:
136  default:
137  m_disabledIcon->Draw(fId, fNormGC, x, y);
138  }
139 }
140 
141 //
142 // static member functions
143 //
DDAxes::y
funct::false
false
Definition: Factorize.h:29
FWCustomIconsButton.h
FWCustomIconsButton::m_downIcon
const TGPicture * m_downIcon
Definition: FWCustomIconsButton.h:71
FWCustomIconsButton::setIcons
void setIcons(const TGPicture *iUpIcon, const TGPicture *iDownIcon, const TGPicture *iDisabledIcon, const TGPicture *ibelowMouseIcon=nullptr)
Definition: FWCustomIconsButton.cc:88
cms::cuda::assert
assert(be >=bs)
FWCustomIconsButton::HandleCrossing
bool HandleCrossing(Event_t *) override
Definition: FWCustomIconsButton.cc:106
DDAxes::x
fileinputsource_cfi.option
option
Definition: fileinputsource_cfi.py:94
FWCustomIconsButton::FWCustomIconsButton
FWCustomIconsButton(const TGWindow *iParent, const TGPicture *iUpIcon, const TGPicture *iDownIcon, const TGPicture *iDisableIcon, const TGPicture *iBelowMouseIcon=nullptr, Int_t id=-1, GContext_t norm=TGButton::GetDefaultGC()(), UInt_t option=0)
Definition: FWCustomIconsButton.cc:32
FWCustomIconsButton::swapIcons
void swapIcons(const TGPicture *&iUpIcon, const TGPicture *&iDownIcon, const TGPicture *&iDisabledIcon)
Definition: FWCustomIconsButton.cc:78
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
FWCustomIconsButton::~FWCustomIconsButton
~FWCustomIconsButton() override
Definition: FWCustomIconsButton.cc:61
FWCustomIconsButton::DoRedraw
void DoRedraw() override
Definition: FWCustomIconsButton.cc:117
FWCustomIconsButton::m_inside
bool m_inside
Definition: FWCustomIconsButton.h:75
hcaldqm::fClient
Definition: DQModule.h:24
FWCustomIconsButton::m_disabledIcon
const TGPicture * m_disabledIcon
Definition: FWCustomIconsButton.h:72
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
FWCustomIconsButton::m_belowMouseIcon
const TGPicture * m_belowMouseIcon
Definition: FWCustomIconsButton.h:73
hcaldqm::quantity::fState
Definition: ValueQuantity.h:47
event
Definition: event.py:1
FWCustomIconsButton::m_upIcon
const TGPicture * m_upIcon
Definition: FWCustomIconsButton.h:70