Mimic push and pop in dc drawing

I am trying to mimic push and pop statements while drawing in dc mode.
The attach file is a demo app for the problem.

1. Run file.
2. Use mouse wheel to zoom in or out.
3. Squares are getting scaled and maintaining their positions.

Now change line:
self.GcDraw(dc)

in class BufferedWindow's "UpdateDrawing" function to:
self.DcDraw(dc)

Run the app again and you can see that squares are getting scaled
related to their top-left coordinates.
I tried various ways (lines are commented) but I am not able to get
the correct behavior as GcDraw function.

If I use:
dc.DrawRectangle(self.itemx1, self.itemy1, 50, 50)

then things are fine but this is not what I am looking for. The draw
operation should be from absolute (0,0).

Prashant
Python 2.6.2
wxPython 2.8.10.1
XP 32

double_buffer_dc_test.py (7.25 KB)

My guess is that SetDeviceOrigin is simply not calculating the position using the user scale setting. You can probably get it to do what you want by doing that calculation yourself and using the result with SetDeviceOrigin.

···

On 1/11/10 8:37 AM, Prashant Saxena wrote:

I am trying to mimic push and pop statements while drawing in dc mode.
The attach file is a demo app for the problem.

1. Run file.
2. Use mouse wheel to zoom in or out.
3. Squares are getting scaled and maintaining their positions.

Now change line:
self.GcDraw(dc)

in class BufferedWindow's "UpdateDrawing" function to:
self.DcDraw(dc)

Run the app again and you can see that squares are getting scaled
related to their top-left coordinates.
I tried various ways (lines are commented) but I am not able to get
the correct behavior as GcDraw function.

--
Robin Dunn
Software Craftsman