Пример #1
0
/**************************************************************************
  Put overlay tile to pixmap
**************************************************************************/
void pixmap_put_overlay_tile(GdkDrawable *pixmap,
			     int canvas_x, int canvas_y,
			     struct sprite *ssprite)
{
  if (!ssprite) {
    return;
  }

  if (ssprite->pixmap) {
    gdk_gc_set_clip_origin(civ_gc, canvas_x, canvas_y);
    gdk_gc_set_clip_mask(civ_gc, ssprite->mask);

    gdk_draw_drawable(pixmap, civ_gc, ssprite->pixmap,
		      0, 0,
		      canvas_x, canvas_y,
		      ssprite->width, ssprite->height);
    gdk_gc_set_clip_mask(civ_gc, NULL);
  } else {
    gdk_draw_pixbuf(pixmap, civ_gc, ssprite->pixbuf,
		    0, 0,
		  canvas_x, canvas_y,
		  ssprite->width, ssprite->height,
		  GDK_RGB_DITHER_NONE, 0, 0);
  }
}
Пример #2
0
void create_server_pixmap (GtkWidget *window, struct pixmap *stype, 
                                   int n, GdkPixmap **pix, GdkBitmap **mask) {
  GdkGC *white_gc;
  int hb, wb, hs, ws;

  if (!GTK_WIDGET_REALIZED (window))
    gtk_widget_realize (window);

  gdk_window_get_size (buddy_pix[1].pix, &wb, &hb);
  gdk_window_get_size (stype->pix, &ws, &hs);

  *pix  = gdk_pixmap_new (window->window, wb + ws, MAX (hs, hb), -1);
  *mask = gdk_pixmap_new (window->window, wb + ws, MAX (hs, hb), 1);

  white_gc = window->style->base_gc[GTK_STATE_NORMAL];

  if (!masks_gc) {
    masks_gc = gdk_gc_new (*mask);
    gdk_gc_set_exposures (masks_gc, FALSE);
  }

  mask_pattern.pixel = 0;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);
  gdk_draw_rectangle (*mask, masks_gc, TRUE, 0, 0, -1, -1);

  mask_pattern.pixel = 1;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);

  if (n) {
    ensure_buddy_pix (window, n);

    gdk_gc_set_clip_origin (white_gc, 0, 0);
    gdk_gc_set_clip_mask (white_gc, buddy_pix[n].mask);
    gdk_draw_pixmap (*pix, white_gc, buddy_pix[n].pix, 0, 0, 0, 0, wb, hb);

    gdk_draw_pixmap (*mask, masks_gc, buddy_pix[n].mask, 0, 0, 0, 0, wb, hb);
  }

  gdk_gc_set_clip_origin (white_gc, wb, 0);
  gdk_gc_set_clip_mask (white_gc, stype->mask);
  gdk_draw_pixmap (*pix, white_gc, stype->pix, 0, 0, wb, 0, ws, hs);

  gdk_draw_pixmap (*mask, masks_gc, stype->mask, 0, 0, wb, 0, ws, hs);

  gdk_gc_set_clip_origin (white_gc, 0, 0);
  gdk_gc_set_clip_mask (white_gc, NULL);
}
Пример #3
0
/* {EV_PIXMAP_IMP}.set_size */
void F1202_17204 (EIF_REFERENCE Current, EIF_INTEGER_32 arg1, EIF_INTEGER_32 arg2)
{
	GTCX
	EIF_POINTER loc1 = (EIF_POINTER) 0;
	EIF_POINTER loc2 = (EIF_POINTER) 0;
	EIF_INTEGER_32 loc3 = (EIF_INTEGER_32) 0;
	EIF_INTEGER_32 loc4 = (EIF_INTEGER_32) 0;
	EIF_POINTER loc5 = (EIF_POINTER) 0;
	EIF_POINTER loc6 = (EIF_POINTER) 0;
	EIF_POINTER loc7 = (EIF_POINTER) 0;
	EIF_POINTER tp1;
	EIF_INTEGER_32 ti4_1;
	RTLD;
	
	RTLI(1);
	RTLR(0,Current);
	
	RTGC;
	loc3 = F1202_17199(Current);
	loc4 = F1202_17200(Current);
	if ((EIF_BOOLEAN) ((EIF_BOOLEAN)(loc3 != arg1) || (EIF_BOOLEAN)(loc4 != arg2))) {
		tp1 = *(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_5_);
		loc1 = (EIF_POINTER) gdk_pixmap_ref((GdkPixmap*) tp1);
		if ((EIF_BOOLEAN)(*(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_4_) != loc7)) {
			tp1 = *(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_4_);
			loc2 = (EIF_POINTER) gdk_pixmap_ref((GdkPixmap*) tp1);
		}
		tp1 = (EIF_POINTER) NULL;
		ti4_1 = *(EIF_INTEGER_32 *)(RTCV(RTOSCF(14148,F1079_14148,(Current)))+ _LNGOFF_49_16_0_19_);
		tp1 = (EIF_POINTER) gdk_pixmap_new((GdkWindow*) tp1, (gint) arg1, (gint) arg2, (gint) ti4_1);
		*(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_5_) = (EIF_POINTER) tp1;
		F1198_17038(Current, ((EIF_INTEGER_32) 0L), ((EIF_INTEGER_32) 0L), arg1, arg2);
		tp1 = *(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_5_);
		loc5 = (EIF_POINTER) gdk_gc_new((GdkWindow*) tp1);
		gdk_gc_set_clip_mask((GdkGC*) loc5, (GdkBitmap*) loc2);
		gdk_gc_set_clip_origin((GdkGC*) loc5, (gint) ((EIF_INTEGER_32) 0L), (gint) ((EIF_INTEGER_32) 0L));
		tp1 = *(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_5_);
		gdk_draw_drawable((GdkDrawable*) tp1, (GdkGC*) loc5, (GdkDrawable*) loc1, (gint) ((EIF_INTEGER_32) 0L), (gint) ((EIF_INTEGER_32) 0L), (gint) ((EIF_INTEGER_32) 0L), (gint) ((EIF_INTEGER_32) 0L), (gint) loc3, (gint) loc4);
		gdk_gc_unref((GdkGC*) loc5);
		gdk_pixmap_unref((GdkPixmap*) loc1);
		if ((EIF_BOOLEAN)(loc2 != loc7)) {
			tp1 = (EIF_POINTER) NULL;
			tp1 = (EIF_POINTER) gdk_pixmap_new((GdkWindow*) tp1, (gint) arg1, (gint) arg2, (gint) ((EIF_INTEGER_32) 1L));
			*(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_4_) = (EIF_POINTER) tp1;
			tp1 = *(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_4_);
			loc6 = (EIF_POINTER) gdk_gc_new((GdkWindow*) tp1);
			tp1 = RTOSCF(17072,F1198_17072,(Current));
			gdk_gc_set_foreground((GdkGC*) loc6, (GdkColor*) tp1);
			tp1 = *(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_4_);
			gdk_draw_rectangle((GdkDrawable*) tp1, (GdkGC*) loc6, (gint) ((EIF_INTEGER_32) 1L), (gint) ((EIF_INTEGER_32) 0L), (gint) ((EIF_INTEGER_32) 0L), (gint) arg1, (gint) arg2);
			tp1 = *(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_4_);
			gdk_draw_drawable((GdkDrawable*) tp1, (GdkGC*) loc6, (GdkDrawable*) loc2, (gint) ((EIF_INTEGER_32) 0L), (gint) ((EIF_INTEGER_32) 0L), (gint) ((EIF_INTEGER_32) 0L), (gint) ((EIF_INTEGER_32) 0L), (gint) loc3, (gint) loc4);
			gdk_gc_unref((GdkGC*) loc6);
			gdk_pixmap_unref((GdkPixmap*) loc2);
		}
		F1202_17215(Current, *(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_5_), *(EIF_POINTER *)(Current+ _PTROFF_46_11_12_3_0_4_));
	}
	RTLE;
}
Пример #4
0
void gtk_graph_smith_plot_traces(GtkGraph *graph)
{
gint i, n;
GtkGraphTrace *tmp;
gfloat CA, CB, CC, CD;

GdkPoint *pts = NULL;

g_return_if_fail (graph != NULL);
g_return_if_fail (GTK_IS_GRAPH (graph));
g_return_if_fail (GTK_WIDGET_REALIZED (graph));
g_return_if_fail (graph->graph_type == SMITH);
	
tmp = graph->traces;
for (n = 0 ; n < graph->num_traces ; n++)
	{
	/* Make sure that there is some data in the trace */
	if (tmp->Xdata == NULL || tmp->Ydata == NULL) 
		continue;

	/* Assign the storage for the co-ordinates of each data point */

	pts = (GdkPoint *) g_malloc ((tmp->num_points) * sizeof(GdkPoint));

	/* The Xdata array contains the resistance whilst the Ydata array has the reactance */
	
	CA = tmp->Xdata[0] - graph->smith_Z0;
	CB = tmp->Ydata[0];
	CC = tmp->Xdata[0] + graph->smith_Z0;
	CD = tmp->Ydata[0];
		
	pts[0].x = centre_x + (CA*CC + CB*CD)/(CC*CC + CD*CD) * graph->dependant->scale_factor;
	pts[0].y = centre_y - (CB*CC - CA*CD)/(CC*CC + CD*CD) * graph->dependant->scale_factor;
	
 	for (i = 1 ; i < tmp->num_points ; i++)
      	{
		CA = tmp->Xdata[i] - graph->smith_Z0;
		CB = tmp->Ydata[i];
		CC = tmp->Xdata[i] + graph->smith_Z0;
		CD = tmp->Ydata[i];
		
		pts[i].x = centre_x + (CA*CC + CB*CD)/(CC*CC + CD*CD) * graph->dependant->scale_factor;
		pts[i].y = centre_y - (CB*CC - CA*CD)/(CC*CC + CD*CD) * graph->dependant->scale_factor;
		}

	gdk_draw_lines (buffer, tmp->format->line_gc, pts, tmp->num_points);/* Draw the lines */	
	for (i = 1 ; i < tmp->num_points ; i++)/* and then draw the markers */	
        if (tmp->format->marker_type != GTK_GRAPH_MARKER_NONE)
			{
			gdk_gc_set_clip_origin(tmp->format->marker_gc, pts[i].x-5, pts[i].y-5);
            gdk_draw_pixmap(buffer, tmp->format->marker_gc, tmp->format->marker, 0, 0, pts[i].x-5, pts[i].y-5, -1, -1);
			}

	g_free(pts);// Free up all storage after use 
	tmp = tmp->next;// and then move onto the next trace 
	
	}
	
}
Пример #5
0
static gint
draw_cell_pixmap (GdkWindow    *window,
                  GdkRectangle *clip_rectangle,
                  GdkGC        *fg_gc,
                  GdkPixmap    *pixmap,
                  GdkBitmap    *mask,
                  gint          x,
                  gint          y,
                  gint          width,
                  gint          height)
{
   gint xsrc = 0, ysrc = 0;

   if (mask) {
      gdk_gc_set_clip_mask (fg_gc, mask);
      gdk_gc_set_clip_origin (fg_gc, x, y);
   }

   if (x < clip_rectangle->x) {
      xsrc = clip_rectangle->x - x;
      width -= xsrc;
      x = clip_rectangle->x;
   }
   if (x + width > clip_rectangle->x + clip_rectangle->width)
      width = clip_rectangle->x + clip_rectangle->width - x;

   if (y < clip_rectangle->y) {
      ysrc = clip_rectangle->y - y;
      height -= ysrc;
      y = clip_rectangle->y;
   }
   if (y + height > clip_rectangle->y + clip_rectangle->height)
      height = clip_rectangle->y + clip_rectangle->height - y;

   gdk_draw_pixmap (window, fg_gc, pixmap, xsrc, ysrc, x, y, width, height);

   if (mask) {
      gdk_gc_set_clip_origin (fg_gc, 0, 0);
      gdk_gc_set_clip_mask (fg_gc, NULL);
   }

   return x + MAX (width, 0);
}
Пример #6
0
/** \brief concatenate two pixmaps
 *
 * horizontal concatenation
 * @param window
 * @param dest destination pixmap
 * @param s1 first pixmap
 * @param s2 second pixmap
 * @returns dest for convenience
 */
