]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/compatdc.py
1 #----------------------------------------------------------------------
3 # Purpose: Make wxPython 2.4 DC classes compatible with the 2.5
10 # Copyright: (c) 2004 by Total Control Software
11 # Licence: wxWindows license
12 #----------------------------------------------------------------------
17 def MakeDCCompatible(klass
, full
=False):
19 Manipulate the DC class passed to this funciton such that it is
20 more compatible with the DC classes used in wxPython 2.5. This
21 should help with writing code that works with both versions. If
22 full is True then in addition to creating the 'XY' versions of the
23 methods, a 'point/size' version (which are the new defaults in
24 2.5) will also be created.
26 if wx
.VERSION
>= (2,5):
27 return # Nothing to do
29 # first create XY methods from the current ones.
30 klass
.FloodFillXY
= klass
.FloodFill
31 klass
.GetPixelXY
= klass
.GetPixel
32 klass
.DrawLineXY
= klass
.DrawLine
33 klass
.CrossHairXY
= klass
.CrossHair
34 klass
.DrawArcXY
= klass
.DrawArc
35 klass
.DrawEllipticArcXY
= klass
.DrawEllipticArc
36 klass
.DrawPointXY
= klass
.DrawPoint
37 klass
.DrawRectangleXY
= klass
.DrawRectangle
38 klass
.DrawRoundedRectangleXY
= klass
.DrawRoundedRectangle
39 klass
.DrawCircleXY
= klass
.DrawCircle
40 klass
.DrawEllipseXY
= klass
.DrawEllipse
41 klass
.DrawIconXY
= klass
.DrawIcon
42 klass
.DrawBitmapXY
= klass
.DrawBitmap
43 klass
.DrawTextXY
= klass
.DrawText
44 klass
.DrawRotatedTextXY
= klass
.DrawRotatedText
45 klass
.BlitXY
= klass
.Blit
47 # now, make some functions that we can use as new methods
49 def FloodFill(self
, pt
, col
, style
=wx
.FLOOD_SURFACE
):
51 return self
.FloodFillXY(pt
.x
, pt
.y
, col
, style
)
52 klass
.FloodFill
= FloodFill
54 def GetPixel(self
, pt
):
56 return self
.GetPixelXY(pt
.x
, pt
.y
)
57 klass
.GetPixel
= GetPixel
59 def DrawLine(self
, pt1
, pt2
):
62 return self
.DrawLineXY(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
)
63 klass
.DrawLine
= DrawLine
65 def CrossHair(self
, pt
):
67 return self
.CrossHairXY(pt
.x
, pt
.y
)
68 klass
.CrossHair
= CrossHair
70 def DrawArc(self
, pt1
, pt2
, centre
):
73 return self
.DrawArcXY(pt1
.x
, pt1
.y
, pt2
.x
, pt2
.y
, centre
.x
, centre
.y
)
74 klass
.DrawArc
= DrawArc
76 def DrawEllipticArc(self
, pt
, sz
, sa
, ea
):
79 return self
.DrawEllipticArcXY(pt
.x
, pt
.y
, sz
.width
, sz
.height
, sa
, ea
)
80 klass
.DrawEllipticArc
= DrawEllipticArc
82 def DrawPoint(self
, pt
):
84 return self
.DrawPointXY(pt
.x
, pt
.y
)
85 klass
.DrawPoint
= DrawPoint
87 def DrawRectangle(self
, pt
, sz
):
90 return self
.DrawRectangleXY(pt
.x
, pt
.y
, sz
.width
, sz
.height
)
91 klass
.DrawRectangle
= DrawRectangle
93 def DrawRoundedRectangle(self
, pt
, sz
, radius
):
96 return self
.DrawRoundedRectangleXY(pt
.x
, pt
.y
, sz
.width
, sz
.height
, radius
)
97 klass
.DrawRoundedRectangle
= DrawRoundedRectangle
99 def DrawCircle(self
, pt
, radius
):
101 return self
.DrawCircleXY(pt
.x
, pt
.y
, radius
)
102 klass
.DrawCircle
= DrawCircle
104 def DrawEllipse(self
, pt
, sz
):
107 return self
.DrawEllipseXY(pt
.x
, pt
.y
, sz
.width
, sz
.height
)
108 klass
.DrawEllipse
= DrawEllipse
110 def DrawIcon(self
, icon
, pt
):
112 return self
.DrawIconXY(icon
, pt
.x
, pt
.y
)
113 klass
.DrawIcon
= DrawIcon
115 def DrawBitmap(self
, bmp
, pt
):
117 return self
.DrawBitmapXY(bmp
, pt
.x
, pt
.y
)
118 klass
.DrawBitmap
= DrawBitmap
120 def DrawText(self
, text
, pt
):
122 return self
.DrawTextXY(text
, pt
.x
, pt
.y
)
123 klass
.DrawText
= DrawText
125 def DrawRotatedText(self
, text
, pt
, angle
):
127 return self
.DrawRotatedTextXY(text
, pt
.x
, pt
.y
, angle
)
128 klass
.DrawRotatedText
= DrawRotatedText
130 def Blit(self
, destPt
, sz
, source
, srcPt
,
131 rop
=wx
.COPY
, useMask
=False, srcPtMask
=wx
.DefaultPosition
):
132 return self
.BlitXY(destPt
.x
, destPt
.y
, sz
.width
, sz
.height
,
133 source
, srcPt
.x
, srcPt
.y
, rop
, useMask
,
134 srcPtMask
.x
, srcPtMask
.y
)
138 def MakeAllDCsCompatible(full
=False):
140 Run MakeDCCompatible on all DC classes in wx.
142 MakeDCCompatible(wx
.BufferedPaintDC
, full
)
143 MakeDCCompatible(wx
.BufferedDC
, full
)
144 MakeDCCompatible(wx
.MemoryDC
, full
)
145 MakeDCCompatible(wx
.ScreenDC
, full
)
146 MakeDCCompatible(wx
.ClientDC
, full
)
147 MakeDCCompatible(wx
.PaintDC
, full
)
148 MakeDCCompatible(wx
.WindowDC
, full
)
149 MakeDCCompatible(wx
.PostScriptDC
, full
)
150 if hasattr(wx
, "MetaFileDC"):
151 MakeDCCompatible(wx
.MetaFileDC
, full
)
152 if hasattr(wx
, "PrinterDC"):
153 MakeDCCompatible(wx
.PrinterDC
, full
)
154 MakeDCCompatible(wx
.DC
, full
)