CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

FWFramedTextTableCellRenderer Class Reference

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

Inheritance diagram for FWFramedTextTableCellRenderer:
FWTableCellRendererBase

List of all members.

Public Types

enum  Justify { kJustifyLeft, kJustifyRight, kJustifyCenter }

Public Member Functions

virtual void draw (Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
const TGFont * font () const
 FWFramedTextTableCellRenderer (const TGGC *iTextContext=&(getDefaultGC()), const TGGC *iFillContext=&(getFillGC()), Justify iJustify=kJustifyLeft)
const TGGC * graphicsContext () const
virtual UInt_t height () const
 returns the minimum height of the cell to which the renderer is representing
void setData (const std::string &)
void setGraphicsContext (const TGGC *iContext)
void setJustify (Justify)
virtual UInt_t width () const
 returns the minimum width of the cell to which the renderer is representing
virtual ~FWFramedTextTableCellRenderer ()

Static Public Member Functions

static const TGGC & getDefaultGC ()
static const TGGC & getFillGC ()

Private Member Functions

 FWFramedTextTableCellRenderer (const FWFramedTextTableCellRenderer &)
const
FWFramedTextTableCellRenderer
operator= (const FWFramedTextTableCellRenderer &)

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 34 of file FWFramedTextTableCellRenderer.h.


Member Enumeration Documentation

Enumerator:
kJustifyLeft 
kJustifyRight 
kJustifyCenter 

Definition at line 40 of file FWFramedTextTableCellRenderer.h.


Constructor & Destructor Documentation

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

Definition at line 35 of file FWFramedTextTableCellRenderer.cc.

References m_context, and m_font.

                                                                                                                                :
   m_context(iTextContext),
   m_frameContext(iFillContext),
   m_font(0),
   m_justify(iJustify)
{
   //TGGC* tggc= gClient->GetGCPool()->GetGC(iContext);
   m_font = gClient->GetFontPool()->FindFontByHandle(m_context->GetFont());
}
FWFramedTextTableCellRenderer::~FWFramedTextTableCellRenderer ( ) [virtual]

Definition at line 50 of file FWFramedTextTableCellRenderer.cc.

{
}
FWFramedTextTableCellRenderer::FWFramedTextTableCellRenderer ( const FWFramedTextTableCellRenderer ) [private]

Member Function Documentation

void FWFramedTextTableCellRenderer::draw ( Drawable_t  iID,
int  iX,
int  iY,
unsigned int  iWidth,
unsigned int  iHeight 
) [virtual]

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 70 of file FWFramedTextTableCellRenderer.cc.

References kJustifyCenter, kJustifyRight, m_context, m_data, m_font, m_frameContext, m_justify, w(), and width().

{
   // GContext_t c = m_frameContext->GetGC();

   gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY-1,iX-1,iY+iHeight);
   gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX+iWidth,iY-1,iX+iWidth,iY+iHeight);
   gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY-1,iX+iWidth,iY-1);
   gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY+iHeight,iX+iWidth,iY+iHeight);

   FontMetrics_t metrics;
   m_font->GetFontMetrics(&metrics);
   int dX=2;
   if(m_justify==kJustifyRight) {
      int w = width();
      dX = iWidth-w;
   }
   if(m_justify==kJustifyCenter) {
      int w = width();
      dX = (iWidth-w)/2;

   }

   gVirtualX->DrawString(iID,m_context->GetGC(),iX+dX,iY+metrics.fAscent, m_data.c_str(),m_data.size());
}
const TGFont * FWFramedTextTableCellRenderer::font ( ) const

Definition at line 124 of file FWFramedTextTableCellRenderer.cc.

References m_font.

{
   return m_font;
}
const TGGC & FWFramedTextTableCellRenderer::getDefaultGC ( ) [static]

Definition at line 133 of file FWFramedTextTableCellRenderer.cc.

{
   static const TGGC* s_default = gClient->GetResourcePool()->GetFrameGC();
   return *s_default;
}
const TGGC & FWFramedTextTableCellRenderer::getFillGC ( ) [static]

Definition at line 140 of file FWFramedTextTableCellRenderer.cc.

{
   // Return graphics context for highlighted frame background.
   static const TGGC* s_default = 0;
   if (!s_default) {
      GCValues_t gval;
      gval.fMask = kGCForeground | kGCBackground | kGCTile |
                   kGCFillStyle  | kGCGraphicsExposures;
      gval.fForeground = gClient->GetResourcePool()->GetFrameHiliteColor();
      gval.fBackground = gClient->GetResourcePool()->GetFrameBgndColor();
      gval.fFillStyle  = kFillTiled;
      gval.fTile       = gClient->GetResourcePool()->GetCheckeredPixmap();
      gval.fGraphicsExposures = kFALSE;
      s_default = gClient->GetGC(&gval, kTRUE);
   }
   return *s_default;
}
const TGGC* FWFramedTextTableCellRenderer::graphicsContext ( ) const [inline]

Definition at line 52 of file FWFramedTextTableCellRenderer.h.

References m_context.

{ return m_context;}
UInt_t FWFramedTextTableCellRenderer::height ( ) const [virtual]

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

Implements FWTableCellRendererBase.

Definition at line 118 of file FWFramedTextTableCellRenderer.cc.

References m_font.

{
   return m_font->TextHeight();
}
const FWFramedTextTableCellRenderer& FWFramedTextTableCellRenderer::operator= ( const FWFramedTextTableCellRenderer ) [private]
void FWFramedTextTableCellRenderer::setData ( const std::string &  iData)

Definition at line 96 of file FWFramedTextTableCellRenderer.cc.

References m_data.

Referenced by FWTableViewTableManager::rowHeader().

                                                             {
   m_data = iData;
}
void FWFramedTextTableCellRenderer::setGraphicsContext ( const TGGC *  iContext) [inline]

Definition at line 61 of file FWFramedTextTableCellRenderer.h.

References m_context.

{ m_context = iContext;}
void FWFramedTextTableCellRenderer::setJustify ( Justify  iJustify)

Definition at line 101 of file FWFramedTextTableCellRenderer.cc.

References m_justify.

{
   m_justify=iJustify;
}
UInt_t FWFramedTextTableCellRenderer::width ( ) const [virtual]

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

Implements FWTableCellRendererBase.

Definition at line 110 of file FWFramedTextTableCellRenderer.cc.

References m_data, and m_font.

Referenced by draw().

{
   if(m_data.size()) {
      return m_font->TextWidth(m_data.c_str(),-1)+3;
   }
   return 0;
}

Member Data Documentation

Definition at line 76 of file FWFramedTextTableCellRenderer.h.

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

Definition at line 74 of file FWFramedTextTableCellRenderer.h.

Referenced by draw().

Definition at line 77 of file FWFramedTextTableCellRenderer.h.

Referenced by draw(), and setJustify().