method to erase a drawing area



Hi,

I have a drawing area, and a window with 2 gtk_range, and them
variable form 1 to 10, and this values go to posH and posV. I'm doing
this to can draw a rectangular with my specification.. max width: 10,
min: 1, max henght:10, min: 1.

This event is called when drawing area is clicked:

static gboolean button_pressed (GtkWidget *a, GdkEventButton *event)
{
    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("\ndrawing 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));
}

But now I must do a eraser function... I do a simple for:
gint x1, x = event->x, y = event->y;

for (x1 = 0; x1 < desenho->parray->len; x1 = x1 + 4)
        {
            if((GPOINTER_TO_INT(desenho->parray->pdata[x1]) == x) &&
(GPOINTER_TO_INT(desenho->parray->pdata[x1+1]) == y))
            {   g_print("\nta no lugar certo mano!");
                g_ptr_array_remove_index(desenho->parray, x1);
                g_ptr_array_remove_index(desenho->parray, x1);
                g_ptr_array_remove_index(desenho->parray, x1);
                g_ptr_array_remove_index(desenho->parray, x1);
            }


 it's work, but not fine... it's only work when i click exactly where
I clicked before to draw this point... but I need to delete from
GPtrArray when I click on somewhere of this rectangle area... not only
center... Can help me list?



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