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

📄 gtktable.c

📁 gtk是linux一款强大的夸平台的图形化开发工具
💻 C
📖 第 1 页 / 共 3 页
字号:
  g_return_if_fail (top_attach < bottom_attach);    if (right_attach >= table->ncols)    gtk_table_resize (table, table->nrows, right_attach);    if (bottom_attach >= table->nrows)    gtk_table_resize (table, bottom_attach, table->ncols);    table_child = g_new (GtkTableChild, 1);  table_child->widget = child;  table_child->left_attach = left_attach;  table_child->right_attach = right_attach;  table_child->top_attach = top_attach;  table_child->bottom_attach = bottom_attach;  table_child->xexpand = (xoptions & GTK_EXPAND) != 0;  table_child->xshrink = (xoptions & GTK_SHRINK) != 0;  table_child->xfill = (xoptions & GTK_FILL) != 0;  table_child->xpadding = xpadding;  table_child->yexpand = (yoptions & GTK_EXPAND) != 0;  table_child->yshrink = (yoptions & GTK_SHRINK) != 0;  table_child->yfill = (yoptions & GTK_FILL) != 0;  table_child->ypadding = ypadding;    table->children = g_list_prepend (table->children, table_child);    gtk_widget_set_parent (child, GTK_WIDGET (table));    if (GTK_WIDGET_REALIZED (child->parent))    gtk_widget_realize (child);  if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child))    {      if (GTK_WIDGET_MAPPED (child->parent))	gtk_widget_map (child);      gtk_widget_queue_resize (child);    }}voidgtk_table_attach_defaults (GtkTable  *table,			   GtkWidget *widget,			   guint      left_attach,			   guint      right_attach,			   guint      top_attach,			   guint      bottom_attach){  gtk_table_attach (table, widget,		    left_attach, right_attach,		    top_attach, bottom_attach,		    GTK_EXPAND | GTK_FILL,		    GTK_EXPAND | GTK_FILL,		    0, 0);}voidgtk_table_set_row_spacing (GtkTable *table,			   guint     row,			   guint     spacing){  g_return_if_fail (table != NULL);  g_return_if_fail (GTK_IS_TABLE (table));  g_return_if_fail (row + 1 < table->nrows);    if (table->rows[row].spacing != spacing)    {      table->rows[row].spacing = spacing;            if (GTK_WIDGET_VISIBLE (table))	gtk_widget_queue_resize (GTK_WIDGET (table));    }}voidgtk_table_set_col_spacing (GtkTable *table,			   guint     column,			   guint     spacing){  g_return_if_fail (table != NULL);  g_return_if_fail (GTK_IS_TABLE (table));  g_return_if_fail (column + 1 < table->ncols);    if (table->cols[column].spacing != spacing)    {      table->cols[column].spacing = spacing;            if (GTK_WIDGET_VISIBLE (table))	gtk_widget_queue_resize (GTK_WIDGET (table));    }}voidgtk_table_set_row_spacings (GtkTable *table,			    guint     spacing){  guint row;    g_return_if_fail (table != NULL);  g_return_if_fail (GTK_IS_TABLE (table));    table->row_spacing = spacing;  for (row = 0; row + 1 < table->nrows; row++)    table->rows[row].spacing = spacing;    if (GTK_WIDGET_VISIBLE (table))    gtk_widget_queue_resize (GTK_WIDGET (table));}voidgtk_table_set_col_spacings (GtkTable *table,			    guint     spacing){  guint col;    g_return_if_fail (table != NULL);  g_return_if_fail (GTK_IS_TABLE (table));    table->column_spacing = spacing;  for (col = 0; col + 1 < table->ncols; col++)    table->cols[col].spacing = spacing;    if (GTK_WIDGET_VISIBLE (table))    gtk_widget_queue_resize (GTK_WIDGET (table));}voidgtk_table_set_homogeneous (GtkTable *table,			   gboolean  homogeneous){  g_return_if_fail (table != NULL);  g_return_if_fail (GTK_IS_TABLE (table));  homogeneous = (homogeneous != 0);  if (homogeneous != table->homogeneous)    {      table->homogeneous = homogeneous;            if (GTK_WIDGET_VISIBLE (table))	gtk_widget_queue_resize (GTK_WIDGET (table));    }}static voidgtk_table_finalize (GtkObject *object){  GtkTable *table;    g_return_if_fail (object != NULL);  g_return_if_fail (GTK_IS_TABLE (object));    table = GTK_TABLE (object);    g_free (table->rows);  g_free (table->cols);    (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);}static voidgtk_table_map (GtkWidget *widget){  GtkTable *table;  GtkTableChild *child;  GList *children;    g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_TABLE (widget));    table = GTK_TABLE (widget);  GTK_WIDGET_SET_FLAGS (table, GTK_MAPPED);    children = table->children;  while (children)    {      child = children->data;      children = children->next;            if (GTK_WIDGET_VISIBLE (child->widget) &&	  !GTK_WIDGET_MAPPED (child->widget))	gtk_widget_map (child->widget);    }}static voidgtk_table_unmap (GtkWidget *widget){  GtkTable *table;  GtkTableChild *child;  GList *children;    g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_TABLE (widget));    table = GTK_TABLE (widget);  GTK_WIDGET_UNSET_FLAGS (table, GTK_MAPPED);    children = table->children;  while (children)    {      child = children->data;      children = children->next;            if (GTK_WIDGET_VISIBLE (child->widget) &&	  GTK_WIDGET_MAPPED (child->widget))	gtk_widget_unmap (child->widget);    }}static voidgtk_table_draw (GtkWidget    *widget,		GdkRectangle *area){  GtkTable *table;  GtkTableChild *child;  GList *children;  GdkRectangle child_area;    g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_TABLE (widget));    if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))    {      table = GTK_TABLE (widget);            children = table->children;      while (children)	{	  child = children->data;	  children = children->next;	  	  if (gtk_widget_intersect (child->widget, area, &child_area))	    gtk_widget_draw (child->widget, &child_area);	}    }}static gintgtk_table_expose (GtkWidget	 *widget,		  GdkEventExpose *event){  GtkTable *table;  GtkTableChild *child;  GList *children;  GdkEventExpose child_event;    g_return_val_if_fail (widget != NULL, FALSE);  g_return_val_if_fail (GTK_IS_TABLE (widget), FALSE);    if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))    {      table = GTK_TABLE (widget);            child_event = *event;            children = table->children;      while (children)	{	  child = children->data;	  children = children->next;	  	  if (GTK_WIDGET_NO_WINDOW (child->widget) &&	      gtk_widget_intersect (child->widget, &event->area, &child_event.area))	    gtk_widget_event (child->widget, (GdkEvent*) &child_event);	}    }    return FALSE;}static voidgtk_table_size_request (GtkWidget      *widget,			GtkRequisition *requisition){  GtkTable *table;  gint row, col;    g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_TABLE (widget));  g_return_if_fail (requisition != NULL);    table = GTK_TABLE (widget);    requisition->width = 0;  requisition->height = 0;    gtk_table_size_request_init (table);  gtk_table_size_request_pass1 (table);  gtk_table_size_request_pass2 (table);  gtk_table_size_request_pass3 (table);  gtk_table_size_request_pass2 (table);    for (col = 0; col < table->ncols; col++)    requisition->width += table->cols[col].requisition;  for (col = 0; col + 1 < table->ncols; col++)    requisition->width += table->cols[col].spacing;    for (row = 0; row < table->nrows; row++)    requisition->height += table->rows[row].requisition;  for (row = 0; row + 1 < table->nrows; row++)    requisition->height += table->rows[row].spacing;    requisition->width += GTK_CONTAINER (table)->border_width * 2;  requisition->height += GTK_CONTAINER (table)->border_width * 2;}static voidgtk_table_size_allocate (GtkWidget     *widget,			 GtkAllocation *allocation){  GtkTable *table;    g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_TABLE (widget));  g_return_if_fail (allocation != NULL);    widget->allocation = *allocation;  table = GTK_TABLE (widget);    gtk_table_size_allocate_init (table);  gtk_table_size_allocate_pass1 (table);  gtk_table_size_allocate_pass2 (table);}static voidgtk_table_add (GtkContainer *container,	       GtkWidget    *widget){  g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_TABLE (container));  g_return_if_fail (widget != NULL);    gtk_table_attach_defaults (GTK_TABLE (container), widget, 0, 1, 0, 1);}static voidgtk_table_remove (GtkContainer *container,		  GtkWidget    *widget){  GtkTable *table;  GtkTableChild *child;  GList *children;    g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_TABLE (container));  g_return_if_fail (widget != NULL);    table = GTK_TABLE (container);  children = table->children;    while (children)    {      child = children->data;      children = children->next;            if (child->widget == widget)	{	  gboolean was_visible = GTK_WIDGET_VISIBLE (widget);	  	  gtk_widget_unparent (widget);	  	  table->children = g_list_remove (table->children, child);	  g_free (child);	  	  if (was_visible && GTK_WIDGET_VISIBLE (container))	    gtk_widget_queue_resize (GTK_WIDGET (container));	  break;	}    }}static voidgtk_table_forall (GtkContainer *container,		  gboolean	include_internals,		  GtkCallback	callback,		  gpointer	callback_data){  GtkTable *table;  GtkTableChild *child;  GList *children;    g_return_if_fail (container != NULL);  g_return_if_fail (GTK_IS_TABLE (container));  g_return_if_fail (callback != NULL);    table = GTK_TABLE (container);  children = table->children;    while (children)    {      child = children->data;      children = children->next;            (* callback) (child->widget, callback_data);    }}static voidgtk_table_size_request_init (GtkTable *table){  GtkTableChild *child;  GList *children;  gint row, col;    for (row = 0; row < table->nrows; row++)    table->rows[row].requisition = 0;  for (col = 0; col < table->ncols; col++)    table->cols[col].requisition = 0;    children = table->children;  while (children)    {      child = children->data;      children = children->next;            if (GTK_WIDGET_VISIBLE (child->widget))	gtk_widget_size_request (child->widget, NULL);    }}static voidgtk_table_size_request_pass1 (GtkTable *table){  GtkTableChild *child;  GList *children;  gint width;  gint height;    children = table->children;  while (children)    {      child = children->data;      children = children->next;            if (GTK_WIDGET_VISIBLE (child->widget))	{	  GtkRequisition child_requisition;	  gtk_widget_get_child_requisition (child->widget, &child_requisition);	  /* Child spans a single column.	   */	  if (child->left_attach == (child->right_attach - 1))	    {	      width = child_requisition.width + child->xpadding * 2;	      table->cols[child->left_attach].requisition = MAX (table->cols[child->left_attach].requisition, width);	    }	  	  /* Child spans a single row.	   */	  if (child->top_attach == (child->bottom_attach - 1))	    {	      height = child_requisition.height + child->ypadding * 2;	      table->rows[child->top_attach].requisition = MAX (table->rows[child->top_attach].requisition, height);	    }	}    }}static voidgtk_table_size_request_pass2 (GtkTable *table){  gint max_width;  gint max_height;  gint row, col;    if (table->homogeneous)    {      max_width = 0;      max_height = 0;            for (col = 0; col < table->ncols; col++)	max_width = MAX (max_width, table->cols[col].requisition);      for (row = 0; row < table->nrows; row++)	max_height = MAX (max_height, table->rows[row].requisition);            for (col = 0; col < table->ncols; col++)	table->cols[col].requisition = max_width;      for (row = 0; row < table->nrows; row++)	table->rows[row].requisition = max_height;    }}static voidgtk_table_size_request_pass3 (GtkTable *table){  GtkTableChild *child;  GList *children;  gint width, height;  gint row, col;  gint extra;    children = table->children;  while (children)    {      child = children->data;      children = children->next;            if (GTK_WIDGET_VISIBLE (child->widget))	{	  /* Child spans multiple columns.	   */	  if (child->left_attach != (child->right_attach - 1))	    {	      GtkRequisition child_requisition;	      gtk_widget_get_child_requisition (child->widget, &child_requisition);	      	      /* Check and see if there is already enough space	       *  for the child.	       */	      width = 0;	      for (col = child->left_attach; col < child->right_attach; col++)

⌨️ 快捷键说明

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