CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: FWFramedTextTableCellRenderer.cc,v 1.3 2010/06/18 12:44:24 yana Exp $
12 //
13 
14 // system include files
15 #include <iostream>
16 #include "TGClient.h"
17 #include "TGFont.h"
18 #include "TVirtualX.h"
19 
20 // user include files
22 
23 
24 //
25 // constants, enums and typedefs
26 //
27 
28 //
29 // static data member definitions
30 //
31 
32 //
33 // constructors and destructor
34 //
35 FWFramedTextTableCellRenderer::FWFramedTextTableCellRenderer(const TGGC* iTextContext, const TGGC* iFillContext, Justify iJustify):
36  m_context(iTextContext),
37  m_frameContext(iFillContext),
38  m_font(0),
39  m_justify(iJustify)
40 {
41  //TGGC* tggc= gClient->GetGCPool()->GetGC(iContext);
42  m_font = gClient->GetFontPool()->FindFontByHandle(m_context->GetFont());
43 }
44 
45 // FWFramedTextTableCellRenderer::FWFramedTextTableCellRenderer(const FWFramedTextTableCellRenderer& rhs)
46 // {
47 // // do actual copying here;
48 // }
49 
51 {
52 }
53 
54 //
55 // assignment operators
56 //
57 // const FWFramedTextTableCellRenderer& FWFramedTextTableCellRenderer::operator=(const FWFramedTextTableCellRenderer& rhs)
58 // {
59 // //An exception safe implementation is
60 // FWFramedTextTableCellRenderer temp(rhs);
61 // swap(rhs);
62 //
63 // return *this;
64 // }
65 
66 //
67 // member functions
68 //
69 void
70 FWFramedTextTableCellRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
71 {
72  // GContext_t c = m_frameContext->GetGC();
73 
74  gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY-1,iX-1,iY+iHeight);
75  gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX+iWidth,iY-1,iX+iWidth,iY+iHeight);
76  gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY-1,iX+iWidth,iY-1);
77  gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY+iHeight,iX+iWidth,iY+iHeight);
78 
79  FontMetrics_t metrics;
80  m_font->GetFontMetrics(&metrics);
81  int dX=2;
83  int w = width();
84  dX = iWidth-w;
85  }
87  int w = width();
88  dX = (iWidth-w)/2;
89 
90  }
91 
92  gVirtualX->DrawString(iID,m_context->GetGC(),iX+dX,iY+metrics.fAscent, m_data.c_str(),m_data.size());
93 }
94 
95 void
97  m_data = iData;
98 }
99 
100 void
102 {
103  m_justify=iJustify;
104 }
105 
106 //
107 // const member functions
108 //
109 UInt_t
111 {
112  if(m_data.size()) {
113  return m_font->TextWidth(m_data.c_str(),-1)+3;
114  }
115  return 0;
116 }
117 UInt_t
119 {
120  return m_font->TextHeight();
121 }
122 
123 const TGFont*
125 {
126  return m_font;
127 }
128 
129 //
130 // static member functions
131 //
132 const TGGC&
134 {
135  static const TGGC* s_default = gClient->GetResourcePool()->GetFrameGC();
136  return *s_default;
137 }
138 
139 const TGGC &
141 {
142  // Return graphics context for highlighted frame background.
143  static const TGGC* s_default = 0;
144  if (!s_default) {
145  GCValues_t gval;
146  gval.fMask = kGCForeground | kGCBackground | kGCTile |
147  kGCFillStyle | kGCGraphicsExposures;
148  gval.fForeground = gClient->GetResourcePool()->GetFrameHiliteColor();
149  gval.fBackground = gClient->GetResourcePool()->GetFrameBgndColor();
150  gval.fFillStyle = kFillTiled;
151  gval.fTile = gClient->GetResourcePool()->GetCheckeredPixmap();
152  gval.fGraphicsExposures = kFALSE;
153  s_default = gClient->GetGC(&gval, kTRUE);
154  }
155  return *s_default;
156 }
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)
unsigned int UInt_t
Definition: FUTypes.h:12
T w() const
FWFramedTextTableCellRenderer(const TGGC *iTextContext=&(getDefaultGC()), const TGGC *iFillContext=&(getFillGC()), Justify iJustify=kJustifyLeft)