📄 gtkctree.c
字号:
gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE, tree_rectangle.x, tree_rectangle.y, tree_rectangle.width, tree_rectangle.height); else gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE, tc_rectangle.x, tc_rectangle.y, tc_rectangle.width, tc_rectangle.height); } if (next_level > GTK_CTREE_ROW (node)->level) gdk_draw_line (clist->clist_window, ctree->lines_gc, xcenter, crect->y, xcenter, crect->y + crect->height); else { gint width; offset_x = MIN (ctree->tree_indent, 2 * TAB_SIZE); width = offset_x / 2 + offset_x % 2; parent = GTK_CTREE_ROW (node)->parent; tree_rectangle.y = ycenter; tree_rectangle.height = (cell_rectangle->y - ycenter + cell_rectangle->height); if (justify_right) { tree_rectangle.x = MAX(xcenter + 1 - width, column_left); tree_rectangle.width = MIN (xcenter + 1 - column_left, width); } else { tree_rectangle.x = xcenter; tree_rectangle.width = MIN (column_right - xcenter, width); } if (!area || gdk_rectangle_intersect (area, &tree_rectangle, &tc_rectangle)) { if (parent) { get_cell_style (clist, >K_CTREE_ROW (parent)->row, state, column, NULL, NULL, &bg_gc); if (bg_gc == clist->bg_gc) gdk_gc_set_foreground (clist->bg_gc, >K_CTREE_ROW (parent)->row.background); } else if (state == GTK_STATE_SELECTED) bg_gc = style->base_gc[state]; else bg_gc = GTK_WIDGET (clist)->style->base_gc[state]; if (!area) gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE, tree_rectangle.x, tree_rectangle.y, tree_rectangle.width, tree_rectangle.height); else gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE, tc_rectangle.x, tc_rectangle.y, tc_rectangle.width, tc_rectangle.height); } get_cell_style (clist, >K_CTREE_ROW (node)->row, state, column, NULL, NULL, &bg_gc); if (bg_gc == clist->bg_gc) gdk_gc_set_foreground (clist->bg_gc, >K_CTREE_ROW (node)->row.background); gdk_gc_set_clip_rectangle (bg_gc, crect); gdk_draw_arc (clist->clist_window, bg_gc, TRUE, xcenter - (justify_right * offset_x), cell_rectangle->y, offset_x, clist->row_height, (180 + (justify_right * 90)) * 64, 90 * 64); gdk_gc_set_clip_rectangle (bg_gc, NULL); gdk_draw_line (clist->clist_window, ctree->lines_gc, xcenter, cell_rectangle->y, xcenter, ycenter); if (justify_right) gdk_draw_arc (clist->clist_window, ctree->lines_gc, FALSE, xcenter - offset_x, cell_rectangle->y, offset_x, clist->row_height, 270 * 64, 90 * 64); else gdk_draw_arc (clist->clist_window, ctree->lines_gc, FALSE, xcenter, cell_rectangle->y, offset_x, clist->row_height, 180 * 64, 90 * 64); } node = GTK_CTREE_ROW (node)->parent; } } if (state != GTK_STATE_SELECTED) { tree_rectangle.y = clip_rectangle->y; tree_rectangle.height = clip_rectangle->height; tree_rectangle.width = COLUMN_INSET + CELL_SPACING + MIN (clist->column[ctree->tree_column].area.width + COLUMN_INSET, TAB_SIZE); if (justify_right) tree_rectangle.x = MAX (xcenter + 1, column_left); else tree_rectangle.x = column_left; if (!area) gdk_draw_rectangle (clist->clist_window, GTK_WIDGET (ctree)->style->base_gc[GTK_STATE_NORMAL], TRUE, tree_rectangle.x, tree_rectangle.y, tree_rectangle.width, tree_rectangle.height); else if (gdk_rectangle_intersect (area, &tree_rectangle, &tc_rectangle)) gdk_draw_rectangle (clist->clist_window, GTK_WIDGET (ctree)->style->base_gc[GTK_STATE_NORMAL], TRUE, tc_rectangle.x, tc_rectangle.y, tc_rectangle.width, tc_rectangle.height); } xcenter = offset + (justification_factor * ctree->tree_indent / 2); get_cell_style (clist, &ctree_row->row, state, column, NULL, NULL, &bg_gc); if (bg_gc == clist->bg_gc) gdk_gc_set_foreground (clist->bg_gc, &ctree_row->row.background); gdk_gc_set_clip_rectangle (bg_gc, crect); if (ctree_row->is_leaf) { GdkPoint points[6]; points[0].x = offset + justification_factor * TAB_SIZE; points[0].y = cell_rectangle->y; points[1].x = points[0].x - justification_factor * 4; points[1].y = points[0].y; points[2].x = points[1].x - justification_factor * 2; points[2].y = points[1].y + 3; points[3].x = points[2].x; points[3].y = points[2].y + clist->row_height - 5; points[4].x = points[3].x + justification_factor * 2; points[4].y = points[3].y + 3; points[5].x = points[4].x + justification_factor * 4; points[5].y = points[4].y; gdk_draw_polygon (clist->clist_window, bg_gc, TRUE, points, 6); gdk_draw_lines (clist->clist_window, ctree->lines_gc, points, 6); } else { gdk_draw_arc (clist->clist_window, bg_gc, TRUE, offset - (justify_right * 2 * TAB_SIZE), cell_rectangle->y, 2 * TAB_SIZE, clist->row_height, (90 + (180 * justify_right)) * 64, 180 * 64); gdk_draw_arc (clist->clist_window, ctree->lines_gc, FALSE, offset - (justify_right * 2 * TAB_SIZE), cell_rectangle->y, 2 * TAB_SIZE, clist->row_height, (90 + (180 * justify_right)) * 64, 180 * 64); } gdk_gc_set_clip_rectangle (bg_gc, NULL); gdk_gc_set_clip_rectangle (ctree->lines_gc, NULL); offset += justification_factor * 3; break; default: xcenter = offset + justification_factor * PM_SIZE / 2; if (area) { tree_rectangle.y = crect->y; tree_rectangle.height = crect->height; if (justify_right) { tree_rectangle.x = xcenter - PM_SIZE / 2 - 2; tree_rectangle.width = (clip_rectangle->x + clip_rectangle->width -tree_rectangle.x); } else { tree_rectangle.x = clip_rectangle->x + PM_SIZE / 2; tree_rectangle.width = (xcenter + PM_SIZE / 2 + 2 - clip_rectangle->x); } if (!gdk_rectangle_intersect (area, &tree_rectangle, &tc_rectangle)) break; } offset_x = 1; offset_y = 0; if (ctree->line_style == GTK_CTREE_LINES_DOTTED) { offset_x += abs((clip_rectangle->x + clist->hoffset) % 2); offset_y = abs((cell_rectangle->y + clist->voffset) % 2); } clip_rectangle->y--; clip_rectangle->height++; gdk_gc_set_clip_rectangle (ctree->lines_gc, clip_rectangle); gdk_draw_line (clist->clist_window, ctree->lines_gc, xcenter, (ctree->show_stub || clist->row_list->data != ctree_row) ? cell_rectangle->y + offset_y : ycenter, xcenter, (ctree_row->sibling) ? crect->y +crect->height : ycenter); gdk_draw_line (clist->clist_window, ctree->lines_gc, xcenter + (justification_factor * offset_x), ycenter, xcenter + (justification_factor * (PM_SIZE / 2 + 2)), ycenter); node = ctree_row->parent; while (node) { xcenter -= (justification_factor * ctree->tree_indent); if (GTK_CTREE_ROW (node)->sibling) gdk_draw_line (clist->clist_window, ctree->lines_gc, xcenter, cell_rectangle->y + offset_y, xcenter, crect->y + crect->height); node = GTK_CTREE_ROW (node)->parent; } gdk_gc_set_clip_rectangle (ctree->lines_gc, NULL); clip_rectangle->y++; clip_rectangle->height--; break; } return offset;}static voiddraw_row (GtkCList *clist, GdkRectangle *area, gint row, GtkCListRow *clist_row){ GtkWidget *widget; GtkCTree *ctree; GdkRectangle *rect; GdkRectangle *crect; GdkRectangle row_rectangle; GdkRectangle cell_rectangle; GdkRectangle clip_rectangle; GdkRectangle intersect_rectangle; gint last_column; gint column_left = 0; gint column_right = 0; gint offset = 0; gint state; gint i; g_return_if_fail (clist != NULL); /* bail now if we arn't drawable yet */ if (!GTK_WIDGET_DRAWABLE (clist) || row < 0 || row >= clist->rows) return; widget = GTK_WIDGET (clist); ctree = GTK_CTREE (clist); /* if the function is passed the pointer to the row instead of null, * it avoids this expensive lookup */ if (!clist_row) clist_row = (g_list_nth (clist->row_list, row))->data; /* rectangle of the entire row */ row_rectangle.x = 0; row_rectangle.y = ROW_TOP_YPIXEL (clist, row); row_rectangle.width = clist->clist_window_width; row_rectangle.height = clist->row_height; /* rectangle of the cell spacing above the row */ cell_rectangle.x = 0; cell_rectangle.y = row_rectangle.y - CELL_SPACING; cell_rectangle.width = row_rectangle.width; cell_rectangle.height = CELL_SPACING; /* rectangle used to clip drawing operations, it's y and height * positions only need to be set once, so we set them once here. * the x and width are set withing the drawing loop below once per * column */ clip_rectangle.y = row_rectangle.y; clip_rectangle.height = row_rectangle.height; if (clist_row->state == GTK_STATE_NORMAL) { if (clist_row->fg_set) gdk_gc_set_foreground (clist->fg_gc, &clist_row->foreground); if (clist_row->bg_set) gdk_gc_set_foreground (clist->bg_gc, &clist_row->background); } state = clist_row->state; gdk_gc_set_foreground (ctree->lines_gc, &widget->style->fg[clist_row->state]); /* draw the cell borders */ if (area) { rect = &intersect_rectangle; crect = &intersect_rectangle; if (gdk_rectangle_intersect (area, &cell_rectangle, crect)) gdk_draw_rectangle (clist->clist_window, widget->style->base_gc[GTK_STATE_ACTIVE], TRUE, crect->x, crect->y, crect->width, crect->height); } else { rect = &clip_rectangle; crect = &cell_rectangle; gdk_draw_rectangle (clist->clist_window, widget->style->base_gc[GTK_STATE_ACTIVE], TRUE, crect->x, crect->y, crect->width, crect->height); } /* horizontal black lines */ if (ctree->line_style == GTK_CTREE_LINES_TABBED) { column_right = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) + clist->column[ctree->tree_column].area.width + COLUMN_INSET); column_left = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) - COLUMN_INSET - (ctree->tree_column != 0) * CELL_SPACING); switch (clist->column[ctree->tree_column].justification) { case GTK_JUSTIFY_CENTER: case GTK_JUSTIFY_FILL: case GTK_JUSTIFY_LEFT: offset = (column_left + ctree->tree_indent * (((GtkCTreeRow *)clist_row)->level - 1)); gdk_draw_line (clist->clist_window, ctree->lines_gc, MIN (offset + TAB_SIZE, column_right), cell_rectangle.y, clist->clist_window_width, cell_rectangle.y); break; case GTK_JUSTIFY_RIGHT: offset = (column_right - 1 - ctree->tree_indent * (((GtkCTreeRow *)clist_row)->level - 1)); gdk_draw_line (clist->clist_window, ctree->lines_gc, -1, cell_rectangle.y, MAX (offset - TAB_SIZE, column_left), cell_rectangle.y); break; } } /* the last row has to clear it's bottom cell spacing too */ if (clist_row == clist->row_list_end->data) { cell_rectangle.y += clist->row_height + CELL_SPACING; if (!area || gdk_rectangle_intersect (area, &cell_rectangle, crect)) { gdk_draw_rectangle (clist->clist_window, widget->style->base_gc[GTK_STATE_ACTIVE], TRUE, crect->x, crect->y, crect->width, crect->height); /* horizontal black lines */ if (ctree->line_style == GTK_CTREE_LINES_TABBED) { switch (clist->column[ctree->tree_column].justification) { case GTK_JUSTIFY_CENTER: case GTK_JUSTIFY_FILL: case GTK_JUSTIFY_LEFT: gdk_draw_line (clist->clist_window, ctree->lines_gc, MIN (column_left + TAB_SIZE + COLUMN_INSET + (((GtkCTreeRow *)clist_row)->level > 1) * MIN (ctree->tree_indent / 2, TAB_SIZE), column_right), cell_rectangle.y, clist->clist_window_width, cell_rectangle.y); break; case GTK_JUSTIFY_RIGHT: gdk_draw_line (clist->clist_window, ctree->lines_gc, -1, cell_rectangle.y, MAX (column_right - TAB_SIZE - 1 - COLUMN_INSET - (((GtkCTreeRow *)clist_row)->level > 1) * MIN (ctree->tree_indent / 2, TAB_SIZE), column_left - 1), cell_rectangle.y); break; } } } } for (last_column = clist->columns - 1; last_column >= 0 && !clist->column[last_column].visible; last_column--) ; /* iterate and draw all the columns (row cells) and draw their contents */ for (i = 0; i < clist->columns; i++) { GtkStyle *style; GdkGC *fg_gc; GdkGC *bg_gc; gint width; gint height; gint pixmap_width; gint string_width; gint old_offset; gint row_center_offset;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -