Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:36

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWCollectionSummaryModelCellRenderer
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Wed Feb 25 10:03:23 CST 2009
0011 //
0012 
0013 // system include files
0014 #include "TVirtualX.h"
0015 #include "TGClient.h"
0016 
0017 // user include files
0018 #include "Fireworks/Core/src/FWCollectionSummaryModelCellRenderer.h"
0019 
0020 #include "Fireworks/Core/src/FWColorBoxIcon.h"
0021 #include "Fireworks/Core/src/FWCheckBoxIcon.h"
0022 
0023 #include "Fireworks/Core/interface/FWEventItem.h"
0024 
0025 //
0026 // constants, enums and typedefs
0027 //
0028 
0029 //
0030 // static data member definitions
0031 //
0032 static const unsigned int kIconSize = 10;
0033 static const unsigned int kSeparation = 2;
0034 //
0035 // constructors and destructor
0036 //
0037 FWCollectionSummaryModelCellRenderer::FWCollectionSummaryModelCellRenderer(const TGGC* iGC, const TGGC* iSelectContext)
0038     : FWTextTableCellRenderer(iGC, iSelectContext),
0039       m_colorBox(new FWColorBoxIcon(kIconSize)),
0040       m_checkBox(new FWCheckBoxIcon(kIconSize)) {
0041   GCValues_t t = *(iGC->GetAttributes());
0042   m_colorContext = gClient->GetResourcePool()->GetGCPool()->GetGC(&t, kTRUE);
0043   m_colorBox->setColor(m_colorContext->GetGC());
0044 }
0045 
0046 // FWCollectionSummaryModelCellRenderer::FWCollectionSummaryModelCellRenderer(const FWCollectionSummaryModelCellRenderer& rhs)
0047 // {
0048 //    // do actual copying here;
0049 // }
0050 
0051 FWCollectionSummaryModelCellRenderer::~FWCollectionSummaryModelCellRenderer() {
0052   delete m_colorBox;
0053   delete m_checkBox;
0054   gClient->GetResourcePool()->GetGCPool()->FreeGC(m_colorContext->GetGC());
0055 }
0056 
0057 //
0058 // assignment operators
0059 //
0060 // const FWCollectionSummaryModelCellRenderer& FWCollectionSummaryModelCellRenderer::operator=(const FWCollectionSummaryModelCellRenderer& rhs)
0061 // {
0062 //   //An exception safe implementation is
0063 //   FWCollectionSummaryModelCellRenderer temp(rhs);
0064 //   swap(rhs);
0065 //
0066 //   return *this;
0067 // }
0068 
0069 //
0070 // member functions
0071 //
0072 UInt_t FWCollectionSummaryModelCellRenderer::width() const {
0073   UInt_t w = FWTextTableCellRenderer::width();
0074   return w + kIconSize + kIconSize + kSeparation + kSeparation;
0075 }
0076 
0077 void FWCollectionSummaryModelCellRenderer::draw(
0078     Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) {
0079   int dY = (iHeight - kIconSize) / 2;
0080   m_checkBox->draw(iID, graphicsContext()->GetGC(), iX, iY + dY);
0081   m_colorBox->draw(iID, graphicsContext()->GetGC(), iX + kIconSize + kSeparation, iY + dY);
0082   FWTextTableCellRenderer::draw(iID,
0083                                 iX + kIconSize + kIconSize + kSeparation + kSeparation,
0084                                 iY,
0085                                 iWidth - kIconSize - kIconSize - kSeparation - kSeparation,
0086                                 iHeight);
0087   return;
0088 }
0089 
0090 void FWCollectionSummaryModelCellRenderer::setData(const FWEventItem* iItem, int iIndex) {
0091   FWEventItem::ModelInfo mi = iItem->modelInfo(iIndex);
0092   FWTextTableCellRenderer::setData(iItem->modelName(iIndex), mi.isSelected());
0093   m_checkBox->setChecked(mi.displayProperties().isVisible());
0094   m_colorContext->SetForeground(gVirtualX->GetPixel(mi.displayProperties().color()));
0095 }
0096 
0097 //
0098 // const member functions
0099 //
0100 FWCollectionSummaryModelCellRenderer::ClickHit FWCollectionSummaryModelCellRenderer::clickHit(int iX, int iY) const {
0101   if (iY < 0 || iY > static_cast<int>(kIconSize)) {
0102     return kMiss;
0103   }
0104   if (iX >= 0 && iX <= static_cast<int>(kIconSize)) {
0105     return kHitCheck;
0106   }
0107   if (iX >= static_cast<int>(kIconSize + kSeparation) && iX <= static_cast<int>(kIconSize + kSeparation + kIconSize)) {
0108     return kHitColor;
0109   }
0110   return kMiss;
0111 }
0112 
0113 //
0114 // static member functions
0115 //