struct pixmap* cat_pixmaps (GtkWidget *window, struct pixmap *dest, struct pixmap* s1, struct pixmap* s2)
{
  GdkGC *white_gc;
  int h1, w1, h2, w2;

  if (!GTK_WIDGET_REALIZED (window))
    gtk_widget_realize (window);

  gdk_window_get_size (s1->pix, &w1, &h1);
  gdk_window_get_size (s2->pix, &w2, &h2);

  dest->pix  = gdk_pixmap_new (window->window, w1 + w2, MAX (h1, h2), -1);
  dest->mask = gdk_pixmap_new (window->window, w1 + w2, MAX (h1, h2), 1);

  white_gc = window->style->base_gc[GTK_STATE_NORMAL];

  if (!masks_gc) {
    masks_gc = gdk_gc_new (dest->mask);
    gdk_gc_set_exposures (masks_gc, FALSE);
  }

  mask_pattern.pixel = 0;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);
  gdk_draw_rectangle (dest->mask, masks_gc, TRUE, 0, 0, -1, -1);

  mask_pattern.pixel = 1;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);

  gdk_gc_set_clip_origin (white_gc, 0, 0);
  gdk_gc_set_clip_mask (white_gc, s1->mask);
  gdk_draw_pixmap (dest->pix, white_gc, s1->pix, 0, 0, 0, 0, w1, h1);
  gdk_draw_pixmap (dest->mask, masks_gc, s1->mask, 0, 0, 0, 0, w1, h1);

  gdk_gc_set_clip_origin (white_gc, w1, 0);
  gdk_gc_set_clip_mask (white_gc, s2->mask);
  gdk_draw_pixmap (dest->pix, white_gc, s2->pix, 0, 0, w1, 0, w2, h2);
  gdk_draw_pixmap (dest->mask, masks_gc, s2->mask, 0, 0, w1, 0, w2, h2);

  gdk_gc_set_clip_origin (white_gc, 0, 0);
  gdk_gc_set_clip_mask (white_gc, NULL);

  return dest;
}
Пример #7
0
void
ghid_use_mask (int use_it)
{
  static int mask_seq_id = 0;
  GdkColor color;
  render_priv *priv = gport->render_priv;

  if (!gport->pixmap)
    return;
  if (use_it == cur_mask)
    return;
  switch (use_it)
    {
    case HID_MASK_OFF:
      gport->drawable = gport->pixmap;
      mask_seq = 0;
      break;

    case HID_MASK_BEFORE:
      /* The HID asks not to receive this mask type, so warn if we get it */
      g_return_if_reached ();

    case HID_MASK_CLEAR:
      if (!gport->mask)
	gport->mask = gdk_pixmap_new (0, gport->width, gport->height, 1);
      gport->drawable = gport->mask;
      mask_seq = 0;
      if (!priv->mask_gc)
	{
	  priv->mask_gc = gdk_gc_new (gport->drawable);
	  gdk_gc_set_clip_origin (priv->mask_gc, 0, 0);
	  set_clip (priv, priv->mask_gc);
	}
      color.pixel = 1;
      gdk_gc_set_foreground (priv->mask_gc, &color);
      gdk_draw_rectangle (gport->drawable, priv->mask_gc, TRUE, 0, 0,
			  gport->width, gport->height);
      color.pixel = 0;
      gdk_gc_set_foreground (priv->mask_gc, &color);
      break;

    case HID_MASK_AFTER:
      mask_seq_id++;
      if (!mask_seq_id)
	mask_seq_id = 1;
      mask_seq = mask_seq_id;

      gport->drawable = gport->pixmap;
      break;

    }
  cur_mask = use_it;
}
Пример #8
0
/* Sets the origin of the clip mask. The coordinates are interpreted relative to
 * the upper-left corner of the destination drawable of  the current operation. */
