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
|
// -*- C++ -*-
//
// Package: Core
// Class : FWCollectionSummaryModelCellRenderer
//
// Implementation:
// <Notes on implementation>
//
// Original Author: Chris Jones
// Created: Wed Feb 25 10:03:23 CST 2009
//
// system include files
#include "TVirtualX.h"
#include "TGClient.h"
// user include files
#include "Fireworks/Core/src/FWCollectionSummaryModelCellRenderer.h"
#include "Fireworks/Core/src/FWColorBoxIcon.h"
#include "Fireworks/Core/src/FWCheckBoxIcon.h"
#include "Fireworks/Core/interface/FWEventItem.h"
//
// constants, enums and typedefs
//
//
// static data member definitions
//
static const unsigned int kIconSize = 10;
static const unsigned int kSeparation = 2;
//
// constructors and destructor
//
FWCollectionSummaryModelCellRenderer::FWCollectionSummaryModelCellRenderer(const TGGC* iGC, const TGGC* iSelectContext)
: FWTextTableCellRenderer(iGC, iSelectContext),
m_colorBox(new FWColorBoxIcon(kIconSize)),
m_checkBox(new FWCheckBoxIcon(kIconSize)) {
GCValues_t t = *(iGC->GetAttributes());
m_colorContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&t, kTRUE);
m_colorBox->setColor(m_colorContext->GetGC());
}
// FWCollectionSummaryModelCellRenderer::FWCollectionSummaryModelCellRenderer(const FWCollectionSummaryModelCellRenderer& rhs)
// {
// // do actual copying here;
// }
FWCollectionSummaryModelCellRenderer::~FWCollectionSummaryModelCellRenderer() {
delete m_colorBox;
delete m_checkBox;
gClient->GetResourcePool()->GetGCPool()->FreeGC(m_colorContext->GetGC());
}
//
// assignment operators
//
// const FWCollectionSummaryModelCellRenderer& FWCollectionSummaryModelCellRenderer::operator=(const FWCollectionSummaryModelCellRenderer& rhs)
// {
// //An exception safe implementation is
// FWCollectionSummaryModelCellRenderer temp(rhs);
// swap(rhs);
//
// return *this;
// }
//
// member functions
//
UInt_t FWCollectionSummaryModelCellRenderer::width() const {
UInt_t w = FWTextTableCellRenderer::width();
return w + kIconSize + kIconSize + kSeparation + kSeparation;
}
void FWCollectionSummaryModelCellRenderer::draw(
Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) {
int dY = (iHeight - kIconSize) / 2;
m_checkBox->draw(iID, graphicsContext()->GetGC(), iX, iY + dY);
m_colorBox->draw(iID, graphicsContext()->GetGC(), iX + kIconSize + kSeparation, iY + dY);
FWTextTableCellRenderer::draw(iID,
iX + kIconSize + kIconSize + kSeparation + kSeparation,
iY,
iWidth - kIconSize - kIconSize - kSeparation - kSeparation,
iHeight);
return;
}
void FWCollectionSummaryModelCellRenderer::setData(const FWEventItem* iItem, int iIndex) {
FWEventItem::ModelInfo mi = iItem->modelInfo(iIndex);
FWTextTableCellRenderer::setData(iItem->modelName(iIndex), mi.isSelected());
m_checkBox->setChecked(mi.displayProperties().isVisible());
m_colorContext->SetForeground(gVirtualX->GetPixel(mi.displayProperties().color()));
}
//
// const member functions
//
FWCollectionSummaryModelCellRenderer::ClickHit FWCollectionSummaryModelCellRenderer::clickHit(int iX, int iY) const {
if (iY < 0 || iY > static_cast<int>(kIconSize)) {
return kMiss;
}
if (iX >= 0 && iX <= static_cast<int>(kIconSize)) {
return kHitCheck;
}
if (iX >= static_cast<int>(kIconSize + kSeparation) && iX <= static_cast<int>(kIconSize + kSeparation + kIconSize)) {
return kHitColor;
}
return kMiss;
}
//
// static member functions
//
|