Re: Canvas basics



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Arnaldo de Moraes Pereira <egghunt gmail com> writes:

I've been looking at George Lebl's "Piskvorky" canvas tutorial.
(ftp://ftp.5z.com/pub/unix/gnome-piskvorky-1.tar.gz)  After
tweaking the Makefile to use pkg-config, this built fine with
GTK+ 2.4/GNOME 2.8.  However, I did find a problem: if I resize the
window, the canvas viewable area becomes centred in the canvas widget,
but the coordinates of button presses are still relative to the top left
corner of the canvas widget, rather than the canvas view itself.  How
should I compensate for this in the code?  Or is this a canvas bug,
since the events are outside the drawable area?

  Are you talking about canvas or world coordinates ? Canvas
coordinates are relative to the item's parent position, so if the
parent of the button you're clicking is at the top left corder, the
behavior you described is right.

I'm not sure--I'll need to check the code some more.

What I really want to do with the canvas is create a grid display
system, similar to Gnumeric, but probably much simpler.  What I want to
do is achieve the same scroll behaviour as Gnumeric: the row and column
labels scroll with the canvas, and scrolling is in discrete steps.  How
should I do this.  I thought of two possible methods:
- packing four canvas widgets into viewports in a GtkTable and tying
  their adjustments to the same scrollbars.
- overlaying the row/column headings on top of the canvas relative to
  the scroll position.
How does Gnumeric do this?  I had a look, but couldn't find the relevant
source files.

  I don't know if I understood, but you could put the row and column
labels and the canvas into a scrolledwindow.

Sorry; I'll try to explain a little more clearly.

Gnumeric displays a grid of cells in the canvas; the canvas itself is
in a ScrolledWindow.  The column and row labels (A-Z and 0-nnnn) are
also in the canvas, but these don't scroll with the rest of the sheet;
they stay fixed along the top and left edges.  If they behaved like
the other canvas items, they would scroll off the top so you couldn't
see them, so they are always visible.  I'd like to mimic this with the
headings on my canvas, but I don't know how Gnumeric achieves this.


I've started to cook up an example to demonstrate what I'm doing.
It's here: http://www.whinlatter.ukfsn.org/gtk/cse-0.1.1.tar.gz
Unfortunately, it crashes when constructing my canvas.  Is it not
possible to use it until it's realised, or am I so tired I'm doing
something really stupid?!  (I'm deriving a CseCanvas from GnomeCanvas,
but the segfault is in my object_init function where I call
gnome_canvas_set_scroll_region().)


Many thanks,
Roger

- -- 
Roger Leigh
                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                Debian GNU/Linux        http://www.debian.org/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>

iD8DBQFByg6OVcFcaSW/uEgRAgrPAKCp1Omid1M5cdvRSRkjFvIOubSCYwCg2uCw
guos4sX4Nzp3hTMMLeUFCWo=
=3uyU
-----END PGP SIGNATURE-----



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