static bool blame_draw(struct view *view, struct line *line, unsigned int lineno) { struct blame_state *state = view->private; struct blame *blame = line->data; struct time *time = NULL; const char *id = NULL, *filename = NULL; const struct ident *author = NULL; enum line_type id_type = LINE_ID; static const enum line_type blame_colors[] = { LINE_PALETTE_0, LINE_PALETTE_1, LINE_PALETTE_2, LINE_PALETTE_3, LINE_PALETTE_4, LINE_PALETTE_5, LINE_PALETTE_6, }; #define BLAME_COLOR(i) \ (blame_colors[(i) % ARRAY_SIZE(blame_colors)]) if (blame->commit && blame->commit->filename) { id = blame->commit->id; author = blame->commit->author; filename = blame->commit->filename; time = &blame->commit->time; id_type = BLAME_COLOR((long) blame->commit); } if (draw_date(view, time)) return TRUE; if (draw_author(view, author)) return TRUE; if (draw_filename(view, filename, state->auto_filename_display)) return TRUE; if (draw_id_custom(view, id_type, id, opt_id_width)) return TRUE; if (draw_lineno(view, lineno)) return TRUE; draw_text(view, LINE_DEFAULT, blame->text); return TRUE; }
//绘制实验数据 void draw_test(int &page) { RECT rect = gDrawClientRect; rect.left += DRAW_TEST_MARGIN; rect.top += DRAW_TEST_MARGIN; rect.right -= DRAW_TEST_MARGIN; rect.bottom -= DRAW_TEST_MARGIN; draw_clear(false); HPEN hPenRed = CreatePen(PS_SOLID, 0, RGB(128,0,0)); //深红线 HGDIOBJ hPenOld = SelectObject(gDrawBmpMemDC, hPenRed); draw_filename(rect); rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); rect.top++; draw_config(rect); //rect.top++; //draw_line(rect.left, rect.top, rect.right, rect.top); rect.top++; draw_test_param(rect); rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); rect.top++; draw_test_robots(rect, page); rect.top++; draw_line(rect.left, rect.top, rect.right, rect.top); SelectObject(gDrawBmpMemDC, hPenOld); DeleteObject(hPenRed); draw_refresh(); }
bool view_column_draw(struct view *view, struct line *line, unsigned int lineno) { struct view_column *column = view->columns; struct view_column_data column_data = {0}; if (!view->ops->get_column_data(view, line, &column_data)) return true; if (column_data.section) column = column_data.section; for (; column; column = column->next) { mode_t mode = column_data.mode ? *column_data.mode : 0; if (column->hidden) continue; switch (column->type) { case VIEW_COLUMN_DATE: if (draw_date(view, column, column_data.date)) return true; continue; case VIEW_COLUMN_AUTHOR: if (draw_author(view, column, column_data.author)) return true; continue; case VIEW_COLUMN_REF: if (draw_ref(view, column, column_data.ref)) return true; continue; case VIEW_COLUMN_ID: if (draw_id(view, column, column_data.reflog ? column_data.reflog : column_data.id)) return true; continue; case VIEW_COLUMN_LINE_NUMBER: if (draw_lineno(view, column, column_data.line_number ? *column_data.line_number : lineno)) return true; continue; case VIEW_COLUMN_MODE: if (draw_mode(view, column, mode)) return true; continue; case VIEW_COLUMN_FILE_SIZE: if (draw_file_size(view, column, column_data.file_size ? *column_data.file_size : 0, mode)) return true; continue; case VIEW_COLUMN_COMMIT_TITLE: if (draw_commit_title(view, column, column_data.graph, column_data.graph_canvas, column_data.refs, column_data.commit_title)) return true; continue; case VIEW_COLUMN_FILE_NAME: if (draw_filename(view, column, column_data.file_name, mode)) return true; continue; case VIEW_COLUMN_SECTION: if (draw_text(view, column->opt.section.type, column->opt.section.text)) return true; continue; case VIEW_COLUMN_STATUS: if (draw_status(view, column, line->type, column_data.status)) return true; continue; case VIEW_COLUMN_TEXT: { enum line_type type = line->type; const char *text = column_data.text; if (line->wrapped && draw_text(view, LINE_DELIMITER, "+")) return true; if (line->graph_indent) { size_t indent = get_graph_indent(text); if (draw_text_expanded(view, LINE_DEFAULT, text, -1, indent, false)) return true; text += indent; } if (line->commit_title) { if (draw_text_overflow(view, text, LINE_DEFAULT, column->opt.text.commit_title_overflow, 4)) return true; } else if (column_data.box) { const struct box *box = column_data.box; const char *text = box->text; size_t i; for (i = 0; i < box->cells; i++) { const struct box_cell *cell = &box->cell[i]; if (draw_textn(view, cell->type, text, cell->length)) return true; text += cell->length; } } else if (draw_text(view, type, text)) { return true; } } continue; } } return true; }
bool view_column_draw(struct view *view, struct line *line, unsigned int lineno) { struct view_column *column; struct view_column_data column_data = {}; if (!view->ops->get_column_data(view, line, &column_data)) return TRUE; for (column = view->columns; column; column = column->next) { mode_t mode = column_data.mode ? *column_data.mode : 0; int width = column->width; if (column->hidden) continue; switch (column->type) { case VIEW_COLUMN_DATE: if (draw_date(view, column, column_data.date)) return TRUE; continue; case VIEW_COLUMN_AUTHOR: if (draw_author(view, column, column_data.author)) return TRUE; continue; case VIEW_COLUMN_REF: { const struct ref *ref = column_data.ref; enum line_type type = !ref || !ref->valid ? LINE_DEFAULT : get_line_type_from_ref(ref); const char *name = ref ? ref->name : NULL; if (draw_field(view, type, name, width, ALIGN_LEFT, FALSE)) return TRUE; continue; } case VIEW_COLUMN_ID: if (draw_id(view, column, column_data.id)) return TRUE; continue; case VIEW_COLUMN_LINE_NUMBER: if (draw_lineno(view, column, column_data.line_number ? *column_data.line_number : lineno)) return TRUE; continue; case VIEW_COLUMN_MODE: if (draw_mode(view, mode)) return TRUE; continue; case VIEW_COLUMN_FILE_SIZE: if (draw_file_size(view, column, column_data.file_size ? *column_data.file_size : 0, mode)) return TRUE; continue; case VIEW_COLUMN_COMMIT_TITLE: if (column_data.graph && draw_graph(view, column_data.graph)) return TRUE; if (column_data.refs && draw_refs(view, column, column_data.refs)) return TRUE; if (draw_commit_title(view, column_data.commit_title, 0)) return TRUE; continue; case VIEW_COLUMN_FILE_NAME: if (draw_filename(view, column, column_data.file_name, TRUE, mode)) return TRUE; continue; case VIEW_COLUMN_TEXT: if (line->wrapped && draw_text(view, LINE_DELIMITER, "+")) return TRUE; if (draw_text(view, line->type, column_data.text)) return TRUE; continue; } } return TRUE; }