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

📄 gtknotebook.c

📁 gtk是linux一款强大的夸平台的图形化开发工具
💻 C
📖 第 1 页 / 共 5 页
字号:
      break;    default:      arg->type = GTK_TYPE_INVALID;      break;    }}/* Private GtkWidget Methods : *  * gtk_notebook_map * gtk_notebook_unmap * gtk_notebook_realize * gtk_notebook_size_request * gtk_notebook_size_allocate * gtk_notebook_draw * gtk_notebook_expose * gtk_notebook_button_press * gtk_notebook_button_release * gtk_notebook_enter_notify * gtk_notebook_leave_notify * gtk_notebook_motion_notify * gtk_notebook_key_press * gtk_notebook_focus_in * gtk_notebook_focus_out * gtk_notebook_draw_focus * gtk_notebook_style_set */static voidgtk_notebook_map (GtkWidget *widget){  GtkNotebook *notebook;  GtkNotebookPage *page;  GList *children;  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_NOTEBOOK (widget));  GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);  notebook = GTK_NOTEBOOK (widget);  if (notebook->cur_page &&       GTK_WIDGET_VISIBLE (notebook->cur_page->child) &&      !GTK_WIDGET_MAPPED (notebook->cur_page->child))    gtk_widget_map (notebook->cur_page->child);  if (notebook->scrollable)      gtk_notebook_pages_allocate (notebook, &(widget->allocation));  else    {      children = notebook->children;      while (children)	{	  page = children->data;	  children = children->next;	  if (page->tab_label && 	      GTK_WIDGET_VISIBLE (page->child) && 	      !GTK_WIDGET_MAPPED (page->tab_label))	    gtk_widget_map (page->tab_label);	}    }  gdk_window_show (widget->window);}static voidgtk_notebook_unmap (GtkWidget *widget){  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_NOTEBOOK (widget));  GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);  gdk_window_hide (widget->window);  if (GTK_NOTEBOOK (widget)->panel)    gdk_window_hide (GTK_NOTEBOOK (widget)->panel);}static voidgtk_notebook_realize (GtkWidget *widget){  GtkNotebook *notebook;  GdkWindowAttr attributes;  gint attributes_mask;  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_NOTEBOOK (widget));  notebook = GTK_NOTEBOOK (widget);  GTK_WIDGET_SET_FLAGS (notebook, GTK_REALIZED);  attributes.window_type = GDK_WINDOW_CHILD;  attributes.x = widget->allocation.x;  attributes.y = widget->allocation.y;  attributes.width = widget->allocation.width;  attributes.height = widget->allocation.height;  attributes.wclass = GDK_INPUT_OUTPUT;  attributes.visual = gtk_widget_get_visual (widget);  attributes.colormap = gtk_widget_get_colormap (widget);  attributes.event_mask = gtk_widget_get_events (widget);  attributes.event_mask |= (GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |			    GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK);  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);  gdk_window_set_user_data (widget->window, notebook);  widget->style = gtk_style_attach (widget->style, widget->window);  gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);  gdk_window_set_back_pixmap (widget->window, NULL, TRUE);  if (notebook->scrollable)    gtk_notebook_panel_realize (notebook);}static voidgtk_notebook_unrealize (GtkWidget *widget){  GtkNotebook *notebook;  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_NOTEBOOK (widget));  notebook = GTK_NOTEBOOK (widget);  if (notebook->panel)    {      gdk_window_set_user_data (notebook->panel, NULL);      gdk_window_destroy (notebook->panel);      notebook->panel = NULL;    }  if (GTK_WIDGET_CLASS (parent_class)->unrealize)    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);}static voidgtk_notebook_size_request (GtkWidget      *widget,			   GtkRequisition *requisition){  GtkNotebook *notebook;  GtkNotebookPage *page;  GList *children;  GtkRequisition child_requisition;  gboolean switch_page = FALSE;  gint vis_pages;  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_NOTEBOOK (widget));  g_return_if_fail (requisition != NULL);  notebook = GTK_NOTEBOOK (widget);  widget->requisition.width = 0;  widget->requisition.height = 0;  for (children = notebook->children, vis_pages = 0; children;       children = children->next)    {      page = children->data;      if (GTK_WIDGET_VISIBLE (page->child))	{	  vis_pages++;	  gtk_widget_size_request (page->child, &child_requisition);	  	  widget->requisition.width = MAX (widget->requisition.width,					   child_requisition.width);	  widget->requisition.height = MAX (widget->requisition.height,					    child_requisition.height);	  if (GTK_WIDGET_MAPPED (page->child) && page != notebook->cur_page)	    gtk_widget_unmap (page->child);	  if (notebook->menu && page->menu_label->parent &&	      !GTK_WIDGET_VISIBLE (page->menu_label->parent))	    gtk_widget_show (page->menu_label->parent);	}      else	{	  if (page == notebook->cur_page)	    switch_page = TRUE;	  if (notebook->menu && page->menu_label->parent &&	      GTK_WIDGET_VISIBLE (page->menu_label->parent))	    gtk_widget_hide (page->menu_label->parent);	}    }  if (notebook->show_border || notebook->show_tabs)    {      widget->requisition.width += widget->style->klass->xthickness * 2;      widget->requisition.height += widget->style->klass->ythickness * 2;      if (notebook->show_tabs)	{	  gint tab_width = 0;	  gint tab_height = 0;	  gint tab_max = 0;	  gint padding;	  	  for (children = notebook->children; children;	       children = children->next)	    {	      page = children->data;	      	      if (GTK_WIDGET_VISIBLE (page->child))		{		  if (!GTK_WIDGET_VISIBLE (page->tab_label))		    gtk_widget_show (page->tab_label);		  gtk_widget_size_request (page->tab_label,					   &child_requisition);		  page->requisition.width = 		    child_requisition.width +		    2 * widget->style->klass->xthickness;		  page->requisition.height = 		    child_requisition.height +		    2 * widget->style->klass->ythickness;		  		  switch (notebook->tab_pos)		    {		    case GTK_POS_TOP:		    case GTK_POS_BOTTOM:		      page->requisition.height += 2 * (notebook->tab_vborder +						       FOCUS_WIDTH);		      tab_height = MAX (tab_height, page->requisition.height);		      tab_max = MAX (tab_max, page->requisition.width);		      break;		    case GTK_POS_LEFT:		    case GTK_POS_RIGHT:		      page->requisition.width += 2 * (notebook->tab_hborder +						      FOCUS_WIDTH);		      tab_width = MAX (tab_width, page->requisition.width);		      tab_max = MAX (tab_max, page->requisition.height);		      break;		    }		}	      else if (GTK_WIDGET_VISIBLE (page->tab_label))		gtk_widget_hide (page->tab_label);	    }	  children = notebook->children;	  if (vis_pages)	    {	      switch (notebook->tab_pos)		{		case GTK_POS_TOP:		case GTK_POS_BOTTOM:		  if (tab_height == 0)		    break;		  if (notebook->scrollable && vis_pages > 1 && 		      widget->requisition.width < tab_width)		    tab_height = MAX (tab_height, ARROW_SIZE);		  padding = 2 * (TAB_CURVATURE + FOCUS_WIDTH +				 notebook->tab_hborder) - TAB_OVERLAP;		  tab_max += padding;		  while (children)		    {		      page = children->data;		      children = children->next;		  		      if (!GTK_WIDGET_VISIBLE (page->child))			continue;		      if (notebook->homogeneous)			page->requisition.width = tab_max;		      else			page->requisition.width += padding;		      tab_width += page->requisition.width;		      page->requisition.height = tab_height;		    }		  if (notebook->scrollable && vis_pages > 1 &&		      widget->requisition.width < tab_width)		    tab_width = tab_max + 2 * (ARROW_SIZE + ARROW_SPACING);                  if (notebook->homogeneous && !notebook->scrollable)                    widget->requisition.width = MAX (widget->requisition.width,                                                     vis_pages * tab_max +                                                     TAB_OVERLAP);                  else                    widget->requisition.width = MAX (widget->requisition.width,                                                     tab_width + TAB_OVERLAP);		  widget->requisition.height += tab_height;		  break;		case GTK_POS_LEFT:		case GTK_POS_RIGHT:		  if (tab_width == 0)		    break;		  if (notebook->scrollable && vis_pages > 1 && 		      widget->requisition.height < tab_height)		    tab_width = MAX (tab_width, ARROW_SPACING +2 * ARROW_SIZE);		  padding = 2 * (TAB_CURVATURE + FOCUS_WIDTH +				 notebook->tab_vborder) - TAB_OVERLAP;		  tab_max += padding;		  while (children)		    {		      page = children->data;		      children = children->next;		      if (!GTK_WIDGET_VISIBLE (page->child))			continue;		      page->requisition.width   = tab_width;		      if (notebook->homogeneous)			page->requisition.height = tab_max;		      else			page->requisition.height += padding;		      tab_height += page->requisition.height;		    }		  if (notebook->scrollable && vis_pages > 1 && 		      widget->requisition.height < tab_height)		    tab_height = tab_max + ARROW_SIZE + ARROW_SPACING;		  widget->requisition.width += tab_width;                  if (notebook->homogeneous && !notebook->scrollable)                    widget->requisition.height =		      MAX (widget->requisition.height,			   vis_pages * tab_max + TAB_OVERLAP);                  else                    widget->requisition.height =		      MAX (widget->requisition.height,			   tab_height + TAB_OVERLAP);		  if (!notebook->homogeneous || notebook->scrollable)		    vis_pages = 1;		  widget->requisition.height = MAX (widget->requisition.height,						    vis_pages * tab_max +						    TAB_OVERLAP);		  break;		}	    }	}    }  widget->requisition.width += GTK_CONTAINER (widget)->border_width * 2;  widget->requisition.height += GTK_CONTAINER (widget)->border_width * 2;  if (switch_page)    {      if (vis_pages)	{	  for (children = notebook->children; children;	       children = children->next)	    {	      page = children->data;	      if (GTK_WIDGET_VISIBLE (page->child))		{		  gtk_notebook_switch_page (notebook, page, -1);		  break;		}	    }	}      else if (GTK_WIDGET_VISIBLE (widget))	{	  widget->requisition.width = GTK_CONTAINER (widget)->border_width * 2;	  widget->requisition.height= GTK_CONTAINER (widget)->border_width * 2;	}    }  if (vis_pages && !notebook->cur_page)    {      children = gtk_notebook_search_page (notebook, NULL, STEP_NEXT, TRUE);      if (children)	{	  notebook->first_tab = children;	  gtk_notebook_switch_page (notebook, GTK_NOTEBOOK_PAGE (children),-1);	}    }}static voidgtk_notebook_size_allocate (GtkWidget     *widget,			    GtkAllocation *allocation){  GtkNotebook *notebook;  GtkNotebookPage *page;  GtkAllocation child_allocation;  GList *children;  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_NOTEBOOK (widget));  g_return_if_fail (allocation != NULL);  widget->allocation = *allocation;  if (GTK_WIDGET_REALIZED (widget))    gdk_window_move_resize (widget->window,			    allocation->x, allocation->y,			    allocation->width, allocation->height);  notebook = GTK_NOTEBOOK (widget);  if (notebook->children)    {      child_allocation.x = GTK_CONTAINER (widget)->border_width;      child_allocation.y = GTK_CONTAINER (widget)->border_width;      child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);      child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);      if (notebook->show_tabs || notebook->show_border)	{	  child_allocation.x += widget->style->klass->xthickness;	  child_allocation.y += widget->style->klass->ythickness;	  child_allocation.width = MAX (1, (gint)child_allocation.width -					(gint) widget->style->klass->xthickness * 2);	  child_allocation.height = MAX (1, (gint)child_allocation.height -					 (gint) widget->style->klass->ythickness * 2);	  if (notebook->show_tabs && notebook->children && notebook->cur_page)	    {	      switch (notebook->tab_pos)		{		case GTK_POS_TOP:		  child_allocation.y += notebook->cur_page->requisition.height;		case GTK_POS_BOTTOM:		  child_allocation.height =		    MAX (1, (gint)child_allocation.height -			 (gint)notebook->cur_page->requisition.height);		  break;		case GTK_POS_LEFT:		  child_allocation.x += notebook->cur_page->requisition.width;		case GTK_POS_RIGHT:		  child_allocation.width =		    MAX (1, (gint)child_allocation.width -			 (gint)notebook->cur_page->requisition.width);		  break;		}	    }	}      children = notebook->children;      while (children)	{	  page = children->data;	  children = children->next;	  	  if (GTK_WIDGET_VISIBLE (page->child))	    gtk_widget_size_allocate (page->child, &child_allocation);	}      gtk_notebook_pages_allocate (notebook, allocation);    }   gtk_notebook_set_shape (notebook);}static voidgtk_notebook_draw (GtkWidget    *widget,		   GdkRectangle *area)

⌨️ 快捷键说明

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