int
clip_GDK_GCSETCLIPORIGIN(ClipMachine * cm)
{
	C_object *cgc = _fetch_co_arg(cm);
	gint        x = _clip_parni(cm,2);
	gint        y = _clip_parni(cm,3);
	CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKOPT(2,NUMERIC_t); CHECKOPT(3,NUMERIC_t);
	gdk_gc_set_clip_origin(GDK_GC(cgc->object), x, y);
	return 0;
err:
	return 1;
}
Пример #9
0
static void
gtk_plot_gdk_clip_mask                              (GtkPlotPC *pc,
						     gdouble x,
						     gdouble y,
                                                     const GdkBitmap *mask)
{
  if(!GTK_PLOT_GDK(pc)->gc) return;

  if(x >= 0 && y >= 0)
    gdk_gc_set_clip_origin(GTK_PLOT_GDK(pc)->gc, x, y);

  gdk_gc_set_clip_mask(GTK_PLOT_GDK(pc)->gc, (GdkBitmap*)mask);
}
Пример #10
0
void
ghid_drawing_area_configure_hook (GHidPort *port)
{
  static int done_once = 0;
  render_priv *priv = port->render_priv;

  if (!done_once)
    {
      priv->bg_gc = gdk_gc_new (port->drawable);
      gdk_gc_set_foreground (priv->bg_gc, &port->bg_color);
      gdk_gc_set_clip_origin (priv->bg_gc, 0, 0);

      priv->offlimits_gc = gdk_gc_new (port->drawable);
      gdk_gc_set_foreground (priv->offlimits_gc, &port->offlimits_color);
      gdk_gc_set_clip_origin (priv->offlimits_gc, 0, 0);
      done_once = 1;
    }

  if (port->mask)
    {
      gdk_pixmap_unref (port->mask);
      port->mask = gdk_pixmap_new (0, port->width, port->height, 1);
    }
}
Пример #11
0
static void
draw_lead_user (render_priv *priv)
{
  GdkWindow *window = gtk_widget_get_window (gport->drawing_area);
  GtkStyle *style = gtk_widget_get_style (gport->drawing_area);
  int i;
  Coord radius = priv->lead_user_radius;
  Coord width = MM_TO_COORD (LEAD_USER_WIDTH);
  Coord separation = MM_TO_COORD (LEAD_USER_ARC_SEPARATION);
  static GdkGC *lead_gc = NULL;
  GdkColor lead_color;

  if (!priv->lead_user)
    return;

  if (lead_gc == NULL)
    {
      lead_gc = gdk_gc_new (window);
      gdk_gc_copy (lead_gc, style->white_gc);
      gdk_gc_set_function (lead_gc, GDK_XOR);
      gdk_gc_set_clip_origin (lead_gc, 0, 0);
      lead_color.pixel = 0;
      lead_color.red   = (int)(65535. * LEAD_USER_COLOR_R);
      lead_color.green = (int)(65535. * LEAD_USER_COLOR_G);
      lead_color.blue  = (int)(65535. * LEAD_USER_COLOR_B);
      gdk_color_alloc (gport->colormap, &lead_color);
      gdk_gc_set_foreground (lead_gc, &lead_color);
    }

  set_clip (priv, lead_gc);
  gdk_gc_set_line_attributes (lead_gc, Vz (width),
                              GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);

  /* arcs at the approrpriate radii */

  for (i = 0; i < LEAD_USER_ARC_COUNT; i++, radius -= separation)
    {
      if (radius < width)
        radius += MM_TO_COORD (LEAD_USER_INITIAL_RADIUS);

      /* Draw an arc at radius */
      gdk_draw_arc (gport->drawable, lead_gc, FALSE,
                    Vx (priv->lead_user_x - radius),
                    Vy (priv->lead_user_y - radius),
                    Vz (2. * radius), Vz (2. * radius),
                    0, 360 * 64);
    }
}
Пример #12
0
void DrawPixmap(GdkWindow* window, GdkGC* gc,
			 gint dstx, gint dsty, GdkPixmap* pixmap, GdkBitmap* mask)
{
	gint map_w, map_h;

	gdk_window_get_size(pixmap, &map_w, &map_h);

	gdk_gc_set_clip_mask(gc, mask);
	gdk_gc_set_clip_origin(gc, dstx, dsty);

	gdk_draw_pixmap(window, gc, pixmap,
					0,0,			// srcx, srcy
					dstx, dsty,
					map_w, map_h);

	gdk_gc_set_clip_mask(gc, NULL);
}
/* Draw the exon view */
static void drawExonView(GtkWidget *exonView, GdkDrawable *drawable)
{
  DEBUG_ENTER("drawExonView");
  
  ExonViewProperties *properties = exonViewGetProperties(exonView);
  DotterContext *dc = properties->dc;

  GdkGC *gc = gdk_gc_new(drawable);

  /* Set a clip rectangle for drawing the exons and introns (because they are drawn "over the
   * edges" to make sure intron lines have the correct slope etc.) */
  gdk_gc_set_clip_origin(gc, 0, 0);
  gdk_gc_set_clip_rectangle(gc, &properties->exonViewRect);
  
  /* Draw the exons and introns. Since we could have a lot of them in the loop, extract all the
   * info we need now and pass it around so we don't have to look for this stuff each time. */
  
  DrawData drawData = {
    properties->parent,
    drawable,
    gc,
    properties->dc,
    properties->dwc,
    
    &properties->exonViewRect,
    properties->qRange,
    
    properties->yPad,
    properties->horizontal ? properties->exonViewRect.y : properties->exonViewRect.x,
    properties->exonHeight,

    properties->strand,
    properties->horizontal,
    properties->bumped,
    FALSE
  };
  
  /* Loop through all sequences, drawing all msps that are exons/introns */
  GList *seqList = dc->seqList;
  g_list_foreach(seqList, drawExonIntronItem, &drawData);

  g_object_unref(gc);
  DEBUG_EXIT("drawExonView returning ");
}
Пример #14
0
/**************************************************************************
  Place part of a (possibly masked) sprite on a pixmap.
**************************************************************************/
static void pixmap_put_sprite(GdkDrawable *pixmap,
			      int pixmap_x, int pixmap_y,
			      struct sprite *ssprite,
			      int offset_x, int offset_y,
			      int width, int height)
{
#ifdef DEBUG
  static int sprites = 0, pixbufs = 0;
#endif

  if (ssprite->pixmap) {
    if (ssprite->mask) {
      gdk_gc_set_clip_origin(civ_gc, pixmap_x, pixmap_y);
      gdk_gc_set_clip_mask(civ_gc, ssprite->mask);
    }

    gdk_draw_drawable(pixmap, civ_gc, ssprite->pixmap,
		      offset_x, offset_y,
		      pixmap_x + offset_x, pixmap_y + offset_y,
		      MIN(width, MAX(0, ssprite->width - offset_x)),
		      MIN(height, MAX(0, ssprite->height - offset_y)));

    gdk_gc_set_clip_mask(civ_gc, NULL);
  } else {
    gdk_draw_pixbuf(pixmap, civ_gc, ssprite->pixbuf,
		    offset_x, offset_y,
		    pixmap_x + offset_x, pixmap_y + offset_y,
		    MIN(width, MAX(0, ssprite->width - offset_x)),
		    MIN(height, MAX(0, ssprite->height - offset_y)),
		    GDK_RGB_DITHER_NONE, 0, 0);
#ifdef DEBUG
    pixbufs++;
#endif
  }

#ifdef DEBUG
  sprites++;
  if (sprites % 1000 == 0) {
    freelog(LOG_DEBUG, "%5d / %5d pixbufs = %d%%",
	    pixbufs, sprites, 100 * pixbufs / sprites);
  }
#endif
}
Пример #15
0
static void
show_crosshair (gboolean paint_new_location)
{
  render_priv *priv = gport->render_priv;
  GdkWindow *window = gtk_widget_get_window (gport->drawing_area);
  GtkStyle *style = gtk_widget_get_style (gport->drawing_area);
  gint x, y;
  static gint x_prev = -1, y_prev = -1;
  static GdkGC *xor_gc;
  static GdkColor cross_color;

  if (gport->crosshair_x < 0 || ghidgui->creating || !gport->has_entered)
    return;

  if (!xor_gc)
    {
      xor_gc = gdk_gc_new (window);
      gdk_gc_copy (xor_gc, style->white_gc);
      gdk_gc_set_function (xor_gc, GDK_XOR);
      gdk_gc_set_clip_origin (xor_gc, 0, 0);
      set_clip (priv, xor_gc);
      /* FIXME: when CrossColor changed from config */
      ghid_map_color_string (Settings.CrossColor, &cross_color);
    }
  x = DRAW_X (gport->crosshair_x);
  y = DRAW_Y (gport->crosshair_y);

  gdk_gc_set_foreground (xor_gc, &cross_color);

  if (x_prev >= 0 && !paint_new_location)
    draw_crosshair (xor_gc, x_prev, y_prev);

  if (x >= 0 && paint_new_location)
    {
      draw_crosshair (xor_gc, x, y);
      x_prev = x;
      y_prev = y;
    }
  else
    x_prev = y_prev = -1;
}
Пример #16
0
/* brush paint: get current pixmap/mask, and draw the part in the
 * rectangle bounds.
 */
