drawing area and GPtrArray illogical error



static gboolean
expose_event (GtkWidget *a, GdkEventButton *event, GtkDesenho *desenho)
{
    guint i, x, y, tamH, tamV, x1, y1;
    GdkPoint points[5];

    // Loop through the coordinates, redrawing them onto the drawing area.
    for (i = 0; i < desenho->parray->len; i = i + 4)
    {
        x = GPOINTER_TO_INT(desenho->parray->pdata[i]);
        y = GPOINTER_TO_INT(desenho->parray->pdata[i+1]);
        tamH = GPOINTER_TO_INT(desenho->parray->pdata[i+2]);
        tamV = GPOINTER_TO_INT(desenho->parray->pdata[i+3]);
        g_print("\nloading x: %d y: %d tamH: %d tamV: %d",x,y,tamH,tamV);
        for(x1 = (0-tamH); x1 <= tamH; x1++)
        {
            for(y1 = (0-tamV); y1 <= tamV; y1++)
            {
                gdk_draw_point(desenho->drawingArea->window,
desenho->drawingArea->style->fg_gc[GTK_WIDGET_STATE(desenho->drawingArea)],
x+x1, y+y1);
            }
        }
    }

  return TRUE;
}

// Desenha quando o botão do mouse for pressionado, e quando ele
estiver pressionado e se movendo!

static gboolean button_pressed (GtkWidget *a, GdkEventButton *event,
GtkDesenho *desenho)

{

    gint x = event->x, y = event->y, x1, y1;

    for(x1 = (0-posH); x1 < posH; x1++)
    {
        for(y1 = (0-posV); y1 < posV; y1++)
        {
            gdk_draw_point(desenho->drawingArea->window,
desenho->drawingArea->style->fg_gc[GTK_WIDGET_STATE(desenho->drawingArea)],
x+x1, y+y1);
        }
    }

    g_print("\nsaving x: %d y: %d tamH: %d tamV: %d", x, y, posH, posV);

    g_ptr_array_add(desenho->parray, GINT_TO_POINTER(x));
    g_ptr_array_add(desenho->parray, GINT_TO_POINTER(y));
    g_ptr_array_add(desenho->parray, GINT_TO_POINTER(posH));
    g_ptr_array_add(desenho->parray, GINT_TO_POINTER(posV));


    return FALSE;

}

##########

Look at the g_print, they are equals, only the first word changes..

When I click with the mouse on the drawing area the callback
button_pressed is called and the g_print message shows, and when I
move the window the callback expose_event is called and shows its
g_print. The only difference between both g_print is the first word,
in other words, o parray is correct and the points should be drawned
in the drawing area. But that isn't happening.

Does anyone have an idea about it?

Thanks

-- 
Abraço,
Frederico Schardong,
SOLIS - O lado livre da tecnologia
www.solis.coop.br


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