Handle drawing all cells in table
| 189 | |
| 190 | // Handle drawing all cells in table |
| 191 | void CsvGrid::draw_cell(TableContext context, int R,int C, int X,int Y,int W,int H) { |
| 192 | DEBUG_PRINTF("#### CsvGrid::draw_cell: %d, %d\n", R, H); |
| 193 | int cell_orientation = FL_ALIGN_LEFT; |
| 194 | int row_top=-1, col_left=-1, row_bot=-1, col_right=-1; // the previous selection |
| 195 | static char s[TCRUNCHER_MAX_CELL_LENGTH + 1]; |
| 196 | std::tuple<int, int> lastFound = app.lastFoundPosition(); |
| 197 | |
| 198 | get_selection(row_top, col_left, row_bot, col_right); |
| 199 | switch( context ) { |
| 200 | case CONTEXT_COL_HEADER: // table wants us to draw a column heading (C is column) |
| 201 | fl_font(app.getCustomFont(CsvApplication::FontUsage::COL_HEADER), text_font_size); // set font for heading to bold |
| 202 | fl_push_clip(X,Y,W,H); // clip region for text |
| 203 | { |
| 204 | if( deletionHighlight && isToBeDeleted(R,C) && !delHighlightType) { |
| 205 | fl_color(ColorThemes::getColor(app.getTheme(), "deletion_bg")); |
| 206 | } else { |
| 207 | fl_color(ColorThemes::getColor(app.getTheme(), "header_row_bg")); |
| 208 | } |
| 209 | fl_rectf(X,Y,W,H); |
| 210 | fl_color(ColorThemes::getColor(app.getTheme(), "header_row_text")); |
| 211 | if( deletionHighlight && isToBeDeleted(R,C) && !delHighlightType ) { |
| 212 | fl_color(ColorThemes::getColor(app.getTheme(), "deletion_text")); |
| 213 | } |
| 214 | snprintf(s, TCRUNCHER_MAX_CELL_LENGTH, "%s", dataTable->getHeaderCell(C,false).c_str()); |
| 215 | fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER); |
| 216 | fl_color(ColorThemes::getColor(app.getTheme(), "grid_border")); |
| 217 | fl_rect(X,Y,W,H); |
| 218 | } |
| 219 | fl_pop_clip(); |
| 220 | fl_font(app.getCustomFont(CsvApplication::FontUsage::TEXT), text_font_size); // set font for heading to normal |
| 221 | return; |
| 222 | |
| 223 | case CONTEXT_ROW_HEADER: // table wants us to draw a row heading (R is row) |
| 224 | fl_font(app.getCustomFont(CsvApplication::FontUsage::ROW_HEADER), text_font_size); // set font for row heading to bold |
| 225 | fl_push_clip(X,Y,W,H); |
| 226 | { |
| 227 | if( deletionHighlight && isToBeDeleted(R,C) && delHighlightType ) { |
| 228 | fl_color(ColorThemes::getColor(app.getTheme(), "deletion_bg")); |
| 229 | } else { |
| 230 | fl_color(ColorThemes::getColor(app.getTheme(), "header_row_bg")); |
| 231 | } |
| 232 | fl_rectf(X,Y,W,H); |
| 233 | // fl_draw_box(FL_BORDER_BOX , X,Y,W,H, row_header_color()); |
| 234 | fl_color(ColorThemes::getColor(app.getTheme(), "header_row_text")); |
| 235 | if( deletionHighlight && isToBeDeleted(R,C) && delHighlightType ) { |
| 236 | fl_color(ColorThemes::getColor(app.getTheme(), "deletion_text")); |
| 237 | } |
| 238 | // snprintf(s, TCRUNCHER_MAX_CELL_LENGTH, "%d", R+1); |
| 239 | snprintf(s, TCRUNCHER_MAX_CELL_LENGTH, "%s", Helper::groupedIntToString(R+1, "\u200A").c_str()); |
| 240 | fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER); |
| 241 | fl_color(ColorThemes::getColor(app.getTheme(), "grid_border")); |
| 242 | fl_rect(X,Y,W,H); |
| 243 | } |
| 244 | fl_pop_clip(); |
| 245 | fl_font(app.getCustomFont(CsvApplication::FontUsage::TEXT), text_font_size); // set font for heading to normal |
| 246 | return; |
| 247 | |
| 248 | case CONTEXT_CELL: { // table wants us to draw a cell |
nothing calls this directly
no test coverage detected