void
_zune_fill_scaled_rectangle(struct MUI_ImageSpec *img,
			    struct MUI_RenderInfo *mri, 
			    LONG left, LONG top, LONG width, LONG height,
			    LONG xoffset, LONG yoffset)
{
    GdkPixmap *pixmap;
    GdkBitmap *mask;

    g_return_if_fail((pixmap = __zune_imspec_get_pixmap(img)) != NULL);

    mask = __zune_imspec_get_mask(img);

    gdk_gc_set_clip_mask(mri->mri_RastPort, mask);
    gdk_gc_set_clip_origin(mri->mri_RastPort, xoffset, yoffset);
/*  g_print("draw pixmap: srcx=%d srcy=%d dstx=%d dsty=%d w=%d h=%d\n", */
/*  	left - xoffset, top - yoffset, left, top, width, height); */
    gdk_draw_pixmap (mri->mri_Window, mri->mri_RastPort, pixmap,
		     left - xoffset, top - yoffset, left, top, width, height);
    gdk_gc_set_clip_mask(mri->mri_RastPort, NULL);
}
Пример #17
0
/**************************************************************************
Only used for isometric view.
**************************************************************************/
void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
				  int canvas_x, int canvas_y,
				  struct sprite *ssprite,
				  bool fog)
{
  if (!ssprite) {
    return;
  }

  if (fog && gui_gtk2_better_fog
      && ((ssprite->pixmap && !ssprite->pixmap_fogged)
	  || (!ssprite->pixmap && !ssprite->pixbuf_fogged))) {
    fog_sprite(ssprite);
    if ((ssprite->pixmap && !ssprite->pixmap_fogged)
	|| (!ssprite->pixmap && !ssprite->pixbuf_fogged)) {
      freelog(LOG_NORMAL,
	      _("Better fog will only work in truecolor.  Disabling it"));
      gui_gtk2_better_fog = FALSE;
    }
  }

  if (fog && gui_gtk2_better_fog) {
    if (ssprite->pixmap) {
      if (ssprite->mask) {
	gdk_gc_set_clip_origin(civ_gc, canvas_x, canvas_y);
	gdk_gc_set_clip_mask(civ_gc, ssprite->mask);
      }
      gdk_draw_drawable(pixmap, civ_gc,
			ssprite->pixmap_fogged,
			0, 0,
			canvas_x, canvas_y,
			ssprite->width, ssprite->height);
      gdk_gc_set_clip_mask(civ_gc, NULL);
    } else {
      gdk_draw_pixbuf(pixmap, civ_gc, ssprite->pixbuf_fogged,
		      0, 0, canvas_x, canvas_y, 
		      ssprite->width, ssprite->height,
		      GDK_RGB_DITHER_NONE, 0, 0);
    }
    return;
  }

  pixmap_put_sprite(pixmap, canvas_x, canvas_y, ssprite,
		    0, 0, ssprite->width, ssprite->height);

  /* I imagine this could be done more efficiently. Some pixels We first
     draw from the sprite, and then draw black afterwards. It would be much
     faster to just draw every second pixel black in the first place. */
  if (fog) {
    gdk_gc_set_clip_origin(fill_tile_gc, canvas_x, canvas_y);
    gdk_gc_set_clip_mask(fill_tile_gc, sprite_get_mask(ssprite));
    gdk_gc_set_foreground(fill_tile_gc,
			  &get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color);
    gdk_gc_set_ts_origin(fill_tile_gc, canvas_x, canvas_y);
    gdk_gc_set_stipple(fill_tile_gc, black50);

    gdk_draw_rectangle(pixmap, fill_tile_gc, TRUE,
		       canvas_x, canvas_y, ssprite->width, ssprite->height);
    gdk_gc_set_clip_mask(fill_tile_gc, NULL);
  }
}
Пример #18
0
static VALUE
rg_set_clip_origin(VALUE self, VALUE x, VALUE y)
{
    gdk_gc_set_clip_origin(_SELF(self), NUM2INT(x), NUM2INT(y));
    return self;
}
Пример #19
0
  /* Push decal pixmaps through their stencils onto a Panel expose pixmap
  */
