Re: cry uncle :)
- From: Pavel Cisler <pavel eazel com>
- To: "Billy N. Patton" <bpatton dal asp ti com>, Gtk users <gtk-list gnome org>
- Subject: Re: cry uncle :)
- Date: Sat, 23 Dec 2000 14:34:26 -0800
Billy,
I think the problem is that you are using an unallocated GdkColor. You
need to use gdk_color_alloc on your white and black to make them mapped
into the color map properly, for instance like so:
GdkColormap *colormap;
colormap = gtk_widget_get_colormap (widget);
gdk_colormap_alloc_color (colormap, &white, TRUE, TRUE);
I suggest you use gdk_rbg colors instead, they don't need to be mapped
and are easier to deal with:
somewhere in your app init:
gdk_rgb_init();
...
guint32 white = 0x00ffffff;
guint32 black = 0x00000000;
gdk_rgb_gc_set_foreground(gc, white);
Hope this helps.
Pavel
>
> I ask about drawing to a drawing area yesterday and got 2 responses that
> stated to change the color of a gc and pass it into the draw_rectangle
> function.
>
> I give I'm unable to do this :( I spent 3 hours in the documentation
> and the examples provided with tkg and cannot get anything to show up.
>
> My target platform is a SUN, I'm developing on winders at home (its
> avoids executing across my ISDN line)
>
> Heres a snippett of my code :
> #include "extern.h"
>
> /* recursive because of my data structure */
> /* after calling this function I emit signal expose_event */
> void draw_cell(cell_p cell /* cell_p */
> ,int view /* view */
> ,int trans_x /* translate x */
> ,int trans_y /* translate y */
> )
> {
> node_p np,detail,strct;
> point_t pts[50000];
> int npts;
> GdkColor white = {0,0,0,0};
> GdkColor black = {0,0xFFFF,0xFFFF,0xFFFF};
> GdkGC *gc = NULL;
>
> if (cell EQ NULL) return;
> if (gc EQ NULL) gc = gdk_gc_new(pixmap);
> fprintf(stderr,"Enter draw_cell\n");
> detail = NodeFind(cell->head,lDETAIL);
> strct = NodeFind(cell->head,lSTRUCT);
> np = LaffNodeNext(detail,detail);
> while (np)
> {
> switch (np->type)
> {
> case lRECT:
> {
> rect_p r = (rect_p) np->data;
> pts[0].x = r->ll.x;
> pts[0].y = r->ll.y;
> pts[1].x = r->ur.x;
> pts[1].y = r->ur.y;
> /* converts database coords to grachic coords applying scale and
> shiftx and shifty */
> Wc2Gc(db,pts,cell,canvas_y,scale,shiftX,shiftY);
> Wc2Gc(db,&pts[1],cell,canvas_y,scale,shiftX,shiftY);
> gdk_gc_set_foreground(gc,&white);
> gdk_draw_rectangle (pixmap
> ,gc
> ,FALSE
> ,pts[0].x
> ,pts[0].y
> ,ABS(pts[0].x - pts[1].x)
> ,ABS(pts[1].y - pts[1].y));
> fprintf(stderr,"Enter draw_cell : lRECT\n");
> break;
> }
> }
> np = LaffNodeNext(np,detail);
> }
> fprintf(stderr,"Leave draw_cell\n");
> }
>
> Also how do I set the drawing mode for the DC
> XOR, OR ...
>
> =========+=========+=========+=========+=========+=========+=========+
> ___ _ ____ ___ __ __
> / _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
> / _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
> /____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
> /___/
> Texas Instruments ASIC Circuit Design Methology Group
> Dallas, Texas
> 214-480-4455
> bpatton dal asp ti com
> =========+=========+=========+=========+=========+=========+=========+
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]