CMS 3D CMS Logo

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

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

Inheritance diagram for FWFramedTextTableCellRenderer:
FWTableCellRendererBase

Public Types

enum  Justify { kJustifyLeft, kJustifyRight, kJustifyCenter }
 

Public Member Functions

void draw (Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override
 
const TGFont * font () const
 
 FWFramedTextTableCellRenderer (const TGGC *iTextContext=&(getDefaultGC()), const TGGC *iFillContext=&(getFillGC()), Justify iJustify=kJustifyLeft)
 
 FWFramedTextTableCellRenderer (const FWFramedTextTableCellRenderer &)=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 FWFramedTextTableCellRendereroperator= (const FWFramedTextTableCellRenderer &)=delete
 
void setData (const std::string &)
 
void setGraphicsContext (const TGGC *iContext)
 
void setJustify (Justify)
 
UInt_t width () const override
 returns the minimum width of the cell to which the renderer is representing More...
 
 ~FWFramedTextTableCellRenderer () 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 & getFillGC ()
 

Private Attributes

const TGGC * m_context
 
std::string m_data
 
TGFont * m_font
 
const TGGC * m_frameContext
 
Justify m_justify
 

Detailed Description

Description: A Cell Renderer who draws text with an outline and fills in the background

Usage: The background color of the text graphics context will be used to draw an outline around the regular text and the color of the regular text is set by the foreground color of the text graphics context.

Definition at line 33 of file FWFramedTextTableCellRenderer.h.

Member Enumeration Documentation

◆ Justify

Constructor & Destructor Documentation

◆ FWFramedTextTableCellRenderer() [1/2]

FWFramedTextTableCellRenderer::FWFramedTextTableCellRenderer ( const TGGC *  iTextContext = &(getDefaultGC()),
const TGGC *  iFillContext = &(getFillGC()),
Justify  iJustify = kJustifyLeft 
)

Definition at line 33 of file FWFramedTextTableCellRenderer.cc.

References m_context, and m_font.

36  : m_context(iTextContext), m_frameContext(iFillContext), m_font(nullptr), m_justify(iJustify) {
37  //TGGC* tggc= gClient->GetGCPool()->GetGC(iContext);
38  m_font = gClient->GetFontPool()->FindFontByHandle(m_context->GetFont());
39 }

◆ ~FWFramedTextTableCellRenderer()

FWFramedTextTableCellRenderer::~FWFramedTextTableCellRenderer ( )
override

Definition at line 46 of file FWFramedTextTableCellRenderer.cc.

46 {}

◆ FWFramedTextTableCellRenderer() [2/2]

FWFramedTextTableCellRenderer::FWFramedTextTableCellRenderer ( const FWFramedTextTableCellRenderer )
delete

Member Function Documentation

◆ draw()

void FWFramedTextTableCellRenderer::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.

Definition at line 63 of file FWFramedTextTableCellRenderer.cc.

References dX(), kJustifyCenter, kJustifyRight, m_context, m_data, m_font, m_frameContext, m_justify, mergeResourcesJson::metrics, w(), and width().

63  {
64  // GContext_t c = m_frameContext->GetGC();
65 
66  gVirtualX->DrawLine(iID, m_frameContext->GetGC(), iX - 1, iY - 1, iX - 1, iY + iHeight);
67  gVirtualX->DrawLine(iID, m_frameContext->GetGC(), iX + iWidth, iY - 1, iX + iWidth, iY + iHeight);
68  gVirtualX->DrawLine(iID, m_frameContext->GetGC(), iX - 1, iY - 1, iX + iWidth, iY - 1);
69  gVirtualX->DrawLine(iID, m_frameContext->GetGC(), iX - 1, iY + iHeight, iX + iWidth, iY + iHeight);
70 
71  FontMetrics_t metrics;
72  m_font->GetFontMetrics(&metrics);
73  int dX = 2;
74  if (m_justify == kJustifyRight) {
75  int w = width();
76  dX = iWidth - w;
77  }
78  if (m_justify == kJustifyCenter) {
79  int w = width();
80  dX = (iWidth - w) / 2;
81  }
82 
83  gVirtualX->DrawString(iID, m_context->GetGC(), iX + dX, iY + metrics.fAscent, m_data.c_str(), m_data.size());
84 }
T w() const
UInt_t width() const override
returns the minimum width of the cell to which the renderer is representing
float dX(const MatchPair &match)

◆ font()

const TGFont * FWFramedTextTableCellRenderer::font ( ) const

Definition at line 101 of file FWFramedTextTableCellRenderer.cc.

References m_font.

◆ getDefaultGC()

const TGGC & FWFramedTextTableCellRenderer::getDefaultGC ( )
static

Definition at line 106 of file FWFramedTextTableCellRenderer.cc.

106  {
107  static const TGGC* s_default = gClient->GetResourcePool()->GetFrameGC();
108  return *s_default;
109 }

◆ getFillGC()

const TGGC & FWFramedTextTableCellRenderer::getFillGC ( )
static

Definition at line 111 of file FWFramedTextTableCellRenderer.cc.

111  {
112  // Return graphics context for highlighted frame background.
113  static const TGGC* s_default = nullptr;
114  if (!s_default) {
115  GCValues_t gval;
116  gval.fMask = kGCForeground | kGCBackground | kGCTile | kGCFillStyle | kGCGraphicsExposures;
117  gval.fForeground = gClient->GetResourcePool()->GetFrameHiliteColor();
118  gval.fBackground = gClient->GetResourcePool()->GetFrameBgndColor();
119  gval.fFillStyle = kFillTiled;
120  gval.fTile = gClient->GetResourcePool()->GetCheckeredPixmap();
121  gval.fGraphicsExposures = kFALSE;
122  s_default = gClient->GetGC(&gval, kTRUE);
123  }
124  return *s_default;
125 }

◆ graphicsContext()

const TGGC* FWFramedTextTableCellRenderer::graphicsContext ( ) const
inline

Definition at line 46 of file FWFramedTextTableCellRenderer.h.

References m_context.

◆ height()

UInt_t FWFramedTextTableCellRenderer::height ( ) const
overridevirtual

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

Implements FWTableCellRendererBase.

Definition at line 99 of file FWFramedTextTableCellRenderer.cc.

References m_font.

99 { return m_font->TextHeight(); }

◆ operator=()

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

◆ setData()

void FWFramedTextTableCellRenderer::setData ( const std::string &  iData)

Definition at line 86 of file FWFramedTextTableCellRenderer.cc.

References m_data.

Referenced by FWTableViewTableManager::rowHeader().

◆ setGraphicsContext()

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

Definition at line 55 of file FWFramedTextTableCellRenderer.h.

References m_context.

55 { m_context = iContext; }

◆ setJustify()

void FWFramedTextTableCellRenderer::setJustify ( Justify  iJustify)

Definition at line 88 of file FWFramedTextTableCellRenderer.cc.

References m_justify.

◆ width()

UInt_t FWFramedTextTableCellRenderer::width ( ) const
overridevirtual

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

Implements FWTableCellRendererBase.

Definition at line 93 of file FWFramedTextTableCellRenderer.cc.

References m_data, and m_font.

Referenced by draw().

93  {
94  if (!m_data.empty()) {
95  return m_font->TextWidth(m_data.c_str(), -1) + 3;
96  }
97  return 0;
98 }

Member Data Documentation

◆ m_context

const TGGC* FWFramedTextTableCellRenderer::m_context
private

◆ m_data

std::string FWFramedTextTableCellRenderer::m_data
private

Definition at line 69 of file FWFramedTextTableCellRenderer.h.

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

◆ m_font

TGFont* FWFramedTextTableCellRenderer::m_font
private

◆ m_frameContext

const TGGC* FWFramedTextTableCellRenderer::m_frameContext
private

Definition at line 67 of file FWFramedTextTableCellRenderer.h.

Referenced by draw().

◆ m_justify

Justify FWFramedTextTableCellRenderer::m_justify
private

Definition at line 70 of file FWFramedTextTableCellRenderer.h.

Referenced by draw(), and setJustify().