Re: Grid Based Canvas

Why don't you just draw a grid with lines on the canvas, and then whenever
you "select" a square you create a canvas rectangle item and put it in the
grid between the grid lines? When you unselect, you just destroy the canvas
item. You will still need 20000 items, which might still be too much...

Another approach which uses a lot less memory but requires more work on your
part is to use my GtkImageViewer widget which is a hybrid between an image
viewer and a canvas. (In spite of its name it does not necessarily display
images). The widget handles zooming, but you have to redraw the contents
yourself on exposure events. See:


On Tue, May 25, 2010 at 22:02, Asad Jibran Ahmed <surfer a1 gmail com>wrote:

On Mon, 2010-05-24 at 23:21 -0400, Liam R E Quin wrote:
On Tue, 2010-05-25 at 05:04 +0500, Asad Jibran Ahmed wrote:

The canvas will have grids, much like a graph paper. Whenever
the user clicks on one of the grid squares, that square will become
selected and the selection will be shown by highlighting the square.

It sounds like you really have a grid of squares, even if the user
doesn't think of it that way.

I think all of the canvas APIs support scrolling and zooming.

Or take a peek at e.g. the minesweeper game?


 Thanks for the info. I checked out the crcanvas widget and I think that
it may just be what I need. I do however have one issue with the square
approach that you have suggested.

The grid I am trying to make needs to be quite large (10000x10000), and
the memory requirements of keeping track of this large a number of
rectangles is very problematic.

Any advice on how to proceed from here? Again, thanks for your earlier

JB ::

gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

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