Re: GnomeCanvas



        I dont know about gnomecanvas
but if you want to use the drawing area;
you'll have to implement a couple of
signal handlers (I think its "expose" and
"configure" that you need). you might also
need to call gdk_add_events(...event_mask...)
on your instance.

This is quite simple because there are a few
examples of theese (to say the least) in the
gtk source.

essentially afterwards you'll need to use
gtk_widget_set_size_request, (resulting
in your handlers getting called in the 
next mainloop iteration) and then you 
should have a new size of drawing area.

ofcourse you can use the usual
gdk_pixbuf_scale_simple to scale
what you want to "draw" to the 
newly sized widget.


Cheers,
                -Tristan

NOTE:
        Theese signal handlers are
treated as class methods. the most
consistant way to do it would be
to inherit from GtkDrawingArea
and polymorph

class->configure = my_configure;

seeing as that way you get your
handler in as the base class handler.

        I'm not even sure if the 
signals will be emmited to "user"
handlers if the "class" handlers
dont exist.
i.e. the GtkWidgetClass is basicly 
a briefcase of declared but untreated
signals.





Chris Garrett wrote:

Hi,

I am coding a program using GTK2.0.  Up until now, I have been using a
GtkDrawingArea, with a pixbuf on it.

I am considering changing to the use of a GnomeCanvas, since it appears to
allow relatively easy scaling.  I have the API reference, but it does not
really explain how the whole thing hangs together.  Can I do the following?

1. Display a GdkPixbuf on a GnomeCanvas, whilst still retaining the ability
to poke directly at the pixel data within the pixbuf.

2. Zoom the canvas with gnome_canvas_set_pixels_per_unit(), and see the
pixbuf on the canvas scale as a result (This would simply scale the rendered
view of the pixbuf.  The pixbuf data itself would be unchanged)

I would also like to know how to actually add a pixbuf to the gnomecanvas in
the first place.  For instance, do I have to use a GnomeCanvasGroup? Is
there a code sample I can look at or a tutorial for the GTK2.0 GnomeCanvas I
can follow?  The scribble app in the GTK tutorial uses the drawing area.

Alternatively, if anyone can tell me how to scale a drawingarea and its
contents I can stick with my current code base.  I cant see anything about
this in the drawingarea documentation.

Best regards,

Chris.

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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