CMS 3D CMS Logo

FWColumnLabelCellRenderer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TableWidget
4 // Class : FWColumnLabelCellRenderer
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Mon Feb 2 16:44:04 EST 2009
11 //
12 
13 #include <cassert>
14 
15 // system include files
16 #include "TVirtualX.h"
17 #include "TGFont.h"
18 
19 // user include files
21 
22 //
23 // constants, enums and typedefs
24 //
25 
26 //
27 // static data member definitions
28 //
29 
30 //
31 // constructors and destructor
32 //
33 FWColumnLabelCellRenderer::FWColumnLabelCellRenderer(const TGGC* iContext, bool isSortable)
34  : FWTextTableCellRenderer(iContext),
35  m_sortOrder(fireworks::table::kNotSorted),
36  m_sizeOfOrderIcon(height()),
37  m_isSortable(isSortable) {
38  if (m_isSortable) {
39  FontMetrics_t metrics;
40  font()->GetFontMetrics(&metrics);
41 
42  m_sizeOfOrderIcon -= 2 * metrics.fDescent;
43  m_sizeOfOrderIconStartX = metrics.fDescent;
44  //we want the number to be even so that the point of the triangle
45  // will be right in the middle
46  if (1 == m_sizeOfOrderIcon % 2) {
48  }
49  }
50 }
51 
52 // FWColumnLabelCellRenderer::FWColumnLabelCellRenderer(const FWColumnLabelCellRenderer& rhs)
53 // {
54 // // do actual copying here;
55 // }
56 
58 
59 //
60 // assignment operators
61 //
62 // const FWColumnLabelCellRenderer& FWColumnLabelCellRenderer::operator=(const FWColumnLabelCellRenderer& rhs)
63 // {
64 // //An exception safe implementation is
65 // FWColumnLabelCellRenderer temp(rhs);
66 // swap(rhs);
67 //
68 // return *this;
69 // }
70 
71 //
72 // member functions
73 //
75  if (!m_isSortable)
77 
78  m_sortOrder = iOrder;
79 }
80 
81 void FWColumnLabelCellRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) {
82  if (m_isSortable) {
83  using namespace fireworks::table;
84  UInt_t h = m_sizeOfOrderIcon;
85  const GContext_t c = graphicsContext()->GetGC();
86  int dY = m_sizeOfOrderIconStartX;
87 
88  if (kAscendingSort == m_sortOrder) {
89  gVirtualX->DrawLine(iID, c, iX + h / 2, iY + 2 + dY, iX, iY + h - 2 + dY);
90  gVirtualX->DrawLine(iID, c, iX, iY + h - 2 + dY, iX + h, iY + h - 2 + dY);
91  gVirtualX->DrawLine(iID, c, iX + h / 2, iY + 2 + dY, iX + h, iY + h - 2 + dY);
92  }
94  gVirtualX->DrawLine(iID, c, iX, iY + 2 + dY, iX + h, iY + 2 + dY);
95  gVirtualX->DrawLine(iID, c, iX + h / 2, iY + h - 2 + dY, iX + h, iY + 2 + dY);
96  gVirtualX->DrawLine(iID, c, iX + h / 2, iY + h - 2 + dY, iX, iY + 2 + dY);
97  }
98  FWTextTableCellRenderer::draw(iID, iX + kGap + h, iY, iWidth - kGap - h, iHeight);
99  } else {
100  return FWTextTableCellRenderer::draw(iID, iX + kGap, iY - kGap, iWidth, iHeight);
101  }
102 }
103 
104 //
105 // const member functions
106 //
108 
110  if (m_isSortable)
112  else {
113  return FWTextTableCellRenderer::width() + kGap * 2;
114  }
115 }
116 
117 //
118 // static member functions
119 //
FWTextTableCellRenderer::draw
void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override
Definition: FWTextTableCellRenderer.cc:66
FWTextTableCellRenderer::graphicsContext
const TGGC * graphicsContext() const
Definition: FWTextTableCellRenderer.h:45
cms::cuda::assert
assert(be >=bs)
FWTextTableCellRenderer
Definition: FWTextTableCellRenderer.h:32
FWColumnLabelCellRenderer::draw
void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override
Definition: FWColumnLabelCellRenderer.cc:81
fireworks::table::SortOrder
SortOrder
Definition: SortOrder.h:29
h
FWColumnLabelCellRenderer::m_sizeOfOrderIcon
int m_sizeOfOrderIcon
Definition: FWColumnLabelCellRenderer.h:55
FWTextTableCellRenderer::width
UInt_t width() const override
returns the minimum width of the cell to which the renderer is representing
Definition: FWTextTableCellRenderer.cc:113
FWColumnLabelCellRenderer.h
fireworks::table::kNotSorted
Definition: SortOrder.h:29
FWColumnLabelCellRenderer::width
UInt_t width() const override
returns the minimum width of the cell to which the renderer is representing
Definition: FWColumnLabelCellRenderer.cc:109
fireworks::table
Definition: SortOrder.h:28
FWColumnLabelCellRenderer::setSortOrder
void setSortOrder(fireworks::table::SortOrder)
Definition: FWColumnLabelCellRenderer.cc:74
FWColumnLabelCellRenderer::kGap
static const UInt_t kGap
Definition: FWColumnLabelCellRenderer.h:53
FWColumnLabelCellRenderer::m_isSortable
bool m_isSortable
Definition: FWColumnLabelCellRenderer.h:58
FWColumnLabelCellRenderer::FWColumnLabelCellRenderer
FWColumnLabelCellRenderer(const TGGC *iContext=&(getDefaultGC()), bool isSortable=true)
Definition: FWColumnLabelCellRenderer.cc:33
FWColumnLabelCellRenderer::m_sizeOfOrderIconStartX
int m_sizeOfOrderIconStartX
Definition: FWColumnLabelCellRenderer.h:56
FWTextTableCellRenderer::font
const TGFont * font() const
Definition: FWTextTableCellRenderer.cc:123
FWColumnLabelCellRenderer::~FWColumnLabelCellRenderer
~FWColumnLabelCellRenderer() override
Definition: FWColumnLabelCellRenderer.cc:57
FWColumnLabelCellRenderer::m_sortOrder
fireworks::table::SortOrder m_sortOrder
Definition: FWColumnLabelCellRenderer.h:54
fireworks::table::kAscendingSort
Definition: SortOrder.h:29
kDescendingSort
static const std::string kDescendingSort
Definition: FWTableView.cc:193
fireworks
Definition: FWTauProxyBuilderBase.h:35
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
TableParser.table
table
Definition: TableParser.py:111
FWColumnLabelCellRenderer::sortOrder
fireworks::table::SortOrder sortOrder() const
Definition: FWColumnLabelCellRenderer.cc:107