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 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
34 FWColumnLabelCellRenderer::FWColumnLabelCellRenderer(const TGGC* iContext, bool isSortable):
35 FWTextTableCellRenderer(iContext),
36 m_sortOrder(fireworks::table::kNotSorted),
37 m_sizeOfOrderIcon(height()),
38 m_isSortable(isSortable)
39 {
40  if (m_isSortable)
41  {
42  FontMetrics_t metrics;
43  font()->GetFontMetrics(&metrics);
44 
45  m_sizeOfOrderIcon -= 2*metrics.fDescent;
46  m_sizeOfOrderIconStartX = metrics.fDescent;
47  //we want the number to be even so that the point of the triangle
48  // will be right in the middle
49  if(1 == m_sizeOfOrderIcon % 2) {
51  }
52  }
53 }
54 
55 
56 // FWColumnLabelCellRenderer::FWColumnLabelCellRenderer(const FWColumnLabelCellRenderer& rhs)
57 // {
58 // // do actual copying here;
59 // }
60 
62 {
63 }
64 
65 //
66 // assignment operators
67 //
68 // const FWColumnLabelCellRenderer& FWColumnLabelCellRenderer::operator=(const FWColumnLabelCellRenderer& rhs)
69 // {
70 // //An exception safe implementation is
71 // FWColumnLabelCellRenderer temp(rhs);
72 // swap(rhs);
73 //
74 // return *this;
75 // }
76 
77 //
78 // member functions
79 //
81 
82  if (!m_isSortable) assert (iOrder == fireworks::table::kNotSorted);
83 
84  m_sortOrder = iOrder;
85 }
86 
87 void
88 FWColumnLabelCellRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
89 {
90  if (m_isSortable)
91  {
92  using namespace fireworks::table;
93  UInt_t h = m_sizeOfOrderIcon;
94  const GContext_t c = graphicsContext()->GetGC();
95  int dY = m_sizeOfOrderIconStartX;
96 
98  gVirtualX->DrawLine(iID, c, iX+h/2, iY+2+dY, iX, iY+h-2+dY);
99  gVirtualX->DrawLine(iID, c, iX, iY+h-2+dY, iX+h, iY+h-2+dY);
100  gVirtualX->DrawLine(iID, c, iX+h/2, iY+2+dY, iX+h, iY+h-2+dY);
101  }
103  gVirtualX->DrawLine(iID, c, iX, iY+2+dY, iX+h, iY+2+dY);
104  gVirtualX->DrawLine(iID, c, iX+h/2, iY+h-2+dY, iX+h, iY+2+dY);
105  gVirtualX->DrawLine(iID, c, iX+h/2, iY+h-2+dY, iX, iY+2+dY);
106  }
107  FWTextTableCellRenderer::draw(iID,iX+kGap+h,iY,iWidth-kGap-h,iHeight);
108  }
109  else
110  {
111  return FWTextTableCellRenderer::draw(iID, iX+kGap, iY-kGap, iWidth, iHeight);
112  }
113 
114 }
115 
116 //
117 // const member functions
118 //
120 {
121  return m_sortOrder;
122 }
123 
125 {
126  if (m_isSortable)
128  else {
130  }
131 
132 }
133 
134 //
135 // static member functions
136 //
FWColumnLabelCellRenderer(const TGGC *iContext=&(getDefaultGC()), bool isSortable=true)
static const std::string kDescendingSort
Definition: FWTableView.cc:201
void setSortOrder(fireworks::table::SortOrder)
const TGFont * font() const
const TGGC * graphicsContext() const
fireworks::table::SortOrder sortOrder() const
virtual UInt_t width() const
returns the minimum width of the cell to which the renderer is representing
virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
fireworks::table::SortOrder m_sortOrder
virtual UInt_t width() const
returns the minimum width of the cell to which the renderer is representing
virtual void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)