CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/Fireworks/Core/src/FWCollectionSummaryModelCellRenderer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWCollectionSummaryModelCellRenderer
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Wed Feb 25 10:03:23 CST 2009
00011 // $Id: FWCollectionSummaryModelCellRenderer.cc,v 1.1 2009/03/04 16:40:50 chrjones Exp $
00012 //
00013 
00014 // system include files
00015 #include "TVirtualX.h"
00016 #include "TGClient.h"
00017 
00018 // user include files
00019 #include "Fireworks/Core/src/FWCollectionSummaryModelCellRenderer.h"
00020 
00021 #include "Fireworks/Core/src/FWColorBoxIcon.h"
00022 #include "Fireworks/Core/src/FWCheckBoxIcon.h"
00023 
00024 #include "Fireworks/Core/interface/FWEventItem.h"
00025 
00026 
00027 //
00028 // constants, enums and typedefs
00029 //
00030 
00031 //
00032 // static data member definitions
00033 //
00034 static const unsigned int kIconSize = 10;
00035 static const unsigned int kSeparation = 2;
00036 //
00037 // constructors and destructor
00038 //
00039 FWCollectionSummaryModelCellRenderer::FWCollectionSummaryModelCellRenderer(const TGGC* iGC, const TGGC* iSelectContext):
00040 FWTextTableCellRenderer(iGC,iSelectContext),
00041 m_colorBox( new FWColorBoxIcon(kIconSize)),
00042 m_checkBox( new FWCheckBoxIcon(kIconSize))
00043 {
00044    GCValues_t t = *(iGC->GetAttributes());
00045    m_colorContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&t,kTRUE);
00046    m_colorBox->setColor(m_colorContext->GetGC());
00047 }
00048 
00049 // FWCollectionSummaryModelCellRenderer::FWCollectionSummaryModelCellRenderer(const FWCollectionSummaryModelCellRenderer& rhs)
00050 // {
00051 //    // do actual copying here;
00052 // }
00053 
00054 FWCollectionSummaryModelCellRenderer::~FWCollectionSummaryModelCellRenderer()
00055 {
00056    delete m_colorBox;
00057    delete m_checkBox;
00058    gClient->GetResourcePool()->GetGCPool()->FreeGC(m_colorContext->GetGC());
00059 }
00060 
00061 //
00062 // assignment operators
00063 //
00064 // const FWCollectionSummaryModelCellRenderer& FWCollectionSummaryModelCellRenderer::operator=(const FWCollectionSummaryModelCellRenderer& rhs)
00065 // {
00066 //   //An exception safe implementation is
00067 //   FWCollectionSummaryModelCellRenderer temp(rhs);
00068 //   swap(rhs);
00069 //
00070 //   return *this;
00071 // }
00072 
00073 //
00074 // member functions
00075 //
00076 UInt_t 
00077 FWCollectionSummaryModelCellRenderer::width() const
00078 {
00079    UInt_t w = FWTextTableCellRenderer::width();
00080    return w+kIconSize+kIconSize+kSeparation+kSeparation;
00081 }
00082 
00083 void 
00084 FWCollectionSummaryModelCellRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
00085 {
00086    int dY = (iHeight-kIconSize)/2;
00087    m_checkBox->draw(iID,graphicsContext()->GetGC(),iX,iY+dY);
00088    m_colorBox->draw(iID,graphicsContext()->GetGC(),iX+kIconSize+kSeparation,iY+dY);
00089    FWTextTableCellRenderer::draw(iID, iX+kIconSize+kIconSize+kSeparation+kSeparation, iY, 
00090                                  iWidth-kIconSize-kIconSize-kSeparation-kSeparation, iHeight);
00091    return ;
00092 }
00093 
00094 void 
00095 FWCollectionSummaryModelCellRenderer::setData(const FWEventItem* iItem, int iIndex)
00096 {
00097    FWEventItem::ModelInfo mi = iItem->modelInfo(iIndex);
00098    FWTextTableCellRenderer::setData(iItem->modelName(iIndex),mi.isSelected());
00099    m_checkBox->setChecked(mi.displayProperties().isVisible());
00100    m_colorContext->SetForeground(gVirtualX->GetPixel(mi.displayProperties().color()));
00101 }
00102 
00103 //
00104 // const member functions
00105 //
00106 FWCollectionSummaryModelCellRenderer::ClickHit 
00107 FWCollectionSummaryModelCellRenderer::clickHit(int iX, int iY) const
00108 {
00109    if(iY < 0 || iY > static_cast<int>(kIconSize)) { return kMiss;}
00110    if(iX>=0 && iX<=static_cast<int>(kIconSize)) {return kHitCheck;}
00111    if(iX>=static_cast<int>(kIconSize+kSeparation) && iX <=static_cast<int>(kIconSize+kSeparation+kIconSize)) { return kHitColor;}
00112    return kMiss;
00113 }
00114 
00115 //
00116 // static member functions
00117 //