Hello,
I'm using wx.lib.graphics.GraphicsContext whith cairo surfaces for a new project and found some issues:
1. DrawBitpap not use the correct x,y position:
DrawBitmap() scale the context to adjust the image to the width and height received, but set the x,y position after scale, then the x,y coords are also modified in the context.
Graphics.py:
def DrawBitmap(self, bmp, x, y, w=-1, h=-1):
...
self._context.scale(scaleX, scaleY)
self._context.translate(x, y)
...
The problem is solved putting translate before rescale:
...
# Set position before scale
self._context.translate(x, y)
self._context.scale(scaleX, scaleY)
...
2. PushState & PopState don't save/restore Pen, Brush and Font.
If you PushState(), set a Font/Brush/Pen, draw anything and then PopState(), those objects are not restored.
GraphicsContext do not apply them when you do SetPen/SetBrush/SetFont. GraphicsContext save it on internal vars and apply them when execute a draw operation.
if you:
SetFont(...."Arial")
PushState()
SetFont(...."Times New Roman")
DrawText("Text with Times new Roman")
PopState()
and then
DrawText("Text")
PopState must restore the Font previous at PushState, but do not it. The las text is printed with Times New Roman because DrawText() instead use the current surface font, apply the last font used and saved in a GraphicsContext var.
In this case the solution is more complex because affects to all Draw... functions.
wx version: '2.8.12.1 (msw-unicode)'
Sorry for my bad english.
Should I open bugs?
···
--
Oswaldo