Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef Fireworks_TableWidget_FWTextTableCellRenderer_h
0002 #define Fireworks_TableWidget_FWTextTableCellRenderer_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     TableWidget
0006 // Class  :     FWTextTableCellRenderer
0007 //
0008 /**\class FWTextTableCellRenderer FWTextTableCellRenderer.h Fireworks/TableWidget/interface/FWTextTableCellRenderer.h
0009 
0010  Description: A Cell Renderer who draws text and can show selection of a cell
0011 
0012  Usage:
0013     Use when the cells of a table are simple text and you want to be able to also show that a cell has been selected.
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Mon Feb  2 16:43:50 EST 2009
0019 //
0020 
0021 // system include files
0022 #include <string>
0023 #include "GuiTypes.h"
0024 #include "TGResourcePool.h"
0025 #include "TGGC.h"
0026 
0027 // user include files
0028 #include "Fireworks/TableWidget/interface/FWTableCellRendererBase.h"
0029 
0030 // forward declarations
0031 
0032 class FWTextTableCellRenderer : public FWTableCellRendererBase {
0033 public:
0034   static const TGGC& getDefaultGC();
0035   static const TGGC& getDefaultHighlightGC();
0036 
0037   enum Justify { kJustifyLeft, kJustifyRight, kJustifyCenter };
0038 
0039   FWTextTableCellRenderer(const TGGC* iContext = &(getDefaultGC()),
0040                           const TGGC* iHighlightContext = &(getDefaultHighlightGC()),
0041                           Justify iJustify = kJustifyLeft);
0042   ~FWTextTableCellRenderer() override;
0043 
0044   // ---------- const member functions ---------------------
0045   const TGGC* graphicsContext() const { return m_context; }
0046   const TGGC* highlightContext() const { return m_highlightContext; }
0047   UInt_t width() const override;
0048   UInt_t height() const override;
0049 
0050   const TGFont* font() const;
0051   // ---------- static member functions --------------------
0052 
0053   // ---------- member functions ---------------------------
0054   void setData(const std::string&, bool isSelected);
0055   void setData(const char*, bool isSelected);
0056   const std::string& data() { return m_data; }
0057   void setGraphicsContext(const TGGC* iContext) { m_context = iContext; }
0058   void setHighlightContext(const TGGC* context) { m_highlightContext = context; }
0059   void setJustify(Justify);
0060   bool selected() { return m_isSelected; }
0061 
0062   void draw(Drawable_t iID, int iX, int iY, unsigned int iWidth, unsigned int iHeight) override;
0063 
0064   FWTextTableCellRenderer(const FWTextTableCellRenderer&) = delete;  // stop default
0065 
0066   const FWTextTableCellRenderer& operator=(const FWTextTableCellRenderer&) = delete;  // stop default
0067 
0068 private:
0069   // ---------- member data --------------------------------
0070   const TGGC* m_context;
0071   const TGGC* m_highlightContext;
0072   TGFont* m_font;
0073   std::string m_data;
0074   bool m_isSelected;
0075   Justify m_justify;
0076 };
0077 
0078 #endif