Пример #1
0
static gint
TSOffsetStyleGCs(GtkStyle* style, gint xorigin, gint yorigin)
{
    TSOffsetStyleGCArray(style->fg_gc, xorigin, yorigin);
    TSOffsetStyleGCArray(style->bg_gc, xorigin, yorigin);
    TSOffsetStyleGCArray(style->light_gc, xorigin, yorigin);
    TSOffsetStyleGCArray(style->dark_gc, xorigin, yorigin);
    TSOffsetStyleGCArray(style->mid_gc, xorigin, yorigin);
    TSOffsetStyleGCArray(style->text_gc, xorigin, yorigin);
    TSOffsetStyleGCArray(style->base_gc, xorigin, yorigin);
    gdk_gc_set_ts_origin(style->black_gc, xorigin, yorigin);
    gdk_gc_set_ts_origin(style->white_gc, xorigin, yorigin);
    return MOZ_GTK_SUCCESS;
}
Пример #2
0
/* Deprecated?  Depend strictly on refresh?   This won't work for blinking
 * and friends
 * x and y are in pixel units */
static void
vga_paint_charcell(GtkWidget *da, VGAText *vga,
				vga_charcell cell, int x, int y)
{
#ifdef USE_DEPRECATED_GDK
	vga_set_textattr(vga, cell.attr);
	gdk_gc_set_ts_origin(vga->pvt->gc, x, y-(16 * cell.c));
	gdk_draw_rectangle(da->window, vga->pvt->gc, TRUE, x, y,
				vga->pvt->font->width, vga->pvt->font->height);
#else
	printf("vga_paint_charcel() called -- why?\n");
#if 0
	char text[2];
	vga_set_textattr(vga, cell.attr);
	gdk_cairo_set_source_color(vga->pvt->cr,
			vga_palette_get_color(vga->pvt->pal, vga->pvt->bg));
	cairo_move_to(vga->pvt->cr, x, y);
	cairo_rectangle(vga->pvt->cr, x, y,
			vga->pvt->font->width, vga->pvt->font->height);
	cairo_fill(vga->pvt->cr);
	gdk_cairo_set_source_color(vga->pvt->cr,
			vga_palette_get_color(vga->pvt->pal, vga->pvt->fg));
	/* FIXME: Don't use toy text API.  Use cairo_show_glyphs() instead */
	text[0] = cell.c;
	text[1] = '\0';
	cairo_show_text(vga->pvt->cr, text);
#endif
#endif
}
Пример #3
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)) {
      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);
  }
}
Пример #4
0
static gint
TSOffsetStyleGCArray(GdkGC** gcs, gint xorigin, gint yorigin)
{
    int i;
    /* there are 5 gc's in each array, for each of the widget states */
    for (i = 0; i < 5; ++i)
        gdk_gc_set_ts_origin(gcs[i], xorigin, yorigin);
    return MOZ_GTK_SUCCESS;
}
Пример #5
0
/* do not use clip mask; only one tile under mask was drawn */
void
_zune_fill_tiled_rectangle(struct MUI_ImageSpec *img,
			   struct MUI_RenderInfo *mri,
			   LONG left, LONG top, LONG width, LONG height,
			   LONG xoffset, LONG yoffset)
{
    GdkPixmap *pixmap;

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

    gdk_gc_set_fill(mri->mri_RastPort, GDK_TILED);
    gdk_gc_set_tile(mri->mri_RastPort, pixmap);
    gdk_gc_set_ts_origin(mri->mri_RastPort, xoffset, yoffset);

    gdk_draw_rectangle (mri->mri_Window, mri->mri_RastPort, TRUE,
			left, top, width, height);
    gdk_gc_set_fill(mri->mri_RastPort, GDK_SOLID);
    gdk_gc_set_ts_origin(mri->mri_RastPort, 0, 0);
}
Пример #6
0
/* Set the origin when using tiles or stipples with the GC.
 * The tile or stipple will be aligned such that the upper left corner of
 * the tile or stipple will coincide with this point. */
