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

📄 gtkctree.c

📁 gtk是linux一款强大的夸平台的图形化开发工具
💻 C
📖 第 1 页 / 共 5 页
字号:
      if (!clist->column[i].visible)	continue;      get_cell_style (clist, clist_row, state, i, &style, &fg_gc, &bg_gc);      /* calculate clipping region */      clip_rectangle.x = clist->column[i].area.x + clist->hoffset;      clip_rectangle.width = clist->column[i].area.width;      cell_rectangle.x = clip_rectangle.x - COLUMN_INSET - CELL_SPACING;      cell_rectangle.width = (clip_rectangle.width + 2 * COLUMN_INSET +			      (1 + (i == last_column)) * CELL_SPACING);      cell_rectangle.y = clip_rectangle.y;      cell_rectangle.height = clip_rectangle.height;      string_width = 0;      pixmap_width = 0;      if (area && !gdk_rectangle_intersect (area, &cell_rectangle,					    &intersect_rectangle))	{	  if (i != ctree->tree_column)	    continue;	}      else	{	  gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,			      crect->x, crect->y, crect->width, crect->height);	  /* calculate real width for column justification */	  switch (clist_row->cell[i].type)	    {	    case GTK_CELL_TEXT:	      width = gdk_string_width		(style->font, GTK_CELL_TEXT (clist_row->cell[i])->text);	      break;	    case GTK_CELL_PIXMAP:	      gdk_window_get_size		(GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap, &pixmap_width,		 &height);	      width = pixmap_width;	      break;	    case GTK_CELL_PIXTEXT:	      if (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap)		gdk_window_get_size		  (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,		   &pixmap_width, &height);	      width = pixmap_width;	      if (GTK_CELL_PIXTEXT (clist_row->cell[i])->text)		{		  string_width = gdk_string_width		    (style->font, GTK_CELL_PIXTEXT (clist_row->cell[i])->text);		  width += string_width;		}	      if (GTK_CELL_PIXTEXT (clist_row->cell[i])->text &&		  GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap)		width +=  GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;	      if (i == ctree->tree_column)		width += (ctree->tree_indent *			  ((GtkCTreeRow *)clist_row)->level);	      break;	    default:	      continue;	      break;	    }	  switch (clist->column[i].justification)	    {	    case GTK_JUSTIFY_LEFT:	      offset = clip_rectangle.x + clist_row->cell[i].horizontal;	      break;	    case GTK_JUSTIFY_RIGHT:	      offset = (clip_rectangle.x + clist_row->cell[i].horizontal +			clip_rectangle.width - width);	      break;	    case GTK_JUSTIFY_CENTER:	    case GTK_JUSTIFY_FILL:	      offset = (clip_rectangle.x + clist_row->cell[i].horizontal +			(clip_rectangle.width / 2) - (width / 2));	      break;	    };	  if (i != ctree->tree_column)	    {	      offset += clist_row->cell[i].horizontal;	      switch (clist_row->cell[i].type)		{		case GTK_CELL_PIXMAP:		  draw_cell_pixmap		    (clist->clist_window, &clip_rectangle, fg_gc,		     GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,		     GTK_CELL_PIXMAP (clist_row->cell[i])->mask,		     offset,		     clip_rectangle.y + clist_row->cell[i].vertical +		     (clip_rectangle.height - height) / 2,		     pixmap_width, height);		  break;		case GTK_CELL_PIXTEXT:		  offset = draw_cell_pixmap		    (clist->clist_window, &clip_rectangle, fg_gc,		     GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,		     GTK_CELL_PIXTEXT (clist_row->cell[i])->mask,		     offset,		     clip_rectangle.y + clist_row->cell[i].vertical +		     (clip_rectangle.height - height) / 2,		     pixmap_width, height);		  offset += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;		case GTK_CELL_TEXT:		  if (style != GTK_WIDGET (clist)->style)		    row_center_offset = (((clist->row_height -					   style->font->ascent -					   style->font->descent - 1) / 2) +					 1.5 + style->font->ascent);		  else		    row_center_offset = clist->row_center_offset;		  gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);		  gdk_draw_string		    (clist->clist_window, style->font, fg_gc,		     offset,		     row_rectangle.y + row_center_offset +		     clist_row->cell[i].vertical,		     (clist_row->cell[i].type == GTK_CELL_PIXTEXT) ?		     GTK_CELL_PIXTEXT (clist_row->cell[i])->text :		     GTK_CELL_TEXT (clist_row->cell[i])->text);		  gdk_gc_set_clip_rectangle (fg_gc, NULL);		  break;		default:		  break;		}	      continue;	    }	}      if (bg_gc == clist->bg_gc)	gdk_gc_set_background (ctree->lines_gc, &clist_row->background);      /* draw ctree->tree_column */      cell_rectangle.y -= CELL_SPACING;      cell_rectangle.height += CELL_SPACING;      if (area && !gdk_rectangle_intersect (area, &cell_rectangle,					    &intersect_rectangle))	continue;      /* draw lines */      offset = gtk_ctree_draw_lines (ctree, (GtkCTreeRow *)clist_row, row, i,				     state, &clip_rectangle, &cell_rectangle,				     crect, area, style);      /* draw expander */      offset = gtk_ctree_draw_expander (ctree, (GtkCTreeRow *)clist_row,					style, &clip_rectangle, offset);      if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)	offset -= ctree->tree_spacing;      else	offset += ctree->tree_spacing;      if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)	offset -= (pixmap_width + clist_row->cell[i].horizontal);      else	offset += clist_row->cell[i].horizontal;      old_offset = offset;      offset = draw_cell_pixmap (clist->clist_window, &clip_rectangle, fg_gc,				 GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,				 GTK_CELL_PIXTEXT (clist_row->cell[i])->mask,				 offset, 				 clip_rectangle.y + clist_row->cell[i].vertical				 + (clip_rectangle.height - height) / 2,				 pixmap_width, height);      if (string_width)	{ 	  if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)	    {	      offset = (old_offset - string_width);	      if (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap)		offset -= GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;	    }	  else	    {	      if (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap)		offset += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;	    }	  if (style != GTK_WIDGET (clist)->style)	    row_center_offset = (((clist->row_height - style->font->ascent -				   style->font->descent - 1) / 2) +				 1.5 + style->font->ascent);	  else	    row_center_offset = clist->row_center_offset;	  	  gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);	  gdk_draw_string (clist->clist_window, style->font, fg_gc, offset,			   row_rectangle.y + row_center_offset +			   clist_row->cell[i].vertical,			   GTK_CELL_PIXTEXT (clist_row->cell[i])->text);	}      gdk_gc_set_clip_rectangle (fg_gc, NULL);    }  /* draw focus rectangle */  if (clist->focus_row == row &&      GTK_WIDGET_CAN_FOCUS (widget) && GTK_WIDGET_HAS_FOCUS (widget))    {      if (!area)	gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,			    row_rectangle.x, row_rectangle.y,			    row_rectangle.width - 1, row_rectangle.height - 1);      else if (gdk_rectangle_intersect (area, &row_rectangle,					&intersect_rectangle))	{	  gdk_gc_set_clip_rectangle (clist->xor_gc, &intersect_rectangle);	  gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,			      row_rectangle.x, row_rectangle.y,			      row_rectangle.width - 1,			      row_rectangle.height - 1);	  gdk_gc_set_clip_rectangle (clist->xor_gc, NULL);	}    }}static voidtree_draw_node (GtkCTree     *ctree, 	        GtkCTreeNode *node){  GtkCList *clist;    clist = GTK_CLIST (ctree);  if (CLIST_UNFROZEN (clist) && gtk_ctree_is_viewable (ctree, node))    {      GtkCTreeNode *work;      gint num = 0;            work = GTK_CTREE_NODE (clist->row_list);      while (work && work != node)	{	  work = GTK_CTREE_NODE_NEXT (work);	  num++;	}      if (work && gtk_clist_row_is_visible (clist, num) != GTK_VISIBILITY_NONE)	GTK_CLIST_CLASS_FW (clist)->draw_row	  (clist, NULL, num, GTK_CLIST_ROW ((GList *) node));    }}static GtkCTreeNode *gtk_ctree_last_visible (GtkCTree     *ctree,			GtkCTreeNode *node){  GtkCTreeNode *work;    if (!node)    return NULL;  work = GTK_CTREE_ROW (node)->children;  if (!work || !GTK_CTREE_ROW (node)->expanded)    return node;  while (GTK_CTREE_ROW (work)->sibling)    work = GTK_CTREE_ROW (work)->sibling;  return gtk_ctree_last_visible (ctree, work);}static voidgtk_ctree_link (GtkCTree     *ctree,		GtkCTreeNode *node,		GtkCTreeNode *parent,		GtkCTreeNode *sibling,		gboolean      update_focus_row){  GtkCList *clist;  GList *list_end;  GList *list;  GList *work;  gboolean visible = FALSE;  gint rows = 0;    if (sibling)    g_return_if_fail (GTK_CTREE_ROW (sibling)->parent == parent);  g_return_if_fail (node != NULL);  g_return_if_fail (node != sibling);  g_return_if_fail (node != parent);  clist = GTK_CLIST (ctree);  if (update_focus_row && clist->selection_mode == GTK_SELECTION_EXTENDED)    {      if (clist->anchor != -1)	GTK_CLIST_CLASS_FW (clist)->resync_selection (clist, NULL);            g_list_free (clist->undo_selection);      g_list_free (clist->undo_unselection);      clist->undo_selection = NULL;      clist->undo_unselection = NULL;    }  for (rows = 1, list_end = (GList *)node; list_end->next;       list_end = list_end->next)    rows++;  GTK_CTREE_ROW (node)->parent = parent;  GTK_CTREE_ROW (node)->sibling = sibling;  if (!parent || (parent && (gtk_ctree_is_viewable (ctree, parent) &&			     GTK_CTREE_ROW (parent)->expanded)))    {      visible = TRUE;      clist->rows += rows;    }  if (parent)    work = (GList *)(GTK_CTREE_ROW (parent)->children);  else    work = clist->row_list;  if (sibling)    {      if (work != (GList *)sibling)	{	  while (GTK_CTREE_ROW (work)->sibling != sibling)	    work = (GList *)(GTK_CTREE_ROW (work)->sibling);	  GTK_CTREE_ROW (work)->sibling = node;	}      if (sibling == GTK_CTREE_NODE (clist->row_list))	clist->row_list = (GList *) node;      if (GTK_CTREE_NODE_PREV (sibling) &&	  GTK_CTREE_NODE_NEXT (GTK_CTREE_NODE_PREV (sibling)) == sibling)	{	  list = (GList *)GTK_CTREE_NODE_PREV (sibling);	  list->next = (GList *)node;	}            list = (GList *)node;      list->prev = (GList *)GTK_CTREE_NODE_PREV (sibling);      list_end->next = (GList *)sibling;      list = (GList *)sibling;      list->prev = list_end;      if (parent && GTK_CTREE_ROW (parent)->children == sibling)	GTK_CTREE_ROW (parent)->children = node;    }  else    {      if (work)	{	  /* find sibling */	  while (GTK_CTREE_ROW (work)->sibling)	    work = (GList *)(GTK_CTREE_ROW (work)->sibling);	  GTK_CTREE_ROW (work)->sibling = node;	  	  /* find last visible child of sibling */	  work = (GList *) gtk_ctree_last_visible (ctree,						   GTK_CTREE_NODE (work));	  	  list_end->next = work->next;	  if (work->next)	    list = work->next->prev = list_end;	  work->next = (GList *)node;	  list = (GList *)node;	  list->prev = work;	}      else	{	  if (parent)	    {	      GTK_CTREE_ROW (parent)->children = node;	      list = (GList *)node;	      list->prev = (GList *)parent;	      if (GTK_CTREE_ROW (parent)->expanded)		{		  list_end->next = (GList *)GTK_CTREE_NODE_NEXT (parent);		  if (GTK_CTREE_NODE_NEXT(parent))		    {		      list = (GList *)GTK_CTREE_NODE_NEXT (parent);		      list->prev = list_end;		    }		  list = (GList *)parent;		  list->next = (GList *)node;		}	      else		list_end->next = NULL;	    }	  else	    {	      clist->row_list = (GList *)node;	      list = (GList *)node;	      list->prev = NULL;	      list_end->next = NULL;	    }	}    }  gtk_ctree_pre_recursive (ctree, node, tree_update_level, NULL);   if (clist->row_list_end == NULL ||      clist->row_list_end->next == (GList *)node)    clist->row_list_end = list_end;  if (visible && update_focus_row)    {      gint pos;	        pos = g_list_position (clist->row_list, (GList *)node);        if (pos <= clist->focus_row)	{	  clist->focus_row += rows;	  clist->undo_anchor = clist->focus_row;	}    }}static voidgtk_ctree_unlink (GtkCTree     *ctree, 		  GtkCTreeNode *node,                  gboolean      update_focus_row){  GtkCList *clist;  gint rows;  gint level;  gint visible;  GtkCTreeNode *work;  GtkCTreeNode *parent;  GList *list;  g_return_if_fail (ctree != NULL);  g_return_i

⌨️ 快捷键说明

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