Hi All,
Well I’ve been up all night trying to sort this out. I’m still experimenting with the DragImage demo. Could someone tell me am I going about this the wrong way?
I am displaying a background ‘paper’ on which to apply text to. The ‘paper’ is just an A4 sized draggable bmp.
bmp = wx.Bitmap("Paper.BMP", wx.BITMAP_TYPE_ANY)
shape1 = DragShape(bmp)
shape1.pos = (125, 55)
shape1.fullscreen = False
self.shapes.append(shape1)
To this I have appended some text and everything seems to work fine - paper drags with text attached. The problem is of course that the text is attached to the default upper left hand corner of the bitmap.
words = ['a','b','c','d','a','b','c','d','a','b','c','d']
text = " "+"".join(words)
bg_colour = wx.Colour(57, 115, 57) # matches the bg image
font = wx.Font(36, wx.MODERN, wx.NORMAL, wx.NORMAL, 0, "Arial")
textExtent = self.GetFullTextExtent(text, font)
# create a bitmap the same size as our text
bmp1 = wx.EmptyBitmap(textExtent[0], textExtent[1])
# 'draw' the text onto the bitmap
dc = wx.MemoryDC()
dc.SelectObject(bmp)
#dc.SetBackground(wx.Brush(bg_colour, wx.SOLID))
#dc.Clear()
dc.SetTextForeground(wx.BLACK)
dc.SetFont(font)
dc.DrawText(text, 0, 0)
dc.SelectObject(wx.NullBitmap)
mask = wx.Mask(bmp, bg_colour)
bmp1.SetMask(mask)
shape = DragShape(bmp1)
shape.pos = (145, 100)
self.shape1.append(shape)
Could someone show / tell me how I go about controlling the co-ordinates for the text so that they are no longer global but refer to the paper?
Thanks,
Malcolm