static gboolean
push_decal_pixmaps(GkrellmPanel *p, gboolean top_layer)
	{
	GList			*list;
	GkrellmDecal	*d;
	gint			x, y, w, h;
	gboolean		on_top, is_non_overlapping_text_decal;
	gboolean		restore_gc = FALSE, do_top_layer = FALSE;

	if (!p)
		return FALSE;
	for (list = p->decal_list; list; list = list->next)
		{
		d = (GkrellmDecal *) list->data;
		on_top = (d->flags & DF_TOP_LAYER);
		is_non_overlapping_text_decal
				= (d->text_list && !(d->flags & DF_TEXT_OVERLAPS));

		if (on_top && !top_layer)
			do_top_layer = TRUE;

		if (   d->state != DS_VISIBLE
			|| (top_layer && !on_top)
			|| (!top_layer && (on_top || is_non_overlapping_text_decal))
		   )
			continue;
		if (d->text_list)
			panel_draw_decal_text_list(p->pixmap, d);
		else if (d->scroll_text)
			{
			x = d->x_off;
			y = d->y_off;

			gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap,
						-x, -y, d->x, d->y, d->w, d->h);
			if (d->flags & DF_SCROLL_TEXT_H_LOOP)
				{
				x %= d->scroll_width;
				if (x > 0)
					{
					gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap,
							d->scroll_width - x, -y,
							d->x, d->y, x, d->h);
					}
				else if (   x <= 0
						 && (w = d->scroll_width + x) < d->w
						)
					{
					gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap,
							0, -y,
							d->x + w, d->y, d->w - w, d->h);
					}
				}
			if (d->flags & DF_SCROLL_TEXT_V_LOOP)
				{
				y %= d->scroll_height + d->y_ink;
				if (y > 0)
					gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap,
							-x, d->scroll_height + d->y_ink - y,
							d->x, d->y, d->w, y);
				else if (   y <= 0
						 && (h = d->scroll_height + d->y_ink + y) < d->h
						)
					gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap,
							-x, 0,
							d->x, d->y + h, d->w, d->h - h);
				}
			}
		else
			{
			gdk_gc_set_clip_mask(_GK.draw3_GC, d->stencil);
			gdk_gc_set_clip_origin(_GK.draw3_GC, d->x, d->y);
			gdk_draw_drawable(p->pixmap, _GK.draw3_GC, d->pixmap,
						0, d->y_src, d->x, d->y, d->w, d->h);
			restore_gc = TRUE;
			}
		}
	if (restore_gc)
		{
		gdk_gc_set_clip_mask(_GK.draw3_GC, NULL);
		gdk_gc_set_clip_origin(_GK.draw3_GC, 0, 0);
		}

	return do_top_layer;
	}
