CMS 3D CMS Logo

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

List of all members.

Public Types

enum  Justify { kJustifyLeft, kJustifyRight, kJustifyCenter }

Public Member Functions

const std::string & data ()
virtual void draw (Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
const TGFont * font () const
 FWTextTableCellRenderer (const TGGC *iContext=&(getDefaultGC()), const TGGC *iHighlightContext=&(getDefaultHighlightGC()), 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
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)
virtual UInt_t width () const
 returns the minimum width of the cell to which the renderer is representing
virtual ~FWTextTableCellRenderer ()

Static Public Member Functions

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

Private Member Functions

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

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 33 of file FWTextTableCellRenderer.h.


Member Enumeration Documentation

Enumerator:
kJustifyLeft 
kJustifyRight 
kJustifyCenter 

Definition at line 39 of file FWTextTableCellRenderer.h.


Constructor & Destructor Documentation

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

Definition at line 36 of file FWTextTableCellRenderer.cc.

References m_context, and m_font.

                                                                                                                     :
   m_context(iContext),
   m_highlightContext(iHighlightContext),
   m_font(0),
   m_isSelected(false),
   m_justify(iJustify)
{
   //TGGC* tggc= gClient->GetGCPool()->GetGC(iContext);
   m_font = gClient->GetFontPool()->FindFontByHandle(m_context->GetFont());
}
FWTextTableCellRenderer::~FWTextTableCellRenderer ( ) [virtual]

Definition at line 52 of file FWTextTableCellRenderer.cc.

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

Member Function Documentation

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

Definition at line 62 of file FWTextTableCellRenderer.h.

References m_data.

Referenced by FWTextTreeCellRenderer::draw().

{ return m_data; }
void FWTextTableCellRenderer::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.

Reimplemented in FWCollectionSummaryModelCellRenderer, FWCheckedTextTableCellRenderer, FWColumnLabelCellRenderer, and FWTextTreeCellRenderer.

Definition at line 72 of file FWTextTableCellRenderer.cc.

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

{
 
   if(m_isSelected) {
      GContext_t c = m_highlightContext->GetGC();
      gVirtualX->FillRectangle(iID, c, iX - FWTabularWidget::kTextBuffer, iY - FWTabularWidget::kTextBuffer,
                               iWidth + 2*FWTabularWidget::kTextBuffer, iHeight + 2*FWTabularWidget::kTextBuffer);
      /*
        gVirtualX->DrawLine(iID,m_context->GetGC(),iX-1,iY-1,iX-1,iY+iHeight);
        gVirtualX->DrawLine(iID,m_context->GetGC(),iX+iWidth,iY-1,iX+iWidth,iY+iHeight);
        gVirtualX->DrawLine(iID,m_context->GetGC(),iX-1,iY-1,iX+iWidth,iY-1);
        gVirtualX->DrawLine(iID,m_context->GetGC(),iX-1,iY+iHeight,iX+iWidth,iY+iHeight);*
      */
   }



   FontMetrics_t metrics;
   m_font->GetFontMetrics(&metrics);
   int dX=0;
   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 +1, m_data.c_str(),m_data.size());
}
const TGFont * FWTextTableCellRenderer::font ( ) const
const TGGC & FWTextTableCellRenderer::getDefaultGC ( ) [static]

Definition at line 150 of file FWTextTableCellRenderer.cc.

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

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

Definition at line 157 of file FWTextTableCellRenderer.cc.

Referenced by FWPSetTableManager::FWPSetTableManager().

{
   // Return graphics context for highlighted frame background.
   static const TGGC* s_default = 0;
   if (!s_default) {
      GCValues_t gval;
      gval.fMask = kGCForeground | kGCBackground | kGCStipple | kGCFillStyle  | kGCGraphicsExposures;
      gval.fForeground = gVirtualX->GetPixel(kGray);//gClient->GetResourcePool()->GetFrameHiliteColor();
      gval.fBackground = gVirtualX->GetPixel(kWhite);//gClient->GetResourcePool()->GetFrameBgndColor();
      gval.fFillStyle  = kFillOpaqueStippled; // kFillTiled;
      gval.fStipple    = gClient->GetResourcePool()->GetCheckeredBitmap();
      gval.fGraphicsExposures = kFALSE;
      s_default = gClient->GetGC(&gval, kTRUE);
   }
   return *s_default;
}
const TGGC* FWTextTableCellRenderer::graphicsContext ( ) const [inline]
UInt_t FWTextTableCellRenderer::height ( ) const [virtual]

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

Implements FWTableCellRendererBase.

Definition at line 135 of file FWTextTableCellRenderer.cc.

References m_font.

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

{
   return m_font->TextHeight(); //+  2*kTextBuffer;
}
const TGGC* FWTextTableCellRenderer::highlightContext ( ) const [inline]

Definition at line 52 of file FWTextTableCellRenderer.h.

References m_highlightContext.

Referenced by FWTextTreeCellRenderer::draw().

{ return m_highlightContext; }
const FWTextTableCellRenderer& FWTextTableCellRenderer::operator= ( const FWTextTableCellRenderer ) [private]
bool FWTextTableCellRenderer::selected ( ) [inline]

Definition at line 66 of file FWTextTableCellRenderer.h.

References m_isSelected.

Referenced by FWTextTreeCellRenderer::draw().

{ return m_isSelected; }
void FWTextTableCellRenderer::setData ( const char *  iData,
bool  isSelected 
)

Definition at line 112 of file FWTextTableCellRenderer.cc.

References m_data, and m_isSelected.

                                                                    {
   m_data = iData;
   m_isSelected=iIsSelected;
}
void FWTextTableCellRenderer::setData ( const std::string &  iData,
bool  isSelected 
)
void FWTextTableCellRenderer::setGraphicsContext ( const TGGC *  iContext) [inline]
void FWTextTableCellRenderer::setHighlightContext ( const TGGC *  context) [inline]
void FWTextTableCellRenderer::setJustify ( Justify  iJustify)

Definition at line 118 of file FWTextTableCellRenderer.cc.

References m_justify.

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

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

Implements FWTableCellRendererBase.

Reimplemented in FWCollectionSummaryModelCellRenderer, FWCheckedTextTableCellRenderer, FWColumnLabelCellRenderer, and FWTextTreeCellRenderer.

Definition at line 127 of file FWTextTableCellRenderer.cc.

References m_data, and m_font.

Referenced by draw().

{
   if(m_data.size()) {
      return m_font->TextWidth(m_data.c_str(),-1);// + 2*kTextBuffer;
   }
   return 0;
}

Member Data Documentation

const TGGC* FWTextTableCellRenderer::m_context [private]
std::string FWTextTableCellRenderer::m_data [private]

Definition at line 80 of file FWTextTableCellRenderer.h.

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

Definition at line 79 of file FWTextTableCellRenderer.h.

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

Definition at line 78 of file FWTextTableCellRenderer.h.

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

Definition at line 81 of file FWTextTableCellRenderer.h.

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

Definition at line 82 of file FWTextTableCellRenderer.h.

Referenced by draw(), and setJustify().