Re: gtk_widget_area - expose_event - problem



Hi,

> Yes, it looks like that ('g' or 'g->pixmap' is/are probably the source

> of your problem). From the sample you've posted it's unclear how you
> allocate and fill a 'typGraphics' structures. You have to do this in
> "configure-event" callback.


Yes, my configure-event make it...

static gint configure_event (GtkWidget *widget, GdkEventConfigure *event,
typGraphics *g)
{
    if (g == NULL) {
        g = NewGraphics ();
    }

    /* --- Free the pixmap --- */
    if (g->pixmap) {
        gdk_pixmap_unref (g->pixmap);
    }

    /* --- Create a new pixmap --- */
    g->pixmap = gdk_pixmap_new (widget->window,
                             widget->allocation.width,
                             widget->allocation.height,
                             -1);

    /* --- if we don't have our pens yet --- */
    if (penBlack == NULL) {

        /* --- Get our colorful pens. --- */
        penBlack = GetPen (NewColor (0, 0, 0),g);
        penRed = GetPen (NewColor (0xffff, 0, 0),g);
        penBlue = GetPen (NewColor (0, 0, 0xffff),g);
        penGreen = GetPen (NewColor (0, 0xffff, 0),g);
        penGray = GetPen (NewColor (0x9000, 0x9000, 0x9000),g);
    }

    /* --- Clear it out --- */
    gdk_draw_rectangle (g->pixmap,
                        widget->style->white_gc,
                        TRUE,
                        0, 0,
                        widget->allocation.width,
                        widget->allocation.height);

    return TRUE;
}

and internal functions used ....

GdkGC *GetPen (GdkColor *c, typGraphics *g)
{
    GdkGC *gc;

    /* --- Create a gc --- */
    gc = gdk_gc_new (g->pixmap);

    /* --- Set the forground to the color --- */
    gdk_gc_set_foreground (gc, c);

    /* --- Return it. --- */
    return (gc);
}


GdkColor *NewColor (long red, long green, long blue)
{
    /* --- Get the color --- */
    GdkColor *c = (GdkColor *) g_malloc (sizeof (GdkColor));

    /* --- Fill it in. --- */
    c->red = red;
    c->green = green;
    c->blue = blue;

    gdk_color_alloc (gdk_colormap_get_system (), c);

    return (c);
}

Thanks
France

__________________________________________________________________
Tiscali ADSL SENZA CANONE:
Attivazione GRATIS, contributo adesione GRATIS, modem GRATIS,
50 ore di navigazione GRATIS.  ABBONARTI TI COSTA SOLO UN CLICK!
http://point.tiscali.it/adsl/index.shtml






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]