Re: Interface with 64 toggleable elements: what's the best way?
- From: Russell Shaw <rjshaw iprimus com au>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Interface with 64 toggleable elements: what's the best way?
- Date: Mon, 10 Nov 2003 03:45:13 +1100
Sean McAfee wrote:
Russell Shaw <rjshaw iprimus com au> wrote:
Sean McAfee wrote:
My next idea was to represent the bits as pixmaps: an empty circle for
a clear bit, and a filled circle for a set bit. I want my program to
be completely standalone, so now I'm trying to create a pair of
textual xpm's that look like decent circles, which isn't completely
It's much easier to create an outline and solid circle using
gdk_draw_arc() onto GdkPixmap at the start of your program.
D'oh! That did sound much easier.
When I tried this approach, however, I ran into some difficulties. In
order to craete a GtkPixmap from a GdkPixmap, one needs a second GdkPixmap,
the bit mask. I searched high and low, but couldn't find any information on
how one would go about creating a bit mask. I finally had to jump into the
source of the gdk_pixmap_create_from_xpm_d() function, the only standard
function that returns a bit mask. After some cutting and pasting, I came up
with the following routine:
circular_pixmap(GdkWindow *window, int size,
GdkPixmap **image, GdkPixmap **mask)
GdkGC *image_gc, *mask_gc;
*image = gdk_pixmap_new(window, size, size, -1);
*mask = gdk_pixmap_new(window, size, size, 1);
image_gc = gdk_gc_new(*image);
mask_gc = gdk_gc_new(*mask);
mask_pattern.pixel = 0;
gdk_draw_rectangle(*mask, mask_gc, TRUE, 0, 0, -1, -1);
mask_pattern.pixel = 1;
gdk_draw_arc(*image, image_gc, TRUE, 0, 0, size, size, 0, 64*360);
gdk_draw_arc(*mask, mask_gc, TRUE, 0, 0, size, size, 0, 64*360);
This works, but damn if it doesn't seem awfully clunky. Is there a better
way to create a pixmap-plus-mask from scratch?
circular_pixmap(GtkWidget *widget, int size, GdkColor *color)
gdk_draw_rectangle(dot,style->bg_gc[NORMAL],TRUE,0,0,size,size); // background
gdk_draw_arc(dot,gc,TRUE,0,0,size,size,0,23040); // foreground
Draw a pixmap instead of a bitmap. I thought there was
a way to extract a "plane" from a pixmap to use as a
bitmap, but can't recall. Ideally, there should be a
way to get a clear background like with a circular clip
region or something.
] [Thread Prev