CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
FWTextTableCellRenderer Class Reference

#include <Fireworks/TableWidget/interface/FWTextTableCellRenderer.h>

Inheritance diagram for FWTextTableCellRenderer:
FWTableCellRendererBase FWCheckedTextTableCellRenderer FWCollectionSummaryModelCellRenderer FWColumnLabelCellRenderer FWTextTreeCellRenderer

Public Types

enum  Justify { kJustifyLeft, kJustifyRight, kJustifyCenter }
 

Public Member Functions

const std::string & data ()
 
void draw (Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override
 
const TGFont * font () const
 
 FWTextTableCellRenderer (const TGGC *iContext=&(getDefaultGC()), const TGGC *iHighlightContext=&(getDefaultHighlightGC()), Justify iJustify=kJustifyLeft)
 
const TGGC * graphicsContext () const
 
UInt_t height () const override
 returns the minimum height of the cell to which the renderer is representing More...
 
const TGGC * highlightContext () const
 
bool selected ()
 
void setData (const char *, bool isSelected)
 
void setData (const std::string &, bool isSelected)
 
void setGraphicsContext (const TGGC *iContext)
 
void setHighlightContext (const TGGC *context)
 
void setJustify (Justify)
 
UInt_t width () const override
 returns the minimum width of the cell to which the renderer is representing More...
 
 ~FWTextTableCellRenderer () override
 
- Public Member Functions inherited from FWTableCellRendererBase
virtual void buttonEvent (Event_t *iClickEvent, int iRelClickX, int iRelClickY)
 
 FWTableCellRendererBase ()
 
virtual ~FWTableCellRendererBase ()
 

Static Public Member Functions

static const TGGC & getDefaultGC ()
 
static const TGGC & getDefaultHighlightGC ()
 

Private Member Functions

 FWTextTableCellRenderer (const FWTextTableCellRenderer &)=delete
 
const FWTextTableCellRendereroperator= (const FWTextTableCellRenderer &)=delete
 

Private Attributes

const TGGC * m_context
 
std::string m_data
 
TGFont * m_font
 
const TGGC * m_highlightContext
 
bool m_isSelected
 
Justify m_justify
 

Detailed Description

Description: A Cell Renderer who draws text and can show selection of a cell

Usage: Use when the cells of a table are simple text and you want to be able to also show that a cell has been selected.

Definition at line 32 of file FWTextTableCellRenderer.h.

Member Enumeration Documentation

◆ Justify

Enumerator
kJustifyLeft 
kJustifyRight 
kJustifyCenter 

Definition at line 37 of file FWTextTableCellRenderer.h.

Constructor & Destructor Documentation

◆ FWTextTableCellRenderer() [1/2]

FWTextTableCellRenderer::FWTextTableCellRenderer ( const TGGC *  iContext = &(getDefaultGC()),
const TGGC *  iHighlightContext = &(getDefaultHighlightGC()),
Justify  iJustify = kJustifyLeft 
)

Definition at line 34 of file FWTextTableCellRenderer.cc.

35  : m_context(iContext),
36  m_highlightContext(iHighlightContext),
37  m_font(nullptr),
38  m_isSelected(false),
39  m_justify(iJustify) {
40  //TGGC* tggc= gClient->GetGCPool()->GetGC(iContext);
41  m_font = gClient->GetFontPool()->FindFontByHandle(m_context->GetFont());
42 }

References m_context, and m_font.

◆ ~FWTextTableCellRenderer()

FWTextTableCellRenderer::~FWTextTableCellRenderer ( )
override

Definition at line 49 of file FWTextTableCellRenderer.cc.

49 {}

◆ FWTextTableCellRenderer() [2/2]

FWTextTableCellRenderer::FWTextTableCellRenderer ( const FWTextTableCellRenderer )
privatedelete

Member Function Documentation

◆ data()

const std::string& FWTextTableCellRenderer::data ( )
inline

◆ draw()

void FWTextTableCellRenderer::draw ( Drawable_t  iID,
int  iX,
int  iY,
unsigned int  iWidth,
unsigned int  iHeight 
)
overridevirtual

Called to draw a particular cell: arguments iID: the id for the drawable in the window. Needed in order to do calls to gVirtualX or to TGFont iX: screen x position that the cell drawing area starts iY: screen y position that the cell drawing area starts iWidth: width (x dimension) of cell drawing area. May be larger than value returned from width() iHeight: height (x dimension) of cell drawing area. May be larger than value returned from height()

Implements FWTableCellRendererBase.

Reimplemented in FWTextTreeCellRenderer.

Definition at line 66 of file FWTextTableCellRenderer.cc.

66  {
67  if (m_isSelected) {
68  GContext_t c = m_highlightContext->GetGC();
69  gVirtualX->FillRectangle(iID,
70  c,
73  iWidth + 2 * FWTabularWidget::kTextBuffer,
74  iHeight + 2 * FWTabularWidget::kTextBuffer);
75  /*
76  gVirtualX->DrawLine(iID,m_context->GetGC(),iX-1,iY-1,iX-1,iY+iHeight);
77  gVirtualX->DrawLine(iID,m_context->GetGC(),iX+iWidth,iY-1,iX+iWidth,iY+iHeight);
78  gVirtualX->DrawLine(iID,m_context->GetGC(),iX-1,iY-1,iX+iWidth,iY-1);
79  gVirtualX->DrawLine(iID,m_context->GetGC(),iX-1,iY+iHeight,iX+iWidth,iY+iHeight);*
80  */
81  }
82 
83  FontMetrics_t metrics;
84  m_font->GetFontMetrics(&metrics);
85  int dX = 0;
86  if (m_justify == kJustifyRight) {
87  int w = width();
88  dX = iWidth - w;
89  }
90  if (m_justify == kJustifyCenter) {
91  int w = width();
92  dX = (iWidth - w) / 2;
93  }
94 
95  gVirtualX->DrawString(iID, m_context->GetGC(), iX + dX, iY + metrics.fAscent + 1, m_data.c_str(), m_data.size());
96 }

References c, kJustifyCenter, kJustifyRight, FWTabularWidget::kTextBuffer, m_context, m_data, m_font, m_highlightContext, m_isSelected, m_justify, w, and width().

Referenced by FWCollectionSummaryModelCellRenderer::draw(), FWCheckedTextTableCellRenderer::draw(), and FWColumnLabelCellRenderer::draw().

◆ font()

const TGFont * FWTextTableCellRenderer::font ( ) const

Definition at line 123 of file FWTextTableCellRenderer.cc.

123 { return m_font; }

References m_font.

Referenced by FWTextTreeCellRenderer::draw(), and FWColumnLabelCellRenderer::FWColumnLabelCellRenderer().

◆ getDefaultGC()

const TGGC & FWTextTableCellRenderer::getDefaultGC ( )
static

Definition at line 128 of file FWTextTableCellRenderer.cc.

128  {
129  static const TGGC* s_default = gClient->GetResourcePool()->GetFrameGC();
130  return *s_default;
131 }

Referenced by FWPSetTableManager::cellRenderer(), and FWTextTreeCellRenderer::draw().

◆ getDefaultHighlightGC()

const TGGC & FWTextTableCellRenderer::getDefaultHighlightGC ( )
static

Definition at line 133 of file FWTextTableCellRenderer.cc.

133  {
134  // Return graphics context for highlighted frame background.
135  static const TGGC* s_default = nullptr;
136  if (!s_default) {
137  GCValues_t gval;
138  gval.fMask = kGCForeground | kGCBackground | kGCStipple | kGCFillStyle | kGCGraphicsExposures;
139  gval.fForeground = gVirtualX->GetPixel(kGray); //gClient->GetResourcePool()->GetFrameHiliteColor();
140  gval.fBackground = gVirtualX->GetPixel(kWhite); //gClient->GetResourcePool()->GetFrameBgndColor();
141  gval.fFillStyle = kFillOpaqueStippled; // kFillTiled;
142  gval.fStipple = gClient->GetResourcePool()->GetCheckeredBitmap();
143  gval.fGraphicsExposures = kFALSE;
144  s_default = gClient->GetGC(&gval, kTRUE);
145  }
146  return *s_default;
147 }

Referenced by FWPSetTableManager::FWPSetTableManager().

◆ graphicsContext()

const TGGC* FWTextTableCellRenderer::graphicsContext ( ) const
inline

◆ height()

UInt_t FWTextTableCellRenderer::height ( ) const
overridevirtual

returns the minimum height of the cell to which the renderer is representing

Implements FWTableCellRendererBase.

Definition at line 119 of file FWTextTableCellRenderer.cc.

119  {
120  return m_font->TextHeight(); //+ 2*kTextBuffer;
121 }

References m_font.

Referenced by FWCheckedTextTableCellRenderer::buttonEvent(), FWCheckedTextTableCellRenderer::draw(), FWGeometryTableManagerBase::FWGeometryTableManagerBase(), and FWCheckedTextTableCellRenderer::width().

◆ highlightContext()

const TGGC* FWTextTableCellRenderer::highlightContext ( ) const
inline

Definition at line 46 of file FWTextTableCellRenderer.h.

46 { return m_highlightContext; }

References m_highlightContext.

Referenced by FWTextTreeCellRenderer::draw().

◆ operator=()

const FWTextTableCellRenderer& FWTextTableCellRenderer::operator= ( const FWTextTableCellRenderer )
privatedelete

◆ selected()

bool FWTextTableCellRenderer::selected ( )
inline

Definition at line 60 of file FWTextTableCellRenderer.h.

60 { return m_isSelected; }

References m_isSelected.

Referenced by FWTextTreeCellRenderer::draw().

◆ setData() [1/2]

void FWTextTableCellRenderer::setData ( const char *  iData,
bool  isSelected 
)

Definition at line 103 of file FWTextTableCellRenderer.cc.

103  {
104  m_data = iData;
105  m_isSelected = iIsSelected;
106 }

References m_data, and m_isSelected.

◆ setData() [2/2]

void FWTextTableCellRenderer::setData ( const std::string &  iData,
bool  isSelected 
)

◆ setGraphicsContext()

void FWTextTableCellRenderer::setGraphicsContext ( const TGGC *  iContext)
inline

◆ setHighlightContext()

void FWTextTableCellRenderer::setHighlightContext ( const TGGC *  context)
inline

◆ setJustify()

void FWTextTableCellRenderer::setJustify ( Justify  iJustify)

Definition at line 108 of file FWTextTableCellRenderer.cc.

108 { m_justify = iJustify; }

References m_justify.

◆ width()

UInt_t FWTextTableCellRenderer::width ( ) const
overridevirtual

returns the minimum width of the cell to which the renderer is representing

Implements FWTableCellRendererBase.

Reimplemented in FWTextTreeCellRenderer.

Definition at line 113 of file FWTextTableCellRenderer.cc.

113  {
114  if (!m_data.empty()) {
115  return m_font->TextWidth(m_data.c_str(), -1); // + 2*kTextBuffer;
116  }
117  return 0;
118 }

References m_data, and m_font.

Referenced by draw(), FWCheckedTextTableCellRenderer::width(), FWColumnLabelCellRenderer::width(), FWCollectionSummaryModelCellRenderer::width(), and FWTextTreeCellRenderer::width().

Member Data Documentation

◆ m_context

const TGGC* FWTextTableCellRenderer::m_context
private

◆ m_data

std::string FWTextTableCellRenderer::m_data
private

Definition at line 73 of file FWTextTableCellRenderer.h.

Referenced by data(), draw(), setData(), and width().

◆ m_font

TGFont* FWTextTableCellRenderer::m_font
private

Definition at line 72 of file FWTextTableCellRenderer.h.

Referenced by draw(), font(), FWTextTableCellRenderer(), height(), and width().

◆ m_highlightContext

const TGGC* FWTextTableCellRenderer::m_highlightContext
private

Definition at line 71 of file FWTextTableCellRenderer.h.

Referenced by draw(), highlightContext(), and setHighlightContext().

◆ m_isSelected

bool FWTextTableCellRenderer::m_isSelected
private

Definition at line 74 of file FWTextTableCellRenderer.h.

Referenced by draw(), selected(), and setData().

◆ m_justify

Justify FWTextTableCellRenderer::m_justify
private

Definition at line 75 of file FWTextTableCellRenderer.h.

Referenced by draw(), and setJustify().

FWTextTableCellRenderer::kJustifyCenter
Definition: FWTextTableCellRenderer.h:37
FWTextTableCellRenderer::kJustifyLeft
Definition: FWTextTableCellRenderer.h:37
FWTabularWidget::kTextBuffer
static const int kTextBuffer
Definition: FWTabularWidget.h:35
visDQMUpload.context
context
Definition: visDQMUpload.py:37
FWTextTableCellRenderer::kJustifyRight
Definition: FWTextTableCellRenderer.h:37
FWTextTableCellRenderer::m_highlightContext
const TGGC * m_highlightContext
Definition: FWTextTableCellRenderer.h:71
FWTextTableCellRenderer::width
UInt_t width() const override
returns the minimum width of the cell to which the renderer is representing
Definition: FWTextTableCellRenderer.cc:113
w
const double w
Definition: UKUtility.cc:23
FWTextTableCellRenderer::m_font
TGFont * m_font
Definition: FWTextTableCellRenderer.h:72
FWTextTableCellRenderer::m_isSelected
bool m_isSelected
Definition: FWTextTableCellRenderer.h:74
FWTextTableCellRenderer::m_context
const TGGC * m_context
Definition: FWTextTableCellRenderer.h:70
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
FWTextTableCellRenderer::m_data
std::string m_data
Definition: FWTextTableCellRenderer.h:73
FWTextTableCellRenderer::m_justify
Justify m_justify
Definition: FWTextTableCellRenderer.h:75