Пример #20
0
/* Draw the exon view */
static void drawExonView(GtkWidget *exonView, GdkDrawable *drawable)
{
    GtkWidget *blxWindow = exonViewGetBlxWindow(exonView);
    BlxViewContext *bc = blxWindowGetContext(blxWindow);

    ExonViewProperties *properties = exonViewGetProperties(exonView);
    const IntRange* const displayRange = bigPictureGetDisplayRange(properties->bigPicture);

    /* First, highlight any assembly gaps */
    /* Get the display range in dna coords */
    IntRange bpRange;
    convertDisplayRangeToDnaRange(displayRange, bc->seqType, bc->numFrames, bc->displayRev, &bc->refSeqRange, &bpRange);

    GdkColor *gapColor = getGdkColor(BLXCOLOR_ASSEMBLY_GAP, bc->defaultColors, FALSE, bc->usePrintColors);
    drawAssemblyGaps(exonView, drawable, gapColor, bc->displayRev, &properties->exonViewRect, &bpRange, bc->featureLists[BLXMSP_GAP]);

    /* Set a clip rectangle for drawing the exons and introns (because they are drawn "over the
     * edges" to make sure intron lines have the correct slope etc.) */
    GdkGC *gc = gdk_gc_new(drawable);

    gdk_gc_set_clip_origin(gc, 0, 0);
    gdk_gc_set_clip_rectangle(gc, &properties->exonViewRect);

    /* Draw the exons and introns. Since we could have a lot of them in the loop, extract all the
     * info we need now and pass it around so we don't have to look for this stuff each time. */

    DrawData drawData = {
        drawable,
        gc,
        &properties->exonViewRect,
        blxWindow,
        bc,
        properties->currentStrand,
        displayRange,
        &bc->refSeqRange,
        bc->displayRev,
        bc->numFrames,
        bc->seqType,
        properties->expanded,
        FALSE,
        properties->yPad,
        properties->exonViewRect.y,
        properties->exonHeight
    };

    /* If the view is compressed (i.e. exons will overlap each other), then
     * only draw "normal" MSPs the first time round, and draw grouped/selected
     * MSPs afterwards, so that they appear on top. If the view is expanded,
     * we can draw them all in a single loop, because they will not overlap. */
    drawData.normalOnly = !properties->expanded;

    /* Loop through all sequences, drawing all msps that are exons/introns */
    GList *seqList = blxWindowGetAllMatchSeqs(blxWindow);
    g_list_foreach(seqList, drawExonIntronItem, &drawData);

    if (!properties->expanded)
    {
        drawData.normalOnly = FALSE;

        /* Draw all selected msps */
        g_list_foreach(bc->selectedSeqs, drawExonIntronItem, &drawData);

        /* Increment the y value when finished, because we calculate the view height based on this */
        drawData.y += drawData.height + drawData.yPad;
    }

    /* Set the height based on the height of the exons that were actually drawn */
    const int newHeight = drawData.y - properties->exonViewRect.y + drawData.yPad;
    gtk_layout_set_size(GTK_LAYOUT(exonView), exonView->allocation.width, newHeight);

    g_object_unref(gc);
}
Пример #21
0
static void
gtk_ui_draw_image(Picture *pict, int x, int y) {
	gdk_gc_set_clip_origin(pict->gc, x, y);
	gdk_draw_pixmap(offscreen, pict->gc, pict->pix, 0, 0, x, y,
			pict->width, pict->height);
}
Пример #22
0
static void
color_area_draw ()
{
  Color col;
  GdkColor *win_bg;
  GdkColor fg, bg, bd;
  gint rect_w, rect_h;
  gint width, height;
  gint def_width, def_height;
  gint swap_width, swap_height;
  GdkColor  mask_pattern;

  /* Check we haven't gotten initial expose yet,
   * no point in drawing anything
   */
  if (!color_area_pixmap || !color_area_gc)
    return;

  gdk_drawable_get_size (color_area_pixmap, &width, &height);

  win_bg = &(color_area->style->bg[GTK_STATE_NORMAL]);
  col = attributes_get_foreground();
  color_convert(&col, &fg);
  col = attributes_get_background();
  color_convert(&col, &bg);
  bd = color_gdk_black;

  rect_w = width * 0.65;
  rect_h = height * 0.65;

  /*  initialize the mask to transparent  */
  mask_pattern.pixel = 0;
  gdk_gc_set_foreground (mask_gc, &mask_pattern);
  gdk_draw_rectangle (color_area_mask, mask_gc, TRUE, 0, 0, -1, -1);

  /*  set the mask's gc to opaque  */
  mask_pattern.pixel = 1;
  gdk_gc_set_foreground (mask_gc, &mask_pattern);

  gdk_gc_set_foreground (color_area_gc, win_bg);
  gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
		      0, 0, width, height);

  gdk_gc_set_foreground (color_area_gc, &bg);
  gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
		      (width - rect_w), (height - rect_h), rect_w, rect_h);
  gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
		      (width - rect_w), (height - rect_h), rect_w, rect_h);

  if (active_color == FOREGROUND)
    gtk_paint_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL,
                      GTK_SHADOW_OUT,
                      NULL, color_area, NULL,
		      (width - rect_w), (height - rect_h),
                      rect_w, rect_h);
  else
    gtk_paint_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL,
                      GTK_SHADOW_IN,
                      NULL, color_area, NULL,
		      (width - rect_w), (height - rect_h),
                      rect_w, rect_h);

  gdk_gc_set_foreground (color_area_gc, &fg);
  gdk_draw_rectangle (color_area_pixmap, color_area_gc, 1,
		      0, 0, rect_w, rect_h);
  gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
		      0, 0, rect_w, rect_h);

  if (active_color == FOREGROUND)
    gtk_paint_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL,
                      GTK_SHADOW_IN,
                      NULL, color_area, NULL,
                      0, 0,
                      rect_w, rect_h);
  else
    gtk_paint_shadow (color_area->style, color_area_pixmap, GTK_STATE_NORMAL,
                      GTK_SHADOW_OUT,
                      NULL, color_area, NULL,
                      0, 0,
                      rect_w, rect_h);

  /*  draw the default pixmap  */
  gdk_drawable_get_size (default_pixmap, &def_width, &def_height);
  gdk_draw_drawable (color_area_pixmap, color_area_gc, default_pixmap,
		     0, 0, 0, height - def_height, def_width, def_height);
  gdk_draw_drawable (color_area_mask, mask_gc, default_mask,
		   0, 0, 0, height - def_height, def_width, def_height);

  /*  draw the swap pixmap  */
  gdk_drawable_get_size (swap_pixmap, &swap_width, &swap_height);
  gdk_draw_drawable (color_area_pixmap, color_area_gc, swap_pixmap,
		     0, 0, width - swap_width, 0, swap_width, swap_height);
  gdk_draw_drawable (color_area_mask, mask_gc, swap_mask,
		   0, 0, width - swap_width, 0, swap_width, swap_height);

  /*  draw the widget  */
  gdk_gc_set_clip_mask (color_area_gc, color_area_mask);
  gdk_gc_set_clip_origin (color_area_gc, 0, 0);
  gdk_draw_drawable (color_area->window, color_area_gc, color_area_pixmap,
		   0, 0, 0, 0, width, height);

  /*  reset the clip mask  */
  gdk_gc_set_clip_mask (color_area_gc, NULL);
}
Пример #23
0
//! Draws the square (x, y). On the board it is shown at (real_x, real_y)
void board_refresh_cell_real (int x, int y, int real_x, int real_y)
{
	GdkGC *gc;
	int parity = (board_wid * board_heit + x + y + 1) % 2;
	int thepiece;
	if (opt_quiet) return;
	if (!cur_pos.board) return;
	gc = board_area->style->bg_gc[GTK_STATE_NORMAL];
	gdk_gc_set_clip_mask (gc, NULL);
	gdk_gc_set_clip_origin (gc, real_x * cell_size, real_y * cell_size);
	thepiece = cur_pos.board[y * board_wid + x] -1 + num_pieces * parity;
	if ((cur_pos.render[y * board_wid + x] & 0xFF) == RENDER_REPLACE)
		thepiece = (cur_pos.render[y * board_wid + x] >> 8) -1 + num_pieces * parity;
	if ((cur_pos.board[y * board_wid + x] != 0
			|| (cur_pos.render[y * board_wid + x] & 0xFF) == RENDER_REPLACE)
			&& !board_suspended)
	{
		/* FIXME: current impl is that if bgimage is set then bgcolor is irrelevant. Maybe we should change it so that bgimage is layered on top of bgcolor */
		if (board_bgimage)
		{
			gdk_draw_pixmap (board_area->window,
					gc, (GdkDrawable *) board_bgimage,
					real_x * cell_size, real_y * cell_size,
					real_x * cell_size, real_y * cell_size,
					cell_size, cell_size
					);
			gdk_gc_set_clip_mask (gc, piece_masks [thepiece]);
			gdk_gc_set_clip_origin (gc, real_x * cell_size, real_y * cell_size);
		}
		gdk_draw_pixmap (board_area->window, 
				gc, (GdkDrawable *) pieces [thepiece],
				0, 0, real_x * cell_size, real_y * cell_size, 
				-1, -1);
	}
	else
	{
		if (board_bgimage)
		{
			gdk_draw_pixmap (board_area->window,
					gc, (GdkDrawable *) board_bgimage,
					real_x * cell_size, real_y * cell_size,
					real_x * cell_size, real_y * cell_size,
					cell_size, cell_size
					);
		}
		else
			gdk_draw_rectangle (board_area->window, board_gcs[parity], 1, 
					real_x * cell_size, real_y * cell_size,
					cell_size, cell_size);
	}

	if (cur_pos.render[y * board_wid + x] == RENDER_SHADE1			
			&& cur_pos.board[y * board_wid + x] != 0
		   	&& !board_suspended)
	{
#if GTK_MAJOR_VERSION > 1
		GdkPixbuf *pixbuf;
		int i;
		guchar *pixels;
		pixbuf = gdk_pixbuf_get_from_drawable (NULL, pieces[thepiece], NULL,
				0, 0, 0, 0, cell_size, cell_size);
		pixels = gdk_pixbuf_get_pixels (pixbuf);
		for (i=0; i<3*cell_size*cell_size; i++)
			pixels[i] = (pixels[i] + 127)/2;
		gdk_pixbuf_render_to_drawable (pixbuf, board_area->window, gc, 0, 0,
				real_x * cell_size, real_y * cell_size, cell_size, cell_size,
				GDK_RGB_DITHER_NONE, 0, 0);
		// FIXME: find out the  correct way to free it
		g_free (pixels);
		g_free (pixbuf);
#else
		fprintf (stderr, "Warning: RENDER_SHADE currently unimplemented in gtk1 version\n");
#endif
	}

	
	if (game_draw_cell_boundaries)
	{
		if (real_x > 0)
			gdk_draw_line (board_area->window, board_gcs[2],
				real_x * cell_size, real_y * cell_size,
				real_x * cell_size, (real_y + 1) * cell_size);
		if (real_y > 0)
			gdk_draw_line (board_area->window, board_gcs[2],
				real_x * cell_size, real_y * cell_size,
				(real_x + 1) * cell_size, real_y * cell_size);
	}
	
	// TODO: do HIGHLIGHT2 and 3 also
	if (cur_pos.render[y * board_wid + x] == RENDER_HIGHLIGHT1 && !board_suspended)
	{
		int incr = game_draw_cell_boundaries ? 1 : 0;
		gdk_draw_line (board_area->window, board_highlight_gcs[0],
			real_x * cell_size + incr, real_y * cell_size + incr,
			real_x * cell_size + incr, (real_y + 1) * cell_size - 1);
		gdk_draw_line (board_area->window, board_highlight_gcs[0],
			real_x * cell_size + incr, real_y * cell_size + incr,
			(real_x + 1) * cell_size - 1, real_y * cell_size + incr);
		gdk_draw_line (board_area->window, board_highlight_gcs[0],
			(real_x + 1) * cell_size - 1, real_y * cell_size + incr,
			(real_x + 1) * cell_size - 1, (real_y + 1) * cell_size - 1);
		gdk_draw_line (board_area->window, board_highlight_gcs[0],
			real_x * cell_size + incr, (real_y + 1) * cell_size - 1,
			(real_x + 1) * cell_size - 1, (real_y + 1) * cell_size - 1);
	}
	
	if (cur_pos.render[y * board_wid + x] == RENDER_BUTTONIZE && !board_suspended)
	{
		int incr = game_draw_cell_boundaries ? 1 : 0;
		gdk_draw_line (board_area->window, board_buttonize_gcs[0],
			real_x * cell_size + incr, real_y * cell_size + incr,
			real_x * cell_size + incr, (real_y + 1) * cell_size - 1);
		gdk_draw_line (board_area->window, board_buttonize_gcs[0],
			real_x * cell_size + incr, real_y * cell_size + incr,
			(real_x + 1) * cell_size - 1, real_y * cell_size + incr);
		gdk_draw_line (board_area->window, board_buttonize_gcs[1],
			(real_x + 1) * cell_size - 1, real_y * cell_size + incr,
			(real_x + 1) * cell_size - 1, (real_y + 1) * cell_size - 1);
		gdk_draw_line (board_area->window, board_buttonize_gcs[1],
			real_x * cell_size + incr, (real_y + 1) * cell_size - 1,
			(real_x + 1) * cell_size - 1, (real_y + 1) * cell_size - 1);
	}
	
}
Пример #24
0
static void 
gtk_plot_gdk_draw_string                        (GtkPlotPC *pc,
                                                gint tx, gint ty,
                                                gint angle,
                                                const GdkColor *fg,
                                                const GdkColor *bg,
                                                gboolean transparent,
                                                gint border,
                                                gint border_space,
                                                gint border_width,
                                                gint shadow_width,
                                                const gchar *font_name,
                                                gint font_height,
                                                GtkJustification just,
                                                const gchar *text)
{
  GdkBitmap *text_bitmap;
  GdkPixmap *text_pixmap;
  GdkBitmap *text_mask;
  GdkImage *image;
  GdkGC *gc, *bitmap_gc;
  GdkColormap *colormap;
  GdkColor white, black, mask_color;
  GList *family = NULL;
  gint y0;
  gint old_width, old_height;
  gboolean bold, italic;
  gint fontsize;
  gint ascent, descent;
  gint numf;
  gint xp = 0, yp = 0;
  gint width, height;
  gint x, y;
  gint i;
  GdkFont *font, *latin_font, *dfont;
  GtkPSFont *psfont, *base_psfont, *latin_psfont;
  gchar subs[2], insert_char;
  GdkWChar *aux, *wtext, *lastchar = NULL, *xaux;
  gchar num[4];

  if(!GTK_PLOT_GDK(pc)->drawable) return;
  if(!GTK_PLOT_GDK(pc)->window) return;
  if(!GTK_PLOT_GDK(pc)->gc) return;
  if(!text || strlen(text) == 0) return;

  colormap = gdk_colormap_get_system ();
  gc = GTK_PLOT_GDK(pc)->gc;

  if(!gc) return;

  gtk_plot_text_get_size(text, angle, font_name, font_height, &width, &height, &ascent, &descent);

  if(height == 0 || width == 0) return;

  old_width = width;
  old_height = height;
  if(angle == 90 || angle == 270)
    {
      old_width = height;
      old_height = width;
    }

  gtk_psfont_get_families(&family, &numf);
  font = gtk_psfont_get_gdkfont(font_name, font_height);
  base_psfont = psfont = gtk_psfont_get_font(font_name);
  italic = psfont->italic;
  bold = psfont->bold;
  fontsize = font_height;
  x = 0;
  y0 = y = ascent;

  if (psfont->i18n_latinfamily) {
    latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily, italic,
					     bold);
    latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname, fontsize);
  } else {
    latin_psfont = NULL;
    latin_font = NULL;
  }

  i = strlen(text) + 2;
  aux = wtext = g_malloc0(sizeof(GdkWChar) * i);
  gdk_mbstowcs(wtext, text, i - 1);

  /* initializing text bitmap - ajd */
  text_bitmap = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window,
                              old_width, old_height, 1);
  bitmap_gc = gdk_gc_new(text_bitmap);
  gdk_color_white (colormap, &white);
  gdk_gc_set_foreground(bitmap_gc, &white);
  gdk_draw_rectangle(text_bitmap, bitmap_gc, TRUE,
                     0, 0, -1, -1);
  gdk_color_black (colormap, &black);
  gdk_gc_set_foreground(bitmap_gc, &black);

  while(aux && *aux != '\0' && *aux != '\n'){
   if(*aux == '\\'){
     aux++;
     switch(*aux){
       case '0': case '1': case '2': case '3':
       case '4': case '5': case '6': case '7': case '9':
           psfont = gtk_psfont_find_by_family((gchar *)g_list_nth_data(family, *aux-'0'), italic, bold);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
           aux++;
           break;
       case '8': case 'g':
           psfont = gtk_psfont_find_by_family("Symbol", italic, bold);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
           aux++;
           break;
       case 'B':
           bold = TRUE;
           psfont = gtk_psfont_find_by_family(psfont->family, italic, bold);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 'x':
           xaux = aux + 1;
           for (i=0; i<3; i++){
            if (xaux[i] >= '0' && xaux[i] <= '9')
              num[i] = xaux[i];
            else
              break;
           }
           if (i < 3){
              aux++;
              break;
           }
           num[3] = '\0';
           insert_char = (gchar)atoi(num);
           subs[0] = insert_char;
           subs[1] = '\0';
	   /* \xNNN is always outputted with latin fonts. */
	   dfont = (psfont->i18n_latinfamily != NULL) ? latin_font : font;
           gdk_draw_string (text_bitmap, dfont,
                            bitmap_gc,
                            x, y,
                            subs);

           x += gdk_char_width(font, insert_char);
           aux += 4;
           lastchar = aux - 1;
           break;
       case 'i':
           italic = TRUE;
           psfont = gtk_psfont_find_by_family(psfont->family, italic, bold);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 'S': case '^':
           fontsize = (int)((gdouble)fontsize * 0.6 + 0.5);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
           y -= font->ascent;
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 's': case '_':
           fontsize = (int)((gdouble)fontsize * 0.6 + 0.5);
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
           y += font->descent;
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case '+':
           fontsize += 3;
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case '-':
           fontsize -= 3;
           gdk_font_unref(font);
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 'N':
	   psfont = base_psfont;
           gdk_font_unref(font);
           fontsize = font_height;
           font = gtk_psfont_get_gdkfont(psfont->psname, fontsize);
           y = y0;
           italic = psfont->italic;
           bold = psfont->bold;
	   if (latin_font) {
	     gdk_font_unref(latin_font);
	     latin_font = NULL;
	   }
	   if (psfont->i18n_latinfamily) {
	     latin_psfont = gtk_psfont_find_by_family(psfont->i18n_latinfamily,
						      italic, bold);
	     latin_font = gtk_psfont_get_gdkfont(latin_psfont->psname,
						 fontsize);
	   }
           aux++;
           break;
       case 'b':
	   if (lastchar) {
	     gtk_psfont_get_char_size(psfont, font, latin_font, *lastchar, &i,
				    NULL, NULL);
	     x -= i;

	     if (lastchar == wtext)
	       lastchar = NULL;
	     else
	       lastchar--;
	   } else {
	     gtk_psfont_get_char_size(psfont, font, latin_font, 'X', &i, NULL,
				    NULL);
	     x -= i;
	   }
           aux++;
           break;
       default:
           if(aux && *aux != '\0' && *aux !='\n'){
	     x += drawstring(pc, text_bitmap, bitmap_gc, &black, &white, x, y,
			     psfont, font, latin_font, *aux);
	     lastchar = aux;
	     aux++;
	   }
	   break;
     }
   } else {
     if(aux && *aux != '\0' && *aux !='\n'){
       x += drawstring(pc, text_bitmap, bitmap_gc, &black, &white, x, y,
		       psfont, font, latin_font, *aux);
       lastchar = aux;
       aux++;
     }
   }
  }

  g_free(wtext);

  /* initializing clip mask bitmap - ajd */
  text_mask = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, width, height, 1);
  mask_color = white;
  mask_color.pixel = 0;
  gdk_gc_set_foreground(bitmap_gc, &mask_color);
  gdk_draw_rectangle(text_mask, bitmap_gc, TRUE, 0, 0, -1, -1);
  mask_color = black;
  mask_color.pixel = 1;
  gdk_gc_set_foreground(bitmap_gc, &mask_color);

  /* performing text rotation and saving it onto clip mask bitmap - ajd */
  image = gdk_image_get(text_bitmap, 0, 0, old_width, old_height);
  for(y = 0; y < old_height; y++)
      for(x = 0; x < old_width; x++)
         {
           if( black.pixel == gdk_image_get_pixel(image, x, y) ){
           switch(angle){
            case 0:
                xp = x;
                yp = y;
                break;
            case 90:
                xp = y;
                yp = old_width - x;
                break;
            case 180:
                xp = old_width - x;
                yp = old_height - y;
                break;
            case 270:
                xp = old_height - y;
                yp = x;
                break;
            }
            gdk_draw_point(text_mask, bitmap_gc, xp, yp);
           }
         }
  gdk_image_destroy(image);


  /* initializing text pixmap - ajd */
  text_pixmap = gdk_pixmap_new(GTK_PLOT_GDK(pc)->window, width, height, -1);
  gdk_gc_set_foreground(gc, (GdkColor *) bg);
  gdk_draw_rectangle(text_pixmap, gc, TRUE, 0, 0, -1, -1);
  gdk_gc_set_foreground(gc, (GdkColor *) fg);

  /* copying clip mask bitmap onto text pixmap - ajd */
  gdk_gc_set_clip_mask(gc, text_mask);
  gdk_gc_set_clip_origin(gc, 0, 0);
  gdk_draw_rectangle(text_pixmap, gc, TRUE, 0, 0, -1, -1);
  gdk_gc_set_clip_mask(gc, NULL);

  gtk_plot_text_get_area(text, angle, just, font_name, font_height,
                         &x, &y, &width, &height);
  tx += x;
  ty += y;

  if(transparent){
    gdk_gc_set_clip_mask (gc, text_mask);
    gdk_gc_set_clip_origin (gc, tx, ty);
  } else {
    gdk_gc_set_foreground(gc, (GdkColor *) bg);
    gtk_plot_pc_draw_rectangle(pc,
   		         TRUE, 
                         tx - border_space, ty - border_space, 
                         width + 2*border_space, height + 2*border_space);
  }

  gdk_draw_pixmap(GTK_PLOT_GDK(pc)->drawable, gc,
                  text_pixmap, 0, 0,
                  tx, ty, -1, -1);
  gdk_gc_set_clip_mask(gc, NULL);

  gdk_pixmap_unref(text_pixmap);
  gdk_bitmap_unref(text_mask);
  gdk_font_unref(font);
  if (latin_font) gdk_font_unref(latin_font);
  gdk_gc_unref(bitmap_gc);
  gdk_pixmap_unref(text_bitmap);


