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;
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 //
FWColumnLabelCellRenderer(const TGGC *iContext=&(getDefaultGC()), bool isSortable=true)
static const std::string kDescendingSort
Definition: FWTableView.cc:193
void setSortOrder(fireworks::table::SortOrder)
void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override
void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override
UInt_t width() const override
returns the minimum width of the cell to which the renderer is representing
fireworks::table::SortOrder sortOrder() const
assert(be >=bs)
const TGGC * graphicsContext() const
UInt_t width() const override
returns the minimum width of the cell to which the renderer is representing
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
fireworks::table::SortOrder m_sortOrder