Re: custom_widget example not working



On Wed, Dec 01, 2004 at 12:57:20 +0000, simon bath ac uk wrote:
> * Immanuel Scheerer (scheerei in tum de) wrote:
> > More precisely I want to create a SDL widget. So i have to draw it 
> myself.
> >
> > Thanks for your answer, Murray.
> 
> I asked about creating a gtkmmsdl widget not so long ago, so I thought I 
> would post you my attempt. Its available at 
> http://www.bath.ac.uk/~ma2snm/gtksdl_example/ and it does what I want it 
> to do. The widget should be fairly easy to use, and also works on 
> windows. You have to create a timeout signal to draw to the surface 
> every so often, as otherwise the sdl surface gets drawn over by gtk (how
>  I understand it anyway). Something like this is fine,
>  
> Glib::signal_timeout().connect(sigc::mem_fun(*this, 
> &MainWindow::renderView),100 );

This feels wrong. I don't know SDL enough, but I don't think it might
need anything like this.

Basicaly Gtk will not overdraw anything on it's own. Your widget is
responsible for drawing itself and Gtk honours that.

The X server does not keep the data though. So if the widget get's
covered by something else, moved and such, it must be repainted. Gtk
will tell that repainting will be necessary by emiting a "expose-event"
signal on the object. I believe the default handler will emit a "draw"
signal from there or something like that -- look at code for some
existing widget. That's were you have to redraw.

Another point where you have to redraw is when the image changes. There
is something like queue_redraw method or somesuch, that should end up
generating "expose-event" or "draw" signal. Have a look at the code for
the details. You want to use it for redraw.

> with renderView drawing directly to the sdl surface. To allow the 
> capture of events to be compatible with both windows and nix, and 
> handled by gtkmm, put the widget in an eventbox. I think thats 
> everything. Any questions, mail me, as well as any improvements / 
> suggestions.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb ucw cz>

Attachment: signature.asc
Description: Digital signature



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