mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-23 07:36:37 +00:00
MiRCARTCanvas.py:resize(): clean up & fix.
MiRCARTCanvasInterface.py:_updateCanvasSize(): merged into ...Canvas.resize(). MiRCARTCanvasInterface.py:canvas{De,In}crCanvas{Height,Width}(): directly call ...Canvas.resize().
This commit is contained in:
parent
7192b66805
commit
55b88412c9
@ -137,30 +137,48 @@ class MiRCARTCanvas(wx.Panel):
|
|||||||
def resize(self, newCanvasSize):
|
def resize(self, newCanvasSize):
|
||||||
if newCanvasSize != self.canvasSize:
|
if newCanvasSize != self.canvasSize:
|
||||||
if self.canvasMap == None:
|
if self.canvasMap == None:
|
||||||
self.canvasMap = [[[(1, 1), 0, " "] \
|
self.canvasMap = []; oldCanvasSize = [0, 0];
|
||||||
for x in range(self.canvasSize[0])] \
|
|
||||||
for y in range(self.canvasSize[1])]
|
|
||||||
else:
|
else:
|
||||||
for numRow in range(self.canvasSize[1]):
|
oldCanvasSize = self.canvasSize
|
||||||
for numNewCol in range(self.canvasSize[0], newCanvasSize[0]):
|
deltaCanvasSize = [b-a for a,b in zip(oldCanvasSize, newCanvasSize)]
|
||||||
self.canvasMap[numRow].append([[1, 1], 0, " "])
|
|
||||||
for numNewRow in range(self.canvasSize[1], newCanvasSize[1]):
|
newWinSize = [a*b for a,b in zip(newCanvasSize, self.canvasBackend.cellSize)]
|
||||||
self.canvasMap.append([])
|
|
||||||
for numNewCol in range(newCanvasSize[0]):
|
|
||||||
self.canvasMap[numNewRow].append([[1, 1], 0, " "])
|
|
||||||
self.canvasSize = newCanvasSize
|
|
||||||
newWinSize = [a*b for a,b in \
|
|
||||||
zip(self.canvasSize, self.canvasBackend.cellSize)]
|
|
||||||
self.SetMinSize(newWinSize)
|
self.SetMinSize(newWinSize)
|
||||||
self.SetSize(wx.DefaultCoord, wx.DefaultCoord, *newWinSize)
|
self.SetSize(wx.DefaultCoord, wx.DefaultCoord, *newWinSize)
|
||||||
curWindow = self
|
curWindow = self
|
||||||
while curWindow != None:
|
while curWindow != None:
|
||||||
curWindow.Layout()
|
curWindow.Layout()
|
||||||
curWindow = curWindow.GetParent()
|
curWindow = curWindow.GetParent()
|
||||||
self.canvasBackend.reset(self.canvasSize, self.canvasBackend.cellSize)
|
|
||||||
|
self.canvasBackend.resize(newCanvasSize, self.canvasBackend.cellSize)
|
||||||
|
eventDc = self.canvasBackend.getDeviceContext(self)
|
||||||
self.canvasJournal.resetCursor(); self.canvasJournal.resetUndo();
|
self.canvasJournal.resetCursor(); self.canvasJournal.resetUndo();
|
||||||
self.parentFrame.onCanvasUpdate( \
|
|
||||||
size=self.canvasSize, undoLevel=-1)
|
if deltaCanvasSize[0] < 0:
|
||||||
|
for numRow in range(oldCanvasSize[1]):
|
||||||
|
del self.canvasMap[numRow][-1:(deltaCanvasSize[0]-1):-1]
|
||||||
|
else:
|
||||||
|
for numRow in range(oldCanvasSize[1]):
|
||||||
|
self.canvasMap[numRow].extend( \
|
||||||
|
[[[1, 1], 0, " "]] * deltaCanvasSize[0])
|
||||||
|
for numNewCol in range(oldCanvasSize[0], newCanvasSize[0]):
|
||||||
|
self.canvasBackend.drawPatch( \
|
||||||
|
eventDc, [[numNewCol, numRow], \
|
||||||
|
*self.canvasMap[numRow][-1]])
|
||||||
|
if deltaCanvasSize[1] < 0:
|
||||||
|
del self.canvasMap[-1:(deltaCanvasSize[1]-1):-1]
|
||||||
|
else:
|
||||||
|
for numNewRow in range(oldCanvasSize[1], newCanvasSize[1]):
|
||||||
|
self.canvasMap.extend( \
|
||||||
|
[[[[1, 1], 0, " "]] * newCanvasSize[0]])
|
||||||
|
for numNewCol in range(newCanvasSize[0]):
|
||||||
|
self.canvasBackend.drawPatch( \
|
||||||
|
eventDc, [[numNewCol, numNewRow], \
|
||||||
|
*self.canvasMap[-1][-1]])
|
||||||
|
|
||||||
|
self.canvasSize = newCanvasSize
|
||||||
|
wx.SafeYield()
|
||||||
|
self.parentFrame.onCanvasUpdate(size=newCanvasSize, undoLevel=-1)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -45,46 +45,6 @@ class MiRCARTCanvasInterface():
|
|||||||
dialogChoice = dialog.ShowModal()
|
dialogChoice = dialog.ShowModal()
|
||||||
return dialogChoice
|
return dialogChoice
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _updateCanvasSize(self, newCanvasSize): XXX
|
|
||||||
def _updateCanvasSize(self, newCanvasSize):
|
|
||||||
eventDc = self.parentCanvas.canvasBackend.getDeviceContext(self.parentCanvas)
|
|
||||||
self.parentCanvas.canvasBackend.drawCursorMaskWithJournal( \
|
|
||||||
self.parentCanvas.canvasJournal, eventDc)
|
|
||||||
oldCanvasSize = self.parentCanvas.canvasSize
|
|
||||||
self.parentCanvas.resize(newCanvasSize)
|
|
||||||
self.parentCanvas.canvasBackend.resize( \
|
|
||||||
newCanvasSize, \
|
|
||||||
self.parentCanvas.canvasBackend.cellSize)
|
|
||||||
if (newCanvasSize[1] - oldCanvasSize[1]) < 0:
|
|
||||||
for numRowOff in range(1, (oldCanvasSize[1] - newCanvasSize[1]) + 1):
|
|
||||||
numRow = oldCanvasSize[1] - numRowOff
|
|
||||||
del self.parentCanvas.canvasMap[numRow]
|
|
||||||
else:
|
|
||||||
for numRowOff in range(oldCanvasSize[1] - newCanvasSize[1]):
|
|
||||||
numRow = oldCanvasSize[1] + numRowOff
|
|
||||||
self.parentCanvas.canvasMap.append(None)
|
|
||||||
self.parentCanvas.canvasMap[numRow] = \
|
|
||||||
[[[1, 1], 0, " "]] * oldCanvasSize[0]
|
|
||||||
self.parentCanvas.canvasBackend.drawPatch( \
|
|
||||||
eventDc, \
|
|
||||||
[[numCol, numRow], *[[1, 1], 0, " "]])
|
|
||||||
if (newCanvasSize[0] - oldCanvasSize[0]) < 0:
|
|
||||||
for numRow in range(newCanvasSize[1]):
|
|
||||||
for numColOff in range(1, (oldCanvasSize[0] - newCanvasSize[0]) + 1):
|
|
||||||
numCol = oldCanvasSize[0] - numColOff
|
|
||||||
del self.parentCanvas.canvasMap[numRow][numCol]
|
|
||||||
else:
|
|
||||||
for numRow in range(newCanvasSize[1]):
|
|
||||||
for numColOff in range(newCanvasSize[0] - oldCanvasSize[0]):
|
|
||||||
numCol = oldCanvasSize[0] + numColOff
|
|
||||||
self.parentCanvas.canvasMap[numRow].append(None)
|
|
||||||
self.parentCanvas.canvasMap[numRow][numCol] = \
|
|
||||||
[[1, 1], 0, " "]
|
|
||||||
self.parentCanvas.canvasBackend.drawPatch( \
|
|
||||||
eventDc, \
|
|
||||||
[[numCol, numRow], *[[1, 1], 0, " "]])
|
|
||||||
wx.SafeYield()
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
# {{{ canvasBrushSolid(self, event): XXX
|
# {{{ canvasBrushSolid(self, event): XXX
|
||||||
def canvasBrushSolid(self, event):
|
def canvasBrushSolid(self, event):
|
||||||
@ -126,7 +86,7 @@ class MiRCARTCanvasInterface():
|
|||||||
# {{{ canvasDecrCanvasHeight(self, event): XXX
|
# {{{ canvasDecrCanvasHeight(self, event): XXX
|
||||||
def canvasDecrCanvasHeight(self, event):
|
def canvasDecrCanvasHeight(self, event):
|
||||||
if self.parentCanvas.canvasSize[1] > 1:
|
if self.parentCanvas.canvasSize[1] > 1:
|
||||||
self._updateCanvasSize([ \
|
self.parentCanvas.resize([ \
|
||||||
self.parentCanvas.canvasSize[0], \
|
self.parentCanvas.canvasSize[0], \
|
||||||
self.parentCanvas.canvasSize[1]-1])
|
self.parentCanvas.canvasSize[1]-1])
|
||||||
# }}}
|
# }}}
|
||||||
@ -138,7 +98,7 @@ class MiRCARTCanvasInterface():
|
|||||||
# {{{ canvasDecrCanvasWidth(self, event): XXX
|
# {{{ canvasDecrCanvasWidth(self, event): XXX
|
||||||
def canvasDecrCanvasWidth(self, event):
|
def canvasDecrCanvasWidth(self, event):
|
||||||
if self.parentCanvas.canvasSize[0] > 1:
|
if self.parentCanvas.canvasSize[0] > 1:
|
||||||
self._updateCanvasSize([ \
|
self.parentCanvas.resize([ \
|
||||||
self.parentCanvas.canvasSize[0]-1, \
|
self.parentCanvas.canvasSize[0]-1, \
|
||||||
self.parentCanvas.canvasSize[1]])
|
self.parentCanvas.canvasSize[1]])
|
||||||
# }}}
|
# }}}
|
||||||
@ -228,7 +188,7 @@ class MiRCARTCanvasInterface():
|
|||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasIncrCanvasHeight(self, event): XXX
|
# {{{ canvasIncrCanvasHeight(self, event): XXX
|
||||||
def canvasIncrCanvasHeight(self, event):
|
def canvasIncrCanvasHeight(self, event):
|
||||||
self._updateCanvasSize([ \
|
self.parentCanvas.resize([ \
|
||||||
self.parentCanvas.canvasSize[0], \
|
self.parentCanvas.canvasSize[0], \
|
||||||
self.parentCanvas.canvasSize[1]+1])
|
self.parentCanvas.canvasSize[1]+1])
|
||||||
# }}}
|
# }}}
|
||||||
@ -239,7 +199,7 @@ class MiRCARTCanvasInterface():
|
|||||||
# }}}
|
# }}}
|
||||||
# {{{ canvasIncrCanvasWidth(self, event): XXX
|
# {{{ canvasIncrCanvasWidth(self, event): XXX
|
||||||
def canvasIncrCanvasWidth(self, event):
|
def canvasIncrCanvasWidth(self, event):
|
||||||
self._updateCanvasSize([ \
|
self.parentCanvas.resize([ \
|
||||||
self.parentCanvas.canvasSize[0]+1, \
|
self.parentCanvas.canvasSize[0]+1, \
|
||||||
self.parentCanvas.canvasSize[1]])
|
self.parentCanvas.canvasSize[1]])
|
||||||
# }}}
|
# }}}
|
||||||
|
Loading…
Reference in New Issue
Block a user