CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/Fireworks/TableWidget/src/FWColumnLabelCellRenderer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     TableWidget
00004 // Class  :     FWColumnLabelCellRenderer
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Mon Feb  2 16:44:04 EST 2009
00011 // $Id: FWColumnLabelCellRenderer.cc,v 1.2 2009/03/04 15:33:35 chrjones Exp $
00012 //
00013 
00014 // system include files
00015 #include "TVirtualX.h"
00016 #include "TGFont.h"
00017 
00018 // user include files
00019 #include "Fireworks/TableWidget/interface/FWColumnLabelCellRenderer.h"
00020 
00021 
00022 //
00023 // constants, enums and typedefs
00024 //
00025 
00026 //
00027 // static data member definitions
00028 //
00029 
00030 //
00031 // constructors and destructor
00032 //
00033 FWColumnLabelCellRenderer::FWColumnLabelCellRenderer(const TGGC* iContext):
00034 FWTextTableCellRenderer(iContext), 
00035 m_sortOrder(fireworks::table::kNotSorted),
00036 m_sizeOfOrderIcon(height())
00037 {
00038    FontMetrics_t metrics;
00039    font()->GetFontMetrics(&metrics);
00040 
00041    m_sizeOfOrderIcon -= 2*metrics.fDescent;
00042    m_sizeOfOrderIconStartX = metrics.fDescent;
00043    //we want the number to be even so that the point of the triangle 
00044    // will be right in the middle
00045    if(1 == m_sizeOfOrderIcon % 2) {
00046       ++m_sizeOfOrderIcon;
00047    }
00048 }
00049 
00050 
00051 // FWColumnLabelCellRenderer::FWColumnLabelCellRenderer(const FWColumnLabelCellRenderer& rhs)
00052 // {
00053 //    // do actual copying here;
00054 // }
00055 
00056 FWColumnLabelCellRenderer::~FWColumnLabelCellRenderer()
00057 {
00058 }
00059 
00060 //
00061 // assignment operators
00062 //
00063 // const FWColumnLabelCellRenderer& FWColumnLabelCellRenderer::operator=(const FWColumnLabelCellRenderer& rhs)
00064 // {
00065 //   //An exception safe implementation is
00066 //   FWColumnLabelCellRenderer temp(rhs);
00067 //   swap(rhs);
00068 //
00069 //   return *this;
00070 // }
00071 
00072 //
00073 // member functions
00074 //
00075 void FWColumnLabelCellRenderer::setSortOrder(fireworks::table::SortOrder iOrder) {
00076    m_sortOrder = iOrder;
00077 }
00078 
00079 void 
00080 FWColumnLabelCellRenderer::draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight)
00081 {
00082    using namespace fireworks::table;
00083    UInt_t h = m_sizeOfOrderIcon;
00084    const GContext_t c = graphicsContext()->GetGC();
00085    int dY = m_sizeOfOrderIconStartX;
00086    
00087    if(kAscendingSort == m_sortOrder) {
00088       gVirtualX->DrawLine(iID, c, iX+h/2, iY+2+dY,   iX,   iY+h-2+dY);
00089       gVirtualX->DrawLine(iID, c, iX,     iY+h-2+dY, iX+h, iY+h-2+dY);
00090       gVirtualX->DrawLine(iID, c, iX+h/2, iY+2+dY,   iX+h, iY+h-2+dY);
00091    }
00092    if(kDescendingSort == m_sortOrder){
00093       gVirtualX->DrawLine(iID, c, iX,     iY+2+dY,   iX+h, iY+2+dY);
00094       gVirtualX->DrawLine(iID, c, iX+h/2, iY+h-2+dY, iX+h, iY+2+dY);
00095       gVirtualX->DrawLine(iID, c, iX+h/2, iY+h-2+dY, iX,   iY+2+dY);      
00096    }
00097    FWTextTableCellRenderer::draw(iID,iX+kGap+h,iY,iWidth-kGap-h,iHeight);
00098 }
00099 
00100 //
00101 // const member functions
00102 //
00103 fireworks::table::SortOrder FWColumnLabelCellRenderer::sortOrder() const
00104 {
00105    return m_sortOrder;
00106 }
00107 
00108 UInt_t FWColumnLabelCellRenderer::width() const
00109 {
00110    return FWTextTableCellRenderer::width()+kGap+m_sizeOfOrderIcon;
00111 }
00112 
00113 //
00114 // static member functions
00115 //