CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/Fireworks/TableWidget/src/GlobalContexts.cc

Go to the documentation of this file.
00001 #include "Fireworks/TableWidget/interface/GlobalContexts.h"
00002 
00003 #include "TGClient.h"
00004 #include "TVirtualX.h"
00005 #include "TSystem.h"
00006 #include "TGFont.h"
00007 #include "TGResourcePool.h"
00008 #include "TGGC.h"
00009 
00010 namespace fireworks
00011 { 
00012 const TGGC& boldGC()
00013 {
00014    static TGGC s_boldGC(*gClient->GetResourcePool()->GetFrameGC());
00015  
00016    TGFontPool *pool = gClient->GetFontPool();
00017    //TGFont *font = pool->FindFontByHandle(s_boldGC.GetFont());
00018    //FontAttributes_t attributes = font->GetFontAttributes();
00019   
00020    /*
00021      This doesn't seem to work:
00022      attributes.fWeight = 1; 
00023      TGFont *newFont = pool->GetFont(attributes.fFamily, 9,
00024      attributes.fWeight, attributes.fSlant);
00025 
00026      But this does:
00027    */
00028   
00029    TGFont* newFont = pool->GetFont("-*-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
00030   
00031    if ( ! newFont )
00032       return s_boldGC;
00033 
00034    s_boldGC.SetFont(newFont->GetFontHandle());
00035   
00036    return s_boldGC;
00037 }
00038 
00039 const TGGC& greenGC()
00040 {
00041    static TGGC s_greenGC(*gClient->GetResourcePool()->GetFrameGC());
00042    s_greenGC.SetForeground(gVirtualX->GetPixel(kGreen-5));
00043    return s_greenGC;
00044 }
00045   
00046 const TGGC& redGC()
00047 {
00048    static TGGC s_redGC(*gClient->GetResourcePool()->GetFrameGC());
00049    s_redGC.SetForeground(gVirtualX->GetPixel(kRed-5));
00050    return s_redGC;
00051 }
00052 
00053 const TGGC& italicGC()
00054 {
00055    static TGGC s_italicGC(*gClient->GetResourcePool()->GetFrameGC());
00056  
00057    TGFontPool *pool = gClient->GetFontPool();
00058    TGFont *font = pool->FindFontByHandle(s_italicGC.GetFont());
00059    FontAttributes_t attributes = font->GetFontAttributes();
00060   
00061    attributes.fSlant = 1;
00062    TGFont *newFont = pool->GetFont(attributes.fFamily, 9,
00063                                    attributes.fWeight, attributes.fSlant);
00064    
00065    s_italicGC.SetFont(newFont->GetFontHandle());
00066   
00067    return s_italicGC;
00068 }
00069 }