CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public 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)
 
 FWTextTableCellRenderer (const FWTextTableCellRenderer &)=delete
 
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
 
const FWTextTableCellRendereroperator= (const FWTextTableCellRenderer &)=delete
 
bool selected ()
 
void setData (const std::string &, bool isSelected)
 
void setData (const char *, 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 ()
 
 FWTableCellRendererBase (const FWTableCellRendererBase &)=delete
 
const FWTableCellRendererBaseoperator= (const FWTableCellRendererBase &)=delete
 
virtual ~FWTableCellRendererBase ()
 

Static Public Member Functions

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

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

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.

References m_context, and m_font.

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 }

◆ ~FWTextTableCellRenderer()

FWTextTableCellRenderer::~FWTextTableCellRenderer ( )
override

Definition at line 49 of file FWTextTableCellRenderer.cc.

49 {}

◆ FWTextTableCellRenderer() [2/2]

FWTextTableCellRenderer::FWTextTableCellRenderer ( const FWTextTableCellRenderer )
delete

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.

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

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

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 }
T w() const
UInt_t width() const override
returns the minimum width of the cell to which the renderer is representing
static const int kTextBuffer

◆ font()

const TGFont * FWTextTableCellRenderer::font ( ) const

◆ getDefaultGC()

const TGGC & FWTextTableCellRenderer::getDefaultGC ( )
static

Definition at line 128 of file FWTextTableCellRenderer.cc.

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

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

◆ getDefaultHighlightGC()

const TGGC & FWTextTableCellRenderer::getDefaultHighlightGC ( )
static

Definition at line 133 of file FWTextTableCellRenderer.cc.

Referenced by FWPSetTableManager::FWPSetTableManager().

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 }

◆ 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.

References m_font.

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

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

◆ highlightContext()

const TGGC* FWTextTableCellRenderer::highlightContext ( ) const
inline

Definition at line 46 of file FWTextTableCellRenderer.h.

References m_highlightContext.

Referenced by FWTextTreeCellRenderer::draw().

46 { return m_highlightContext; }

◆ operator=()

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

◆ selected()

bool FWTextTableCellRenderer::selected ( )
inline

Definition at line 60 of file FWTextTableCellRenderer.h.

References m_isSelected.

Referenced by FWTextTreeCellRenderer::draw().

◆ setData() [1/2]

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

◆ setData() [2/2]

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

Definition at line 103 of file FWTextTableCellRenderer.cc.

References m_data, and m_isSelected.

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

◆ 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.

References m_justify.

108 { m_justify = iJustify; }

◆ 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.

References m_data, and m_font.

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

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

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().