Lots of bup fixes, API updates, etc

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24621 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-11-21 07:39:05 +00:00
parent fbd5dd1dfa
commit 7722248d75
36 changed files with 462 additions and 352 deletions

View File

@@ -103,7 +103,7 @@ class Canvas(wxWindow):
"""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):

View File

@@ -134,15 +134,15 @@ class wxPyColourChooser(wxPanel):
self.custom_boxs.append(custom)
csizer = wxBoxSizer(wxVERTICAL)
csizer.Add(1, 25)
csizer.Add((1, 25))
csizer.Add(self.basic_label, 0, wxEXPAND)
csizer.Add(1, 5)
csizer.Add((1, 5))
csizer.Add(colour_grid, 0, wxEXPAND)
csizer.Add(1, 25)
csizer.Add((1, 25))
csizer.Add(self.custom_label, 0, wxEXPAND)
csizer.Add(1, 5)
csizer.Add((1, 5))
csizer.Add(custom_grid, 0, wxEXPAND)
csizer.Add(1, 5)
csizer.Add((1, 5))
csizer.Add(self.add_button, 0, wxEXPAND)
self.palette = pypalette.PyPalette(self, -1)
@@ -152,7 +152,7 @@ class wxPyColourChooser(wxPanel):
EVT_COMMAND_SCROLL(self, self.idSCROLL, self.onScroll)
psizer = wxBoxSizer(wxHORIZONTAL)
psizer.Add(self.palette, 0, 0)
psizer.Add(10, 1)
psizer.Add((10, 1))
psizer.Add(self.colour_slider, 0, wxALIGN_CENTER_VERTICAL)
psizer.Add(self.slider, 0, wxALIGN_CENTER_VERTICAL)
@@ -166,7 +166,7 @@ class wxPyColourChooser(wxPanel):
slabel = wxStaticText(self, -1, _("Solid Colour"))
ssizer = wxBoxSizer(wxVERTICAL)
ssizer.Add(self.solid, 0, 0)
ssizer.Add(1, 2)
ssizer.Add((1, 2))
ssizer.Add(slabel, 0, wxALIGN_CENTER_HORIZONTAL)
hlabel = wxStaticText(self, -1, _("H:"))
@@ -212,15 +212,15 @@ class wxPyColourChooser(wxPanel):
hsizer.Add(gsizer, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
vsizer = wxBoxSizer(wxVERTICAL)
vsizer.Add(1, 5)
vsizer.Add((1, 5))
vsizer.Add(psizer, 0, 0)
vsizer.Add(1, 15)
vsizer.Add((1, 15))
vsizer.Add(hsizer, 0, wxEXPAND)
sizer = wxBoxSizer(wxHORIZONTAL)
sizer.Add(5, 1)
sizer.Add((5, 1))
sizer.Add(csizer, 0, wxEXPAND)
sizer.Add(10, 1)
sizer.Add((10, 1))
sizer.Add(vsizer, 0, wxEXPAND)
self.SetAutoLayout(True)
self.SetSizer(sizer)

View File

@@ -58,7 +58,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
@@ -78,5 +78,5 @@ class PyColourSlider(canvas.Canvas):
r,g,b = [c * 255.0 for c in colorsys.hsv_to_rgb(h,s,v)]
colour = wxColour(int(r), int(g), int(b))
self.buffer.SetPen(wxPen(colour, 1, wxSOLID))
self.buffer.DrawRectangle(0, y_pos, 15, 1)
self.buffer.DrawRectangle((0, y_pos), (15, 1))
v = v - vstep

View File

@@ -163,12 +163,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
@@ -176,7 +176,7 @@ class PyPalette(canvas.Canvas):
colour = wxColour(0, 0, 0)
self.buffer.SetPen(wxPen(colour, 1, wxSOLID))
self.buffer.SetBrush(wxBrush(colour, wxTRANSPARENT))
self.buffer.DrawCircle(x, y, 3)
self.buffer.DrawCircle((x, y), 3)
self.Refresh()
def GeneratePaletteBMP(self, file_name, granularity=1):
@@ -204,9 +204,8 @@ class PyPalette(canvas.Canvas):
colour = wxColour(int(r * 255.0), int(g * 255.0), int(b * 255.0))
self.buffer.SetPen(wxPen(colour, 1, wxSOLID))
self.buffer.SetBrush(wxBrush(colour, wxSOLID))
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()

View File

@@ -661,9 +661,10 @@ _haveUpdated = False
def updateColourDB():
global _haveUpdated
if not _haveUpdated:
from wxPython.wx import wxTheColourDatabase
import wx
assert wx.GetApp() is not None, "You must have a wx.App object before you can use the colour database."
cl = getColourInfoList()
for info in cl:
wxTheColourDatabase.Append(*info)
wx.TheColourDatabase.Append(*info)

View File

@@ -32,42 +32,91 @@ from wxPython.wx import *
EVT_COMMAND_COLOURSELECT = wxNewId()
class ColourSelectEvent(wxPyCommandEvent):
def __init__(self, id, value):
wxPyCommandEvent.__init__(self, id = id)
self.SetEventType(EVT_COMMAND_COLOURSELECT)
self.value = value
def __init__(self, id, value):
wxPyCommandEvent.__init__(self, id = id)
self.SetEventType(EVT_COMMAND_COLOURSELECT)
self.value = value
def GetValue(self):
return self.value
def GetValue(self):
return self.value
def EVT_COLOURSELECT(win, id, func):
win.Connect(id, -1, EVT_COMMAND_COLOURSELECT, func)
class ColourSelect(wxButton):
def __init__(self, parent, id, label = "", bcolour=(0, 0, 0),
pos = wxDefaultPosition, size = wxDefaultSize,
callback = None):
wxButton.__init__(self, parent, id, label, pos=pos, size=size)
self.SetColour(bcolour)
class ColourSelect(wxBitmapButton):
def __init__(self, parent, id, label="", colour=wxBLACK,
pos=wxDefaultPosition, size=wxDefaultSize,
callback=None, style=0):
if label:
w, h = parent.GetTextExtent(label)
w += 6
h += 6
else:
w, h = 20, 20
wxBitmapButton.__init__(self, parent, id, wxEmptyBitmap(w,h),
pos=pos, size=size, style=style|wxBU_AUTODRAW)
if type(colour) == type( () ):
colour = wxColour(*colour)
self.colour = colour
self.SetLabel(label)
self.callback = callback
bmp = self.MakeBitmap()
self.SetBitmap(bmp)
EVT_BUTTON(parent, self.GetId(), self.OnClick)
def GetColour(self):
return self.set_colour
return self.colour
def GetValue(self):
return self.set_colour
return self.colour
def SetColour(self, bcolour):
self.set_colour_val = wxColor(bcolour[0], bcolour[1], bcolour[2])
self.SetBackgroundColour(self.set_colour_val)
avg = reduce(lambda a, b: a + b, bcolour) / 3
fcolour = avg > 128 and (0, 0, 0) or (255, 255, 255)
self.SetForegroundColour(apply(wxColour, fcolour))
self.set_colour = bcolour
def SetValue(self, bcolour):
self.SetColour(bcolour)
def SetValue(self, colour):
self.SetColour(colour)
def SetColour(self, colour):
if type(colour) == type( () ):
colour = wxColour(*colour)
self.colour = colour
bmp = self.MakeBitmap()
self.SetBitmap(bmp)
def MakeBitmap(self):
bdr = 10
sz = self.GetSize()
bmp = wxEmptyBitmap(sz.width-bdr, sz.height-bdr)
dc = wxMemoryDC()
dc.SelectObject(bmp)
label = self.GetLabel()
# Just make a little colored bitmap
dc.SetBackground(wxBrush(self.colour))
dc.Clear()
if label:
# Add a label to it
avg = reduce(lambda a, b: a + b, self.colour.Get()) / 3
fcolour = avg > 128 and wxBLACK or wxWHITE
dc.SetTextForeground(fcolour)
dc.DrawLabel(label, (0,0, sz.width-bdr, sz.height-bdr),
wxALIGN_CENTER)
dc.SelectObject(wxNullBitmap)
return bmp
def SetBitmap(self, bmp):
self.SetBitmapLabel(bmp)
self.SetBitmapSelected(bmp)
self.SetBitmapDisabled(bmp)
self.SetBitmapFocus(bmp)
self.SetBitmapSelected(bmp)
def OnChange(self):
wxPostEvent(self, ColourSelectEvent(self.GetId(), self.GetValue()))
@@ -77,12 +126,12 @@ class ColourSelect(wxButton):
def OnClick(self, event):
data = wxColourData()
data.SetChooseFull(True)
data.SetColour(self.set_colour_val)
data.SetColour(self.colour)
dlg = wxColourDialog(self.GetParent(), data)
changed = dlg.ShowModal() == wxID_OK
if changed:
data = dlg.GetColourData()
self.SetColour(data.GetColour().Get())
self.SetColour(data.GetColour())
dlg.Destroy()
if changed:

View File

@@ -149,12 +149,12 @@ class wxEditor(wxScrolledWindow):
else:
self.sh = self.bh / self.fh
if self.LinesInFile() >= self.sh:
self.bw = self.bw - wxSystemSettings_GetSystemMetric(wxSYS_VSCROLL_X)
self.bw = self.bw - wxSystemSettings_GetMetric(wxSYS_VSCROLL_X)
self.sw = (self.bw / self.fw) - 1
self.sw = (self.bw / self.fw) - 1
if self.CalcMaxLineLen() >= self.sw:
self.bh = self.bh - wxSystemSettings_GetSystemMetric(wxSYS_HSCROLL_Y)
self.bh = self.bh - wxSystemSettings_GetMetric(wxSYS_HSCROLL_Y)
self.sh = self.bh / self.fh
@@ -197,7 +197,7 @@ class wxEditor(wxScrolledWindow):
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):
@@ -245,7 +245,7 @@ class wxEditor(wxScrolledWindow):
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
@@ -274,7 +274,7 @@ class wxEditor(wxScrolledWindow):
szy = self.fh
x = xp * szx
y = yp * szy
dc.Blit(x,y,szx,szy,dc,x,y,wxSRC_INVERT)
dc.Blit((x,y), (szx,szy), dc, (x,y), wxSRC_INVERT)
self.sco_x = xp
self.sco_y = yp

View File

@@ -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))
#---------------------------------------------------------------------------
@@ -808,13 +808,13 @@ class FloatCanvas(wxPanel):
tb.SetToolBitmapSize((23,23))
tb.AddTool(ID_ZOOM_IN_BUTTON, GetPlusBitmap(), isToggle=true,shortHelpString = "Zoom In")
tb.AddTool(ID_ZOOM_IN_BUTTON, GetPlusBitmap(), isToggle=True,shortHelpString = "Zoom In")
EVT_TOOL(self, ID_ZOOM_IN_BUTTON, self.SetMode)
tb.AddTool(ID_ZOOM_OUT_BUTTON, GetMinusBitmap(), isToggle=true,shortHelpString = "Zoom Out")
tb.AddTool(ID_ZOOM_OUT_BUTTON, GetMinusBitmap(), isToggle=True,shortHelpString = "Zoom Out")
EVT_TOOL(self, ID_ZOOM_OUT_BUTTON, self.SetMode)
tb.AddTool(ID_MOVE_MODE_BUTTON, GetHandBitmap(), isToggle=true,shortHelpString = "Move")
tb.AddTool(ID_MOVE_MODE_BUTTON, GetHandBitmap(), isToggle=True,shortHelpString = "Move")
EVT_TOOL(self, ID_MOVE_MODE_BUTTON, self.SetMode)
tb.AddSeparator()
@@ -869,8 +869,8 @@ class FloatCanvas(wxPanel):
dc.SetBrush(wxTRANSPARENT_BRUSH)
dc.SetLogicalFunction(wxXOR)
if self.PrevRBBox:
dc.DrawRectangle(*self.PrevRBBox)
dc.DrawRectangle(x_c-w/2,y_c-h/2,w,h)
dc.DrawRectangleXY(*self.PrevRBBox)
dc.DrawRectangleXY(x_c-w/2,y_c-h/2,w,h)
self.PrevRBBox = (x_c-w/2,y_c-h/2,w,h)
dc.EndDrawing()
@@ -908,8 +908,8 @@ class FloatCanvas(wxPanel):
dc.SetBrush(wxTRANSPARENT_BRUSH)
dc.SetLogicalFunction(wxXOR)
if self.PrevMoveBox:
dc.DrawRectangle(*self.PrevMoveBox)
dc.DrawRectangle(x_tl,y_tl,w,h)
dc.DrawRectangleXY(*self.PrevMoveBox)
dc.DrawRectangleXY(x_tl,y_tl,w,h)
self.PrevMoveBox = (x_tl,y_tl,w,h)
dc.EndDrawing()
@@ -954,7 +954,7 @@ class FloatCanvas(wxPanel):
def OnPaint(self, event):
#dc = wxBufferedPaintDC(self.DrawPanel, self._Buffer)
dc = wxPaintDC(self.DrawPanel)
dc.DrawBitmap(self._Buffer,0,0)
dc.DrawBitmap(self._Buffer, (0,0))
def Draw(self):
"""
@@ -990,7 +990,7 @@ class FloatCanvas(wxPanel):
i+=1
Object._Draw(dc,self.WorldToPixel,self.ScaleFunction)
if i % self.NumBetweenBlits == 0:
ScreenDC.Blit(0, 0, self.PanelSize[0],self.PanelSize[1], dc, 0, 0)
ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
dc.EndDrawing()
else:
dc.Clear()
@@ -1005,7 +1005,7 @@ class FloatCanvas(wxPanel):
i+=1
Object._Draw(dc,self.WorldToPixel,self.ScaleFunction)
if i % self.NumBetweenBlits == 0:
ScreenDC.Blit(0, 0, self.PanelSize[0],self.PanelSize[1], dc, 0, 0)
ScreenDC.Blit((0, 0), self.PanelSize, dc, (0, 0))
dc.EndDrawing()
else: # not using a Background DC
dc = wxMemoryDC()
@@ -1021,25 +1021,25 @@ class FloatCanvas(wxPanel):
i+=1
Object._Draw(dc,self.WorldToPixel,self.ScaleFunction)
if i % self.NumBetweenBlits == 0:
ScreenDC.Blit(0, 0, self.PanelSize[0],self.PanelSize[1], dc, 0, 0)
ScreenDC.Blit((0, 0), self.PanelSize, 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[0],self.PanelSize[1], dc, 0, 0)
ScreenDC.Blit((0, 0), self.PanelSize, 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(wxPen('WHITE', 2,wxSHORT_DASH))
ScreenDC.SetBrush(wxTRANSPARENT_BRUSH)
ScreenDC.SetLogicalFunction(wxXOR)
ScreenDC.DrawRectangle(*self.PrevRBBox)
ScreenDC.DrawRectangleXY(*self.PrevRBBox)
elif self.PrevMoveBox:
ScreenDC.SetPen(wxPen('WHITE', 1,))
ScreenDC.SetBrush(wxTRANSPARENT_BRUSH)
ScreenDC.SetLogicalFunction(wxXOR)
ScreenDC.DrawRectangle(*self.PrevMoveBox)
ScreenDC.DrawRectangleXY(*self.PrevMoveBox)
if self.Debug: print "Drawing took %f seconds of CPU time"%(clock()-start)
def BBCheck(self, BB1, BB2):

View File

@@ -92,7 +92,7 @@ wxGrid.RowToRect = _RowToRect
class ColDragWindow(wxWindow):
def __init__(self,parent,image,dragCol):
wxWindow.__init__(self,parent,wxSIMPLE_BORDER)
wxWindow.__init__(self,parent,-1, style=wxSIMPLE_BORDER)
self.image = image
self.SetSize((self.image.GetWidth(),self.image.GetHeight()))
self.ux = parent.GetScrollPixelsPerUnit()[0]
@@ -139,19 +139,19 @@ class ColDragWindow(wxWindow):
def OnPaint(self,evt):
dc = wxPaintDC(self)
w,h = self.GetSize()
dc.DrawBitmap(self.image,0,0)
dc.DrawBitmap(self.image, (0,0))
dc.SetPen(wxPen(wxBLACK,1,wxSOLID))
dc.SetBrush(wxTRANSPARENT_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))
class RowDragWindow(wxWindow):
def __init__(self,parent,image,dragRow):
wxWindow.__init__(self,parent,wxSIMPLE_BORDER)
wxWindow.__init__(self,parent,-1, style=wxSIMPLE_BORDER)
self.image = image
self.SetSize((self.image.GetWidth(),self.image.GetHeight()))
self.uy = parent.GetScrollPixelsPerUnit()[1]
@@ -198,12 +198,12 @@ class RowDragWindow(wxWindow):
def OnPaint(self,evt):
dc = wxPaintDC(self)
w,h = self.GetSize()
dc.DrawBitmap(self.image,0,0)
dc.DrawBitmap(self.image, (0,0))
dc.SetPen(wxPen(wxBLACK,1,wxSOLID))
dc.SetBrush(wxTRANSPARENT_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))
#----------------------------------------------------------------------------
@@ -306,7 +306,7 @@ class wxGridColMover(wxEvtHandler):
memdc = wxMemoryDC()
memdc.SelectObject(bmp)
dc = wxWindowDC(self.lwin)
memdc.Blit(0,0,rect.width,rect.height,dc,rect.x,rect.y)
memdc.Blit((0,0), rect.GetSize(), dc, rect.GetPosition())
memdc.SelectObject(wxNullBitmap)
return bmp
@@ -411,7 +411,7 @@ class wxGridRowMover(wxEvtHandler):
memdc = wxMemoryDC()
memdc.SelectObject(bmp)
dc = wxWindowDC(self.lwin)
memdc.Blit(0,0,rect.width,rect.height,dc,rect.x,rect.y)
memdc.Blit((0,0), rect.GetSize(), dc, rect.GetPosition())
memdc.SelectObject(wxNullBitmap)
return bmp

