Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:     TableWidget
0004 // Class  :     FWCheckedTextTableCellRenderer
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Tue Feb  3 14:29:51 EST 2009
0011 //
0012 
0013 // system include files
0014 #include "TVirtualX.h"
0015 
0016 // user include files
0017 #include "Fireworks/TableWidget/interface/FWCheckedTextTableCellRenderer.h"
0018 
0019 //
0020 // constants, enums and typedefs
0021 //
0022 
0023 //
0024 // static data member definitions
0025 //
0026 
0027 //
0028 // constructors and destructor
0029 //
0030 FWCheckedTextTableCellRenderer::FWCheckedTextTableCellRenderer(const TGGC* iContext)
0031     : FWTextTableCellRenderer(iContext), m_isChecked(false) {}
0032 
0033 // FWCheckedTextTableCellRenderer::FWCheckedTextTableCellRenderer(const FWCheckedTextTableCellRenderer& rhs)
0034 // {
0035 //    // do actual copying here;
0036 // }
0037 
0038 FWCheckedTextTableCellRenderer::~FWCheckedTextTableCellRenderer() {}
0039 
0040 //
0041 // assignment operators
0042 //
0043 // const FWCheckedTextTableCellRenderer& FWCheckedTextTableCellRenderer::operator=(const FWCheckedTextTableCellRenderer& rhs)
0044 // {
0045 //   //An exception safe implementation is
0046 //   FWCheckedTextTableCellRenderer temp(rhs);
0047 //   swap(rhs);
0048 //
0049 //   return *this;
0050 // }
0051 
0052 //
0053 // member functions
0054 //
0055 void FWCheckedTextTableCellRenderer::setChecked(bool iChecked) { m_isChecked = iChecked; }
0056 
0057 void FWCheckedTextTableCellRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) {
0058   const UInt_t h = height();
0059 
0060   //draw the check box
0061   GContext_t c = graphicsContext()->GetGC();
0062   gVirtualX->DrawLine(iID, c, iX, iY, iX, iY + h);
0063   gVirtualX->DrawLine(iID, c, iX + h, iY + h, iX, iY + h);
0064   gVirtualX->DrawLine(iID, c, iX + h, iY + h, iX + h, iY);
0065   gVirtualX->DrawLine(iID, c, iX + h, iY, iX, iY);
0066 
0067   if (m_isChecked) {
0068     gVirtualX->DrawLine(iID, c, iX, iY + h / 2, iX + h / 2, iY + h);
0069     gVirtualX->DrawLine(iID, c, iX + h, iY, iX + h / 2, iY + h);
0070   }
0071   FWTextTableCellRenderer::draw(iID, iX + kGap + h, iY, iWidth - kGap - h, iHeight);
0072 }
0073 
0074 void FWCheckedTextTableCellRenderer::buttonEvent(Event_t* iClickEvent, int iRelClickX, int iRelClickY) {
0075   const int h = height();
0076 
0077   bool wasClicked =
0078       iClickEvent->fType == kButtonRelease && iRelClickX >= 0 && iRelClickX <= h && iRelClickY >= 0 && iRelClickY <= h;
0079   if (wasClicked) {
0080     //std::cout <<"clicked"<<std::endl;
0081     checkBoxClicked();
0082   }
0083 }
0084 
0085 void FWCheckedTextTableCellRenderer::checkBoxClicked() { Emit("checkBoxClicked()"); }
0086 
0087 //
0088 // const member functions
0089 //
0090 bool FWCheckedTextTableCellRenderer::isChecked() const { return m_isChecked; }
0091 
0092 UInt_t FWCheckedTextTableCellRenderer::width() const {
0093   UInt_t h = height();
0094   return FWTextTableCellRenderer::width() + kGap + h;
0095 }
0096 
0097 //
0098 // static member functions
0099 //
0100 ClassImp(FWCheckedTextTableCellRenderer);