Reverted to old method names/signatures for wx.DC, updated lib and
demo to match. Also fixed some deprecation warnings. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27049 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -103,11 +103,17 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
|
||||
self.currentTime=None
|
||||
|
||||
size = wx.Size(*size)
|
||||
bestSize = self.GetBestSize()
|
||||
size.x = max(size.x, bestSize.x)
|
||||
size.y = max(size.y, bestSize.y)
|
||||
self.SetSize(size)
|
||||
|
||||
# Make an initial bitmap for the face, it will be updated and
|
||||
# painted at the first EVT_SIZE event.
|
||||
W, H = size
|
||||
self.faceBitmap = wx.EmptyBitmap(max(W,1), max(H,1))
|
||||
|
||||
|
||||
# Set event handlers...
|
||||
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: None)
|
||||
@@ -117,18 +123,20 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
self.Bind(wx.EVT_RIGHT_DOWN, self.OnRightDown)
|
||||
self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)
|
||||
|
||||
|
||||
# Initialize the timer that drives the update of the clock
|
||||
# face. Update every half second to ensure that there is at
|
||||
# least one true update during each realtime second.
|
||||
self.timer = wx.Timer(self)
|
||||
self.timer.Start(500)
|
||||
|
||||
|
||||
def DoGetBestSize(self):
|
||||
return wx.Size(25,25)
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
self._doDrawHands(wx.BufferedPaintDC(self), True)
|
||||
dc = wx.BufferedPaintDC(self)
|
||||
self._doDrawHands(dc, True)
|
||||
|
||||
|
||||
def OnTimerExpire(self, event):
|
||||
@@ -187,6 +195,9 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
# The faceBitmap init is done here, to make sure the buffer is always
|
||||
# the same size as the Window
|
||||
size = self.GetClientSize()
|
||||
if size.x < 1 or size.y < 1:
|
||||
return
|
||||
|
||||
self.faceBitmap = wx.EmptyBitmap(size.width, size.height)
|
||||
|
||||
# Update drawing coordinates...
|
||||
@@ -221,7 +232,7 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
hour, minutes, seconds = currentTime
|
||||
|
||||
# Start by drawing the face bitmap
|
||||
drawDC.DrawBitmap(self.faceBitmap, (0,0))
|
||||
drawDC.DrawBitmap(self.faceBitmap, 0,0)
|
||||
|
||||
|
||||
# NOTE: All this hand drawing code below should be refactored into a helper function.
|
||||
@@ -240,10 +251,10 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
drawDC.SetPen(wx.Pen(self.shadowPenColour,
|
||||
int(self.handHoursThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX + self.shadowDistance),
|
||||
int(self.centerY + self.shadowDistance),
|
||||
int(x + self.shadowDistance),
|
||||
int(y + self.shadowDistance))
|
||||
drawDC.DrawLine(self.centerX + self.shadowDistance,
|
||||
self.centerY + self.shadowDistance,
|
||||
x + self.shadowDistance,
|
||||
y + self.shadowDistance)
|
||||
|
||||
# Draw minutes hand shadow
|
||||
angle = minutes * 6
|
||||
@@ -253,10 +264,10 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
drawDC.SetPen(wx.Pen(self.shadowPenColour,
|
||||
int(self.handMinutesThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX + self.shadowDistance),
|
||||
int(self.centerY + self.shadowDistance),
|
||||
int(x + self.shadowDistance),
|
||||
int(y + self.shadowDistance))
|
||||
drawDC.DrawLine(self.centerX + self.shadowDistance,
|
||||
self.centerY + self.shadowDistance,
|
||||
x + self.shadowDistance,
|
||||
y + self.shadowDistance)
|
||||
|
||||
# Draw seconds hand shadow if required
|
||||
if seconds >= 0:
|
||||
@@ -267,10 +278,10 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
drawDC.SetPen(wx.Pen(self.shadowPenColour,
|
||||
int(self.handSecondsThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX + self.shadowDistance),
|
||||
int(self.centerY + self.shadowDistance),
|
||||
int(x + self.shadowDistance),
|
||||
int(y + self.shadowDistance))
|
||||
drawDC.DrawLine(self.centerX + self.shadowDistance,
|
||||
self.centerY + self.shadowDistance,
|
||||
x + self.shadowDistance,
|
||||
y + self.shadowDistance)
|
||||
|
||||
|
||||
# Draw hours hand
|
||||
@@ -285,7 +296,7 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
drawDC.SetPen(wx.Pen(self.handHoursColour,
|
||||
int(self.handHoursThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX), int(self.centerY), int(x), int(y))
|
||||
drawDC.DrawLine(self.centerX, self.centerY, x, y)
|
||||
|
||||
# Draw minutes hand
|
||||
angle = minutes * 6
|
||||
@@ -295,7 +306,7 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
drawDC.SetPen(wx.Pen(self.handMinutesColour,
|
||||
int(self.handMinutesThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX), int(self.centerY), int(x), int(y))
|
||||
drawDC.DrawLine(self.centerX, self.centerY, x, y)
|
||||
|
||||
# Draw seconds hand if required
|
||||
if seconds >= 0:
|
||||
@@ -305,7 +316,7 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
drawDC.SetPen(wx.Pen(self.handSecondsColour,
|
||||
int(self.handSecondsThickness * self.scale),
|
||||
wx.SOLID))
|
||||
drawDC.DrawLineXY(int(self.centerX), int(self.centerY), int(x), int(y))
|
||||
drawDC.DrawLine(self.centerX, self.centerY, x, y)
|
||||
|
||||
|
||||
|
||||
@@ -371,11 +382,11 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
|
||||
if style & TICKS_CIRCLE:
|
||||
x, y = self._center2corner(x, y, tipo)
|
||||
drawDC.DrawEllipse((x, y), (int(size), int(size)))
|
||||
drawDC.DrawEllipse(x, y, size, size)
|
||||
|
||||
elif style & TICKS_SQUARE:
|
||||
x, y = self._center2corner(x, y, tipo)
|
||||
drawDC.DrawRectangle((x, y), (int(size), int(size)))
|
||||
drawDC.DrawRectangle(x, y, size, size)
|
||||
|
||||
elif (style & TICKS_DECIMAL) or (style & TICKS_ROMAN):
|
||||
self._draw_rotate_text(drawDC, x, y, tipo, angle)
|
||||
@@ -398,12 +409,12 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
y = int(y -
|
||||
((math.cos((angle) * radiansPerDegree)*lY) -
|
||||
(math.sin((angle) * radiansPerDegree)*lX)))
|
||||
drawDC.DrawRotatedText(text, (x,y), angle)
|
||||
drawDC.DrawRotatedText(text, x,y, angle)
|
||||
|
||||
else:
|
||||
x = x - lX
|
||||
y = y - lY
|
||||
drawDC.DrawText(text, (x, y))
|
||||
drawDC.DrawText(text, x, y)
|
||||
|
||||
|
||||
def _draw_rotate_polygon(self, drawDC, x, y, tipo, angle):
|
||||
@@ -527,7 +538,7 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
drawDC.SetBrush(self.watchBrush)
|
||||
else:
|
||||
drawDC.SetBrush(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
|
||||
drawDC.DrawCircle((self.centerX, self.centerY), self.radius_watch)
|
||||
drawDC.DrawCircle(self.centerX, self.centerY, self.radius_watch)
|
||||
|
||||
|
||||
def _calcSteps(self):
|
||||
@@ -574,7 +585,7 @@ class AnalogClockWindow(wx.PyWindow):
|
||||
f=False
|
||||
coords["ticks_minutes"][3][i][2]=f
|
||||
|
||||
self.coords=coords
|
||||
self.coords = coords
|
||||
|
||||
|
||||
def _getCoords(self, tipo, angle):
|
||||
|
@@ -217,8 +217,8 @@ class GenButton(wx.PyControl):
|
||||
else:
|
||||
dc.SetPen(self.shadowPen)
|
||||
for i in range(self.bezelWidth):
|
||||
dc.DrawLine((x1+i, y1), (x1+i, y2-i))
|
||||
dc.DrawLine((x1, y1+i), (x2-i, y1+i))
|
||||
dc.DrawLine(x1+i, y1, x1+i, y2-i)
|
||||
dc.DrawLine(x1, y1+i, x2-i, y1+i)
|
||||
|
||||
# draw the lower right sides
|
||||
if self.up:
|
||||
@@ -226,8 +226,8 @@ class GenButton(wx.PyControl):
|
||||
else:
|
||||
dc.SetPen(self.highlightPen)
|
||||
for i in range(self.bezelWidth):
|
||||
dc.DrawLine((x1+i, y2-i), (x2+1, y2-i))
|
||||
dc.DrawLine((x2-i, y1+i), (x2-i, y2))
|
||||
dc.DrawLine(x1+i, y2-i, x2+1, y2-i)
|
||||
dc.DrawLine(x2-i, y1+i, x2-i, y2)
|
||||
|
||||
|
||||
def DrawLabel(self, dc, width, height, dw=0, dy=0):
|
||||
@@ -240,7 +240,7 @@ class GenButton(wx.PyControl):
|
||||
tw, th = dc.GetTextExtent(label)
|
||||
if not self.up:
|
||||
dw = dy = self.labelDelta
|
||||
dc.DrawText(label, ((width-tw)/2+dw, (height-th)/2+dy))
|
||||
dc.DrawText(label, (width-tw)/2+dw, (height-th)/2+dy)
|
||||
|
||||
|
||||
def DrawFocusIndicator(self, dc, w, h):
|
||||
@@ -254,7 +254,7 @@ class GenButton(wx.PyControl):
|
||||
dc.SetLogicalFunction(wx.INVERT)
|
||||
dc.SetPen(self.focusIndPen)
|
||||
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
dc.DrawRectangle((bw+2,bw+2), (w-bw*2-4, h-bw*2-4))
|
||||
dc.DrawRectangle(bw+2,bw+2, w-bw*2-4, h-bw*2-4)
|
||||
dc.SetLogicalFunction(wx.COPY)
|
||||
|
||||
|
||||
@@ -419,7 +419,7 @@ class GenBitmapButton(GenButton):
|
||||
if not self.up:
|
||||
dw = dy = self.labelDelta
|
||||
hasMask = bmp.GetMask() != None
|
||||
dc.DrawBitmap(bmp, ((width-bw)/2+dw, (height-bh)/2+dy), hasMask)
|
||||
dc.DrawBitmap(bmp, (width-bw)/2+dw, (height-bh)/2+dy, hasMask)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@@ -479,10 +479,10 @@ class GenBitmapTextButton(GenBitmapButton): # generic bitmapped button with
|
||||
|
||||
pos_x = (width-bw-tw)/2+dw # adjust for bitmap and text to centre
|
||||
if bmp !=None:
|
||||
dc.DrawBitmap(bmp, (pos_x, (height-bh)/2+dy), hasMask) # draw bitmap if available
|
||||
dc.DrawBitmap(bmp, pos_x, (height-bh)/2+dy, hasMask) # draw bitmap if available
|
||||
pos_x = pos_x + 2 # extra spacing from bitmap
|
||||
|
||||
dc.DrawText(label, (pos_x + dw+bw, (height-th)/2+dy)) # draw the text
|
||||
dc.DrawText(label, pos_x + dw+bw, (height-th)/2+dy) # draw the text
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@@ -359,7 +359,7 @@ class CalDraw:
|
||||
|
||||
tw,th = DC.GetTextExtent(month)
|
||||
adjust = self.cx_st + (self.sizew-tw)/2
|
||||
DC.DrawText(month, (adjust, self.cy_st + th))
|
||||
DC.DrawText(month, adjust, self.cy_st + th)
|
||||
|
||||
year = str(self.year)
|
||||
tw,th = DC.GetTextExtent(year)
|
||||
@@ -369,7 +369,7 @@ class CalDraw:
|
||||
|
||||
f = wx.Font(sizef, self.font, wx.NORMAL, self.bold)
|
||||
DC.SetFont(f)
|
||||
DC.DrawText(year, (self.cx_st + adjust, self.cy_st + th))
|
||||
DC.DrawText(year, self.cx_st + adjust, self.cy_st + th)
|
||||
|
||||
def DrawWeek(self, DC): # draw the week days
|
||||
# increase by 1 to include all gridlines
|
||||
@@ -431,7 +431,7 @@ class CalDraw:
|
||||
else:
|
||||
pen = wx.Pen(MakeColor(self.GetColor(COLOR_BACKGROUND)), 1, wx.SOLID)
|
||||
DC.SetPen(pen)
|
||||
DC.DrawRectangle( pointXY, pointWH)
|
||||
DC.DrawRectanglePointSize( pointXY, pointWH)
|
||||
|
||||
old_pen = DC.GetPen()
|
||||
|
||||
@@ -440,12 +440,12 @@ class CalDraw:
|
||||
# draw the horizontal hilight
|
||||
startPoint = wx.Point(x + 1 , y + 1)
|
||||
endPoint = wx.Point(x + width - 1, y + 1)
|
||||
DC.DrawLine(startPoint, endPoint )
|
||||
DC.DrawLinePoint(startPoint, endPoint )
|
||||
|
||||
# draw the vertical hilight
|
||||
startPoint = wx.Point(x + 1 , y + 1)
|
||||
endPoint = wx.Point(x + 1, y + height - 2)
|
||||
DC.DrawLine(startPoint, endPoint )
|
||||
DC.DrawLinePoint(startPoint, endPoint )
|
||||
|
||||
pen = wx.Pen(MakeColor(self.colors[COLOR_3D_DARK]), 1, wx.SOLID)
|
||||
DC.SetPen(pen)
|
||||
@@ -453,19 +453,19 @@ class CalDraw:
|
||||
# draw the horizontal lowlight
|
||||
startPoint = wx.Point(x + 1, y + height - 2)
|
||||
endPoint = wx.Point(x + width - 1, y + height - 2)
|
||||
DC.DrawLine(startPoint, endPoint )
|
||||
DC.DrawLinePoint(startPoint, endPoint )
|
||||
|
||||
# draw the vertical lowlight
|
||||
startPoint = wx.Point(x + width - 2 , y + 2)
|
||||
endPoint = wx.Point(x + width - 2, y + height - 2)
|
||||
DC.DrawLine(startPoint, endPoint )
|
||||
DC.DrawLinePoint(startPoint, endPoint )
|
||||
|
||||
pen = wx.Pen(MakeColor(self.colors[COLOR_FONT]), 1, wx.SOLID)
|
||||
|
||||
DC.SetPen(pen)
|
||||
|
||||
point = (x+diffx, y+diffy)
|
||||
DC.DrawText(day, point)
|
||||
DC.DrawTextPoint(day, point)
|
||||
cnt_x = cnt_x + 1
|
||||
|
||||
def _CalcFontSize(self, DC, f):
|
||||
@@ -536,7 +536,7 @@ class CalDraw:
|
||||
|
||||
adj_v = adj_v + self.num_indent_vert
|
||||
|
||||
DC.DrawText(text, (x+adj_h, y+adj_v))
|
||||
DC.DrawTextPoint(text, (x+adj_h, y+adj_v))
|
||||
|
||||
def DrawDayText(self, DC, key):
|
||||
f = wx.Font(10, self.font, wx.NORMAL, self.bold) # initial font setting
|
||||
@@ -589,7 +589,7 @@ class CalDraw:
|
||||
nkey = key + self.st_pos -1
|
||||
rect = self.rg[nkey]
|
||||
|
||||
DC.DrawRectangle((rect.x, rect.y), (rect.width, rect.height))
|
||||
DC.DrawRectangleRect(rect)
|
||||
|
||||
# calculate and draw the grid lines
|
||||
def DrawGrid(self, DC):
|
||||
@@ -611,7 +611,7 @@ class CalDraw:
|
||||
x1 = x1 + self.restW
|
||||
|
||||
if self.hide_grid is False:
|
||||
DC.DrawLine((x1, y1), (x1, y2))
|
||||
DC.DrawLinePoint((x1, y1), (x1, y2))
|
||||
|
||||
self.gridx.append(x1)
|
||||
|
||||
@@ -626,7 +626,7 @@ class CalDraw:
|
||||
y1 = y1 + self.restH
|
||||
|
||||
if self.hide_grid is False:
|
||||
DC.DrawLine((x1, y1), (x2, y1))
|
||||
DC.DrawLinePoint((x1, y1), (x2, y1))
|
||||
|
||||
self.gridy.append(y1)
|
||||
|
||||
@@ -1019,7 +1019,7 @@ class Calendar( wx.PyControl ):
|
||||
DC.SetPen(wx.TRANSPARENT_PEN)
|
||||
|
||||
rect = self.rg[key]
|
||||
DC.DrawRectangle((rect.x+1, rect.y+1), (rect.width-2, rect.height-2))
|
||||
DC.DrawRectangle(rect.x+1, rect.y+1, rect.width-2, rect.height-2)
|
||||
|
||||
self.caldraw.DrawDayText(DC,key)
|
||||
|
||||
@@ -1041,7 +1041,7 @@ class Calendar( wx.PyControl ):
|
||||
DC.SetPen(wx.Pen(MakeColor(self.GetColor(COLOR_GRID_LINES)), width))
|
||||
|
||||
rect = self.rg[key]
|
||||
DC.DrawRectangle((rect.x, rect.y), (rect.width, rect.height))
|
||||
DC.DrawRectangleRect(rect)
|
||||
|
||||
DC.EndDrawing()
|
||||
|
||||
|
@@ -113,7 +113,7 @@ class Canvas(wx.Window):
|
||||
"""Performs the blit of the buffer contents on-screen."""
|
||||
width, height = self.buffer.GetSize()
|
||||
dc.BeginDrawing()
|
||||
dc.Blit((0, 0), (width, height), self.buffer, (0, 0))
|
||||
dc.Blit(0, 0, width, height, self.buffer, 0, 0)
|
||||
dc.EndDrawing()
|
||||
|
||||
def GetBoundingRect(self):
|
||||
|
@@ -68,7 +68,7 @@ class PyColourSlider(canvas.Canvas):
|
||||
"""Returns the colour value for a position on the slider. The position
|
||||
must be within the valid height of the slider, or results can be
|
||||
unpredictable."""
|
||||
return self.buffer.GetPixel((0, pos))
|
||||
return self.buffer.GetPixel(0, pos)
|
||||
|
||||
def DrawBuffer(self):
|
||||
"""Actual implementation of the widget's drawing. We simply draw
|
||||
@@ -88,5 +88,5 @@ class PyColourSlider(canvas.Canvas):
|
||||
r,g,b = [c * 255.0 for c in colorsys.hsv_to_rgb(h,s,v)]
|
||||
colour = wx.Colour(int(r), int(g), int(b))
|
||||
self.buffer.SetPen(wx.Pen(colour, 1, wx.SOLID))
|
||||
self.buffer.DrawRectangle((0, y_pos), (15, 1))
|
||||
self.buffer.DrawRectangle(0, y_pos, 15, 1)
|
||||
v = v - vstep
|
||||
|
@@ -184,12 +184,12 @@ class PyPalette(canvas.Canvas):
|
||||
"""Returns a colour value at a specific x, y coordinate pair. This
|
||||
is useful for determining the colour found a specific mouse click
|
||||
in an external event handler."""
|
||||
return self.buffer.GetPixel((x, y))
|
||||
return self.buffer.GetPixel(x, y)
|
||||
|
||||
def DrawBuffer(self):
|
||||
"""Draws the palette XPM into the memory buffer."""
|
||||
#self.GeneratePaletteBMP ("foo.bmp")
|
||||
self.buffer.DrawBitmap(self.palette, (0, 0), 0)
|
||||
self.buffer.DrawBitmap(self.palette, 0, 0, 0)
|
||||
|
||||
def HighlightPoint(self, x, y):
|
||||
"""Highlights an area of the palette with a little circle around
|
||||
@@ -197,7 +197,7 @@ class PyPalette(canvas.Canvas):
|
||||
colour = wx.Colour(0, 0, 0)
|
||||
self.buffer.SetPen(wx.Pen(colour, 1, wx.SOLID))
|
||||
self.buffer.SetBrush(wx.Brush(colour, wx.TRANSPARENT))
|
||||
self.buffer.DrawCircle((x, y), 3)
|
||||
self.buffer.DrawCircle(x, y, 3)
|
||||
self.Refresh()
|
||||
|
||||
def GeneratePaletteBMP(self, file_name, granularity=1):
|
||||
@@ -225,8 +225,8 @@ class PyPalette(canvas.Canvas):
|
||||
colour = wx.Colour(int(r * 255.0), int(g * 255.0), int(b * 255.0))
|
||||
self.buffer.SetPen(wx.Pen(colour, 1, wx.SOLID))
|
||||
self.buffer.SetBrush(wx.Brush(colour, wx.SOLID))
|
||||
self.buffer.DrawRectangle((x, y),
|
||||
(self.HORIZONTAL_STEP, self.vertical_step))
|
||||
self.buffer.DrawRectangle(x, y,
|
||||
self.HORIZONTAL_STEP, self.vertical_step)
|
||||
|
||||
# this code is now simpler (and works)
|
||||
bitmap = self.buffer.GetBitmap()
|
||||
|
@@ -1,155 +0,0 @@
|
||||
#----------------------------------------------------------------------
|
||||
# Name: compatdc.py
|
||||
# Purpose: Make wxPython 2.4 DC classes compatible with the 2.5
|
||||
# DC classes
|
||||
#
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: 21-Apr-2004
|
||||
# RCS-ID: $Id$
|
||||
# Copyright: (c) 2004 by Total Control Software
|
||||
# Licence: wxWindows license
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
import wx
|
||||
|
||||
|
||||
def MakeDCCompatible(klass, full=False):
|
||||
"""
|
||||
Manipulate the DC class passed to this funciton such that it is
|
||||
more compatible with the DC classes used in wxPython 2.5. This
|
||||
should help with writing code that works with both versions. If
|
||||
full is True then in addition to creating the 'XY' versions of the
|
||||
methods, a 'point/size' version (which are the new defaults in
|
||||
2.5) will also be created.
|
||||
"""
|
||||
if wx.VERSION >= (2,5):
|
||||
return # Nothing to do
|
||||
|
||||
# first create XY methods from the current ones.
|
||||
klass.FloodFillXY = klass.FloodFill
|
||||
klass.GetPixelXY = klass.GetPixel
|
||||
klass.DrawLineXY = klass.DrawLine
|
||||
klass.CrossHairXY = klass.CrossHair
|
||||
klass.DrawArcXY = klass.DrawArc
|
||||
klass.DrawEllipticArcXY = klass.DrawEllipticArc
|
||||
klass.DrawPointXY = klass.DrawPoint
|
||||
klass.DrawRectangleXY = klass.DrawRectangle
|
||||
klass.DrawRoundedRectangleXY = klass.DrawRoundedRectangle
|
||||
klass.DrawCircleXY = klass.DrawCircle
|
||||
klass.DrawEllipseXY = klass.DrawEllipse
|
||||
klass.DrawIconXY = klass.DrawIcon
|
||||
klass.DrawBitmapXY = klass.DrawBitmap
|
||||
klass.DrawTextXY = klass.DrawText
|
||||
klass.DrawRotatedTextXY = klass.DrawRotatedText
|
||||
klass.BlitXY = klass.Blit
|
||||
|
||||
# now, make some functions that we can use as new methods
|
||||
if full:
|
||||
def FloodFill(self, pt, col, style=wx.FLOOD_SURFACE):
|
||||
pt = wx.Point(*pt)
|
||||
return self.FloodFillXY(pt.x, pt.y, col, style)
|
||||
klass.FloodFill = FloodFill
|
||||
|
||||
def GetPixel(self, pt):
|
||||
pt = wx.Point(*pt)
|
||||
return self.GetPixelXY(pt.x, pt.y)
|
||||
klass.GetPixel = GetPixel
|
||||
|
||||
def DrawLine(self, pt1, pt2):
|
||||
pt1 = wx.Point(*pt1)
|
||||
pt2 = wx.Point(*pt2)
|
||||
return self.DrawLineXY(pt1.x, pt1.y, pt2.x, pt2.y)
|
||||
klass.DrawLine = DrawLine
|
||||
|
||||
def CrossHair(self, pt):
|
||||
pt = wx.Point(*pt)
|
||||
return self.CrossHairXY(pt.x, pt.y)
|
||||
klass.CrossHair = CrossHair
|
||||
|
||||
def DrawArc(self, pt1, pt2, centre):
|
||||
pt1 = wx.Point(*pt1)
|
||||
pt2 = wx.Point(*pt2)
|
||||
return self.DrawArcXY(pt1.x, pt1.y, pt2.x, pt2.y, centre.x, centre.y)
|
||||
klass.DrawArc = DrawArc
|
||||
|
||||
def DrawEllipticArc(self, pt, sz, sa, ea):
|
||||
pt = wx.Point(*pt)
|
||||
sz = wx.Size(*sz)
|
||||
return self.DrawEllipticArcXY(pt.x, pt.y, sz.width, sz.height, sa, ea)
|
||||
klass.DrawEllipticArc = DrawEllipticArc
|
||||
|
||||
def DrawPoint(self, pt):
|
||||
pt = wx.Point(*pt)
|
||||
return self.DrawPointXY(pt.x, pt.y)
|
||||
klass.DrawPoint = DrawPoint
|
||||
|
||||
def DrawRectangle(self, pt, sz):
|
||||
pt = wx.Point(*pt)
|
||||
sz = wx.Size(*sz)
|
||||
return self.DrawRectangleXY(pt.x, pt.y, sz.width, sz.height)
|
||||
klass.DrawRectangle = DrawRectangle
|
||||
|
||||
def DrawRoundedRectangle(self, pt, sz, radius):
|
||||
pt = wx.Point(*pt)
|
||||
sz = wx.Size(*sz)
|
||||
return self.DrawRoundedRectangleXY(pt.x, pt.y, sz.width, sz.height, radius)
|
||||
klass.DrawRoundedRectangle = DrawRoundedRectangle
|
||||
|
||||
def DrawCircle(self, pt, radius):
|
||||
pt = wx.Point(*pt)
|
||||
return self.DrawCircleXY(pt.x, pt.y, radius)
|
||||
klass.DrawCircle = DrawCircle
|
||||
|
||||
def DrawEllipse(self, pt, sz):
|
||||
pt = wx.Point(*pt)
|
||||
sz = wx.Size(*sz)
|
||||
return self.DrawEllipseXY(pt.x, pt.y, sz.width, sz.height)
|
||||
klass.DrawEllipse = DrawEllipse
|
||||
|
||||
def DrawIcon(self, icon, pt):
|
||||
pt = wx.Point(*pt)
|
||||
return self.DrawIconXY(icon, pt.x, pt.y )
|
||||
klass.DrawIcon = DrawIcon
|
||||
|
||||
def DrawBitmap(self, bmp, pt):
|
||||
pt = wx.Point(*pt)
|
||||
return self.DrawBitmapXY(bmp, pt.x, pt.y)
|
||||
klass.DrawBitmap = DrawBitmap
|
||||
|
||||
def DrawText(self, text, pt):
|
||||
pt = wx.Point(*pt)
|
||||
return self.DrawTextXY(text, pt.x, pt.y)
|
||||
klass.DrawText = DrawText
|
||||
|
||||
def DrawRotatedText(self, text, pt, angle):
|
||||
pt = wx.Point(*pt)
|
||||
return self.DrawRotatedTextXY(text, pt.x, pt.y, angle)
|
||||
klass.DrawRotatedText = DrawRotatedText
|
||||
|
||||
def Blit(self, destPt, sz, source, srcPt,
|
||||
rop=wx.COPY, useMask=False, srcPtMask=wx.DefaultPosition):
|
||||
return self.BlitXY(destPt.x, destPt.y, sz.width, sz.height,
|
||||
source, srcPt.x, srcPt.y, rop, useMask,
|
||||
srcPtMask.x, srcPtMask.y)
|
||||
klass.Blit = Blit
|
||||
|
||||
|
||||
def MakeAllDCsCompatible(full=False):
|
||||
"""
|
||||
Run MakeDCCompatible on all DC classes in wx.
|
||||
"""
|
||||
MakeDCCompatible(wx.BufferedPaintDC, full)
|
||||
MakeDCCompatible(wx.BufferedDC, full)
|
||||
MakeDCCompatible(wx.MemoryDC, full)
|
||||
MakeDCCompatible(wx.ScreenDC, full)
|
||||
MakeDCCompatible(wx.ClientDC, full)
|
||||
MakeDCCompatible(wx.PaintDC, full)
|
||||
MakeDCCompatible(wx.WindowDC, full)
|
||||
MakeDCCompatible(wx.PostScriptDC, full)
|
||||
if hasattr(wx, "MetaFileDC"):
|
||||
MakeDCCompatible(wx.MetaFileDC, full)
|
||||
if hasattr(wx, "PrinterDC"):
|
||||
MakeDCCompatible(wx.PrinterDC, full)
|
||||
MakeDCCompatible(wx.DC, full)
|
||||
|
@@ -216,7 +216,7 @@ class Editor(wx.ScrolledWindow):
|
||||
pass
|
||||
|
||||
def DrawEditText(self, t, x, y, dc):
|
||||
dc.DrawText(t, (x * self.fw, y * self.fh))
|
||||
dc.DrawText(t, x * self.fw, y * self.fh)
|
||||
|
||||
def DrawLine(self, line, dc):
|
||||
if self.IsLine(line):
|
||||
@@ -264,7 +264,7 @@ class Editor(wx.ScrolledWindow):
|
||||
x = 0
|
||||
y = (len(self.lines) - self.sy) * self.fh
|
||||
hasTransparency = 1
|
||||
dc.DrawBitmap(self.eofMarker, (x, y), hasTransparency)
|
||||
dc.DrawBitmap(self.eofMarker, x, y, hasTransparency)
|
||||
|
||||
##------------------ cursor-related functions
|
||||
|
||||
@@ -293,7 +293,7 @@ class Editor(wx.ScrolledWindow):
|
||||
szy = self.fh
|
||||
x = xp * szx
|
||||
y = yp * szy
|
||||
dc.Blit((x,y), (szx,szy), dc, (x,y), wx.SRC_INVERT)
|
||||
dc.Blit(x,y, szx,szy, dc, x,y, wx.SRC_INVERT)
|
||||
self.sco_x = xp
|
||||
self.sco_y = yp
|
||||
|
||||
|
@@ -277,15 +277,15 @@ class DCRenderer(Renderer):
|
||||
|
||||
def renderCharacterData(self, data, x, y):
|
||||
self.dc.SetTextForeground(self.getCurrentColor())
|
||||
self.dc.DrawText(data, (x, y))
|
||||
self.dc.DrawText(data, x, y)
|
||||
|
||||
def start_angle(self, attrs):
|
||||
self.dc.SetFont(self.getCurrentFont())
|
||||
self.dc.SetPen(self.getCurrentPen())
|
||||
width, height, descent, leading = self.dc.GetFullTextExtent("M")
|
||||
y = self.y + self.offsets[-1]
|
||||
self.dc.DrawLine((iround(self.x), iround(y)), (iround( self.x+width), iround(y)))
|
||||
self.dc.DrawLine((iround(self.x), iround(y)), (iround(self.x+width), iround(y-width)))
|
||||
self.dc.DrawLine(iround(self.x), iround(y), iround( self.x+width), iround(y))
|
||||
self.dc.DrawLine(iround(self.x), iround(y), iround(self.x+width), iround(y-width))
|
||||
self.updateDims(width, height, descent, leading)
|
||||
|
||||
|
||||
@@ -301,8 +301,8 @@ class DCRenderer(Renderer):
|
||||
r = iround( 0.95 * width / 4)
|
||||
xc = (2*self.x + width) / 2
|
||||
yc = iround(y-1.5*r)
|
||||
self.dc.DrawCircle((xc - r, yc), r)
|
||||
self.dc.DrawCircle((xc + r, yc), r)
|
||||
self.dc.DrawCircle(xc - r, yc, r)
|
||||
self.dc.DrawCircle(xc + r, yc, r)
|
||||
self.updateDims(width, height, 0, 0)
|
||||
|
||||
def start_times(self, attrs):
|
||||
@@ -313,8 +313,8 @@ class DCRenderer(Renderer):
|
||||
width *= 0.8
|
||||
width = iround(width+.5)
|
||||
self.dc.SetPen(wx.Pen(self.getCurrentColor(), 1))
|
||||
self.dc.DrawLine((iround(self.x), iround(y-width)), (iround(self.x+width-1), iround(y-1)))
|
||||
self.dc.DrawLine((iround(self.x), iround(y-2)), (iround(self.x+width-1), iround(y-width-1)))
|
||||
self.dc.DrawLine(iround(self.x), iround(y-width), iround(self.x+width-1), iround(y-1))
|
||||
self.dc.DrawLine(iround(self.x), iround(y-2), iround(self.x+width-1), iround(y-width-1))
|
||||
self.updateDims(width, height, 0, 0)
|
||||
|
||||
|
||||
|
@@ -450,7 +450,7 @@ class PointSet(draw_object):
|
||||
dc.SetBrush(self.Brush)
|
||||
radius = int(round(self.Diameter/2))
|
||||
for (x,y) in Points:
|
||||
dc.DrawEllipse(((x - radius), (y - radius)), (self.Diameter, self.Diameter))
|
||||
dc.DrawEllipse((x - radius), (y - radius), self.Diameter, self.Diameter)
|
||||
|
||||
|
||||
|
||||
@@ -486,7 +486,7 @@ class Dot(draw_object):
|
||||
dc.SetBrush(self.Brush)
|
||||
radius = int(round(self.Diameter/2))
|
||||
(X,Y) = WorldToPixel((self.X,self.Y))
|
||||
dc.DrawEllipse(((X - radius), (Y - radius)), (self.Diameter, self.Diameter))
|
||||
dc.DrawEllipse((X - radius), (Y - radius), self.Diameter, self.Diameter)
|
||||
|
||||
|
||||
class Rectangle(draw_object):
|
||||
@@ -513,7 +513,7 @@ class Rectangle(draw_object):
|
||||
|
||||
dc.SetPen(self.Pen)
|
||||
dc.SetBrush(self.Brush)
|
||||
dc.DrawRectangle((X,Y), (Width,Height))
|
||||
dc.DrawRectangle(X,Y, Width,Height)
|
||||
|
||||
class Ellipse(draw_object):
|
||||
def __init__(self,x,y,width,height,LineColor,LineStyle,LineWidth,FillColor,FillStyle,Foreground = 0):
|
||||
@@ -539,7 +539,7 @@ class Ellipse(draw_object):
|
||||
|
||||
dc.SetPen(self.Pen)
|
||||
dc.SetBrush(self.Brush)
|
||||
dc.DrawEllipse((X,Y), (Width,Height))
|
||||
dc.DrawEllipse(X,Y, Width,Height)
|
||||
|
||||
class Circle(draw_object):
|
||||
def __init__(self,x,y,Diameter,LineColor,LineStyle,LineWidth,FillColor,FillStyle,Foreground = 0):
|
||||
@@ -564,7 +564,7 @@ class Circle(draw_object):
|
||||
|
||||
dc.SetPen(self.Pen)
|
||||
dc.SetBrush(self.Brush)
|
||||
dc.DrawEllipse((X-Diameter/2,Y-Diameter/2), (Diameter,Diameter))
|
||||
dc.DrawEllipse(X-Diameter/2,Y-Diameter/2, Diameter,Diameter)
|
||||
|
||||
class Text(draw_object):
|
||||
"""
|
||||
@@ -647,7 +647,7 @@ class Text(draw_object):
|
||||
raise "Invalid value for Text Object Position Attribute"
|
||||
self.x_shift = x_shift
|
||||
self.y_shift = y_shift
|
||||
dc.DrawText(self.String, (X-self.x_shift, Y-self.y_shift))
|
||||
dc.DrawText(self.String, X-self.x_shift, Y-self.y_shift)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -870,8 +870,8 @@ class FloatCanvas(wx.Panel):
|
||||
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
dc.SetLogicalFunction(wx.XOR)
|
||||
if self.PrevRBBox:
|
||||
dc.DrawRectangleXY(*self.PrevRBBox)
|
||||
dc.DrawRectangleXY(x_c-w/2,y_c-h/2,w,h)
|
||||
dc.DrawRectangle(*self.PrevRBBox)
|
||||
dc.DrawRectangle(x_c-w/2,y_c-h/2,w,h)
|
||||
self.PrevRBBox = (x_c-w/2,y_c-h/2,w,h)
|
||||
dc.EndDrawing()
|
||||
|
||||
@@ -909,8 +909,8 @@ class FloatCanvas(wx.Panel):
|
||||
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
dc.SetLogicalFunction(wx.XOR)
|
||||
if self.PrevMoveBox:
|
||||
dc.DrawRectangleXY(*self.PrevMoveBox)
|
||||
dc.DrawRectangleXY(x_tl,y_tl,w,h)
|
||||
dc.DrawRectangle(*self.PrevMoveBox)
|
||||
dc.DrawRectangle(x_tl,y_tl,w,h)
|
||||
self.PrevMoveBox = (x_tl,y_tl,w,h)
|
||||
dc.EndDrawing()
|
||||
|
||||
@@ -955,7 +955,7 @@ class FloatCanvas(wx.Panel):
|
||||
def OnPaint(self, event):
|
||||
#dc = wx.BufferedPaintDC(self.DrawPanel, self._Buffer)
|
||||
dc = wx.PaintDC(self.DrawPanel)
|
||||
dc.DrawBitmap(self._Buffer, (0,0))
|
||||
dc.DrawBitmap(self._Buffer, 0,0)
|
||||
|
||||
def Draw(self):
|
||||
"""
|
||||
@@ -991,7 +991,8 @@ class FloatCanvas(wx.Panel):
|
||||
i+=1
|
||||
Object._Draw(dc,self.WorldToPixel,self.ScaleFunction)
|
||||
if i % self.NumBetweenBlits == 0:
|
||||
ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
|
||||
w,h = self.PanelSize
|
||||
ScreenDC.Blit(0, 0, w,h, dc, 0, 0)
|
||||
dc.EndDrawing()
|
||||
else:
|
||||
dc.Clear()
|
||||
@@ -1006,7 +1007,8 @@ class FloatCanvas(wx.Panel):
|
||||
i+=1
|
||||
Object._Draw(dc,self.WorldToPixel,self.ScaleFunction)
|
||||
if i % self.NumBetweenBlits == 0:
|
||||
ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
|
||||
w, h = self.PanelSize
|
||||
ScreenDC.Blit(0, 0, w,h, dc, 0, 0)
|
||||
dc.EndDrawing()
|
||||
else: # not using a Background DC
|
||||
dc = wx.MemoryDC()
|
||||
@@ -1022,25 +1024,27 @@ class FloatCanvas(wx.Panel):
|
||||
i+=1
|
||||
Object._Draw(dc,self.WorldToPixel,self.ScaleFunction)
|
||||
if i % self.NumBetweenBlits == 0:
|
||||
ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
|
||||
w, h = self.PanelSize
|
||||
ScreenDC.Blit(0, 0, w, h, dc, 0, 0)
|
||||
dc.EndDrawing()
|
||||
else:
|
||||
dc.Clear()
|
||||
# now refresh the screen
|
||||
#ScreenDC.DrawBitmap(self._Buffer,0,0) #NOTE: uisng DrawBitmap didn't work right on MSW
|
||||
ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
|
||||
w, h = self.PanelSize
|
||||
ScreenDC.Blit(0, 0, w, h, dc, 0, 0)
|
||||
|
||||
# If the canvas is in the middle of a zoom or move, the Rubber Band box needs to be re-drawn
|
||||
if self.PrevRBBox:
|
||||
ScreenDC.SetPen(wx.Pen('WHITE', 2,wx.SHORT_DASH))
|
||||
ScreenDC.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
ScreenDC.SetLogicalFunction(wx.XOR)
|
||||
ScreenDC.DrawRectangleXY(*self.PrevRBBox)
|
||||
ScreenDC.DrawRectangle(*self.PrevRBBox)
|
||||
elif self.PrevMoveBox:
|
||||
ScreenDC.SetPen(wx.Pen('WHITE', 1,))
|
||||
ScreenDC.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
ScreenDC.SetLogicalFunction(wx.XOR)
|
||||
ScreenDC.DrawRectangleXY(*self.PrevMoveBox)
|
||||
ScreenDC.DrawRectangle(*self.PrevMoveBox)
|
||||
if self.Debug: print "Drawing took %f seconds of CPU time"%(clock()-start)
|
||||
|
||||
def BBCheck(self, BB1, BB2):
|
||||
|
@@ -159,12 +159,12 @@ class ColDragWindow(wx.Window):
|
||||
def OnPaint(self,evt):
|
||||
dc = wx.PaintDC(self)
|
||||
w,h = self.GetSize()
|
||||
dc.DrawBitmap(self.image, (0,0))
|
||||
dc.DrawBitmap(self.image, 0,0)
|
||||
dc.SetPen(wx.Pen(wx.BLACK,1,wx.SOLID))
|
||||
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
dc.DrawRectangle((0,0), (w,h))
|
||||
dc.DrawRectangle(0,0, w,h)
|
||||
iPos = self.GetInsertionPos()
|
||||
dc.DrawLine((iPos,h - 10), (iPos,h))
|
||||
dc.DrawLine(iPos,h - 10, iPos,h)
|
||||
|
||||
|
||||
|
||||
@@ -222,12 +222,12 @@ class RowDragWindow(wx.Window):
|
||||
def OnPaint(self,evt):
|
||||
dc = wx.PaintDC(self)
|
||||
w,h = self.GetSize()
|
||||
dc.DrawBitmap(self.image, (0,0))
|
||||
dc.DrawBitmap(self.image, 0,0)
|
||||
dc.SetPen(wx.Pen(wx.BLACK,1,wx.SOLID))
|
||||
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
dc.DrawRectangle((0,0), (w,h))
|
||||
dc.DrawRectangle(0,0, w,h)
|
||||
iPos = self.GetInsertionPos()
|
||||
dc.DrawLine((w - 10,iPos), (w,iPos))
|
||||
dc.DrawLine(w - 10,iPos, w,iPos)
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
@@ -346,7 +346,7 @@ class GridColMover(wx.EvtHandler):
|
||||
memdc = wx.MemoryDC()
|
||||
memdc.SelectObject(bmp)
|
||||
dc = wx.WindowDC(self.lwin)
|
||||
memdc.Blit((0,0), rect.GetSize(), dc, rect.GetPosition())
|
||||
memdc.Blit(0,0, rect.width, rect.height, dc, rect.x, rect.y)
|
||||
memdc.SelectObject(wx.NullBitmap)
|
||||
return bmp
|
||||
|
||||
@@ -469,7 +469,7 @@ class GridRowMover(wx.EvtHandler):
|
||||
memdc = wx.MemoryDC()
|
||||
memdc.SelectObject(bmp)
|
||||
dc = wx.WindowDC(self.lwin)
|
||||
memdc.Blit((0,0), rect.GetSize(), dc, rect.GetPosition())
|
||||
memdc.Blit(0,0, rect.width, rect.height, dc, rect.x, rect.y)
|
||||
memdc.SelectObject(wx.NullBitmap)
|
||||
return bmp
|
||||
|
||||
|
@@ -82,7 +82,7 @@ class ImageView(wx.Window):
|
||||
brush = wx.Brush(wx.NamedColour(self.back_color), wx.SOLID)
|
||||
dc.SetBrush(brush)
|
||||
dc.SetPen(wx.Pen(wx.NamedColour(self.border_color), 1))
|
||||
dc.DrawRectangle((0, 0), (self.image_sizex, self.image_sizey))
|
||||
dc.DrawRectangle(0, 0, self.image_sizex, self.image_sizey)
|
||||
|
||||
def DrawImage(self, dc):
|
||||
try:
|
||||
@@ -113,7 +113,7 @@ class ImageView(wx.Window):
|
||||
image.Rescale(iwidth, iheight) # rescale to fit the window
|
||||
image.ConvertToBitmap()
|
||||
bmp = image.ConvertToBitmap()
|
||||
dc.DrawBitmap(bmp, (diffx, diffy)) # draw the image to window
|
||||
dc.DrawBitmap(bmp, diffx, diffy) # draw the image to window
|
||||
|
||||
|
||||
class ImageDialog(wx.Dialog):
|
||||
|
@@ -610,13 +610,13 @@ class MultiCreator(wx.Window):
|
||||
|
||||
# Draw outline
|
||||
dc.SetPen(highlight)
|
||||
dc.DrawLine((0,0), (0,h))
|
||||
dc.DrawLine((0,0), (w,0))
|
||||
dc.DrawLine(0,0, 0,h)
|
||||
dc.DrawLine(0,0, w,0)
|
||||
dc.SetPen(black)
|
||||
dc.DrawLine((0,h), (w+1,h))
|
||||
dc.DrawLine((w,0), (w,h))
|
||||
dc.DrawLine(0,h, w+1,h)
|
||||
dc.DrawLine(w,0, w,h)
|
||||
dc.SetPen(shadow)
|
||||
dc.DrawLine((w-1,2), (w-1,h))
|
||||
dc.DrawLine(w-1,2, w-1,h)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
@@ -692,11 +692,11 @@ def DrawSash(win,x,y,direction):
|
||||
bmp = wx.EmptyBitmap(8,8)
|
||||
bdc = wx.MemoryDC()
|
||||
bdc.SelectObject(bmp)
|
||||
bdc.DrawRectangle((-1,-1), (10,10))
|
||||
bdc.DrawRectangle(-1,-1, 10,10)
|
||||
for i in range(8):
|
||||
for j in range(8):
|
||||
if ((i + j) & 1):
|
||||
bdc.DrawPoint((i,j))
|
||||
bdc.DrawPoint(i,j)
|
||||
|
||||
brush = wx.Brush(wx.Colour(0,0,0))
|
||||
brush.SetStipple(bmp)
|
||||
@@ -726,8 +726,8 @@ def DrawSash(win,x,y,direction):
|
||||
h = body_h
|
||||
|
||||
if direction == MV_HOR:
|
||||
dc.DrawRectangle((x,y-2), (w,4))
|
||||
dc.DrawRectangle(x,y-2, w,4)
|
||||
else:
|
||||
dc.DrawRectangle((x-2,y), (4,h))
|
||||
dc.DrawRectangle(x-2,y, 4,h)
|
||||
|
||||
dc.EndDrawingOnTop()
|
||||
|
@@ -608,14 +608,14 @@ class TreePainter(Painter):
|
||||
mem_dc.SelectObject(self.GetBuffer())
|
||||
mem_dc.SetPen(self.GetBackgroundPen())
|
||||
mem_dc.SetBrush(self.GetBackgroundBrush())
|
||||
mem_dc.DrawRectangle((0, 0), (size[0], size[1]))
|
||||
mem_dc.DrawRectangle(0, 0, size[0], size[1])
|
||||
mem_dc.SetFont(self.tree.GetFont())
|
||||
self.paintWalk(node, mem_dc)
|
||||
else:
|
||||
mem_dc.SelectObject(self.GetBuffer())
|
||||
xstart, ystart = self.tree.CalcUnscrolledPosition(0,0)
|
||||
size = self.tree.GetClientSizeTuple()
|
||||
dc.Blit((xstart, ystart), (size[0], size[1]), mem_dc, (xstart, ystart))
|
||||
dc.Blit(xstart, ystart, size[0], size[1], mem_dc, xstart, ystart)
|
||||
else:
|
||||
if node == self.tree.currentRoot:
|
||||
self.knobs = []
|
||||
@@ -624,7 +624,7 @@ class TreePainter(Painter):
|
||||
dc.SetBrush(self.GetBackgroundBrush())
|
||||
dc.SetFont(self.tree.GetFont())
|
||||
if paintBackground:
|
||||
dc.DrawRectangle((0, 0), (size[0], size[1]))
|
||||
dc.DrawRectangle(0, 0, size[0], size[1])
|
||||
if node:
|
||||
#Call with not paintBackground because if we are told not to paint the
|
||||
#whole background, we have to paint in parts to undo selection coloring.
|
||||
@@ -652,23 +652,23 @@ class TreePainter(Painter):
|
||||
if (not self.tree.model.IsLeaf(kid.data)) or ((kid.expanded or self.tree._assumeChildren) and len(kid.kids)):
|
||||
dc.SetPen(self.linepen)
|
||||
dc.SetBrush(self.bgbrush)
|
||||
dc.DrawRectangle((px -4, py-4), (9, 9))
|
||||
dc.DrawRectangle(px -4, py-4, 9, 9)
|
||||
self.knobs.append( (kid, Rect(px -4, py -4, 9, 9)) )
|
||||
dc.SetPen(self.textpen)
|
||||
if not kid.expanded:
|
||||
dc.DrawLine((px, py -2), (px, py + 3))
|
||||
dc.DrawLine((px -2, py), (px + 3, py))
|
||||
dc.DrawLine(px, py -2, px, py + 3)
|
||||
dc.DrawLine(px -2, py, px + 3, py)
|
||||
if node == self.tree.currentRoot:
|
||||
px = (node.projx - self.tree.layout.NODE_STEP) + 5
|
||||
py = node.projy + node.height/2
|
||||
dc.SetPen(self.linepen)
|
||||
dc.SetBrush(self.bgbrush)
|
||||
dc.DrawRectangle((px -4, py-4), (9, 9))
|
||||
dc.DrawRectangle(px -4, py-4, 9, 9)
|
||||
self.knobs.append( (node, Rect(px -4, py -4, 9, 9)) )
|
||||
dc.SetPen(self.textpen)
|
||||
if not node.expanded:
|
||||
dc.DrawLine((px, py -2), (px, py + 3))
|
||||
dc.DrawLine((px -2, py), (px + 3, py))
|
||||
dc.DrawLine(px, py -2, px, py + 3)
|
||||
dc.DrawLine(px -2, py, px + 3, py)
|
||||
return True
|
||||
|
||||
def OnMouse(self, evt):
|
||||
@@ -684,14 +684,14 @@ class TreeNodePainter(NodePainter):
|
||||
dc.SetPen(self.painter.GetLinePen())
|
||||
dc.SetBrush(self.painter.GetForegroundBrush())
|
||||
dc.SetTextForeground(wx.NamedColour("WHITE"))
|
||||
dc.DrawRectangle((node.projx -1, node.projy -1), (node.width + 3, node.height + 3))
|
||||
dc.DrawRectangle(node.projx -1, node.projy -1, node.width + 3, node.height + 3)
|
||||
else:
|
||||
if drawRects:
|
||||
dc.SetBrush(self.painter.GetBackgroundBrush())
|
||||
dc.SetPen(self.painter.GetBackgroundPen())
|
||||
dc.DrawRectangle((node.projx -1, node.projy -1), (node.width + 3, node.height + 3))
|
||||
dc.DrawRectangle(node.projx -1, node.projy -1, node.width + 3, node.height + 3)
|
||||
dc.SetTextForeground(self.painter.GetTextColour())
|
||||
dc.DrawText(text, (node.projx, node.projy))
|
||||
dc.DrawText(text, node.projx, node.projy)
|
||||
self.painter.rectangles.append((node, Rect(node.projx, node.projy, node.width, node.height)))
|
||||
|
||||
class TreeLinePainter(LinePainter):
|
||||
@@ -703,14 +703,14 @@ class TreeLinePainter(LinePainter):
|
||||
py = child.projy + self.painter.tree.layout.NODE_HEIGHT/2 -2
|
||||
cx = child.projx
|
||||
cy = py
|
||||
dc.DrawLine((px, py), (cx, cy))
|
||||
dc.DrawLine(px, py, cx, cy)
|
||||
else:
|
||||
px = parent.projx + 5
|
||||
py = parent.projy + parent.height
|
||||
cx = child.projx -5
|
||||
cy = child.projy + self.painter.tree.layout.NODE_HEIGHT/2 -3
|
||||
dc.DrawLine((px, py), (px, cy))
|
||||
dc.DrawLine((px, cy), (cx, cy))
|
||||
dc.DrawLine(px, py, px, cy)
|
||||
dc.DrawLine(px, cy, cx, cy)
|
||||
|
||||
#>> Event defs
|
||||
wxEVT_MVCTREE_BEGIN_EDIT = wx.NewEventType() #Start editing. Vetoable.
|
||||
|
@@ -978,7 +978,7 @@ class PlotCanvas(wx.Window):
|
||||
dc.SetPen(wx.Pen(wx.BLACK))
|
||||
dc.SetBrush(wx.Brush( wx.WHITE, wx.TRANSPARENT ) )
|
||||
dc.SetLogicalFunction(wx.INVERT)
|
||||
dc.DrawRectangle( (ptx,pty), (rectWidth,rectHeight))
|
||||
dc.DrawRectangle( ptx,pty, rectWidth,rectHeight)
|
||||
dc.SetLogicalFunction(wx.COPY)
|
||||
dc.EndDrawing()
|
||||
|
||||
@@ -1204,16 +1204,16 @@ class FloatDCWrapper:
|
||||
self.theDC = aDC
|
||||
|
||||
def DrawLine(self, x1,y1,x2,y2):
|
||||
self.theDC.DrawLine((int(x1),int(y1)),(int(x2),int(y2)))
|
||||
self.theDC.DrawLine(int(x1),int(y1), int(x2),int(y2))
|
||||
|
||||
def DrawText(self, txt, x, y):
|
||||
self.theDC.DrawText(txt, (int(x), int(y)))
|
||||
self.theDC.DrawText(txt, int(x), int(y))
|
||||
|
||||
def DrawRotatedText(self, txt, x, y, angle):
|
||||
self.theDC.DrawRotatedText(txt, (int(x), int(y)), angle)
|
||||
self.theDC.DrawRotatedText(txt, int(x), int(y), angle)
|
||||
|
||||
def SetClippingRegion(self, x, y, width, height):
|
||||
self.theDC.SetClippingRegion((int(x), int(y)), (int(width), int(height)))
|
||||
self.theDC.SetClippingRegion(int(x), int(y), int(width), int(height))
|
||||
|
||||
def SetDeviceOrigin(self, x, y):
|
||||
self.theDC.SetDeviceOrigin(int(x), int(y))
|
||||
|
@@ -104,8 +104,8 @@ class PopButton(wx.PyControl):
|
||||
else:
|
||||
dc.SetPen(self.shadowPen)
|
||||
for i in range(2):
|
||||
dc.DrawLine((x1+i, y1), (x1+i, y2-i))
|
||||
dc.DrawLine((x1, y1+i), (x2-i, y1+i))
|
||||
dc.DrawLine(x1+i, y1, x1+i, y2-i)
|
||||
dc.DrawLine(x1, y1+i, x2-i, y1+i)
|
||||
|
||||
# draw the lower right sides
|
||||
if self.up:
|
||||
@@ -113,20 +113,20 @@ class PopButton(wx.PyControl):
|
||||
else:
|
||||
dc.SetPen(self.highlightPen)
|
||||
for i in range(2):
|
||||
dc.DrawLine((x1+i, y2-i), (x2+1, y2-i))
|
||||
dc.DrawLine((x2-i, y1+i), (x2-i, y2))
|
||||
dc.DrawLine(x1+i, y2-i, x2+1, y2-i)
|
||||
dc.DrawLine(x2-i, y1+i, x2-i, y2)
|
||||
|
||||
def DrawArrow(self,dc):
|
||||
w, h = self.GetSize()
|
||||
mx = w / 2
|
||||
my = h / 2
|
||||
dc.SetPen(self.highlightPen)
|
||||
dc.DrawLine((mx-5,my-5), (mx+5,my-5))
|
||||
dc.DrawLine((mx-5,my-5), (mx,my+5))
|
||||
dc.DrawLine(mx-5,my-5, mx+5,my-5)
|
||||
dc.DrawLine(mx-5,my-5, mx,my+5)
|
||||
dc.SetPen(self.shadowPen)
|
||||
dc.DrawLine((mx+4,my-5), (mx,my+5))
|
||||
dc.DrawLine(mx+4,my-5, mx,my+5)
|
||||
dc.SetPen(self.blackPen)
|
||||
dc.DrawLine((mx+5,my-5), (mx,my+5))
|
||||
dc.DrawLine(mx+5,my-5, mx,my+5)
|
||||
|
||||
def OnPaint(self, event):
|
||||
width, height = self.GetClientSize()
|
||||
|
@@ -60,18 +60,18 @@ class PrintBase:
|
||||
if self.draw == True and txtdraw == True:
|
||||
test_out = self.TestFull(vout)
|
||||
if self.align == wx.ALIGN_LEFT:
|
||||
self.DC.DrawText(test_out, (self.indent+self.pcell_left_margin, y))
|
||||
self.DC.DrawText(test_out, self.indent+self.pcell_left_margin, y)
|
||||
|
||||
elif self.align == wx.ALIGN_CENTRE:
|
||||
diff = self.GetCellDiff(test_out, self.region)
|
||||
self.DC.DrawText(test_out, (self.indent+diff/2, y))
|
||||
self.DC.DrawText(test_out, self.indent+diff/2, y)
|
||||
|
||||
elif self.align == wx.ALIGN_RIGHT:
|
||||
diff = self.GetCellDiff(test_out, self.region)
|
||||
self.DC.DrawText(test_out, (self.indent+diff, y))
|
||||
self.DC.DrawText(test_out, self.indent+diff, y)
|
||||
|
||||
else:
|
||||
self.DC.DrawText(test_out, (self.indent+self.pcell_left_margin, y))
|
||||
self.DC.DrawText(test_out, self.indent+self.pcell_left_margin, y)
|
||||
text = remain
|
||||
y = y + self.space
|
||||
return y - self.space + self.pt_space_after
|
||||
@@ -148,18 +148,18 @@ class PrintBase:
|
||||
if self.draw == True and txtdraw == True:
|
||||
test_out = vout
|
||||
if align == wx.ALIGN_LEFT:
|
||||
self.DC.DrawText(test_out, (indent, y))
|
||||
self.DC.DrawText(test_out, indent, y)
|
||||
|
||||
elif align == wx.ALIGN_CENTRE:
|
||||
diff = self.GetCellDiff(test_out, pagew)
|
||||
self.DC.DrawText(test_out, (indent+diff/2, y))
|
||||
self.DC.DrawText(test_out, indent+diff/2, y)
|
||||
|
||||
elif align == wx.ALIGN_RIGHT:
|
||||
diff = self.GetCellDiff(test_out, pagew)
|
||||
self.DC.DrawText(test_out, (indent+diff, y))
|
||||
self.DC.DrawText(test_out, indent+diff, y)
|
||||
|
||||
else:
|
||||
self.DC.DrawText(test_out, (indent, y_out))
|
||||
self.DC.DrawText(test_out, indent, y_out)
|
||||
text = remain
|
||||
y = y + y_line
|
||||
return y - y_line
|
||||
@@ -496,8 +496,8 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase):
|
||||
brush = wx.Brush(colour, wx.SOLID)
|
||||
self.DC.SetBrush(brush)
|
||||
height = self.label_space + self.label_pt_space_before + self.label_pt_space_after
|
||||
self.DC.DrawRectangle((self.column[0], self.y),
|
||||
(self.end_x-self.column[0]+1, height))
|
||||
self.DC.DrawRectangle(self.column[0], self.y,
|
||||
self.end_x-self.column[0]+1, height)
|
||||
|
||||
def ColourRowCells(self, height):
|
||||
if self.draw == False:
|
||||
@@ -515,7 +515,7 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase):
|
||||
|
||||
start_x = self.column[col]
|
||||
width = self.column[col+1] - start_x + 2
|
||||
self.DC.DrawRectangle((start_x, self.y), (width, height))
|
||||
self.DC.DrawRectangle(start_x, self.y, width, height)
|
||||
col = col + 1
|
||||
|
||||
def PrintRow(self, row_val, draw = True, align = wx.ALIGN_LEFT):
|
||||
@@ -586,7 +586,7 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase):
|
||||
|
||||
y_out = self.y
|
||||
# y_out = self.y + self.pt_space_before + self.pt_space_after # adjust for extra spacing
|
||||
self.DC.DrawLine((self.column[0], y_out), (self.end_x, y_out))
|
||||
self.DC.DrawLine(self.column[0], y_out, self.end_x, y_out)
|
||||
|
||||
def DrawColumns(self):
|
||||
if self.draw == True:
|
||||
@@ -605,7 +605,7 @@ class PrintTableDraw(wx.ScrolledWindow, PrintBase):
|
||||
indent = val
|
||||
|
||||
self.DC.SetPen(wx.Pen(colour, size))
|
||||
self.DC.DrawLine((indent, self.y_start), (indent, self.y))
|
||||
self.DC.DrawLine(indent, self.y_start, indent, self.y)
|
||||
col = col + 1
|
||||
|
||||
def DrawText(self):
|
||||
|
@@ -113,8 +113,8 @@ class RowColSizer(wx.PySizer):
|
||||
assert row != -1, "Row must be specified"
|
||||
assert col != -1, "Column must be specified"
|
||||
|
||||
wx.PySizer.AddSpacer(self, (width, height), option, flag, border,
|
||||
userData=(row, col, row+rowspan, col+colspan))
|
||||
wx.PySizer.Add(self, (width, height), option, flag, border,
|
||||
userData=(row, col, row+rowspan, col+colspan))
|
||||
|
||||
#--------------------------------------------------
|
||||
def _add( self, size, dim ):
|
||||
|
@@ -89,17 +89,17 @@ class RightTextCtrl(wx.TextCtrl):
|
||||
dc.SetTextForeground(fclr)
|
||||
|
||||
dc.SetClippingRegion((0, 0), (dcwidth, dcheight))
|
||||
dc.DrawText(text, (x, y))
|
||||
dc.DrawText(text, x, y)
|
||||
|
||||
if x < 0:
|
||||
toofat = '...'
|
||||
markwidth = dc.GetTextExtent(toofat)[0]
|
||||
dc.SetPen(wx.Pen(dc.GetBackground().GetColour(), 1, wx.SOLID ))
|
||||
dc.DrawRectangle((0,0), (markwidth, dcheight))
|
||||
dc.DrawRectangle(0,0, markwidth, dcheight)
|
||||
dc.SetPen(wx.Pen(wx.RED, 1, wx.SOLID ))
|
||||
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||
dc.DrawRectangle((1, 1), (dcwidth-2, dcheight-2))
|
||||
dc.DrawText(toofat, (1, y))
|
||||
dc.DrawRectangle(1, 1, dcwidth-2, dcheight-2)
|
||||
dc.DrawText(toofat, 1, y)
|
||||
|
||||
|
||||
def OnKillFocus(self, event):
|
||||
|
@@ -93,7 +93,7 @@ class SplashScreen(wx.Frame):
|
||||
|
||||
def OnPaint(self, event):
|
||||
dc = wx.PaintDC(self)
|
||||
dc.DrawBitmap(self.bitmap, (0,0), False)
|
||||
dc.DrawBitmap(self.bitmap, 0,0, False)
|
||||
|
||||
def OnEraseBG(self, event):
|
||||
pass
|
||||
|
@@ -131,7 +131,7 @@ class GenStaticText(wx.PyControl):
|
||||
x = width - w
|
||||
if style & wx.ALIGN_CENTER:
|
||||
x = (width - w)/2
|
||||
dc.DrawText(line, (x, y))
|
||||
dc.DrawText(line, x, y)
|
||||
y += h
|
||||
|
||||
|
||||
|
@@ -143,13 +143,13 @@ class Throbber(wx.PyPanel):
|
||||
|
||||
|
||||
def Draw(self, dc):
|
||||
dc.DrawBitmap(self.submaps[self.sequence[self.current]], (0, 0), True)
|
||||
dc.DrawBitmap(self.submaps[self.sequence[self.current]], 0, 0, True)
|
||||
if self.overlay and self.showOverlay:
|
||||
dc.DrawBitmap(self.overlay, (self.overlayX, self.overlayY), True)
|
||||
dc.DrawBitmap(self.overlay, self.overlayX, self.overlayY, True)
|
||||
if self.label and self.showLabel:
|
||||
dc.DrawText(self.label, (self.labelX, self.labelY))
|
||||
dc.DrawText(self.label, self.labelX, self.labelY)
|
||||
dc.SetTextForeground(wx.WHITE)
|
||||
dc.DrawText(self.label, (self.labelX-1, self.labelY-1))
|
||||
dc.DrawText(self.label, self.labelX-1, self.labelY-1)
|
||||
|
||||
|
||||
def OnPaint(self, event):
|
||||
|
@@ -135,7 +135,7 @@ class PolyMarker(PolyPoints):
|
||||
f(dc, xc, yc, size)
|
||||
|
||||
def _circle(self, dc, xc, yc, size=1):
|
||||
dc.DrawEllipse((xc-2.5*size,yc-2.5*size), (5.*size,5.*size))
|
||||
dc.DrawEllipse(xc-2.5*size,yc-2.5*size, 5.*size,5.*size)
|
||||
|
||||
def _dot(self, dc, xc, yc, size=1):
|
||||
dc.DrawPoint(xc,yc)
|
||||
@@ -154,12 +154,12 @@ class PolyMarker(PolyPoints):
|
||||
(0.0,0.577350*size*5)],xc,yc)
|
||||
|
||||
def _cross(self, dc, xc, yc, size=1):
|
||||
dc.DrawLine((xc-2.5*size, yc-2.5*size), (xc+2.5*size,yc+2.5*size))
|
||||
dc.DrawLine((xc-2.5*size,yc+2.5*size), (xc+2.5*size,yc-2.5*size))
|
||||
dc.DrawLine(xc-2.5*size, yc-2.5*size, xc+2.5*size,yc+2.5*size)
|
||||
dc.DrawLine(xc-2.5*size,yc+2.5*size, xc+2.5*size,yc-2.5*size)
|
||||
|
||||
def _plus(self, dc, xc, yc, size=1):
|
||||
dc.DrawLine((xc-2.5*size,yc), (xc+2.5*size,yc))
|
||||
dc.DrawLine((xc,yc-2.5*size,xc), (yc+2.5*size))
|
||||
dc.DrawLine(xc-2.5*size,yc, xc+2.5*size,yc)
|
||||
dc.DrawLine(xc,yc-2.5*size,xc, yc+2.5*size)
|
||||
|
||||
class PlotGraphics:
|
||||
|
||||
@@ -318,12 +318,12 @@ class PlotCanvas(wx.Window):
|
||||
for y, d in [(bb1[1], -3), (bb2[1], 3)]:
|
||||
p1 = scale*Numeric.array([lower, y])+shift
|
||||
p2 = scale*Numeric.array([upper, y])+shift
|
||||
dc.DrawLine((p1[0],p1[1]), (p2[0],p2[1]))
|
||||
dc.DrawLine(p1[0],p1[1], p2[0],p2[1])
|
||||
for x, label in xticks:
|
||||
p = scale*Numeric.array([x, y])+shift
|
||||
dc.DrawLine((p[0],p[1]), (p[0],p[1]+d))
|
||||
dc.DrawLine(p[0],p[1], p[0],p[1]+d)
|
||||
if text:
|
||||
dc.DrawText(label, (p[0],p[1]))
|
||||
dc.DrawText(label, p[0],p[1])
|
||||
text = 0
|
||||
|
||||
if yaxis is not None:
|
||||
@@ -333,13 +333,13 @@ class PlotCanvas(wx.Window):
|
||||
for x, d in [(bb1[0], -3), (bb2[0], 3)]:
|
||||
p1 = scale*Numeric.array([x, lower])+shift
|
||||
p2 = scale*Numeric.array([x, upper])+shift
|
||||
dc.DrawLine((p1[0],p1[1]), (p2[0],p2[1]))
|
||||
dc.DrawLine(p1[0],p1[1], p2[0],p2[1])
|
||||
for y, label in yticks:
|
||||
p = scale*Numeric.array([x, y])+shift
|
||||
dc.DrawLine((p[0],p[1]), (p[0]-d,p[1]))
|
||||
dc.DrawLine(p[0],p[1], p[0]-d,p[1])
|
||||
if text:
|
||||
dc.DrawText(label,
|
||||
(p[0]-dc.GetTextExtent(label)[0], p[1]-0.5*h))
|
||||
p[0]-dc.GetTextExtent(label)[0], p[1]-0.5*h)
|
||||
text = 0
|
||||
|
||||
def _ticks(self, lower, upper):
|
||||
|
Reference in New Issue
Block a user