Hi,
I tried to do it on the target DC but i’m not sure it’s the correct one (i put it under the OnPaint handler):
def OnPaint(self, event):
# Create a buffered paint DC. It will create the real
# wx.PaintDC and then blit the bitmap to it when dc is
# deleted.
dc = wx.BufferedPaintDC(self)
dc.Clear()
self.PrepareDC(dc)
bg = wx.Brush(self.GetBackgroundColour())
dc.SetBackground(bg)
dc.SetUserScale(2,1)
#dc.Clear()
# create a clipping rect from our position and size
# and the Update Region
xv, yv = self.GetViewStart()
dx, dy = self.GetScrollPixelsPerUnit()
x, y = (xv * dx, yv * dy)
rgn = self.GetUpdateRegion()
rgn.Offset(x,y)
r = rgn.GetBox()
# draw to the dc using the calculated clipping rect
self.pdc.DrawToDCClipped(dc,r)
as for ClearId and re-draw, the Pseudo example overview states:
To re-draw an object use:
ClearId(id)
SetId(id)
and then re-draw the object.
and this is what i did (again, i am not sure that i do the redraw correct):
def OnMouse(self, event):
global hitradius
if event.LeftDown():
x,y = self.ConvertEventCoords(event)
l = self.pdc.FindObjectsByBBox(x, y)
for id in l:
if not self.pdc.GetIdGreyedOut(id):
r = self.pdc.GetIdBounds(id)
x,y,w,h = r.Get()
self.buffer = wx.EmptyBitmap(w, h)
self.pdc.ClearId(id)
self.pdc.SetId(id)
dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
dc.Clear()
self.PrepareDC(dc)
self.pdc.DrawIdToDC(id, dc)
self.dragid = id
self.lastpos = (event.GetX(),event.GetY())
break
can you tell the problem ?
Thanks,
Roy
···
On Tue, Aug 12, 2008 at 8:44 PM, Robin Dunn robin@alldunn.com wrote:
roy zinn wrote:
Hi Chris, Robin,
As for float canvas, i’m still facing some problems with the coordinates system which is very important for my app, so i’m checking new ways (but maybe i’ll come back)
As for SetUserScale, well, wx.PseudoDC don’t have this attribute. What is the big benefit of the PseudoDC ? i started to use it because of the example in the wx docs and demos and it went well till that point.
Try using it on the target DC before you play back the operations of the PseudoDC to it.
speaking of the example, when i choose one of the items, it’s sometimes on top of other items and sometime behind, is there a way to bring it to the top once selected?
PseudoDC doesn’t provide a way to reorder the items in its list of operations. I think the best you can do is use ClearId to remove all items associated with the ID, and then draw them again so they end up at the end of the list.
–
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users