⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gtkctree.c

📁 gtk是linux一款强大的夸平台的图形化开发工具
💻 C
📖 第 1 页 / 共 5 页
字号:
	    points[0].y = y;	    points[3].x = points[0].x;	    points[3].y = y - clist->row_height - 1;	    points[1].x = clist->clist_window_width - 1;	    points[1].y = points[0].y;	    points[2].x = points[1].x;	    points[2].y = points[3].y;	    for (i = 0; i < 3; i++)	      gdk_draw_line (clist->clist_window, clist->xor_gc,			     points[i].x, points[i].y,			     points[i+1].x, points[i+1].y);	    if (ctree->tree_column > 0)	      {		points[0].x = COLUMN_LEFT_XPIXEL(clist,						 ctree->tree_column - 1) +		  clist->column[ctree->tree_column - 1].area.width ;		points[0].y = y;		points[3].x = points[0].x;		points[3].y = y - clist->row_height - 1;		points[1].x = 0;		points[1].y = points[0].y;		points[2].x = 0;		points[2].y = points[3].y;		for (i = 0; i < 3; i++)		  gdk_draw_line (clist->clist_window, clist->xor_gc,				 points[i].x, points[i].y, points[i+1].x, 				 points[i+1].y);	      }	    break;	  case GTK_JUSTIFY_RIGHT:	    points[0].x =  COLUMN_LEFT_XPIXEL(clist, ctree->tree_column) - 	      ctree->tree_indent * level + (ctree->tree_indent - PM_SIZE) / 2 +	      clist->column[ctree->tree_column].area.width;	    points[0].y = y;	    points[3].x = points[0].x;	    points[3].y = y - clist->row_height - 1;	    points[1].x = 0;	    points[1].y = points[0].y;	    points[2].x = 0;	    points[2].y = points[3].y;	    for (i = 0; i < 3; i++)	      gdk_draw_line (clist->clist_window, clist->xor_gc,			     points[i].x, points[i].y,			     points[i+1].x, points[i+1].y);	    if (ctree->tree_column < clist->columns - 1)	      {		points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column +1);		points[0].y = y;		points[3].x = points[0].x;		points[3].y = y - clist->row_height - 1;		points[1].x = clist->clist_window_width - 1;		points[1].y = points[0].y;		points[2].x = points[1].x;		points[2].y = points[3].y;		for (i = 0; i < 3; i++)		  gdk_draw_line (clist->clist_window, clist->xor_gc,				 points[i].x, points[i].y,				 points[i+1].x, points[i+1].y);	      }	    break;	  }      else	gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,			    0, y - clist->row_height,			    clist->clist_window_width - 1, clist->row_height);      break;    }}static gintdraw_cell_pixmap (GdkWindow    *window,		  GdkRectangle *clip_rectangle,		  GdkGC        *fg_gc,		  GdkPixmap    *pixmap,		  GdkBitmap    *mask,		  gint          x,		  gint          y,		  gint          width,		  gint          height){  gint xsrc = 0;  gint ysrc = 0;  if (mask)    {      gdk_gc_set_clip_mask (fg_gc, mask);      gdk_gc_set_clip_origin (fg_gc, x, y);    }  if (x < clip_rectangle->x)    {      xsrc = clip_rectangle->x - x;      width -= xsrc;      x = clip_rectangle->x;    }  if (x + width > clip_rectangle->x + clip_rectangle->width)    width = clip_rectangle->x + clip_rectangle->width - x;  if (y < clip_rectangle->y)    {      ysrc = clip_rectangle->y - y;      height -= ysrc;      y = clip_rectangle->y;    }  if (y + height > clip_rectangle->y + clip_rectangle->height)    height = clip_rectangle->y + clip_rectangle->height - y;  if (width > 0 && height > 0)    gdk_draw_pixmap (window, fg_gc, pixmap, xsrc, ysrc, x, y, width, height);  if (mask)    {      gdk_gc_set_clip_rectangle (fg_gc, NULL);      gdk_gc_set_clip_origin (fg_gc, 0, 0);    }  return x + MAX (width, 0);}static voidget_cell_style (GtkCList     *clist,		GtkCListRow  *clist_row,		gint          state,		gint          column,		GtkStyle    **style,		GdkGC       **fg_gc,		GdkGC       **bg_gc){  gint fg_state;  if ((state == GTK_STATE_NORMAL) &&      (GTK_WIDGET (clist)->state == GTK_STATE_INSENSITIVE))    fg_state = GTK_STATE_INSENSITIVE;  else    fg_state = state;  if (clist_row->cell[column].style)    {      if (style)	*style = clist_row->cell[column].style;      if (fg_gc)	*fg_gc = clist_row->cell[column].style->fg_gc[fg_state];      if (bg_gc) {	if (state == GTK_STATE_SELECTED)	  *bg_gc = clist_row->cell[column].style->bg_gc[state];	else	  *bg_gc = clist_row->cell[column].style->base_gc[state];      }    }  else if (clist_row->style)    {      if (style)	*style = clist_row->style;      if (fg_gc)	*fg_gc = clist_row->style->fg_gc[fg_state];      if (bg_gc) {	if (state == GTK_STATE_SELECTED)	  *bg_gc = clist_row->style->bg_gc[state];	else	  *bg_gc = clist_row->style->base_gc[state];      }    }  else    {      if (style)	*style = GTK_WIDGET (clist)->style;      if (fg_gc)	*fg_gc = GTK_WIDGET (clist)->style->fg_gc[fg_state];      if (bg_gc) {	if (state == GTK_STATE_SELECTED)	  *bg_gc = GTK_WIDGET (clist)->style->bg_gc[state];	else	  *bg_gc = GTK_WIDGET (clist)->style->base_gc[state];      }      if (state != GTK_STATE_SELECTED)	{	  if (fg_gc && clist_row->fg_set)	    *fg_gc = clist->fg_gc;	  if (bg_gc && clist_row->bg_set)	    *bg_gc = clist->bg_gc;	}    }}static gintgtk_ctree_draw_expander (GtkCTree     *ctree,			 GtkCTreeRow  *ctree_row,			 GtkStyle     *style,			 GdkRectangle *clip_rectangle,			 gint          x){  GtkCList *clist;  GdkPoint points[3];  gint justification_factor;  gint y; if (ctree->expander_style == GTK_CTREE_EXPANDER_NONE)   return x;  clist = GTK_CLIST (ctree);  if (clist->column[ctree->tree_column].justification == GTK_JUSTIFY_RIGHT)    justification_factor = -1;  else    justification_factor = 1;  y = (clip_rectangle->y + (clip_rectangle->height - PM_SIZE) / 2 -       (clip_rectangle->height + 1) % 2);  if (!ctree_row->children)    {      switch (ctree->expander_style)	{	case GTK_CTREE_EXPANDER_NONE:	  return x;	case GTK_CTREE_EXPANDER_TRIANGLE:	  return x + justification_factor * (PM_SIZE + 3);	case GTK_CTREE_EXPANDER_SQUARE:	case GTK_CTREE_EXPANDER_CIRCULAR:	  return x + justification_factor * (PM_SIZE + 1);	}    }  gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], clip_rectangle);  gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], clip_rectangle);  switch (ctree->expander_style)    {    case GTK_CTREE_EXPANDER_NONE:      break;    case GTK_CTREE_EXPANDER_TRIANGLE:      if (ctree_row->expanded)	{	  points[0].x = x;	  points[0].y = y + (PM_SIZE + 2) / 6;	  points[1].x = points[0].x + justification_factor * (PM_SIZE + 2);	  points[1].y = points[0].y;	  points[2].x = (points[0].x +			 justification_factor * (PM_SIZE + 2) / 2);	  points[2].y = y + 2 * (PM_SIZE + 2) / 3;	}      else	{	  points[0].x = x + justification_factor * ((PM_SIZE + 2) / 6 + 2);	  points[0].y = y - 1;	  points[1].x = points[0].x;	  points[1].y = points[0].y + (PM_SIZE + 2);	  points[2].x = (points[0].x +			 justification_factor * (2 * (PM_SIZE + 2) / 3 - 1));	  points[2].y = points[0].y + (PM_SIZE + 2) / 2;	}      gdk_draw_polygon (clist->clist_window, style->base_gc[GTK_STATE_NORMAL],			TRUE, points, 3);      gdk_draw_polygon (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],			FALSE, points, 3);      x += justification_factor * (PM_SIZE + 3);      break;    case GTK_CTREE_EXPANDER_SQUARE:    case GTK_CTREE_EXPANDER_CIRCULAR:      if (justification_factor == -1)	x += justification_factor * (PM_SIZE + 1);      if (ctree->expander_style == GTK_CTREE_EXPANDER_CIRCULAR)	{	  gdk_draw_arc (clist->clist_window, style->base_gc[GTK_STATE_NORMAL],			TRUE, x, y, PM_SIZE, PM_SIZE, 0, 360 * 64);	  gdk_draw_arc (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],			FALSE, x, y, PM_SIZE, PM_SIZE, 0, 360 * 64);	}      else	{	  gdk_draw_rectangle (clist->clist_window,			      style->base_gc[GTK_STATE_NORMAL], TRUE,			      x, y, PM_SIZE, PM_SIZE);	  gdk_draw_rectangle (clist->clist_window,			      style->fg_gc[GTK_STATE_NORMAL], FALSE,			      x, y, PM_SIZE, PM_SIZE);	}      gdk_draw_line (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL], 		     x + 2, y + PM_SIZE / 2, x + PM_SIZE - 2, y + PM_SIZE / 2);      if (!ctree_row->expanded)	gdk_draw_line (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],		       x + PM_SIZE / 2, y + 2,		       x + PM_SIZE / 2, y + PM_SIZE - 2);      if (justification_factor == 1)	x += justification_factor * (PM_SIZE + 1);      break;    }  gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);  gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);  return x;}static gintgtk_ctree_draw_lines (GtkCTree     *ctree,		      GtkCTreeRow  *ctree_row,		      gint          row,		      gint          column,		      gint          state,		      GdkRectangle *clip_rectangle,		      GdkRectangle *cell_rectangle,		      GdkRectangle *crect,		      GdkRectangle *area,		      GtkStyle     *style){  GtkCList *clist;  GtkCTreeNode *node;  GtkCTreeNode *parent;  GdkRectangle tree_rectangle;  GdkRectangle tc_rectangle;  GdkGC *bg_gc;  gint offset;  gint offset_x;  gint offset_y;  gint xcenter;  gint ycenter;  gint next_level;  gint column_right;  gint column_left;  gint justify_right;  gint justification_factor;    clist = GTK_CLIST (ctree);  ycenter = clip_rectangle->y + (clip_rectangle->height / 2);  justify_right = (clist->column[column].justification == GTK_JUSTIFY_RIGHT);  if (justify_right)    {      offset = (clip_rectangle->x + clip_rectangle->width - 1 -		ctree->tree_indent * (ctree_row->level - 1));      justification_factor = -1;    }  else    {      offset = clip_rectangle->x + ctree->tree_indent * (ctree_row->level - 1);      justification_factor = 1;    }  switch (ctree->line_style)    {    case GTK_CTREE_LINES_NONE:      break;    case GTK_CTREE_LINES_TABBED:      xcenter = offset + justification_factor * TAB_SIZE;      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 - CELL_SPACING);      if (area)	{	  tree_rectangle.y = crect->y;	  tree_rectangle.height = crect->height;	  if (justify_right)	    {	      tree_rectangle.x = xcenter;	      tree_rectangle.width = column_right - xcenter;	    }	  else	    {	      tree_rectangle.x = column_left;	      tree_rectangle.width = xcenter - column_left;	    }	  if (!gdk_rectangle_intersect (area, &tree_rectangle, &tc_rectangle))	    {	      offset += justification_factor * 3;	      break;	    }	}      gdk_gc_set_clip_rectangle (ctree->lines_gc, crect);      next_level = ctree_row->level;      if (!ctree_row->sibling || (ctree_row->children && ctree_row->expanded))	{	  node = gtk_ctree_find_node_ptr (ctree, ctree_row);	  if (GTK_CTREE_NODE_NEXT (node))	    next_level = GTK_CTREE_ROW (GTK_CTREE_NODE_NEXT (node))->level;	  else	    next_level = 0;	}      if (ctree->tree_indent > 0)	{	  node = ctree_row->parent;	  while (node)	    {	      xcenter -= (justification_factor * ctree->tree_indent);	      if ((justify_right && xcenter < column_left) ||		  (!justify_right && xcenter > column_right))		{		  node = GTK_CTREE_ROW (node)->parent;		  continue;		}	      tree_rectangle.y = cell_rectangle->y;	      tree_rectangle.height = cell_rectangle->height;	      if (justify_right)		{		  tree_rectangle.x = MAX (xcenter - ctree->tree_indent + 1,					  column_left);		  tree_rectangle.width = MIN (xcenter - column_left,					      ctree->tree_indent);		}	      else		{		  tree_rectangle.x = xcenter;		  tree_rectangle.width = MIN (column_right - xcenter,					      ctree->tree_indent);		}	      if (!area || gdk_rectangle_intersect (area, &tree_rectangle,						    &tc_rectangle))		{		  get_cell_style (clist, &GTK_CTREE_ROW (node)->row,				  state, column, NULL, NULL, &bg_gc);		  if (bg_gc == clist->bg_gc)		    gdk_gc_set_foreground		      (clist->bg_gc, &GTK_CTREE_ROW (node)->row.background);		  if (!area)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -