MiRCART{anvas{,ImportStore,Interface},Frame}.py: pass & initialise from default canvas position, size, and cell size.

This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-01-10 15:04:59 +01:00
parent 49ef54ef76
commit c9d6b90e68
4 changed files with 18 additions and 13 deletions

View File

@ -32,6 +32,7 @@ import wx
class MiRCARTCanvas(wx.Panel):
"""XXX"""
parentFrame = None
defaultCanvasPos = defaultCanvasSize = defaultCellSize = None
canvasMap = canvasPos = canvasSize = None
brushColours = brushPos = brushSize = None
canvasBackend = canvasJournal = None
@ -155,17 +156,19 @@ class MiRCARTCanvas(wx.Panel):
# }}}
#
# _init__(self, parent, parentFrame, canvasPos, canvasSize, cellSize): initialisation method
def __init__(self, parent, parentFrame, canvasPos, canvasSize, cellSize):
super().__init__(parent, pos=canvasPos, \
size=[w*h for w,h in zip(canvasSize, cellSize)])
# _init__(self, parent, parentFrame, defaultCanvasPos, defaultCanvasSize, defaultCellSize): initialisation method
def __init__(self, parent, parentFrame, defaultCanvasPos, defaultCanvasSize, defaultCellSize):
super().__init__(parent, pos=defaultCanvasPos, \
size=[w*h for w,h in zip(defaultCanvasSize, defaultCellSize)])
self.parentFrame = parentFrame
self.canvasMap = None; self.canvasPos = canvasPos; self.canvasSize = canvasSize;
self.canvasMap = None
self.canvasPos = defaultCanvasPos; self.canvasSize = defaultCanvasSize;
self.defaultCanvasPos = defaultCanvasPos; self.defaultCanvasSize = defaultCanvasSize;
self.brushColours = [4, 1]; self.brushPos = [0, 0]; self.brushSize = [1, 1];
self.parentFrame.onCanvasUpdate( \
brushSize=self.brushSize, colours=self.brushColours)
self.canvasBackend = MiRCARTCanvasBackend(canvasSize, cellSize)
self.canvasBackend = MiRCARTCanvasBackend(defaultCanvasSize, defaultCellSize)
self.canvasJournal = MiRCARTCanvasJournal()
self.canvasExportStore = MiRCARTCanvasExportStore(parentCanvas=self)
self.canvasImportStore = MiRCARTCanvasImportStore(parentCanvas=self)

View File

@ -137,9 +137,9 @@ class MiRCARTCanvasImportStore():
# }}}
# {{{ importNew(self, newCanvasSize=None): XXX
def importNew(self, newCanvasSize=None):
newMap = [[[(1, 1), 0, " "] \
for x in range(self.parentCanvas.canvasSize[0])] \
for y in range(self.parentCanvas.canvasSize[1])]
newMap = [[[[1, 1], 0, " "] \
for x in range(newCanvasSize[0])] \
for y in range(newCanvasSize[1])]
self.parentCanvas.onStoreUpdate(newCanvasSize, newMap)
# }}}

View File

@ -192,7 +192,7 @@ class MiRCARTCanvasInterface():
self.canvasSave()
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
if newCanvasSize == None:
newCanvasSize = (100, 30)
newCanvasSize = list(self.parentCanvas.defaultCanvasSize)
self.parentCanvas.canvasImportStore.importNew(newCanvasSize)
self.canvasPathName = None
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))

View File

@ -203,12 +203,14 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
# }}}
#
# __init__(self, parent, appSize=(840, 630), canvasPos=(25, 50), canvasSize=(125, 35), cellSize=(7, 14)): initialisation method
def __init__(self, parent, appSize=(840, 630), canvasPos=(25, 50), canvasSize=(125, 35), cellSize=(7, 14)):
# __init__(self, parent, appSize=(840, 630), defaultCanvasPos=(25, 50), defaultCanvasSize=(100, 30), defaultCellSize=(7, 14)): initialisation method
def __init__(self, parent, appSize=(840, 630), defaultCanvasPos=(25, 50), defaultCanvasSize=(100, 30), defaultCellSize=(7, 14)):
self._initPaletteToolBitmaps()
panelSkin = super().__init__(parent, wx.ID_ANY, "MiRCART", size=appSize)
self.panelCanvas = MiRCARTCanvas(panelSkin, parentFrame=self, \
canvasPos=canvasPos, canvasSize=canvasSize, cellSize=cellSize)
defaultCanvasPos=defaultCanvasPos, \
defaultCanvasSize=defaultCanvasSize, \
defaultCellSize=defaultCellSize)
self.panelCanvas.canvasInterface.canvasNew(None)
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120