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

📄 gtkhandlebox.c

📁 gtk是linux一款强大的夸平台的图形化开发工具
💻 C
📖 第 1 页 / 共 3 页
字号:
static voidgtk_handle_box_unrealize (GtkWidget *widget){  GtkHandleBox *hb;  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_HANDLE_BOX (widget));  hb = GTK_HANDLE_BOX (widget);  gdk_window_set_user_data (hb->bin_window, NULL);  gdk_window_destroy (hb->bin_window);  hb->bin_window = NULL;  gdk_window_set_user_data (hb->float_window, NULL);  gdk_window_destroy (hb->float_window);  hb->float_window = NULL;  if (GTK_WIDGET_CLASS (parent_class)->unrealize)    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);}static voidgtk_handle_box_style_set (GtkWidget *widget,			  GtkStyle  *previous_style){  GtkHandleBox *hb;  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_HANDLE_BOX (widget));  hb = GTK_HANDLE_BOX (widget);  if (GTK_WIDGET_REALIZED (widget) &&      !GTK_WIDGET_NO_WINDOW (widget))    {      gtk_style_set_background (widget->style, widget->window,widget->state);      gtk_style_set_background (widget->style, hb->bin_window, widget->state);      gtk_style_set_background (widget->style, hb->float_window, widget->state);    }}static voidgtk_handle_box_size_request (GtkWidget      *widget,			     GtkRequisition *requisition){  GtkBin *bin;  GtkHandleBox *hb;  GtkRequisition child_requisition;  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_HANDLE_BOX (widget));  g_return_if_fail (requisition != NULL);  bin = GTK_BIN (widget);  hb = GTK_HANDLE_BOX (widget);  if (hb->handle_position == GTK_POS_LEFT ||      hb->handle_position == GTK_POS_RIGHT)    {      requisition->width = DRAG_HANDLE_SIZE;      requisition->height = 0;    }  else    {      requisition->width = 0;      requisition->height = DRAG_HANDLE_SIZE;    }  /* if our child is not visible, we still request its size, since we   * won't have any usefull hint for our size otherwise.   */  if (bin->child)    gtk_widget_size_request (bin->child, &child_requisition);  else    {      child_requisition.width = 0;      child_requisition.height = 0;    }        if (hb->child_detached)    {      /* FIXME: This doesn't work currently */      if (!hb->shrink_on_detach)	{	  if (hb->handle_position == GTK_POS_LEFT ||	      hb->handle_position == GTK_POS_RIGHT)	    requisition->height += child_requisition.height;	  else	    requisition->width += child_requisition.width;	}      else	{	  if (hb->handle_position == GTK_POS_LEFT ||	      hb->handle_position == GTK_POS_RIGHT)	    requisition->height += widget->style->klass->ythickness;	  else	    requisition->width += widget->style->klass->xthickness;	}    }  else    {      requisition->width += GTK_CONTAINER (widget)->border_width * 2;      requisition->height += GTK_CONTAINER (widget)->border_width * 2;            if (bin->child)	{	  requisition->width += child_requisition.width;	  requisition->height += child_requisition.height;	}      else	{	  requisition->width += CHILDLESS_SIZE;	  requisition->height += CHILDLESS_SIZE;	}    }}static voidgtk_handle_box_size_allocate (GtkWidget     *widget,			      GtkAllocation *allocation){  GtkBin *bin;  GtkHandleBox *hb;  GtkRequisition child_requisition;    g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_HANDLE_BOX (widget));  g_return_if_fail (allocation != NULL);    bin = GTK_BIN (widget);  hb = GTK_HANDLE_BOX (widget);    if (bin->child)    gtk_widget_get_child_requisition (bin->child, &child_requisition);  else    {      child_requisition.width = 0;      child_requisition.height = 0;    }              widget->allocation = *allocation;  if (GTK_WIDGET_REALIZED (hb))    gdk_window_move_resize (widget->window,			    widget->allocation.x,			    widget->allocation.y,			    widget->allocation.width,			    widget->allocation.height);  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))    {      GtkWidget *child;      GtkAllocation child_allocation;      guint border_width;      child = bin->child;      border_width = GTK_CONTAINER (widget)->border_width;      child_allocation.x = border_width;      child_allocation.y = border_width;      if (hb->handle_position == GTK_POS_LEFT)	child_allocation.x += DRAG_HANDLE_SIZE;      else if (hb->handle_position == GTK_POS_TOP)	child_allocation.y += DRAG_HANDLE_SIZE;      if (hb->child_detached)	{	  guint float_width;	  guint float_height;	  	  child_allocation.width = child_requisition.width;	  child_allocation.height = child_requisition.height;	  	  float_width = child_allocation.width + 2 * border_width;	  float_height = child_allocation.height + 2 * border_width;	  	  if (hb->handle_position == GTK_POS_LEFT ||	      hb->handle_position == GTK_POS_RIGHT)	    float_width += DRAG_HANDLE_SIZE;	  else	    float_height += DRAG_HANDLE_SIZE;	  if (GTK_WIDGET_REALIZED (hb))	    {	      gdk_window_resize (hb->float_window,				 float_width,				 float_height);	      gdk_window_move_resize (hb->bin_window,				      0,				      0,				      float_width,				      float_height);	    }	}      else	{	  child_allocation.width = MAX (1, (gint)widget->allocation.width - 2 * border_width);	  child_allocation.height = MAX (1, (gint)widget->allocation.height - 2 * border_width);	  if (hb->handle_position == GTK_POS_LEFT ||	      hb->handle_position == GTK_POS_RIGHT)	    child_allocation.width -= DRAG_HANDLE_SIZE;	  else	    child_allocation.height -= DRAG_HANDLE_SIZE;	  	  if (GTK_WIDGET_REALIZED (hb))	    gdk_window_move_resize (hb->bin_window,				    0,				    0,				    widget->allocation.width,				    widget->allocation.height);	}      gtk_widget_size_allocate (bin->child, &child_allocation);    }}static voidgtk_handle_box_draw_ghost (GtkHandleBox *hb){  GtkWidget *widget;  guint x;  guint y;  guint width;  guint height;  widget = GTK_WIDGET (hb);  if (hb->handle_position == GTK_POS_LEFT ||      hb->handle_position == GTK_POS_RIGHT)    {      x = hb->handle_position == GTK_POS_LEFT ? 0 : widget->allocation.width - DRAG_HANDLE_SIZE;      y = 0;      width = DRAG_HANDLE_SIZE;      height = widget->allocation.height;    }  else    {      x = 0;      y = hb->handle_position == GTK_POS_TOP ? 0 : widget->allocation.height - DRAG_HANDLE_SIZE;      width = widget->allocation.width;      height = DRAG_HANDLE_SIZE;    }  gtk_paint_shadow (widget->style,		    widget->window,		    GTK_WIDGET_STATE (widget),		    GTK_SHADOW_ETCHED_IN,		    NULL, widget, "handle",		    x,		    y,		    width,		    height);   if (hb->handle_position == GTK_POS_LEFT ||       hb->handle_position == GTK_POS_RIGHT)     gtk_paint_hline (widget->style,		      widget->window,		      GTK_WIDGET_STATE (widget),		      NULL, widget, "handlebox",		      hb->handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0,		      hb->handle_position == GTK_POS_LEFT ? widget->allocation.width : widget->allocation.width - DRAG_HANDLE_SIZE,		      widget->allocation.height / 2);   else     gtk_paint_vline (widget->style,		      widget->window,		      GTK_WIDGET_STATE (widget),		      NULL, widget, "handlebox",		      hb->handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0,		      hb->handle_position == GTK_POS_TOP ? widget->allocation.height : widget->allocation.height - DRAG_HANDLE_SIZE,		      widget->allocation.width / 2);}static voiddraw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow,		     GdkRectangle *clip){   gtk_paint_handle(widget->style, window, GTK_STATE_NORMAL, shadow,		    clip, widget, "handlebox",		    rect->x, rect->y, rect->width, rect->height, 		    GTK_ORIENTATION_VERTICAL);}voidgtk_handle_box_set_shadow_type (GtkHandleBox  *handle_box,				GtkShadowType  type){  g_return_if_fail (handle_box != NULL);  g_return_if_fail (GTK_IS_HANDLE_BOX (handle_box));  if ((GtkShadowType) handle_box->shadow_type != type)    {      handle_box->shadow_type = type;      gtk_widget_queue_resize (GTK_WIDGET (handle_box));    }}void        gtk_handle_box_set_handle_position  (GtkHandleBox    *handle_box,				     GtkPositionType  position){  if ((GtkPositionType) handle_box->handle_position != position)    {      handle_box->handle_position = position;      gtk_widget_queue_resize (GTK_WIDGET (handle_box));    }}void        gtk_handle_box_set_snap_edge        (GtkHandleBox    *handle_box,				     GtkPositionType  edge){  g_return_if_fail (handle_box != NULL);  g_return_if_fail (GTK_IS_HANDLE_BOX (handle_box));  handle_box->snap_edge = edge;}static voidgtk_handle_box_paint (GtkWidget      *widget,		      GdkEventExpose *event,		      GdkRectangle   *area){  GtkBin *bin;  GtkHandleBox *hb;  guint width;  guint height;  GdkRectangle rect;  GdkRectangle dest;  bin = GTK_BIN (widget);  hb = GTK_HANDLE_BOX (widget);  gdk_window_get_size (hb->bin_window, &width, &height);    if (!event)   gtk_paint_box(widget->style,		 hb->bin_window,		 GTK_WIDGET_STATE (widget),		 hb->shadow_type,		 area, widget, "handlebox_bin",		 0, 0, -1, -1);  else   gtk_paint_box(widget->style,		 hb->bin_window,		 GTK_WIDGET_STATE (widget),		 hb->shadow_type,		 &event->area, widget, "handlebox_bin",		 0, 0, -1, -1);/* We currently draw the handle _above_ the relief of the handlebox. * it could also be drawn on the same level...		 hb->handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0,		 hb->handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0,		 width,		 height);*/  switch (hb->handle_position)    {    case GTK_POS_LEFT:      rect.x = 0;      rect.y = 0;       rect.width = DRAG_HANDLE_SIZE;      rect.height = height;      break;    case GTK_POS_RIGHT:      rect.x = width - DRAG_HANDLE_SIZE;       rect.y = 0;      rect.width = DRAG_HANDLE_SIZE;      rect.height = height;      break;    case GTK_POS_TOP:      rect.x = 0;      rect.y = 0;       rect.width = width;      rect.height = DRAG_HANDLE_SIZE;      break;    case GTK_POS_BOTTOM:      rect.x = 0;      rect.y = height - DRAG_HANDLE_SIZE;      rect.width = width;      rect.height = DRAG_HANDLE_SIZE;      break;    }  if (gdk_rectangle_intersect (event ? &event->area : area, &rect, &dest))    draw_textured_frame (widget, hb->bin_window, &rect,			 GTK_SHADOW_OUT,			 event ? &event->area : area);  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))    {      GdkRectangle child_area;      GdkEventExpose child_event;      if (!event) /* we were called from draw() */	{	  if (gtk_widget_intersect (bin->child, area, &child_area))	    gtk_widget_draw (bin->child, &child_area);	}      else /* we were called from expose() */	{	  child_event = *event;	  	  if (GTK_WIDGET_NO_WINDOW (bin->child) &&	      gtk_widget_intersect (bin->child, &event->area, &child_event.area))	    gtk_widget_event (bin->child, (GdkEvent *) &child_event);	}    }}static voidgtk_handle_box_draw (GtkWidget    *widget,		     GdkRectangle *area){  GtkHandleBox *hb;  g_return_if_fail (widget != NULL);  g_return_if_fail (GTK_IS_HANDLE_BOX (widget));  g_return_if_fail (area != NULL);

⌨️ 快捷键说明

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