int
clip_GDK_GCSETTSORIGIN(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_ts_origin(GDK_GC(cgc->object), x, y);
	return 0;
err:
	return 1;
}
Пример #7
0
GdkRectangle tandrawpiece (GtkWidget *widget,GdkPixmap *pixmap,
			   tanpiecepos *piecepos,
			   double zoom, tanremplis remplis){

  GdkPoint pnt[PNTNBRMAX+1];
  int i,pntnbr,ix,iy,ixmax=-20000,ixmin=20000,iymax=-20000,iymin=20000;
  GdkRectangle update_rect;
  GdkGC *gc;
  double gris,rx,ry;

  pntnbr=tanplacepiece(piecepos,pnt,zoom);

  for(i=0; i<pntnbr; i++){
    ix=pnt[i].x;
    iy=pnt[i].y;
    if (ix<ixmin)
      ixmin=ix;
    if (ix>ixmax)
      ixmax=ix;
    if (iy<iymin)
      iymin=iy;
    if (iy>iymax)
      iymax=iy;
  }

  update_rect.x=ixmin;
  update_rect.y=iymin;
  update_rect.width=ixmax-ixmin+1;
  update_rect.height=iymax-iymin+1;

  switch (remplis){
  case TAN_PETITEHLP:
    gc=tabgc[GCPETITEHLP];
    break;
  case TAN_PIECENOR:
    gc=tabgc[GCPIECENOR];
    gdk_gc_set_ts_origin (gc,pnt[pntnbr].x,pnt[pntnbr].y);
    break;
  case TAN_PIECEHI:
    gc=tabgc[GCPIECEHI];
    gdk_gc_set_ts_origin (gc,pnt[pntnbr].x,pnt[pntnbr].y);
    break;
  default:
    gc=widget->style->white_gc;
    break;
  }

  gdk_draw_polygon (pixmap,
		    gc,
		    TRUE,
		    pnt,
		    pntnbr);

  if ( remplis==TAN_PIECENOR || remplis==TAN_PIECEHI ){
    pnt[pntnbr]=pnt[0];                 /* ecrase le point du centre */
    for (i=0; i<pntnbr; i++){
      rx=pnt[i+1].x-pnt[i].x;
      ry=pnt[i].y-pnt[i+1].y;
      gris=(ry+rx)*0.35355339/sqrt(rx*rx+ry*ry);
      if (piecepos->flipped)
	gris=-gris;
      gris=gris+0.5;
      gdk_draw_line (pixmap,
		     tabgc[(int)(gris*(GRISNBR))],
		     pnt[i].x,pnt[i].y,pnt[i+1].x,pnt[i+1].y);
    }
  }
  return(update_rect);

}
Пример #8
0
/*
 * vga_render_area:
 * @vga: VGAText structure pointer
 * @area: Area to refresh
 *
 * For the given rectangular area, render the contents of the VGA buffer
 * onto the surface buffer (NOT on-screen).
 */
