mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 11:30:06 +01:00
Cleanup Cairo Demos - They work fine.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@74397 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -23,13 +23,11 @@ class TestPanel(wx.Panel):
|
||||
|
||||
|
||||
def OnPaint(self, evt):
|
||||
if self.IsDoubleBuffered():
|
||||
dc = wx.PaintDC(self)
|
||||
else:
|
||||
dc = wx.BufferedPaintDC(self)
|
||||
dc.SetBackground(wx.Brush('white'))
|
||||
#dc = wx.PaintDC(self)
|
||||
dc = wx.BufferedPaintDC(self)
|
||||
dc.SetBackground(wx.WHITE_BRUSH)
|
||||
dc.Clear()
|
||||
|
||||
|
||||
self.Render(dc)
|
||||
|
||||
|
||||
@@ -42,7 +40,7 @@ class TestPanel(wx.Panel):
|
||||
x += 20
|
||||
y += 20
|
||||
dc.DrawLine(x, 0, 0, y)
|
||||
|
||||
|
||||
# now draw something with cairo
|
||||
ctx = wx.lib.wxcairo.ContextFromDC(dc)
|
||||
ctx.set_line_width(15)
|
||||
@@ -71,7 +69,7 @@ class TestPanel(wx.Panel):
|
||||
|
||||
# Draw some text
|
||||
face = wx.lib.wxcairo.FontFaceFromFont(
|
||||
wx.FFont(10, wx.SWISS, wx.FONTFLAG_BOLD))
|
||||
wx.FFont(10, wx.FONTFAMILY_SWISS, wx.FONTFLAG_BOLD))
|
||||
ctx.set_font_face(face)
|
||||
ctx.set_font_size(60)
|
||||
ctx.move_to(360, 180)
|
||||
@@ -113,15 +111,15 @@ class TestPanel(wx.Panel):
|
||||
bmp = wx.Bitmap(opj('bitmaps/toucan.png'))
|
||||
#bmp = wx.Bitmap(opj('bitmaps/splash.png'))
|
||||
img = wx.lib.wxcairo.ImageSurfaceFromBitmap(bmp)
|
||||
|
||||
|
||||
ctx.set_source_surface(img, 70, 230)
|
||||
ctx.paint()
|
||||
|
||||
# this is how to convert an image surface to a wx.Bitmap
|
||||
bmp2 = wx.lib.wxcairo.BitmapFromImageSurface(img)
|
||||
dc.DrawBitmap(bmp2, 280, 300)
|
||||
|
||||
|
||||
|
||||
|
||||
def warpPath(self, ctx, tw, th, dx, dy):
|
||||
def f(x, y):
|
||||
xn = x - tw/2
|
||||
@@ -148,7 +146,7 @@ class TestPanel(wx.Panel):
|
||||
|
||||
elif type == cairo.PATH_CLOSE_PATH:
|
||||
ctx.close_path()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if not haveCairo:
|
||||
@@ -159,7 +157,7 @@ if not haveCairo:
|
||||
'Sorry', wx.ICON_WARNING)
|
||||
return win
|
||||
else:
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
|
||||
@@ -25,7 +25,7 @@ class DisplayPanel(wx.Panel):
|
||||
|
||||
def OnPaint(self, evt):
|
||||
dc = wx.PaintDC(self)
|
||||
|
||||
|
||||
if self.curr_snippet:
|
||||
width, height = self.GetClientSize()
|
||||
cr = wx.lib.wxcairo.ContextFromDC(dc)
|
||||
@@ -36,7 +36,7 @@ class DisplayPanel(wx.Panel):
|
||||
self.curr_snippet = text
|
||||
self.Refresh()
|
||||
|
||||
|
||||
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
@@ -47,7 +47,7 @@ class TestPanel(wx.Panel):
|
||||
self.canvas = DisplayPanel(self)
|
||||
self.editor = DemoCodeEditor(self, style=wx.BORDER_SIMPLE)
|
||||
self.editor.SetEditable(False)
|
||||
|
||||
|
||||
self.Bind(wx.EVT_LISTBOX, self.OnListBoxSelect, self.lb)
|
||||
|
||||
sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
@@ -62,14 +62,14 @@ class TestPanel(wx.Panel):
|
||||
border.Add(sizer, 1, wx.EXPAND|wx.ALL, 30)
|
||||
self.SetSizer(border)
|
||||
|
||||
|
||||
|
||||
def OnListBoxSelect(self, evt):
|
||||
snippet_file = opj('snippets/%s.py' % evt.GetString())
|
||||
text = file(snippet_file).read()
|
||||
self.canvas.SetSnippet(text)
|
||||
self.editor.SetValue(text)
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
if not haveCairo:
|
||||
@@ -77,10 +77,10 @@ if not haveCairo:
|
||||
def runTest(frame, nb, log):
|
||||
win = MessagePanel(nb, 'This demo requires the Pycairo package,\n'
|
||||
'or there is some other unmet dependency.',
|
||||
'Sorry', wx.ICON_WARNING)
|
||||
'Sorry', wx.ICON_WARNING)
|
||||
return win
|
||||
else:
|
||||
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
@@ -93,7 +93,7 @@ if haveCairo:
|
||||
else:
|
||||
extra = '\n<p>See the docstring in the wx.lib.wxcairo module for details about installing dependencies.'
|
||||
|
||||
|
||||
|
||||
overview = """<html><body>
|
||||
<h2><center>Cairo Integration</center></h2>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user