View File

@@ -1723,7 +1723,7 @@ class wxMaskedEditMixin:
'foregroundColour', 'signedForegroundColour'):
if ctrl_kwargs.has_key(key):
if type(ctrl_kwargs[key]) in (types.StringType, types.UnicodeType):
c = wxNamedColor(ctrl_kwargs[key])
c = wxNamedColour(ctrl_kwargs[key])
if c.Get() == (-1, -1, -1):
raise TypeError('%s not a legal color specification for %s' % (repr(ctrl_kwargs[key]), key))
else:
@@ -2262,7 +2262,7 @@ class wxMaskedEditMixin:
# if no fillchar change, but old value == old template, replace it:
if newvalue == old_template:
newvalue = self._template
reset_value = true
reset_value = True
else:
self._defaultValue = None
@@ -2768,7 +2768,7 @@ class wxMaskedEditMixin:
if newfield != field and newfield._selectOnFieldEntry:
dbg('queuing selection: (%d, %d)' % (newfield._extent[0], newfield._extent[1]))
wxCallAfter(self._SetSelection, newfield._extent[0], newfield._extent[1])
keep_processing = false
keep_processing = False
elif keep_processing:
dbg('char not allowed')
@@ -2985,7 +2985,7 @@ class wxMaskedEditMixin:
def _OnCtrl_Z(self, event=None):
""" Handles ctrl-Z keypress in control and Undo operation on context menu.
Should return false to skip other processing. """
Should return False to skip other processing. """
dbg("wxMaskedEditMixin::_OnCtrl_Z", indent=1)
self.Undo()
dbg(indent=0)
@@ -3415,7 +3415,7 @@ class wxMaskedEditMixin:
dbg('cursor before 1st field; cannot change to a previous field')
if not wxValidator_IsSilent():
wxBell()
return false
return False
if event.ControlDown():
dbg('queuing select to beginning of field:', field_start, pos)
@@ -4218,7 +4218,7 @@ class wxMaskedEditMixin:
if self._isTemplateChar( pos ): ## if a template character, return empty
dbg('%d is a template character; returning false' % pos, indent=0)
dbg('%d is a template character; returning False' % pos, indent=0)
return False
if self._isMaskChar( pos ):
@@ -4263,7 +4263,7 @@ class wxMaskedEditMixin:
dbg(indent=0)
return approved
else:
dbg('%d is a !???! character; returning false', indent=0)
dbg('%d is a !???! character; returning False', indent=0)
return False
@@ -4846,7 +4846,7 @@ class wxMaskedEditMixin:
else:
text = candidate
valid = True # assume true
valid = True # assume True
for i in [-1] + self._field_indices: # process global constraints first:
field = self._fields[i]
start, end = field._extent
@@ -5840,12 +5840,12 @@ class wxMaskedTextCtrl( wxTextCtrl, wxMaskedEditMixin ):
self._isNeg = False # (clear current assumptions)
value = self._adjustInt(value)
elif self._isDate and not self.IsValid(value) and self._4digityear:
value = self._adjustDate(value, fixcentury=true)
value = self._adjustDate(value, fixcentury=True)
except ValueError:
# If date, year might be 2 digits vs. 4; try adjusting it:
if self._isDate and self._4digityear:
dateparts = value.split(' ')
dateparts[0] = self._adjustDate(dateparts[0], fixcentury=true)
dateparts[0] = self._adjustDate(dateparts[0], fixcentury=True)
value = string.join(dateparts, ' ')
dbg('adjusted value: "%s"' % value)
value = self._Paste(value, raise_on_invalid=True, just_return_value=True)
@@ -6157,12 +6157,12 @@ class wxMaskedComboBox( wxComboBox, wxMaskedEditMixin ):
self._isNeg = False # (clear current assumptions)
value = self._adjustInt(value)
elif self._isDate and not self.IsValid(value) and self._4digityear:
value = self._adjustDate(value, fixcentury=true)
value = self._adjustDate(value, fixcentury=True)
except ValueError:
# If date, year might be 2 digits vs. 4; try adjusting it:
if self._isDate and self._4digityear:
dateparts = value.split(' ')
dateparts[0] = self._adjustDate(dateparts[0], fixcentury=true)
dateparts[0] = self._adjustDate(dateparts[0], fixcentury=True)
value = string.join(dateparts, ' ')
dbg('adjusted value: "%s"' % value)
value = self._Paste(value, raise_on_invalid=True, just_return_value=True)
@@ -6547,7 +6547,7 @@ class wxIpAddrCtrl( wxMaskedTextCtrl ):
dbg(indent=0)
raise ValueError('%s must be a string', str(value))
bValid = True # assume true
bValid = True # assume True
parts = value.split('.')
if len(parts) != 4:
bValid = False

View File

@@ -592,10 +592,8 @@ class MultiCreator(wxWindow):
dc.SetBackground(wxBrush(self.GetBackgroundColour(),wxSOLID))
dc.Clear()
highlight = wxPen(wxSystemSettings_GetSystemColour(
wxSYS_COLOUR_BTNHIGHLIGHT),1,wxSOLID)
shadow = wxPen(wxSystemSettings_GetSystemColour(
wxSYS_COLOUR_BTNSHADOW),1,wxSOLID)
highlight = wxPen(wxSystemSettings_GetColour(wxSYS_COLOUR_BTNHIGHLIGHT), 1, wxSOLID)
shadow = wxPen(wxSystemSettings_GetColour(wxSYS_COLOUR_BTNSHADOW), 1, wxSOLID)
black = wxPen(wxBLACK,1,wxSOLID)
w,h = self.GetSizeTuple()
w -= 1
@@ -603,13 +601,13 @@ class MultiCreator(wxWindow):
# 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))
#----------------------------------------------------------------------
@@ -685,11 +683,11 @@ def DrawSash(win,x,y,direction):
bmp = wxEmptyBitmap(8,8)
bdc = wxMemoryDC()
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 = wxBrush(wxColour(0,0,0))
brush.SetStipple(bmp)
@@ -719,8 +717,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()

View File

@@ -29,12 +29,12 @@ class PopButton(wxPyControl):
EVT_PAINT(self, self.OnPaint)
def InitColours(self):
faceClr = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_BTNFACE)
faceClr = wxSystemSettings_GetColour(wxSYS_COLOUR_BTNFACE)
self.faceDnClr = faceClr
self.SetBackgroundColour(faceClr)
shadowClr = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_BTNSHADOW)
highlightClr = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_BTNHIGHLIGHT)
shadowClr = wxSystemSettings_GetColour(wxSYS_COLOUR_BTNSHADOW)
highlightClr = wxSystemSettings_GetColour(wxSYS_COLOUR_BTNHIGHLIGHT)
self.shadowPen = wxPen(shadowClr, 1, wxSOLID)
self.highlightPen = wxPen(highlightClr, 1, wxSOLID)
self.blackPen = wxPen(wxBLACK, 1, wxSOLID)
@@ -95,8 +95,8 @@ class PopButton(wxPyControl):
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:
@@ -104,20 +104,20 @@ class PopButton(wxPyControl):
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):
size = self.GetSize()
mx = size.x / 2
my = size.y / 2
mx = size.width / 2
my = size.height / 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.GetClientSizeTuple()
@@ -161,15 +161,15 @@ class wxPopupDialog(wxDialog):
selfSize = self.GetSize()
tcSize = self.ctrl.GetSize()
pos.x -= (selfSize.x - tcSize.x) / 2
if pos.x + selfSize.x > dSize.x:
pos.x = dSize.x - selfSize.x
pos.x -= (selfSize.width - tcSize.width) / 2
if pos.x + selfSize.width > dSize.width:
pos.x = dSize.width - selfSize.width
if pos.x < 0:
pos.x = 0
pos.y += tcSize.height
if pos.y + selfSize.y > dSize.y:
pos.y = dSize.y - selfSize.y
if pos.y + selfSize.height > dSize.height:
pos.y = dSize.height - selfSize.height
if pos.y < 0:
pos.y = 0