Re: How wide can a widget get ?



On Thu, 9 Dec 2004 03:58:37 +0200, Paul Pogonyshev <pogonyshev gmx net> wrote:
What's the maximum width I can set a widget to ? I end up attempting to
set the width of one of my drawing area widgets to 66327, and it doesn't
seem to want to go that wide. Is there an inherent limit to the width of
a widget ?

There was in gtk+-1.2, but gtk2 (pretty much) removed this. I have
drawing areas in my app which go up to several million pixels in each
axis and gtk scrolls them fine. Memory isn't allocated for invisible
pixels, so there's no limit there either.

You can have problems with a 16 bit coordinate limit on drawing
operations on very large drawing areas: you may need to do some
clipping yourself.

Can you please explain this further?  (Sample code would be especially
helpful.)  Here is one particular example that causes problems:

        gdk_draw_line (window, gc, 20, 20, 20, 40000);

Instead of going downwards, the line goes upwards (seems like X
considers 40000 to be a negative 16-bit number.)

Yes, you've hit the 16 bit coordinate limit (+/- 32k). This will
limitation will vanish at some point in the beautiful cairo future (I
think), but it's very annoying until then.

The solution is to do some clipping yourself before issuing the draw
command. You know the position and size of the viewport, so you need
to draw just the bit of the line that intersects that area.

AFAIK, the 16 bit limit is for the length of the line rather than the
absolute position (thanks to the magic of gdk2 scrolling), so

    gdk_draw_line (window, gc, 20, 35000, 20, 40000);

should work ok (provided your viewport is positioned at 35000 or lower).



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