static void
vga_render_area(VGAText *vga, GdkRectangle * area)
{
	int x, y, x2, y2;
	int char_x, char_y, x_drawn, y_drawn, row, col;
	x2 = area->x + area->width;	/* Last column in area + 1 */
	y2 = area->y + area->height;	/* Last row in area + 1 */
	x2 = MIN(x2, vga->pvt->font->width * vga->pvt->cols);
	y2 = MIN(y2, vga->pvt->font->height * vga->pvt->rows);
	y = area->y;
	vga_charcell * cell;
	char text[2];
	cairo_t *cr;
	guchar attr;
	int cols_sameattr;
	int col_topaint;
	int num_cols;
	int last_col;
	vga_charcell *video_buf;

//printf("vga_render_area(): x,y = (%d,%d), width=%d, height=%d\n", area->x, area->y, area->width, area->height);
	/* We must create/destroy the context in each expose event */
	//cr = gdk_cairo_create(da->window);
	cr = cairo_create(vga->pvt->surface_buf);
#if 1
	/* Set clip region for speed */
	cairo_rectangle(cr, area->x, area->y, area->width, area->height);
	cairo_clip(cr);
#endif

	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
	//cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
#if 1
	cairo_set_font_face(cr, vga->pvt->font->face);
	cairo_set_font_size(cr, 1.0);
#endif

	if (vga->pvt->render_sec_buf)
		video_buf = vga->pvt->sec_buf;
	else
		video_buf = vga->pvt->video_buf;

#define NEW_WAY
#ifdef NEW_WAY
	while (y < y2) {
	//printf("while loop: y (%d) < y2 (%d)\n", y, y2);
		row = PIXEL_TO_ROW(y, vga->pvt->font);
		char_y = row * vga->pvt->font->height;
		y_drawn = (char_y + vga->pvt->font->height) - y;

		col = PIXEL_TO_COL(area->x, vga->pvt->font);
		num_cols = PIXEL_TO_COL(x2-1, vga->pvt->font) - col + 1;
		cols_sameattr = 0;
		x = col * vga->pvt->font->width;
		col_topaint = col;
		cell = &(video_buf[row * 80 + col]);
		attr = cell->attr;
		last_col = col + num_cols - 1;
		//printf("col_topaint = %d, last_col = %d, num_cols=%d\n", col_topaint, last_col, num_cols);
		while (col <= last_col) {
			cell = &(video_buf[row * 80 + col]);
			//printf("CHAR: '%c', cell attr = 0x%02x, old attr was 0x%02x\n", cell->c, cell->attr, attr);
			if (cell->attr == attr) {
				cols_sameattr++;
			} else {
				vga_set_textattr(vga, attr);
				//printf("vga_block_paint() - mid line, cols_sameattr=%d\n", cols_sameattr);
				vga_block_paint(vga, cr, col_topaint,
						row, cols_sameattr);
				attr = cell->attr;
				col_topaint += cols_sameattr;
				cols_sameattr = 1;
			}
			col++;
		}
		/* Paint last chunk of row */
		vga_set_textattr(vga, cell->attr);
		//printf("vga_block_paint() - last chunk, col_to_paint=%d, cols=%d\n", col_topaint, last_col-col_topaint);
		vga_block_paint(vga, cr, col_topaint, row,
				last_col - col_topaint + 1);
		y += vga->pvt->font->height;
	}
#else	/* !NEW_WAY */
	while (y < y2)
	{
		row = PIXEL_TO_ROW(y, vga->pvt->font);
		char_y = row * vga->pvt->font->height;
		y_drawn = (char_y + vga->pvt->font->height) - y;

		x = area->x;
		while (x < x2)
		{
		/*
		 * x       : pixel position to start drawing at (top left)
		 * y       : pixel position to start drawing at (top left)
		 * row     : row of character (usually 0-24)
		 * col     : column of character (usually 0-79)
		 * char_x  : pixel coordinate of beginning of whole character
		 * char_y  : pixel coordinate of beginning of whole character
		 * x_drawn : number of columns to draw of character
		 * y_drawn : number of rows to draw of character
		 */
			col = PIXEL_TO_COL(x, vga->pvt->font);
			char_x = col * vga->pvt->font->width;
			x_drawn = (char_x + vga->pvt->font->width) - x;
		
			cell = &(video_buf[row * 80 + col]);
	
#ifdef USE_DEPRECATED_GDK
			vga_set_textattr(vga, cell->attr);
			gdk_gc_set_ts_origin(vga->pvt->gc, char_x,
					char_y-(16 * cell->c));
			gdk_draw_rectangle(da->window, vga->pvt->gc, TRUE, x, y,
					x_drawn, y_drawn);
#else

/* NEW WAY, TESTING TO SEE HOW MUCH CAIRO FONTS ARE SLOWING ME DOWN */
/* SPeed seems similar... although things aren't getting wiped now */
#if 1
	guchar *data; int row, col, i, j;
	vga_set_textattr(vga, cell->attr);

	/* Background */
	//printf("Char at (%d, %d)\n", x, y);
	cairo_translate(cr, x, y);
	gdk_cairo_set_source_color(cr,
			vga_palette_get_color(vga->pvt->pal, vga->pvt->bg));
	cairo_rectangle(cr, 0, 0,
			vga->pvt->font->width, vga->pvt->font->height);
	cairo_fill(cr);

	/* Foreground character */
	data = vga_font_get_glyph_data(vga->pvt->font, cell->c);
	gdk_cairo_set_source_color(cr,
			vga_palette_get_color(vga->pvt->pal, vga->pvt->fg));
	for (i = 0; i < vga->pvt->font->bytes_per_glyph; i++) {
		row = i;
		for (j = 0; j < 8; j++) {
			if (data[i] & (1 << j)) {
				col = 7 - j;
				cairo_rectangle(cr, col * 1.0, row,
						1.0, 1.0);
				cairo_fill(cr);
			}
		}
	}
#endif

#endif
			x += x_drawn;
		}
		y += y_drawn;
	}
#endif	/* NEW_WAY */
	cairo_destroy(cr);
}
Пример #9
0
static VALUE
rg_set_ts_origin(VALUE self, VALUE x, VALUE y)
{
    gdk_gc_set_ts_origin(_SELF(self), NUM2INT(x), NUM2INT(y));
    return self;
}