MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / draw_cell

Method draw_cell

src/csvgrid.cpp:191–349  ·  view source on GitHub ↗

Handle drawing all cells in table

Source from the content-addressed store, hash-verified

189
190// Handle drawing all cells in table
191void 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

Callers

nothing calls this directly

Calls 9

lastFoundPositionMethod · 0.80
getCustomFontMethod · 0.80
getThemeMethod · 0.80
getHeaderCellMethod · 0.80
isFlaggedMethod · 0.80
getCellMethod · 0.80
getNumberRowsMethod · 0.80
getNumberColsMethod · 0.80
resizeMethod · 0.80

Tested by

no test coverage detected