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