/* border */

  gdk_gc_set_foreground(gc, (GdkColor *) fg);
  gtk_plot_pc_set_dash(pc, 0, NULL, 0);
  gtk_plot_pc_set_lineattr(pc, border_width, 0, 0, 0);
  switch(border){
    case GTK_PLOT_BORDER_SHADOW: 
      gtk_plot_pc_draw_rectangle(pc,
   		         TRUE, 
                         tx - border_space + shadow_width, 
                         ty + height + border_space, 
                         width + 2 * border_space, shadow_width);
      gtk_plot_pc_draw_rectangle(pc,
   		         TRUE, 
                         tx + width + border_space, 
                         ty - border_space + shadow_width, 
                         shadow_width, height + 2 * border_space);
    case GTK_PLOT_BORDER_LINE: 
      gtk_plot_pc_draw_rectangle(pc,
   		         FALSE, 
                         tx - border_space, ty - border_space, 
                         width + 2*border_space, height + 2*border_space);
    case GTK_PLOT_BORDER_NONE: 
    default:
	break; 
  }

  return;
}
Пример #25
0
static void
ghid_draw_grid (void)
{
  static GdkPoint *points = 0;
  static int npoints = 0;
  Coord x1, y1, x2, y2, x, y;
  int n, i;
  render_priv *priv = gport->render_priv;

  if (!Settings.DrawGrid)
    return;
  if (Vz (PCB->Grid) < MIN_GRID_DISTANCE)
    return;
  if (!priv->grid_gc)
    {
      if (gdk_color_parse (Settings.GridColor, &gport->grid_color))
	{
	  gport->grid_color.red ^= gport->bg_color.red;
	  gport->grid_color.green ^= gport->bg_color.green;
	  gport->grid_color.blue ^= gport->bg_color.blue;
	  gdk_color_alloc (gport->colormap, &gport->grid_color);
	}
      priv->grid_gc = gdk_gc_new (gport->drawable);
      gdk_gc_set_function (priv->grid_gc, GDK_XOR);
      gdk_gc_set_foreground (priv->grid_gc, &gport->grid_color);
      gdk_gc_set_clip_origin (priv->grid_gc, 0, 0);
      set_clip (priv, priv->grid_gc);
    }
  x1 = GridFit (SIDE_X (gport->view.x0), PCB->Grid, PCB->GridOffsetX);
  y1 = GridFit (SIDE_Y (gport->view.y0), PCB->Grid, PCB->GridOffsetY);
  x2 = GridFit (SIDE_X (gport->view.x0 + gport->view.width - 1),
                PCB->Grid, PCB->GridOffsetX);
  y2 = GridFit (SIDE_Y (gport->view.y0 + gport->view.height - 1),
                PCB->Grid, PCB->GridOffsetY);
  if (x1 > x2)
    {
      Coord tmp = x1;
      x1 = x2;
      x2 = tmp;
    }
  if (y1 > y2)
    {
      Coord tmp = y1;
      y1 = y2;
      y2 = tmp;
    }
  if (Vx (x1) < 0)
    x1 += PCB->Grid;
  if (Vy (y1) < 0)
    y1 += PCB->Grid;
  if (Vx (x2) >= gport->width)
    x2 -= PCB->Grid;
  if (Vy (y2) >= gport->height)
    y2 -= PCB->Grid;
  n = (x2 - x1) / PCB->Grid + 1;
  if (n > npoints)
    {
      npoints = n + 10;
      points = (GdkPoint *)realloc (points, npoints * sizeof (GdkPoint));
    }
  n = 0;
  for (x = x1; x <= x2; x += PCB->Grid)
    {
      points[n].x = Vx (x);
      n++;
    }
  if (n == 0)
    return;
  for (y = y1; y <= y2; y += PCB->Grid)
    {
      for (i = 0; i < n; i++)
	points[i].y = Vy (y);
      gdk_draw_points (gport->drawable, priv->grid_gc, points, n);
    }
}