예제 #1
0
파일: gtk.c 프로젝트: Centuriondan/xlennart
static void
gtk_ui_graphics_init(void) {
	offscreen = gdk_pixmap_new(field->window, screensize, screensize, -1);
	stdgc = gdk_gc_new(offscreen);
	gdk_gc_set_exposures(stdgc, FALSE);
	gdk_gc_set_line_attributes(stdgc, 2, GDK_LINE_SOLID, GDK_CAP_ROUND,
				   GDK_JOIN_MITER);
	font = gdk_font_load("fixed");
}
예제 #2
0
파일: gdkgc.c 프로젝트: amery/clip-itk
/* Sets whether copying non-visible portions of a drawable using this graphics
 * context generate exposure events for the corresponding regions of the
 * destination drawable. (See gdk_draw_pixmap()). */
int
clip_GDK_GCSETEXPOSURES(ClipMachine * cm)
{
	C_object  *cgc = _fetch_co_arg(cm);
	gint exposures = _clip_parni (cm, 2);

	CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKARG(2,NUMERIC_t);
	gdk_gc_set_exposures(GDK_GC(cgc->object), exposures);
	return 0;
err:
	return 1;
}
예제 #3
0
파일: pixmaps.c 프로젝트: svn2github/xqf
void ensure_buddy_pix (GtkWidget *window, int n) {
  int width, height;
  GdkGC *white_gc;
  int pri;
  int sec;

  if (!buddy_pix[1].pix)	/* not initialized */
    return;

  if (n < 0 || n > 9 || buddy_pix[n].pix)
    return;

  sec = ((n & 0x04) != 0)? 0x04 : 0x02;
  pri = n & ~sec;

  ensure_buddy_pix (window, pri);

  if (!pri || !sec)
    return;

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

  gdk_window_get_size (buddy_pix[1].pix, &width, &height);

  buddy_pix[n].pix = gdk_pixmap_new (window->window, width, height, -1);
  buddy_pix[n].mask = gdk_pixmap_new (window->window, width, height, 1);

  white_gc = window->style->white_gc;

  if (!masks_gc) {
    masks_gc = gdk_gc_new (buddy_pix[n].mask);
    gdk_gc_set_exposures (masks_gc, FALSE);
  }

  gdk_gc_set_foreground (masks_gc, &window->style->white);

  gdk_draw_pixmap (buddy_pix[n].pix, white_gc, buddy_pix[pri].pix,
                                                   0, 0, 0, 0, width, height);
  gdk_draw_pixmap (buddy_pix[n].mask, masks_gc, buddy_pix[pri].mask,
                                                   0, 0, 0, 0, width, height);

  gdk_gc_set_clip_mask (white_gc, buddy_pix[sec].mask);
  gdk_draw_pixmap (buddy_pix[n].pix, white_gc, buddy_pix[sec].pix,
                                                   0, 0, 0, 0, width, height);
  gdk_gc_set_clip_mask (white_gc, NULL);

  gdk_gc_set_clip_mask (masks_gc, buddy_pix[sec].mask);
  gdk_draw_rectangle (buddy_pix[n].mask, masks_gc, TRUE, 0, 0, width, height);
  gdk_gc_set_clip_mask (masks_gc, NULL);
}
예제 #4
0
파일: pixmaps.c 프로젝트: svn2github/xqf
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);
}
예제 #5
0
파일: pixmaps.c 프로젝트: svn2github/xqf
/** \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;
}
예제 #6
0
파일: gtk.c 프로젝트: Centuriondan/xlennart
static void
gtk_ui_load_picture(const char *name, int trans, Picture **pictp) {
	Picture *pict;
	char file[255];
	GdkBitmap *mask;

	UNUSED(trans);

	pict = xalloc(sizeof *pict);

	sprintf(file, "%s/pixmaps/%s.xpm", pictdir, name);
	pict->pix = gdk_pixmap_create_from_xpm(toplevel->window, &mask,
					       NULL, file);
	if (pict->pix == NULL)
		fatal("error reading %s", file);
	pict->mask = mask;
	pict->gc = gdk_gc_new(toplevel->window);
	gdk_gc_set_exposures(pict->gc, FALSE);
	gdk_gc_set_clip_mask(pict->gc, mask);
	gdk_window_get_size(pict->pix, &pict->width, &pict->height);

	*pictp = pict;
}
예제 #7
0
/**
 * uni_image_view_fast_scroll:
 *
 * Actually scroll the views window using gdk_draw_drawable().
 * GTK_WIDGET (view)->window is guaranteed to be non-NULL in this
 * function.
 **/
static void
uni_image_view_fast_scroll (UniImageView * view, int delta_x, int delta_y)
{
    GdkDrawable *drawable = GTK_WIDGET (view)->window;

    int src_x, src_y;
    int dest_x, dest_y;
    if (delta_x < 0)
    {
        src_x = 0;
        dest_x = -delta_x;
    }
    else
    {
        src_x = delta_x;
        dest_x = 0;
    }
    if (delta_y < 0)
    {
        src_y = 0;
        dest_y = -delta_y;
    }
    else
    {
        src_y = delta_y;
        dest_y = 0;
    }

    /* First move the part of the image that did not become hidden or
       shown by this operation. gdk_draw_drawable is probably very
       fast because it does not involve sending any data to the X11
       server.

       Remember that X11 is weird shit. It does not remember how
       windows beneath other windows look like. So if another window
       overlaps this window, it will temporarily look corrupted. We
       fix that later by turning on "exposures." See below. */

    GdkGC *gc = gdk_gc_new (drawable);
    Size alloc = uni_image_view_get_allocated_size (view);

    gdk_gc_set_exposures (gc, TRUE);
    gdk_draw_drawable (drawable,
                       gc,
                       drawable,
                       src_x, src_y,
                       dest_x, dest_y,
                       alloc.width - abs (delta_x),
                       alloc.height - abs (delta_y));
    g_object_unref (gc);

    /* If we moved in both the x and y directions, two "strips" of the
       image becomes visible. One horizontal strip and one vertical
       strip. */
    GdkRectangle horiz_strip = {
        0,
        (delta_y < 0) ? 0 : alloc.height - abs (delta_y),
        alloc.width,
        abs (delta_y)
    };
    uni_image_view_repaint_area (view, &horiz_strip);

    GdkRectangle vert_strip = {
        (delta_x < 0) ? 0 : alloc.width - abs (delta_x),
        0,
        abs (delta_x),
        alloc.height
    };
    uni_image_view_repaint_area (view, &vert_strip);

    /* Here is where we fix the weirdness mentioned above. I do not
     * really know why it works, but it does! */
    GdkEvent *ev;
    while ((ev = gdk_event_get_graphics_expose (drawable)) != NULL)
    {
        GdkEventExpose *expose = (GdkEventExpose *) ev;
        int exp_count = expose->count;
        uni_image_view_repaint_area (view, &expose->area);
        gdk_event_free (ev);
        if (exp_count == 0)
            break;
    }
}
예제 #8
0
파일: rbgdkgc.c 프로젝트: tec/ruby-gnome2
static VALUE
rg_set_exposures(VALUE self, VALUE exposures)
{
    gdk_gc_set_exposures(_SELF(self), RVAL2CBOOL(exposures));
    return self;
}