Skip to content

Commit 49d4e66

Browse files
RDRD
authored andcommitted
Merge r55721 from 2.8 branch
git-svn-id: http://svn.wxwidgets.org/svn/wx/wxPython@55723 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
1 parent 8736df6 commit 49d4e66

4 files changed

Lines changed: 248 additions & 26 deletions

File tree

trunk/docs/CHANGES.txt

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,30 @@ cairo.ImageSurface objects. In order to use this module you will need
150150
to have the Cairo library and its dependencies installed, as well as
151151
the pycairo Python package. For Linux and other unix-like systems you
152152
most likely have what you need installed already, or can easily do so
153-
from your package manager application. See the wx.lib.wxcairo module's
154-
docstring for notes on where to get what you need for Windows or Mac.
155-
This module uses ctypes, and depending on platform it may need to find
156-
and load additional dynamic libraries at runtime in addition to cairo.
157-
153+
from your package manager application. See the wx.lib.wxcairo
154+
module's docstring for notes on where to get what you need for Windows
155+
or Mac. This module uses ctypes, and depending on platform it may
156+
need to find and load additional dynamic libraries at runtime in
157+
addition to cairo. The pycairo package used needs to be new enough to
158+
export the CAPI structure in the package namespace. I believe that
159+
started sometime in the 1.4.x release series.
160+
161+
Added the wx.lib.graphics module, which is an implementation of the
162+
wx.GraphicsContext API using Cairo (via wx.lib.wxcairo). This allows
163+
us to be totally consistent across platforms, and also use Cairo to
164+
implement some things that are missing from the GraphicsContext API.
165+
It's not 100% compatible with the GraphicsContext API, but probably
166+
close enough to be able to share code between them if desired, plus it
167+
can do a few things more.
168+
169+
Updated wx.Bitmap.CopyFromBuffer to be a bit more flexible. You can
170+
now specify the format of the buffer, and the CopyFromBufferRGBA is
171+
now just a wrapper around CopyFromBuffer that specifies a different
172+
format than the default. Also added the complement method,
173+
CopyToBuffer. See the docstring for CopyFromBuffer for details on the
174+
currently allowed buffer formats. The existing wx.BitmapFromBuffer
175+
factory functions are also now implemented using the same underlying
176+
code as CopyFromBuffer.
158177

159178

160179

trunk/sandbox/test_cairoContext.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,28 @@ def Render(self, dc):
9797
ctx.Translate(120, 0)
9898
ctx.DrawPath(sqpath)
9999

100+
ctx.SetTransform(ctx.CreateMatrix())
101+
ctx.Translate(10, 250)
102+
ctx.SetFont(wx.FFont(28, wx.SWISS, wx.FONTFLAG_BOLD), 'blue')
103+
ctx.DrawText("Hello", 0,0)
104+
ctx.DrawText("World", 0,35, g.GraphicsBrush('orchid'))
105+
106+
ctx.Translate(125, 0)
107+
ctx.DrawRotatedText("wxPython", 0, 0, math.radians(-30))
108+
ctx.SetFont(wx.FFont(28, wx.ROMAN, wx.FONTFLAG_BOLD))
109+
ctx.DrawRotatedText("& Cairo", 0, 45, math.radians(-30), g.GraphicsBrush('orchid'))
110+
111+
ctx.SetBrush(g.GraphicsBrush((0,128,0,128)))
112+
ctx.FillPath(g.GraphicsPath().AddCircle(0,0,4))
113+
ctx.FillPath(g.GraphicsPath().AddCircle(0,45,4))
114+
115+
ctx.Translate(125, 0)
116+
font = ctx.CreateFont(wx.FFont(40, wx.SWISS, wx.FONTFLAG_BOLD))
117+
gbrush = ctx.CreateLinearGradientBrush(0,0, 100,0, "orchid", "navy")
118+
font.Brush = gbrush
119+
ctx.SetFont(font)
120+
ctx.DrawText("brush", 0,0)
121+
100122

101123

102124
app = wx.App(redirect=False)

trunk/sandbox/test_cairoContext2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def OnPaint(self, evt):
2929
def Render(self, dc):
3030
gc = wx.lib.graphics.GraphicsContext.Create(dc)
3131

32-
## font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
33-
## font.SetWeight(wx.BOLD)
34-
## gc.SetFont(font)
32+
font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
33+
font.SetWeight(wx.BOLD)
34+
gc.SetFont(font)
3535

3636
# make a path that contains a circle and some lines, centered at 0,0
3737
path = gc.CreatePath()
@@ -55,9 +55,9 @@ def Render(self, dc):
5555
for label, PathFunc in [("StrokePath", gc.StrokePath),
5656
("FillPath", gc.FillPath),
5757
("DrawPath", gc.DrawPath)]:
58-
## w, h = gc.GetTextExtent(label)
58+
w, h = gc.GetTextExtent(label)
5959

60-
## gc.DrawText(label, -w/2, -BASE2-h-4)
60+
gc.DrawText(label, -w/2, -BASE2-h-4)
6161
PathFunc(path)
6262
gc.Translate(2*BASE, 0)
6363

0 commit comments

Comments
 (0)