Should there be a gtk "canvas" widget?



If you don't mind extrapolating from two data points, the proper use
of a the drawing area widget seems to be a FAQ.  (Alois Camenzind
<camenzind@cyberlink.ch> just asked a question very similar to one I
sent to this list a week or two ago...)

For convenience and perhaps just to shave a tiny bit off of the gtk
learning curve, maybe there should be a "canvas widget" (to borrow a
name from Tk) that derive from a drawing area and add the tricky bits
that are frustrating to newbies, namely:

* Automatically providing an backing pixmap to draw to, handling expose
  and resize events properly.
* Allowing all events through.
* Adding little routines to simplify drawing, setting colors,
  dealing with GCs, fonts, etc., trading off complete flexibility for
  some simplicity.

I'm currently working on a graphing/data visualization program using
gtk--, and the first thing I did was define a Gtk_Canvas widget that
did the above.  Then I can derive Gtk_Plot from it and just write code
like:

	plot.set_foreground("red");
	plot.draw_line(10,10,plot.width()-10,10);

This is makes it easy for a novice (like me) to actually write a program
that does something non-trivial.

Now I'd be more than happy to clean up this (very simple) code and
contribute it to gtk--, but it does raise a philosophical question:
should their be widgets/functionality in gtk-- that doesn't exist in
gtk+?  Or would it be more proper to add define the canvas object in
gtk+ and then just make a C++ wrapper for it?  I would think that the
latter option made more sense --- but that is sufficiently beyond the
scope of my current understanding gtk+ that I couldn't be much help in
such an endeavor...

-Jon Trowbridge
 EMC Capital Management, Inc.



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