CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Fireworks/TableWidget/src/FWCheckedTextTableCellRenderer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     TableWidget
00004 // Class  :     FWCheckedTextTableCellRenderer
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Tue Feb  3 14:29:51 EST 2009
00011 // $Id: FWCheckedTextTableCellRenderer.cc,v 1.3 2009/03/23 19:08:16 amraktad Exp $
00012 //
00013 
00014 // system include files
00015 #include "TVirtualX.h"
00016 
00017 // user include files
00018 #include "Fireworks/TableWidget/interface/FWCheckedTextTableCellRenderer.h"
00019 
00020 
00021 //
00022 // constants, enums and typedefs
00023 //
00024 
00025 //
00026 // static data member definitions
00027 //
00028 
00029 //
00030 // constructors and destructor
00031 //
00032 FWCheckedTextTableCellRenderer::FWCheckedTextTableCellRenderer(const TGGC* iContext):
00033 FWTextTableCellRenderer(iContext), 
00034 m_isChecked(false) {}
00035 
00036 // FWCheckedTextTableCellRenderer::FWCheckedTextTableCellRenderer(const FWCheckedTextTableCellRenderer& rhs)
00037 // {
00038 //    // do actual copying here;
00039 // }
00040 
00041 FWCheckedTextTableCellRenderer::~FWCheckedTextTableCellRenderer()
00042 {
00043 }
00044 
00045 //
00046 // assignment operators
00047 //
00048 // const FWCheckedTextTableCellRenderer& FWCheckedTextTableCellRenderer::operator=(const FWCheckedTextTableCellRenderer& rhs)
00049 // {
00050 //   //An exception safe implementation is
00051 //   FWCheckedTextTableCellRenderer temp(rhs);
00052 //   swap(rhs);
00053 //
00054 //   return *this;
00055 // }
00056 
00057 //
00058 // member functions
00059 //
00060 void FWCheckedTextTableCellRenderer::setChecked(bool iChecked) {
00061    m_isChecked = iChecked;
00062 }
00063 
00064 void 
00065 FWCheckedTextTableCellRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
00066 {
00067    const UInt_t h = height();
00068    
00069    //draw the check box
00070    GContext_t c = graphicsContext()->GetGC();
00071    gVirtualX->DrawLine(iID,c,iX,iY,iX,iY+h);
00072    gVirtualX->DrawLine(iID,c,iX+h,iY+h,iX,iY+h);
00073    gVirtualX->DrawLine(iID,c,iX+h,iY+h,iX+h,iY);
00074    gVirtualX->DrawLine(iID,c,iX+h,iY,iX,iY);
00075    
00076    if(m_isChecked) {
00077       gVirtualX->DrawLine(iID,c,iX,iY+h/2,iX+h/2,iY+h);      
00078       gVirtualX->DrawLine(iID,c,iX+h,iY,iX+h/2,iY+h);      
00079    }
00080    FWTextTableCellRenderer::draw(iID,iX+kGap+h,iY,iWidth-kGap-h,iHeight);
00081 }
00082 
00083 void 
00084 FWCheckedTextTableCellRenderer::buttonEvent(Event_t* iClickEvent, int iRelClickX, int iRelClickY)
00085 {
00086    const int h = height();
00087    
00088    bool wasClicked = iClickEvent->fType==kButtonRelease &&
00089                      iRelClickX >=0 &&
00090                      iRelClickX <=h &&
00091                      iRelClickY >=0 &&
00092                      iRelClickY <=h;
00093    if(wasClicked) {
00094       //std::cout <<"clicked"<<std::endl;
00095       checkBoxClicked();
00096    }
00097 }
00098 
00099 void
00100 FWCheckedTextTableCellRenderer::checkBoxClicked()
00101 {
00102    Emit("checkBoxClicked()");
00103 }
00104 
00105 //
00106 // const member functions
00107 //
00108 bool FWCheckedTextTableCellRenderer::isChecked() const
00109 {
00110    return m_isChecked;
00111 }
00112 
00113 UInt_t FWCheckedTextTableCellRenderer::width() const
00114 {
00115    UInt_t h = height();
00116    return FWTextTableCellRenderer::width()+kGap+h;
00117 }
00118 
00119 
00120 //
00121 // static member functions
00122 //
00123 ClassImp(FWCheckedTextTableCellRenderer)
00124