CMS 3D CMS Logo

FWFramedTextTableCellRenderer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TableWidget
4 // Class : FWFramedTextTableCellRenderer
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Mon Feb 2 16:43:54 EST 2009
11 //
12 
13 // system include files
14 #include <iostream>
15 #include "TGClient.h"
16 #include "TGFont.h"
17 #include "TVirtualX.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 FWFramedTextTableCellRenderer::FWFramedTextTableCellRenderer(const TGGC* iTextContext, const TGGC* iFillContext, Justify iJustify):
35  m_context(iTextContext),
36  m_frameContext(iFillContext),
37  m_font(0),
38  m_justify(iJustify)
39 {
40  //TGGC* tggc= gClient->GetGCPool()->GetGC(iContext);
41  m_font = gClient->GetFontPool()->FindFontByHandle(m_context->GetFont());
42 }
43 
44 // FWFramedTextTableCellRenderer::FWFramedTextTableCellRenderer(const FWFramedTextTableCellRenderer& rhs)
45 // {
46 // // do actual copying here;
47 // }
48 
50 {
51 }
52 
53 //
54 // assignment operators
55 //
56 // const FWFramedTextTableCellRenderer& FWFramedTextTableCellRenderer::operator=(const FWFramedTextTableCellRenderer& rhs)
57 // {
58 // //An exception safe implementation is
59 // FWFramedTextTableCellRenderer temp(rhs);
60 // swap(rhs);
61 //
62 // return *this;
63 // }
64 
65 //
66 // member functions
67 //
68 void
69 FWFramedTextTableCellRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
70 {
71  // GContext_t c = m_frameContext->GetGC();
72 
73  gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY-1,iX-1,iY+iHeight);
74  gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX+iWidth,iY-1,iX+iWidth,iY+iHeight);
75  gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY-1,iX+iWidth,iY-1);
76  gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY+iHeight,iX+iWidth,iY+iHeight);
77 
78  FontMetrics_t metrics;
79  m_font->GetFontMetrics(&metrics);
80  int dX=2;
82  int w = width();
83  dX = iWidth-w;
84  }
86  int w = width();
87  dX = (iWidth-w)/2;
88 
89  }
90 
91  gVirtualX->DrawString(iID,m_context->GetGC(),iX+dX,iY+metrics.fAscent, m_data.c_str(),m_data.size());
92 }
93 
94 void
96  m_data = iData;
97 }
98 
99 void
101 {
102  m_justify=iJustify;
103 }
104 
105 //
106 // const member functions
107 //
108 UInt_t
110 {
111  if(m_data.size()) {
112  return m_font->TextWidth(m_data.c_str(),-1)+3;
113  }
114  return 0;
115 }
116 UInt_t
118 {
119  return m_font->TextHeight();
120 }
121 
122 const TGFont*
124 {
125  return m_font;
126 }
127 
128 //
129 // static member functions
130 //
131 const TGGC&
133 {
134  static const TGGC* s_default = gClient->GetResourcePool()->GetFrameGC();
135  return *s_default;
136 }
137 
138 const TGGC &
140 {
141  // Return graphics context for highlighted frame background.
142  static const TGGC* s_default = 0;
143  if (!s_default) {
144  GCValues_t gval;
145  gval.fMask = kGCForeground | kGCBackground | kGCTile |
146  kGCFillStyle | kGCGraphicsExposures;
147  gval.fForeground = gClient->GetResourcePool()->GetFrameHiliteColor();
148  gval.fBackground = gClient->GetResourcePool()->GetFrameBgndColor();
149  gval.fFillStyle = kFillTiled;
150  gval.fTile = gClient->GetResourcePool()->GetCheckeredPixmap();
151  gval.fGraphicsExposures = kFALSE;
152  s_default = gClient->GetGC(&gval, kTRUE);
153  }
154  return *s_default;
155 }
const double w
Definition: UKUtility.cc:23
virtual UInt_t width() const
returns the minimum width of the cell to which the renderer is representing
virtual UInt_t height() const
returns the minimum height 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)
FWFramedTextTableCellRenderer(const TGGC *iTextContext=&(getDefaultGC()), const TGGC *iFillContext=&(getFillGC()), Justify iJustify=kJustifyLeft)