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

📄 gdkdrawable-x11.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 4 页
字号:
 	{ 	  XRectangle rect; 	   	  rect.x = CLAMP (boxes[i].x1 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT); 	  rect.y = CLAMP (boxes[i].y1 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT); 	  rect.width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rect.x; 	  rect.height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rect.y;	   	  XUnionRectWithRegion (&rect, xregion, xregion); 	}            XftDrawSetClip (xft_draw, xregion);      XDestroyRegion (xregion);#endif          }  else    {      XftDrawSetClip (xft_draw, NULL);    }}/***************************************************** * X11 specific implementations of generic functions * *****************************************************/static GdkColormap*gdk_x11_get_colormap (GdkDrawable *drawable){  GdkDrawableImplX11 *impl;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);  return impl->colormap;}static voidgdk_x11_set_colormap (GdkDrawable *drawable,                      GdkColormap *colormap){  GdkDrawableImplX11 *impl;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);  if (impl->colormap == colormap)    return;    if (impl->colormap)    g_object_unref (impl->colormap);  impl->colormap = colormap;  if (impl->colormap)    g_object_ref (impl->colormap);}/* Drawing */static voidgdk_x11_draw_rectangle (GdkDrawable *drawable,			GdkGC       *gc,			gboolean     filled,			gint         x,			gint         y,			gint         width,			gint         height){  GdkDrawableImplX11 *impl;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);    if (filled)    XFillRectangle (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,		    GDK_GC_GET_XGC (gc), x, y, width, height);  else    XDrawRectangle (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,		    GDK_GC_GET_XGC (gc), x, y, width, height);}static voidgdk_x11_draw_arc (GdkDrawable *drawable,		  GdkGC       *gc,		  gboolean     filled,		  gint         x,		  gint         y,		  gint         width,		  gint         height,		  gint         angle1,		  gint         angle2){  GdkDrawableImplX11 *impl;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);    if (filled)    XFillArc (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,	      GDK_GC_GET_XGC (gc), x, y, width, height, angle1, angle2);  else    XDrawArc (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,	      GDK_GC_GET_XGC (gc), x, y, width, height, angle1, angle2);}static voidgdk_x11_draw_polygon (GdkDrawable *drawable,		      GdkGC       *gc,		      gboolean     filled,		      GdkPoint    *points,		      gint         npoints){  XPoint *tmp_points;  gint tmp_npoints, i;  GdkDrawableImplX11 *impl;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);    if (!filled &&      (points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y))    {      tmp_npoints = npoints + 1;      tmp_points = g_new (XPoint, tmp_npoints);      tmp_points[npoints].x = points[0].x;      tmp_points[npoints].y = points[0].y;    }  else    {      tmp_npoints = npoints;      tmp_points = g_new (XPoint, tmp_npoints);    }  for (i=0; i<npoints; i++)    {      tmp_points[i].x = points[i].x;      tmp_points[i].y = points[i].y;    }    if (filled)    XFillPolygon (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,		  GDK_GC_GET_XGC (gc), tmp_points, tmp_npoints, Complex, CoordModeOrigin);  else    XDrawLines (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,		GDK_GC_GET_XGC (gc), tmp_points, tmp_npoints, CoordModeOrigin);  g_free (tmp_points);}/* gdk_x11_draw_text * * Modified by Li-Da Lho to draw 16 bits and Multibyte strings * * Interface changed: add "GdkFont *font" to specify font or fontset explicitely */static voidgdk_x11_draw_text (GdkDrawable *drawable,		   GdkFont     *font,		   GdkGC       *gc,		   gint         x,		   gint         y,		   const gchar *text,		   gint         text_length){  GdkDrawableImplX11 *impl;  Display *xdisplay;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);  xdisplay = GDK_SCREEN_XDISPLAY (impl->screen);    if (font->type == GDK_FONT_FONT)    {      XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT (font);      XSetFont(xdisplay, GDK_GC_GET_XGC (gc), xfont->fid);      if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))	{	  XDrawString (xdisplay, impl->xid,		       GDK_GC_GET_XGC (gc), x, y, text, text_length);	}      else	{	  XDrawString16 (xdisplay, impl->xid,			 GDK_GC_GET_XGC (gc), x, y, (XChar2b *) text, text_length / 2);	}    }  else if (font->type == GDK_FONT_FONTSET)    {      XFontSet fontset = (XFontSet) GDK_FONT_XFONT (font);      XmbDrawString (xdisplay, impl->xid,		     fontset, GDK_GC_GET_XGC (gc), x, y, text, text_length);    }  else    g_error("undefined font type\n");}static voidgdk_x11_draw_text_wc (GdkDrawable    *drawable,		      GdkFont	     *font,		      GdkGC	     *gc,		      gint	      x,		      gint	      y,		      const GdkWChar *text,		      gint	      text_length){  GdkDrawableImplX11 *impl;  Display *xdisplay;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);  xdisplay = GDK_SCREEN_XDISPLAY (impl->screen);    if (font->type == GDK_FONT_FONT)    {      XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT (font);      gchar *text_8bit;      gint i;      XSetFont(xdisplay, GDK_GC_GET_XGC (gc), xfont->fid);      text_8bit = g_new (gchar, text_length);      for (i=0; i<text_length; i++) text_8bit[i] = text[i];      XDrawString (xdisplay, impl->xid,                   GDK_GC_GET_XGC (gc), x, y, text_8bit, text_length);      g_free (text_8bit);    }  else if (font->type == GDK_FONT_FONTSET)    {      if (sizeof(GdkWChar) == sizeof(wchar_t))	{	  XwcDrawString (xdisplay, impl->xid,			 (XFontSet) GDK_FONT_XFONT (font),			 GDK_GC_GET_XGC (gc), x, y, (wchar_t *)text, text_length);	}      else	{	  wchar_t *text_wchar;	  gint i;	  text_wchar = g_new (wchar_t, text_length);	  for (i=0; i<text_length; i++) text_wchar[i] = text[i];	  XwcDrawString (xdisplay, impl->xid,			 (XFontSet) GDK_FONT_XFONT (font),			 GDK_GC_GET_XGC (gc), x, y, text_wchar, text_length);	  g_free (text_wchar);	}    }  else    g_error("undefined font type\n");}static voidgdk_x11_draw_drawable (GdkDrawable *drawable,		       GdkGC       *gc,		       GdkPixmap   *src,		       gint         xsrc,		       gint         ysrc,		       gint         xdest,		       gint         ydest,		       gint         width,		       gint         height){  int src_depth = gdk_drawable_get_depth (src);  int dest_depth = gdk_drawable_get_depth (drawable);  GdkDrawableImplX11 *impl;  GdkDrawableImplX11 *src_impl;    impl = GDK_DRAWABLE_IMPL_X11 (drawable);  if (GDK_IS_DRAWABLE_IMPL_X11 (src))    src_impl = GDK_DRAWABLE_IMPL_X11 (src);  else    src_impl = NULL;    if (src_depth == 1)    {      XCopyArea (GDK_SCREEN_XDISPLAY (impl->screen),                 src_impl ? src_impl->xid : GDK_DRAWABLE_XID (src),		 impl->xid,		 GDK_GC_GET_XGC (gc),		 xsrc, ysrc,		 width, height,		 xdest, ydest);    }  else if (dest_depth != 0 && src_depth == dest_depth)    {      XCopyArea (GDK_SCREEN_XDISPLAY (impl->screen),                 src_impl ? src_impl->xid : GDK_DRAWABLE_XID (src),		 impl->xid,		 GDK_GC_GET_XGC (gc),		 xsrc, ysrc,		 width, height,		 xdest, ydest);    }  else    g_warning ("Attempt to draw a drawable with depth %d to a drawable with depth %d",               src_depth, dest_depth);}static voidgdk_x11_draw_points (GdkDrawable *drawable,		     GdkGC       *gc,		     GdkPoint    *points,		     gint         npoints){  GdkDrawableImplX11 *impl;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);    /* We special-case npoints == 1, because X will merge multiple   * consecutive XDrawPoint requests into a PolyPoint request   */  if (npoints == 1)    {      XDrawPoint (GDK_SCREEN_XDISPLAY (impl->screen),		  impl->xid,		  GDK_GC_GET_XGC (gc),		  points[0].x, points[0].y);    }  else    {      gint i;      XPoint *tmp_points = g_new (XPoint, npoints);      for (i=0; i<npoints; i++)	{	  tmp_points[i].x = points[i].x;	  tmp_points[i].y = points[i].y;	}            XDrawPoints (GDK_SCREEN_XDISPLAY (impl->screen),		   impl->xid,		   GDK_GC_GET_XGC (gc),		   tmp_points,		   npoints,		   CoordModeOrigin);      g_free (tmp_points);    }}static voidgdk_x11_draw_segments (GdkDrawable *drawable,		       GdkGC       *gc,		       GdkSegment  *segs,		       gint         nsegs){  GdkDrawableImplX11 *impl;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);    /* We special-case nsegs == 1, because X will merge multiple   * consecutive XDrawLine requests into a PolySegment request   */  if (nsegs == 1)    {      XDrawLine (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,		 GDK_GC_GET_XGC (gc), segs[0].x1, segs[0].y1,		 segs[0].x2, segs[0].y2);    }  else    {      gint i;      XSegment *tmp_segs = g_new (XSegment, nsegs);      for (i=0; i<nsegs; i++)	{	  tmp_segs[i].x1 = segs[i].x1;	  tmp_segs[i].x2 = segs[i].x2;	  tmp_segs[i].y1 = segs[i].y1;	  tmp_segs[i].y2 = segs[i].y2;	}            XDrawSegments (GDK_SCREEN_XDISPLAY (impl->screen),		     impl->xid,		     GDK_GC_GET_XGC (gc),		     tmp_segs, nsegs);      g_free (tmp_segs);    }}static voidgdk_x11_draw_lines (GdkDrawable *drawable,		    GdkGC       *gc,		    GdkPoint    *points,		    gint         npoints){  gint i;  XPoint *tmp_points = g_new (XPoint, npoints);  GdkDrawableImplX11 *impl;  impl = GDK_DRAWABLE_IMPL_X11 (drawable);    for (i=0; i<npoints; i++)    {      tmp_points[i].x = points[i].x;      tmp_points[i].y = points[i].y;    }        XDrawLines (GDK_SCREEN_XDISPLAY (impl->screen),	      impl->xid,	      GDK_GC_GET_XGC (gc),	      tmp_points, npoints,	      CoordModeOrigin);  g_free (tmp_points);}static voidgdk_x11_draw_glyphs (GdkDrawable      *drawable,		     GdkGC            *gc,		     PangoFont        *font,		     gint              x,		     gint              y,		     PangoGlyphString *glyphs){  gdk_x11_draw_glyphs_transformed (drawable, gc, NULL,				   font,				   x * PANGO_SCALE,				   y * PANGO_SCALE,				   glyphs);}static voidgdk_x11_draw_glyphs_transformed (GdkDrawable      *drawable,				 GdkGC            *gc,				 PangoMatrix      *matrix,				 PangoFont        *font,				 gint              x,				 gint              y,				 PangoGlyphString *glyphs){  GdkDrawableImplX11 *impl;

⌨️ 快捷键说明

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