views:

337

answers:

1

Hey,

I am drawing inside a wx.Window using a PaintDC. I am drawing circles and stuff like that into that window. Problem is, sometimes the circles go outside the scope of the window. I want a scrollbar to automatically appear whenever the drawing gets too big. What do I do?

+1  A: 

Use a wx.ScrolledWindow and set the size of the window as soon as your 'drawing go outside' the window with

SetVirtualSize(width,height)

If this size is bigger than the client size, then wx will show scrollbars. When drawing in the window make sure to use CalcUnscrolledPosition and CalcScrolledPosition

Here you can find some more information.

RSabet
I didn't fully understand. Do I need to calculate on my own how much width and height the drawings take? Because I don't understand how to get the "width" and "height" inputs for SetVirtualSize.
cool-RR
If your circle is 10 pixel wider than your screen, then add 10 to the current client size and you have the new width.
RSabet
Sorry, I don't understand yet. Assume I draw all kinds of different things into that DC. Is it my responsibility to keep track of how much space my drawing takes?
cool-RR