Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <iostream>
00016 #include "TGClient.h"
00017 #include "TGFont.h"
00018 #include "TVirtualX.h"
00019
00020
00021 #include "Fireworks/TableWidget/interface/FWFramedTextTableCellRenderer.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 FWFramedTextTableCellRenderer::FWFramedTextTableCellRenderer(const TGGC* iTextContext, const TGGC* iFillContext, Justify iJustify):
00036 m_context(iTextContext),
00037 m_frameContext(iFillContext),
00038 m_font(0),
00039 m_justify(iJustify)
00040 {
00041
00042 m_font = gClient->GetFontPool()->FindFontByHandle(m_context->GetFont());
00043 }
00044
00045
00046
00047
00048
00049
00050 FWFramedTextTableCellRenderer::~FWFramedTextTableCellRenderer()
00051 {
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 void
00070 FWFramedTextTableCellRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
00071 {
00072
00073
00074 gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY-1,iX-1,iY+iHeight);
00075 gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX+iWidth,iY-1,iX+iWidth,iY+iHeight);
00076 gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY-1,iX+iWidth,iY-1);
00077 gVirtualX->DrawLine(iID,m_frameContext->GetGC(),iX-1,iY+iHeight,iX+iWidth,iY+iHeight);
00078
00079 FontMetrics_t metrics;
00080 m_font->GetFontMetrics(&metrics);
00081 int dX=2;
00082 if(m_justify==kJustifyRight) {
00083 int w = width();
00084 dX = iWidth-w;
00085 }
00086 if(m_justify==kJustifyCenter) {
00087 int w = width();
00088 dX = (iWidth-w)/2;
00089
00090 }
00091
00092 gVirtualX->DrawString(iID,m_context->GetGC(),iX+dX,iY+metrics.fAscent, m_data.c_str(),m_data.size());
00093 }
00094
00095 void
00096 FWFramedTextTableCellRenderer::setData(const std::string& iData) {
00097 m_data = iData;
00098 }
00099
00100 void
00101 FWFramedTextTableCellRenderer::setJustify(Justify iJustify)
00102 {
00103 m_justify=iJustify;
00104 }
00105
00106
00107
00108
00109 UInt_t
00110 FWFramedTextTableCellRenderer::width() const
00111 {
00112 if(m_data.size()) {
00113 return m_font->TextWidth(m_data.c_str(),-1)+3;
00114 }
00115 return 0;
00116 }
00117 UInt_t
00118 FWFramedTextTableCellRenderer::height() const
00119 {
00120 return m_font->TextHeight();
00121 }
00122
00123 const TGFont*
00124 FWFramedTextTableCellRenderer::font() const
00125 {
00126 return m_font;
00127 }
00128
00129
00130
00131
00132 const TGGC&
00133 FWFramedTextTableCellRenderer::getDefaultGC()
00134 {
00135 static const TGGC* s_default = gClient->GetResourcePool()->GetFrameGC();
00136 return *s_default;
00137 }
00138
00139 const TGGC &
00140 FWFramedTextTableCellRenderer::getFillGC()
00141 {
00142
00143 static const TGGC* s_default = 0;
00144 if (!s_default) {
00145 GCValues_t gval;
00146 gval.fMask = kGCForeground | kGCBackground | kGCTile |
00147 kGCFillStyle | kGCGraphicsExposures;
00148 gval.fForeground = gClient->GetResourcePool()->GetFrameHiliteColor();
00149 gval.fBackground = gClient->GetResourcePool()->GetFrameBgndColor();
00150 gval.fFillStyle = kFillTiled;
00151 gval.fTile = gClient->GetResourcePool()->GetCheckeredPixmap();
00152 gval.fGraphicsExposures = kFALSE;
00153 s_default = gClient->GetGC(&gval, kTRUE);
00154 }
00155 return *s_default;
00156 }