[gtkada] Problem with drawing

Michael Gonzalez mgh at unican.es
Thu Nov 29 16:40:03 CET 2001


Emmanuel:

Emmanuel Briot wrote:
> 
> Michael Gonzalez <mgh at unican.es> writes:
> 
> > I have a drawing window for which I wrote a handler for the expose event
> > that copies a pixmap into the window. From my main program I can make
> > changes to the drawing, then re-draw the window using a Queue_Draw
> > operation, and then let GtkAda process the events with the  following
> > loop (suggested in the reference manual):
> >
> >     while Gtk.Main.Events_Pending loop
> >          Dead := Gtk.Main.Main_Iteration;
> >     end loop;
> 
> Why do you need to explicitely use this loop ? The Gtk main loop should do it
> for you ?
> Unless you have a routine that is slow and you need to refresh the screen, the
> above loop shouldn't be needed. And even in that case, it is probably better to
> implement things in an idle callback (see Gtk.Main), and give back the control
> to gtk+ periodically.

The problem is that I am writing a drawing package for first-year
students who do not know about Gtk-Ada. This means that I want them to
keep control of their application, and just invoke the Draw operation
when they want to refresh the drawing.
 
> You could try to return True from your expose_event handler to stop its
> propagation. Maybe what happens is that some other widget receives the event
> and queues a drawing request as well.
> Or try calling Gtk.Handlers.Emit_Stop_By_Name.

I tried, but none worked. For now, I just limited the amount of times
that the loop executes, and the application works. But the limit is
arbitrary, and perhaps there could be more events that would need to be
handled. In addition, the implementation is slow because it always
executes the events up to the limit that I set. Curiously, if I minimize
the window then the events don't queue up.

Best regards,

Michael. 

P.D. By the way, I have published the drawing package together with some
other simple I/O and plotting packages in:

    http://ctrpc17.ctr.unican.es/win_io/

They are really fun and easy to use.

My only concern is with the problem that I have been reporting to the
list.
-----------------------------------------------------------------------
Michael Gonzalez Harbour                      E-mail: mgh at unican.es
Dpto. de Electronica y Computadores
Universidad de Cantabria                      Phone : +34-942-201483
Avda. de los Castros s/n
E-39005 Santander                             Fax   : +34-942-201402
SPAIN
-----------------------------------------------------------------------




More information about the gtkada mailing list