# data file for the Fltk User Interface Designer (fluid) version 1.0304 header_name {.h} code_name {.cxx} declblock {\#include } {open public after {\#include } } {} declblock {\#include } {open public after {\#include } } {} class SimpleTable {open : {public Fl_Table_Row} } { Function {draw_cell(TableContext context, int R=0, int C=0, int X=0, int Y=0, int W=0, int H=0)} {open return_type void } { code {static char s[40]; switch ( context ) { case CONTEXT_STARTPAGE: // before page is drawn.. fl_font(FL_HELVETICA, 16); // set the font for our drawing operations return; case CONTEXT_COL_HEADER: // Draw column headers sprintf(s,"%c",'A'+C); // "A", "B", "C", etc. DrawHeader(s,X,Y,W,H); return; case CONTEXT_ROW_HEADER: // Draw row headers sprintf(s,"%02d:",R); // "001:", "002:", etc DrawHeader(s,X,Y,W,H); return; case CONTEXT_CELL: // Draw data in cells if((int)m_TableData.size()-1 < R) SetTableData("", 0, R); if((int)m_TableData.at(R).size()-1 < C) SetTableData("", C, 0); DrawData(m_TableData.at(R).at(C).c_str(), m_CellColors.at(R).at(C),X,Y,W,H); return; default: return; }} {} } Function {SimpleTable(int x, int y, int w, int h, const char *l = 0) : Fl_Table_Row(x,y,w,h,l)} {} { code {} {} } Function {SetTableData(std::string data, unsigned int x = 0, unsigned int y = 0, Fl_Color color = FL_WHITE)} {return_type void } { code {if(m_TableData.empty() || (m_TableData.size() < y+1)) { m_TableData.resize(y+1); rows(y+1); } for (unsigned int i = 0; i < m_TableData.size(); ++i) if(m_TableData.at(i).empty() || (m_TableData.at(i).size() < x+1)) { m_TableData.at(i).resize(x+1, ""); cols(x+1); } m_TableData.at(y).at(x) = data; SetCellColor(color,x,y);} {} } Function {SetCellColor(Fl_Color color, unsigned int x = 0, unsigned int y = 0)} {return_type void } { code {if(m_CellColors.empty() || (m_CellColors.size() < y+1)) { m_CellColors.resize(y+1); rows(y+1); } for (unsigned int i = 0; i < m_CellColors.size(); ++i) if(m_CellColors.at(i).empty() || (m_CellColors.at(i).size() < x+1)) { m_CellColors.at(i).resize(x+1, FL_WHITE); cols(x+1); } m_CellColors.at(y).at(x) = color;} {} } Function {GetTableData()} {return_type {std::vector>} } { code {return m_TableData;} {} } Function {Resize(unsigned int x = 0, unsigned int y = 0)} {} { code {m_TableData.resize(y+1); m_CellColors.resize(y+1); rows(y+1); for (unsigned int i = 0; i < m_TableData.size(); ++i) { m_CellColors.at(i).resize(x+1, FL_WHITE); m_TableData.at(i).resize(x+1, ""); } cols(x+1);} {} } decl {using TableData = std::vector>;} {public local } decl {using TableCellColors = std::vector>;} {public local } Function {DrawData(const char *s, Fl_Color cell_color, int X, int Y, int W, int H)} {private return_type void } { code {fl_push_clip(X,Y,W,H); // Draw cell bg fl_color(cell_color); fl_rectf(X,Y,W,H); // Draw cell data fl_color(FL_GRAY0); fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER); // Draw box border fl_color(color()); fl_rect(X,Y,W,H); fl_pop_clip();} {} } Function {DrawHeader(const char *s, int X, int Y, int W, int H)} {private return_type void } { code {fl_push_clip(X,Y,W,H); fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, row_header_color()); fl_color(FL_BLACK); fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER); fl_pop_clip();} {} } decl {TableData m_TableData;} {private local } decl {TableCellColors m_CellColors;} {private local } } class ViewFluid {} { Function {ViewFluid()} {protected } { Fl_Window win_exmpl { label Example open protected xywh {728 312 500 300} type Double box GTK_DOWN_BOX hide hotspot size_range {585 555 0 0} } { Fl_Button btn_exception { label {Throw Exception} protected xywh {20 120 135 45} } Fl_Table tbl_example {open protected tooltip {Simple Table Implementation Example} xywh {170 0 330 300} class SimpleTable } {} } } }