mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-26 08:56:36 +00:00
MiRCARTCanvasInterface.py: split from MiRCARTCanvas.py.
MiRCART{Canvas,{,General}Frame}.py: updated.
This commit is contained in:
parent
398ee3af3d
commit
3e03126006
@ -26,7 +26,7 @@ from MiRCARTCanvasBackend import MiRCARTCanvasBackend
|
|||||||
from MiRCARTCanvasJournal import MiRCARTCanvasJournal
|
from MiRCARTCanvasJournal import MiRCARTCanvasJournal
|
||||||
from MiRCARTCanvasExportStore import MiRCARTCanvasExportStore, haveMiRCARTToPngFile, haveUrllib
|
from MiRCARTCanvasExportStore import MiRCARTCanvasExportStore, haveMiRCARTToPngFile, haveUrllib
|
||||||
from MiRCARTCanvasImportStore import MiRCARTCanvasImportStore
|
from MiRCARTCanvasImportStore import MiRCARTCanvasImportStore
|
||||||
from MiRCARTColours import MiRCARTColours
|
from MiRCARTCanvasInterface import MiRCARTCanvasInterface
|
||||||
import wx
|
import wx
|
||||||
|
|
||||||
class MiRCARTCanvas(wx.Panel):
|
class MiRCARTCanvas(wx.Panel):
|
||||||
@ -34,8 +34,9 @@ class MiRCARTCanvas(wx.Panel):
|
|||||||
parentFrame = None
|
parentFrame = None
|
||||||
canvasMap = canvasPos = canvasSize = None
|
canvasMap = canvasPos = canvasSize = None
|
||||||
brushColours = brushPos = brushSize = None
|
brushColours = brushPos = brushSize = None
|
||||||
canvasBackend = canvasCurTool = canvasJournal = None
|
canvasBackend = canvasJournal = None
|
||||||
canvasExportStore = canvasImportStore = None
|
canvasExportStore = canvasImportStore = None
|
||||||
|
canvasInterface = None
|
||||||
|
|
||||||
# {{{ _commitPatch(self, patch): XXX
|
# {{{ _commitPatch(self, patch): XXX
|
||||||
def _commitPatch(self, patch):
|
def _commitPatch(self, patch):
|
||||||
@ -47,7 +48,7 @@ class MiRCARTCanvas(wx.Panel):
|
|||||||
for patch in deltaPatches:
|
for patch in deltaPatches:
|
||||||
if self.canvasBackend.drawPatch(eventDc, patch):
|
if self.canvasBackend.drawPatch(eventDc, patch):
|
||||||
self._commitPatch(patch)
|
self._commitPatch(patch)
|
||||||
self.parentFrame.onCanvasUpdate()
|
self.parentFrame.onUndoUpdate()
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _dispatchPatch(self, eventDc, isCursor, patch): XXX
|
# {{{ _dispatchPatch(self, eventDc, isCursor, patch): XXX
|
||||||
def _dispatchPatch(self, eventDc, isCursor, patch):
|
def _dispatchPatch(self, eventDc, isCursor, patch):
|
||||||
@ -72,12 +73,16 @@ class MiRCARTCanvas(wx.Panel):
|
|||||||
def onPanelClose(self, event):
|
def onPanelClose(self, event):
|
||||||
self.Destroy()
|
self.Destroy()
|
||||||
# }}}
|
# }}}
|
||||||
|
# {{{ onPanelEnterWindow(self, event): XXX
|
||||||
|
def onPanelEnterWindow(self, event):
|
||||||
|
self.parentFrame.SetFocus()
|
||||||
|
# }}}
|
||||||
# {{{ onPanelInput(self, event): XXX
|
# {{{ onPanelInput(self, event): XXX
|
||||||
def onPanelInput(self, event):
|
def onPanelInput(self, event):
|
||||||
eventDc = self.canvasBackend.getDeviceContext(self)
|
eventDc = self.canvasBackend.getDeviceContext(self)
|
||||||
eventType = event.GetEventType()
|
eventType = event.GetEventType()
|
||||||
self._canvasDirty = self._canvasDirtyCursor = False
|
self._canvasDirty = self._canvasDirtyCursor = False
|
||||||
tool = self.canvasCurTool
|
tool = self.canvasInterface.canvasTool
|
||||||
if eventType == wx.wxEVT_CHAR:
|
if eventType == wx.wxEVT_CHAR:
|
||||||
mapPoint = self.brushPos
|
mapPoint = self.brushPos
|
||||||
doSkip = tool.onKeyboardEvent( \
|
doSkip = tool.onKeyboardEvent( \
|
||||||
@ -93,15 +98,15 @@ class MiRCARTCanvas(wx.Panel):
|
|||||||
event.Dragging(), event.LeftIsDown(), event.RightIsDown(), \
|
event.Dragging(), event.LeftIsDown(), event.RightIsDown(), \
|
||||||
self._dispatchPatch, eventDc)
|
self._dispatchPatch, eventDc)
|
||||||
if self._canvasDirty:
|
if self._canvasDirty:
|
||||||
self.parentFrame.onCanvasUpdate()
|
self.parentFrame.onUndoUpdate()
|
||||||
self.parentFrame.onCanvasMotion(event, mapPoint)
|
if eventType == wx.wxEVT_MOTION:
|
||||||
|
self.parentFrame.onStatusBarUpdate(showPos=mapPoint)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onPanelLeaveWindow(self, event): XXX
|
# {{{ onPanelLeaveWindow(self, event): XXX
|
||||||
def onPanelLeaveWindow(self, event):
|
def onPanelLeaveWindow(self, event):
|
||||||
eventDc = self.canvasBackend.getDeviceContext(self)
|
eventDc = self.canvasBackend.getDeviceContext(self)
|
||||||
self.canvasBackend.drawCursorMaskWithJournal( \
|
self.canvasBackend.drawCursorMaskWithJournal( \
|
||||||
self.canvasJournal, eventDc)
|
self.canvasJournal, eventDc)
|
||||||
self.parentFrame.onCanvasMotion(event)
|
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onPanelPaint(self, event): XXX
|
# {{{ onPanelPaint(self, event): XXX
|
||||||
def onPanelPaint(self, event):
|
def onPanelPaint(self, event):
|
||||||
@ -123,14 +128,6 @@ class MiRCARTCanvas(wx.Panel):
|
|||||||
*self.canvasMap[numRow][numCol]))
|
*self.canvasMap[numRow][numCol]))
|
||||||
wx.SafeYield()
|
wx.SafeYield()
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ popRedo(self): XXX
|
|
||||||
def popRedo(self):
|
|
||||||
self._dispatchDeltaPatches(self.canvasJournal.popRedo())
|
|
||||||
# }}}
|
|
||||||
# {{{ popUndo(self): XXX
|
|
||||||
def popUndo(self):
|
|
||||||
self._dispatchDeltaPatches(self.canvasJournal.popUndo())
|
|
||||||
# }}}
|
|
||||||
# {{{ resize(self, newCanvasSize): XXX
|
# {{{ resize(self, newCanvasSize): XXX
|
||||||
def resize(self, newCanvasSize):
|
def resize(self, newCanvasSize):
|
||||||
if newCanvasSize != self.canvasSize:
|
if newCanvasSize != self.canvasSize:
|
||||||
@ -152,7 +149,7 @@ class MiRCARTCanvas(wx.Panel):
|
|||||||
self.canvasBackend.cellSize)])
|
self.canvasBackend.cellSize)])
|
||||||
self.canvasBackend.reset(self.canvasSize, self.canvasBackend.cellSize)
|
self.canvasBackend.reset(self.canvasSize, self.canvasBackend.cellSize)
|
||||||
self.canvasJournal.resetCursor(); self.canvasJournal.resetUndo();
|
self.canvasJournal.resetCursor(); self.canvasJournal.resetUndo();
|
||||||
self.parentFrame.onCanvasUpdate()
|
self.parentFrame.onUndoUpdate()
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -165,13 +162,14 @@ class MiRCARTCanvas(wx.Panel):
|
|||||||
self.canvasMap = None; self.canvasPos = canvasPos; self.canvasSize = canvasSize;
|
self.canvasMap = None; self.canvasPos = canvasPos; self.canvasSize = canvasSize;
|
||||||
self.brushColours = [4, 1]; self.brushPos = [0, 0]; self.brushSize = [1, 1];
|
self.brushColours = [4, 1]; self.brushPos = [0, 0]; self.brushSize = [1, 1];
|
||||||
self.canvasBackend = MiRCARTCanvasBackend(canvasSize, cellSize)
|
self.canvasBackend = MiRCARTCanvasBackend(canvasSize, cellSize)
|
||||||
self.canvasCurTool = None
|
|
||||||
self.canvasJournal = MiRCARTCanvasJournal()
|
self.canvasJournal = MiRCARTCanvasJournal()
|
||||||
self.canvasExportStore = MiRCARTCanvasExportStore(parentCanvas=self)
|
self.canvasExportStore = MiRCARTCanvasExportStore(parentCanvas=self)
|
||||||
self.canvasImportStore = MiRCARTCanvasImportStore(parentCanvas=self)
|
self.canvasImportStore = MiRCARTCanvasImportStore(parentCanvas=self)
|
||||||
|
self.canvasInterface = MiRCARTCanvasInterface(self, parentFrame)
|
||||||
|
|
||||||
# Bind event handlers
|
# Bind event handlers
|
||||||
self.Bind(wx.EVT_CLOSE, self.onPanelClose)
|
self.Bind(wx.EVT_CLOSE, self.onPanelClose)
|
||||||
|
self.Bind(wx.EVT_ENTER_WINDOW, self.onPanelEnterWindow)
|
||||||
self.Bind(wx.EVT_LEAVE_WINDOW, self.onPanelLeaveWindow)
|
self.Bind(wx.EVT_LEAVE_WINDOW, self.onPanelLeaveWindow)
|
||||||
self.parentFrame.Bind(wx.EVT_CHAR, self.onPanelInput)
|
self.parentFrame.Bind(wx.EVT_CHAR, self.onPanelInput)
|
||||||
for eventType in( \
|
for eventType in( \
|
||||||
|
@ -97,7 +97,9 @@ class MiRCARTCanvasBackend():
|
|||||||
# {{{ drawPatch(self, eventDc, patch): XXX
|
# {{{ drawPatch(self, eventDc, patch): XXX
|
||||||
def drawPatch(self, eventDc, patch):
|
def drawPatch(self, eventDc, patch):
|
||||||
if patch[0][0] < self.canvasSize[0] \
|
if patch[0][0] < self.canvasSize[0] \
|
||||||
and patch[0][1] < self.canvasSize[1]:
|
and patch[0][0] >= 0 \
|
||||||
|
and patch[0][1] < self.canvasSize[1] \
|
||||||
|
and patch[0][1] >= 0:
|
||||||
if patch[3] == " ":
|
if patch[3] == " ":
|
||||||
self._drawBrushPatch(eventDc, patch)
|
self._drawBrushPatch(eventDc, patch)
|
||||||
else:
|
else:
|
||||||
|
272
MiRCARTCanvasInterface.py
Normal file
272
MiRCARTCanvasInterface.py
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
# MiRCARTCanvasInterface.py -- XXX
|
||||||
|
# Copyright (c) 2018 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
from MiRCARTToolCircle import MiRCARTToolCircle
|
||||||
|
from MiRCARTToolLine import MiRCARTToolLine
|
||||||
|
from MiRCARTToolRect import MiRCARTToolRect
|
||||||
|
from MiRCARTToolText import MiRCARTToolText
|
||||||
|
|
||||||
|
import os, wx
|
||||||
|
|
||||||
|
class MiRCARTCanvasInterface():
|
||||||
|
"""XXX"""
|
||||||
|
parentCanvas = parentFrame = canvasPathName = canvasTool = None
|
||||||
|
|
||||||
|
# {{{ _dialogSaveChanges(self)
|
||||||
|
def _dialogSaveChanges(self):
|
||||||
|
with wx.MessageDialog(self.parentCanvas, \
|
||||||
|
"Do you want to save changes to {}?".format( \
|
||||||
|
self.canvasPathName), "MiRCART", \
|
||||||
|
wx.CANCEL|wx.CANCEL_DEFAULT|wx.ICON_QUESTION|wx.YES_NO) as dialog:
|
||||||
|
dialogChoice = dialog.ShowModal()
|
||||||
|
return dialogChoice
|
||||||
|
# }}}
|
||||||
|
# {{{ _updateCanvasSize(self, newCanvasSize): XXX
|
||||||
|
def _updateCanvasSize(self, newCanvasSize):
|
||||||
|
eventDc = self.parentCanvas.canvasBackend.getDeviceContext(self.parentCanvas)
|
||||||
|
self.parentCanvas.resize(newCanvasSize)
|
||||||
|
self.parentCanvas.canvasBackend.resize( \
|
||||||
|
newCanvasSize, \
|
||||||
|
self.parentCanvas.canvasBackend.cellSize)
|
||||||
|
for numRow in range(self.parentCanvas.canvasSize[1] - 1):
|
||||||
|
self.parentCanvas.canvasMap.append([[1, 1], 0, " "])
|
||||||
|
self.parentCanvas.canvasMap.append([])
|
||||||
|
for numCol in range(self.parentCanvas.canvasSize[0]):
|
||||||
|
self.parentCanvas.canvasMap[-1].append([[1, 1], 0, " "])
|
||||||
|
self.parentCanvas.canvasBackend.drawPatch(eventDc, \
|
||||||
|
([numCol, self.parentCanvas.canvasSize[1] - 1], *[[1, 1], 0, " "]))
|
||||||
|
wx.SafeYield()
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
# {{{ canvasBrushSolid(self, event): XXX
|
||||||
|
def canvasBrushSolid(self, event):
|
||||||
|
pass
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasColour(self, event, numColour): XXX
|
||||||
|
def canvasColour(self, event, numColour):
|
||||||
|
if event.GetEventType() == wx.wxEVT_TOOL:
|
||||||
|
self.parentCanvas.brushColours[0] = numColour
|
||||||
|
elif event.GetEventType() == wx.wxEVT_TOOL_RCLICKED:
|
||||||
|
self.parentCanvas.brushColours[1] = numColour
|
||||||
|
self.parentFrame.onStatusBarUpdate()
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasCopy(self, event): XXX
|
||||||
|
def canvasCopy(self, event):
|
||||||
|
pass
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasCut(self, event): XXX
|
||||||
|
def canvasCut(self, event):
|
||||||
|
pass
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasDecrBrush(self, event): XXX
|
||||||
|
def canvasDecrBrush(self, event):
|
||||||
|
if self.parentCanvas.brushSize[0] > 1 \
|
||||||
|
and self.parentCanvas.brushSize[1] > 1:
|
||||||
|
self.parentCanvas.brushSize = \
|
||||||
|
[a-1 for a in self.parentCanvas.brushSize]
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasDecrCanvas(self, event): XXX
|
||||||
|
def canvasDecrCanvas(self, event):
|
||||||
|
newCanvasSize = [a-1 if a > 1 else a for a in self.parentCanvas.canvasSize]
|
||||||
|
self._updateCanvasSize(newCanvasSize)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasDelete(self, event): XXX
|
||||||
|
def canvasDelete(self, event):
|
||||||
|
pass
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasExit(self, event): XXX
|
||||||
|
def canvasExit(self, event):
|
||||||
|
self.parentFrame.Close(True)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasExportAsPng(self, event): XXX
|
||||||
|
def canvasExportAsPng(self, event):
|
||||||
|
with wx.FileDialog(self, "Save As...", os.getcwd(), "", \
|
||||||
|
"*.png", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
||||||
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
outPathName = dialog.GetPath()
|
||||||
|
self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
|
self.parentCanvas.canvasExportStore.exportBitmapToPngFile( \
|
||||||
|
self.parentCanvas.canvasBackend.canvasBitmap, outPathName, \
|
||||||
|
wx.BITMAP_TYPE_PNG)
|
||||||
|
self.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
|
return True
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasExportImgur(self, event): XXX
|
||||||
|
def canvasExportImgur(self, event):
|
||||||
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
|
imgurResult = self.parentCanvas.canvasExportStore.exportBitmapToImgur( \
|
||||||
|
"c9a6efb3d7932fd", self.parentCanvas.canvasBackend.canvasBitmap, \
|
||||||
|
"", "", wx.BITMAP_TYPE_PNG)
|
||||||
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
|
if imgurResult[0] == 200:
|
||||||
|
if not wx.TheClipboard.IsOpened():
|
||||||
|
wx.TheClipboard.Open()
|
||||||
|
wx.TheClipboard.SetData(wx.TextDataObject(imgurResult[1]))
|
||||||
|
wx.TheClipboard.Close()
|
||||||
|
wx.MessageBox("Exported to Imgur: " + imgurResult[1], \
|
||||||
|
"Export to Imgur", wx.OK|wx.ICON_INFORMATION)
|
||||||
|
else:
|
||||||
|
wx.MessageBox("Failed to export to Imgur: " + imgurResult[1], \
|
||||||
|
"Export to Imgur", wx.OK|wx.ICON_EXCLAMATION)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasExportPastebin(self, event): XXX
|
||||||
|
def canvasExportPastebin(self, event):
|
||||||
|
self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
|
pasteStatus, pasteResult = \
|
||||||
|
self.parentCanvas.canvasExportStore.exportPastebin( \
|
||||||
|
"", \
|
||||||
|
self.parentCanvas.canvasMap, \
|
||||||
|
self.parentCanvas.canvasSize)
|
||||||
|
self.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
|
if pasteStatus:
|
||||||
|
if not wx.TheClipboard.IsOpened():
|
||||||
|
wx.TheClipboard.Open()
|
||||||
|
wx.TheClipboard.SetData(wx.TextDataObject(pasteResult))
|
||||||
|
wx.TheClipboard.Close()
|
||||||
|
wx.MessageBox("Exported to Pastebin: " + pasteResult, \
|
||||||
|
"Export to Pastebin", wx.OK|wx.ICON_INFORMATION)
|
||||||
|
else:
|
||||||
|
wx.MessageBox("Failed to export to Pastebin: " + pasteResult, \
|
||||||
|
"Export to Pastebin", wx.OK|wx.ICON_EXCLAMATION)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasIncrBrush(self, event): XXX
|
||||||
|
def canvasIncrBrush(self, event):
|
||||||
|
self.parentCanvas.brushSize = \
|
||||||
|
[a+1 for a in self.parentCanvas.brushSize]
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasIncrCanvas(self, event): XXX
|
||||||
|
def canvasIncrCanvas(self, event):
|
||||||
|
newCanvasSize = [a+1 for a in self.parentCanvas.canvasSize]
|
||||||
|
self._updateCanvasSize(newCanvasSize)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasNew(self, event, newCanvasSize=None): XXX
|
||||||
|
def canvasNew(self, event, newCanvasSize=None):
|
||||||
|
if self.canvasPathName != None:
|
||||||
|
saveChanges = self._dialogSaveChanges()
|
||||||
|
if saveChanges == wx.ID_CANCEL:
|
||||||
|
return
|
||||||
|
elif saveChanges == wx.ID_NO:
|
||||||
|
pass
|
||||||
|
elif saveChanges == wx.ID_YES:
|
||||||
|
self.canvasSave()
|
||||||
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
|
if newCanvasSize == None:
|
||||||
|
newCanvasSize = (100, 30)
|
||||||
|
self.parentCanvas.canvasImportStore.importNew(newCanvasSize)
|
||||||
|
self.canvasPathName = None
|
||||||
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
|
self.parentFrame.onStatusBarUpdate()
|
||||||
|
self.parentFrame.onUndoUpdate()
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasOpen(self, event): XXX
|
||||||
|
def canvasOpen(self, event):
|
||||||
|
if self.canvasPathName != None:
|
||||||
|
saveChanges = self._dialogSaveChanges()
|
||||||
|
if saveChanges == wx.ID_CANCEL:
|
||||||
|
return
|
||||||
|
elif saveChanges == wx.ID_NO:
|
||||||
|
pass
|
||||||
|
elif saveChanges == wx.ID_YES:
|
||||||
|
self.canvasSave()
|
||||||
|
with wx.FileDialog(self.parentCanvas, "Open", os.getcwd(), "", \
|
||||||
|
"*.txt", wx.FD_OPEN) as dialog:
|
||||||
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
self.canvasPathName = dialog.GetPath()
|
||||||
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
|
self.parentCanvas.canvasImportStore.importTextFile(self.canvasPathName)
|
||||||
|
self.parentCanvas.canvasImportStore.importIntoPanel()
|
||||||
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
|
self.parentFrame.onStatusBarUpdate(showFileName=self.canvasPathName)
|
||||||
|
self.parentFrame.onUndoUpdate()
|
||||||
|
return True
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasPaste(self, event): XXX
|
||||||
|
def canvasPaste(self, event):
|
||||||
|
pass
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasRedo(self, event): XXX
|
||||||
|
def canvasRedo(self, event):
|
||||||
|
self.parentCanvas._dispatchDeltaPatches( \
|
||||||
|
self.parentCanvas.canvasJournal.popRedo())
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasSave(self, event): XXX
|
||||||
|
def canvasSave(self, event):
|
||||||
|
if self.canvasPathName == None:
|
||||||
|
if self.canvasSaveAs(event) == False:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
with open(self.canvasPathName, "w") as outFile:
|
||||||
|
self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
|
self.parentCanvas.canvasExportStore.exportTextFile( \
|
||||||
|
self.parentCanvas.canvasMap, \
|
||||||
|
self.parentCanvas.canvasSize, outFile)
|
||||||
|
self.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
|
return True
|
||||||
|
except IOError as error:
|
||||||
|
return False
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasSaveAs(self, event): XXX
|
||||||
|
def canvasSaveAs(self, event):
|
||||||
|
with wx.FileDialog(self.parentCanvas, "Save As", os.getcwd(), "", \
|
||||||
|
"*.txt", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
||||||
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
self.canvasPathName = dialog.GetPath()
|
||||||
|
return self.canvasSave(event)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasToolCircle(self, event): XXX
|
||||||
|
def canvasToolCircle(self, event):
|
||||||
|
self.canvasTool = MiRCARTToolCircle(self.parentCanvas)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasToolLine(self, event): XXX
|
||||||
|
def canvasToolLine(self, event):
|
||||||
|
self.canvasTool = MiRCARTToolLine(self.parentCanvas)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasToolRect(self, event): XXX
|
||||||
|
def canvasToolRect(self, event):
|
||||||
|
self.canvasTool = MiRCARTToolRect(self.parentCanvas)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasToolText(self, event): XXX
|
||||||
|
def canvasToolText(self, event):
|
||||||
|
self.canvasTool = MiRCARTToolText(self.parentCanvas)
|
||||||
|
# }}}
|
||||||
|
# {{{ canvasUndo(self, event): XXX
|
||||||
|
def canvasUndo(self, event):
|
||||||
|
self.parentCanvas._dispatchDeltaPatches( \
|
||||||
|
self.parentCanvas.canvasJournal.popUndo())
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
#
|
||||||
|
# __init__(self, parentCanvas, parentFrame):
|
||||||
|
def __init__(self, parentCanvas, parentFrame):
|
||||||
|
self.parentCanvas = parentCanvas; self.parentFrame = parentFrame;
|
||||||
|
self.canvasPathName = None
|
||||||
|
self.canvasToolRect(None)
|
||||||
|
|
||||||
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|
345
MiRCARTFrame.py
345
MiRCARTFrame.py
@ -23,74 +23,68 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from MiRCARTCanvas import MiRCARTCanvas, haveUrllib
|
from MiRCARTCanvas import MiRCARTCanvas, haveUrllib
|
||||||
|
from MiRCARTCanvasInterface import MiRCARTCanvasInterface
|
||||||
from MiRCARTColours import MiRCARTColours
|
from MiRCARTColours import MiRCARTColours
|
||||||
from MiRCARTGeneralFrame import MiRCARTGeneralFrame, \
|
from MiRCARTGeneralFrame import MiRCARTGeneralFrame, \
|
||||||
TID_ACCELS, TID_COMMAND, TID_LIST, TID_MENU, TID_NOTHING, TID_SELECT, TID_TOOLBAR
|
TID_ACCELS, TID_COMMAND, TID_LIST, TID_MENU, TID_NOTHING, TID_SELECT, TID_TOOLBAR, \
|
||||||
from MiRCARTToolCircle import MiRCARTToolCircle
|
NID_MENU_SEP, NID_TOOLBAR_SEP
|
||||||
from MiRCARTToolLine import MiRCARTToolLine
|
|
||||||
from MiRCARTToolRect import MiRCARTToolRect
|
|
||||||
from MiRCARTToolText import MiRCARTToolText
|
|
||||||
|
|
||||||
import os, wx
|
import os, wx
|
||||||
|
|
||||||
class MiRCARTFrame(MiRCARTGeneralFrame):
|
class MiRCARTFrame(MiRCARTGeneralFrame):
|
||||||
"""XXX"""
|
"""XXX"""
|
||||||
panelCanvas = canvasPathName = None
|
panelCanvas = None
|
||||||
|
|
||||||
# {{{ Commands
|
# {{{ Commands
|
||||||
# Id Type Id Labels Icon bitmap Accelerator [Initial state]
|
# Id Type Id Labels Icon bitmap Accelerator [Initial state]
|
||||||
CID_NEW = [0x100, TID_COMMAND, "New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")]]
|
CID_NEW = [0x100, TID_COMMAND, "New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None, MiRCARTCanvasInterface.canvasNew]
|
||||||
CID_OPEN = [0x101, TID_COMMAND, "Open", "&Open", ["", wx.ART_FILE_OPEN], [wx.ACCEL_CTRL, ord("O")]]
|
CID_OPEN = [0x101, TID_COMMAND, "Open", "&Open", ["", wx.ART_FILE_OPEN], [wx.ACCEL_CTRL, ord("O")], None, MiRCARTCanvasInterface.canvasOpen]
|
||||||
CID_SAVE = [0x102, TID_COMMAND, "Save", "&Save", ["", wx.ART_FILE_SAVE], [wx.ACCEL_CTRL, ord("S")]]
|
CID_SAVE = [0x102, TID_COMMAND, "Save", "&Save", ["", wx.ART_FILE_SAVE], [wx.ACCEL_CTRL, ord("S")], None, MiRCARTCanvasInterface.canvasSave]
|
||||||
CID_SAVEAS = [0x103, TID_COMMAND, "Save As...", "Save &As...", ["", wx.ART_FILE_SAVE_AS], None]
|
CID_SAVEAS = [0x103, TID_COMMAND, "Save As...", "Save &As...", ["", wx.ART_FILE_SAVE_AS], None, None, MiRCARTCanvasInterface.canvasSaveAs]
|
||||||
CID_EXPORT_AS_PNG = [0x104, TID_COMMAND, "Export as PNG...", \
|
CID_EXPORT_AS_PNG = [0x104, TID_COMMAND, "Export as PNG...", \
|
||||||
"Export as PN&G...", None, None]
|
"Export as PN&G...", None, None, None, MiRCARTCanvasInterface.canvasExportAsPng]
|
||||||
CID_EXPORT_IMGUR = [0x105, TID_COMMAND, "Export to Imgur...", \
|
CID_EXPORT_IMGUR = [0x105, TID_COMMAND, "Export to Imgur...", \
|
||||||
"Export to I&mgur...", None, None, haveUrllib]
|
"Export to I&mgur...", None, None, haveUrllib, MiRCARTCanvasInterface.canvasExportImgur]
|
||||||
CID_EXPORT_PASTEBIN = [0x106, TID_COMMAND, "Export to Pastebin...", \
|
CID_EXPORT_PASTEBIN = [0x106, TID_COMMAND, "Export to Pastebin...", \
|
||||||
"Export to Pasteb&in...", None, None, haveUrllib]
|
"Export to Pasteb&in...", None, None, haveUrllib, MiRCARTCanvasInterface.canvasExportPastebin]
|
||||||
CID_EXIT = [0x107, TID_COMMAND, "Exit", "E&xit", None, None]
|
CID_EXIT = [0x107, TID_COMMAND, "Exit", "E&xit", None, None, None, MiRCARTCanvasInterface.canvasExit]
|
||||||
CID_UNDO = [0x108, TID_COMMAND, "Undo", "&Undo", ["", wx.ART_UNDO], [wx.ACCEL_CTRL, ord("Z")], False]
|
CID_UNDO = [0x108, TID_COMMAND, "Undo", "&Undo", ["", wx.ART_UNDO], [wx.ACCEL_CTRL, ord("Z")], False, MiRCARTCanvasInterface.canvasUndo]
|
||||||
CID_REDO = [0x109, TID_COMMAND, "Redo", "&Redo", ["", wx.ART_REDO], [wx.ACCEL_CTRL, ord("Y")], False]
|
CID_REDO = [0x109, TID_COMMAND, "Redo", "&Redo", ["", wx.ART_REDO], [wx.ACCEL_CTRL, ord("Y")], False, MiRCARTCanvasInterface.canvasRedo]
|
||||||
CID_CUT = [0x10a, TID_COMMAND, "Cut", "Cu&t", ["", wx.ART_CUT], None, False]
|
CID_CUT = [0x10a, TID_COMMAND, "Cut", "Cu&t", ["", wx.ART_CUT], None, False, MiRCARTCanvasInterface.canvasCut]
|
||||||
CID_COPY = [0x10b, TID_COMMAND, "Copy", "&Copy", ["", wx.ART_COPY], None, False]
|
CID_COPY = [0x10b, TID_COMMAND, "Copy", "&Copy", ["", wx.ART_COPY], None, False, MiRCARTCanvasInterface.canvasCopy]
|
||||||
CID_PASTE = [0x10c, TID_COMMAND, "Paste", "&Paste", ["", wx.ART_PASTE], None, False]
|
CID_PASTE = [0x10c, TID_COMMAND, "Paste", "&Paste", ["", wx.ART_PASTE], None, False, MiRCARTCanvasInterface.canvasPaste]
|
||||||
CID_DELETE = [0x10d, TID_COMMAND, "Delete", "De&lete", ["", wx.ART_DELETE], None, False]
|
CID_DELETE = [0x10d, TID_COMMAND, "Delete", "De&lete", ["", wx.ART_DELETE], None, False, MiRCARTCanvasInterface.canvasDelete]
|
||||||
CID_INCR_CANVAS = [0x10e, TID_COMMAND, "Increase canvas size", \
|
CID_INCR_CANVAS = [0x10e, TID_COMMAND, "Increase canvas size", \
|
||||||
"I&ncrease canvas size", ["", wx.ART_PLUS], [wx.ACCEL_ALT, ord("+")]]
|
"I&ncrease canvas size", ["", wx.ART_PLUS], [wx.ACCEL_ALT, ord("+")], None, MiRCARTCanvasInterface.canvasIncrCanvas]
|
||||||
CID_DECR_CANVAS = [0x10f, TID_COMMAND, "Decrease canvas size", \
|
CID_DECR_CANVAS = [0x10f, TID_COMMAND, "Decrease canvas size", \
|
||||||
"D&ecrease canvas size", ["", wx.ART_MINUS], [wx.ACCEL_ALT, ord("-")]]
|
"D&ecrease canvas size", ["", wx.ART_MINUS], [wx.ACCEL_ALT, ord("-")], None, MiRCARTCanvasInterface.canvasDecrCanvas]
|
||||||
CID_INCR_BRUSH = [0x110, TID_COMMAND, "Increase brush size", \
|
CID_INCR_BRUSH = [0x110, TID_COMMAND, "Increase brush size", \
|
||||||
"&Increase brush size", ["", wx.ART_PLUS], [wx.ACCEL_CTRL, ord("+")]]
|
"&Increase brush size", ["", wx.ART_PLUS], [wx.ACCEL_CTRL, ord("+")], None, MiRCARTCanvasInterface.canvasIncrBrush]
|
||||||
CID_DECR_BRUSH = [0x111, TID_COMMAND, "Decrease brush size", \
|
CID_DECR_BRUSH = [0x111, TID_COMMAND, "Decrease brush size", \
|
||||||
"&Decrease brush size", ["", wx.ART_MINUS], [wx.ACCEL_CTRL, ord("-")]]
|
"&Decrease brush size", ["", wx.ART_MINUS], [wx.ACCEL_CTRL, ord("-")], None, MiRCARTCanvasInterface.canvasDecrBrush]
|
||||||
CID_SOLID_BRUSH = [0x112, TID_SELECT, "Solid brush", "&Solid brush", None, None, True]
|
CID_SOLID_BRUSH = [0x112, TID_SELECT, "Solid brush", "&Solid brush", None, None, True, MiRCARTCanvasInterface.canvasBrushSolid]
|
||||||
|
|
||||||
CID_RECT = [0x150, TID_SELECT, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True]
|
CID_RECT = [0x150, TID_SELECT, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True, MiRCARTCanvasInterface.canvasToolRect]
|
||||||
CID_CIRCLE = [0x151, TID_SELECT, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False]
|
CID_CIRCLE = [0x151, TID_SELECT, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False, MiRCARTCanvasInterface.canvasToolCircle]
|
||||||
CID_LINE = [0x152, TID_SELECT, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False]
|
CID_LINE = [0x152, TID_SELECT, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False, MiRCARTCanvasInterface.canvasToolLine]
|
||||||
CID_TEXT = [0x153, TID_SELECT, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False]
|
CID_TEXT = [0x153, TID_SELECT, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False, MiRCARTCanvasInterface.canvasToolText]
|
||||||
|
|
||||||
CID_COLOUR00 = [0x1a0, TID_COMMAND, "Colour #00", "Colour #00", None, None]
|
CID_COLOUR00 = [0x1a0, TID_COMMAND, "Colour #00", "Colour #00", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR01 = [0x1a1, TID_COMMAND, "Colour #01", "Colour #01", None, None]
|
CID_COLOUR01 = [0x1a1, TID_COMMAND, "Colour #01", "Colour #01", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR02 = [0x1a2, TID_COMMAND, "Colour #02", "Colour #02", None, None]
|
CID_COLOUR02 = [0x1a2, TID_COMMAND, "Colour #02", "Colour #02", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR03 = [0x1a3, TID_COMMAND, "Colour #03", "Colour #03", None, None]
|
CID_COLOUR03 = [0x1a3, TID_COMMAND, "Colour #03", "Colour #03", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR04 = [0x1a4, TID_COMMAND, "Colour #04", "Colour #04", None, None]
|
CID_COLOUR04 = [0x1a4, TID_COMMAND, "Colour #04", "Colour #04", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR05 = [0x1a5, TID_COMMAND, "Colour #05", "Colour #05", None, None]
|
CID_COLOUR05 = [0x1a5, TID_COMMAND, "Colour #05", "Colour #05", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR06 = [0x1a6, TID_COMMAND, "Colour #06", "Colour #06", None, None]
|
CID_COLOUR06 = [0x1a6, TID_COMMAND, "Colour #06", "Colour #06", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR07 = [0x1a7, TID_COMMAND, "Colour #07", "Colour #07", None, None]
|
CID_COLOUR07 = [0x1a7, TID_COMMAND, "Colour #07", "Colour #07", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR08 = [0x1a8, TID_COMMAND, "Colour #08", "Colour #08", None, None]
|
CID_COLOUR08 = [0x1a8, TID_COMMAND, "Colour #08", "Colour #08", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR09 = [0x1a9, TID_COMMAND, "Colour #09", "Colour #09", None, None]
|
CID_COLOUR09 = [0x1a9, TID_COMMAND, "Colour #09", "Colour #09", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR10 = [0x1aa, TID_COMMAND, "Colour #10", "Colour #10", None, None]
|
CID_COLOUR10 = [0x1aa, TID_COMMAND, "Colour #10", "Colour #10", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR11 = [0x1ab, TID_COMMAND, "Colour #11", "Colour #11", None, None]
|
CID_COLOUR11 = [0x1ab, TID_COMMAND, "Colour #11", "Colour #11", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR12 = [0x1ac, TID_COMMAND, "Colour #12", "Colour #12", None, None]
|
CID_COLOUR12 = [0x1ac, TID_COMMAND, "Colour #12", "Colour #12", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR13 = [0x1ad, TID_COMMAND, "Colour #13", "Colour #13", None, None]
|
CID_COLOUR13 = [0x1ad, TID_COMMAND, "Colour #13", "Colour #13", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR14 = [0x1ae, TID_COMMAND, "Colour #14", "Colour #14", None, None]
|
CID_COLOUR14 = [0x1ae, TID_COMMAND, "Colour #14", "Colour #14", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
CID_COLOUR15 = [0x1af, TID_COMMAND, "Colour #15", "Colour #15", None, None]
|
CID_COLOUR15 = [0x1af, TID_COMMAND, "Colour #15", "Colour #15", None, None, None, MiRCARTCanvasInterface.canvasColour]
|
||||||
# }}}
|
|
||||||
# {{{ Non-items
|
|
||||||
NID_MENU_SEP = (0x200, TID_NOTHING)
|
|
||||||
NID_TOOLBAR_SEP = (0x201, TID_NOTHING)
|
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Menus
|
# {{{ Menus
|
||||||
MID_FILE = (0x300, TID_MENU, "File", "&File", ( \
|
MID_FILE = (0x300, TID_MENU, "File", "&File", ( \
|
||||||
@ -147,23 +141,25 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
|
|||||||
toolBitmapDc.DrawRectangle(0, 0, 16, 16)
|
toolBitmapDc.DrawRectangle(0, 0, 16, 16)
|
||||||
paletteDescr[numColour][4] = ["", None, toolBitmap]
|
paletteDescr[numColour][4] = ["", None, toolBitmap]
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _dialogSaveChanges(self)
|
|
||||||
def _dialogSaveChanges(self):
|
# {{{ onInput(self, event): XXX
|
||||||
with wx.MessageDialog(self, \
|
def onInput(self, event):
|
||||||
"Do you want to save changes to {}?".format( \
|
eventId = event.GetId()
|
||||||
self.canvasPathName), "MiRCART", \
|
if eventId >= self.CID_COLOUR00[0] \
|
||||||
wx.CANCEL|wx.CANCEL_DEFAULT|wx.ICON_QUESTION|wx.YES_NO) as dialog:
|
and eventId <= self.CID_COLOUR15[0]:
|
||||||
dialogChoice = dialog.ShowModal()
|
numColour = eventId - self.CID_COLOUR00[0]
|
||||||
return dialogChoice
|
self.itemsById[eventId][7](self.panelCanvas.canvasInterface, event, numColour)
|
||||||
|
else:
|
||||||
|
self.itemsById[eventId][7](self.panelCanvas.canvasInterface, event)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _updateStatusBar(self, showColours=None, showFileName=True, showPos=None): XXX
|
# {{{ onStatusBarUpdate(self, showColours=None, showFileName=True, showPos=None): XXX
|
||||||
def _updateStatusBar(self, showColours=True, showFileName=True, showPos=True):
|
def onStatusBarUpdate(self, showColours=True, showFileName=True, showPos=True):
|
||||||
if showColours == True:
|
if showColours == True:
|
||||||
showColours = self.panelCanvas.brushColours
|
showColours = self.panelCanvas.brushColours
|
||||||
if showPos == True:
|
if showPos == True:
|
||||||
showPos = self.panelCanvas.brushPos
|
showPos = self.panelCanvas.brushPos
|
||||||
if showFileName == True:
|
if showFileName == True:
|
||||||
showFileName = self.canvasPathName
|
showFileName = self.panelCanvas.canvasInterface.canvasPathName
|
||||||
textItems = []
|
textItems = []
|
||||||
if showPos != None:
|
if showPos != None:
|
||||||
textItems.append("X: {:03d} Y: {:03d}".format( \
|
textItems.append("X: {:03d} Y: {:03d}".format( \
|
||||||
@ -179,139 +175,8 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
|
|||||||
os.path.basename(showFileName)))
|
os.path.basename(showFileName)))
|
||||||
self.statusBar.SetStatusText(" | ".join(textItems))
|
self.statusBar.SetStatusText(" | ".join(textItems))
|
||||||
# }}}
|
# }}}
|
||||||
|
# {{{ onUndoUpdate(self): XXX
|
||||||
# {{{ canvasExportAsPng(self): XXX
|
def onUndoUpdate(self):
|
||||||
def canvasExportAsPng(self):
|
|
||||||
with wx.FileDialog(self, self.CID_SAVEAS[2], os.getcwd(), "", \
|
|
||||||
"*.png", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
|
||||||
if dialog.ShowModal() == wx.ID_CANCEL:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
outPathName = dialog.GetPath()
|
|
||||||
self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
||||||
self.panelCanvas.canvasExportStore.exportBitmapToPngFile( \
|
|
||||||
self.panelCanvas.canvasBackend.canvasBitmap, outPathName, \
|
|
||||||
wx.BITMAP_TYPE_PNG)
|
|
||||||
self.SetCursor(wx.Cursor(wx.NullCursor))
|
|
||||||
return True
|
|
||||||
# }}}
|
|
||||||
# {{{ canvasExportImgur(self): XXX
|
|
||||||
def canvasExportImgur(self):
|
|
||||||
self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
||||||
imgurResult = self.panelCanvas.canvasExportStore.exportBitmapToImgur( \
|
|
||||||
"c9a6efb3d7932fd", self.panelCanvas.canvasBackend.canvasBitmap, \
|
|
||||||
"", "", wx.BITMAP_TYPE_PNG)
|
|
||||||
self.SetCursor(wx.Cursor(wx.NullCursor))
|
|
||||||
if imgurResult[0] == 200:
|
|
||||||
if not wx.TheClipboard.IsOpened():
|
|
||||||
wx.TheClipboard.Open()
|
|
||||||
wx.TheClipboard.SetData(wx.TextDataObject(imgurResult[1]))
|
|
||||||
wx.TheClipboard.Close()
|
|
||||||
wx.MessageBox("Exported to Imgur: " + imgurResult[1], \
|
|
||||||
"Export to Imgur", wx.OK|wx.ICON_INFORMATION)
|
|
||||||
else:
|
|
||||||
wx.MessageBox("Failed to export to Imgur: " + imgurResult[1], \
|
|
||||||
"Export to Imgur", wx.OK|wx.ICON_EXCLAMATION)
|
|
||||||
# }}}
|
|
||||||
# {{{ canvasExportPastebin(self): XXX
|
|
||||||
def canvasExportPastebin(self):
|
|
||||||
self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
||||||
pasteStatus, pasteResult = \
|
|
||||||
self.panelCanvas.canvasExportStore.exportPastebin( \
|
|
||||||
"", \
|
|
||||||
self.panelCanvas.canvasMap, \
|
|
||||||
self.panelCanvas.canvasSize)
|
|
||||||
self.SetCursor(wx.Cursor(wx.NullCursor))
|
|
||||||
if pasteStatus:
|
|
||||||
if not wx.TheClipboard.IsOpened():
|
|
||||||
wx.TheClipboard.Open()
|
|
||||||
wx.TheClipboard.SetData(wx.TextDataObject(pasteResult))
|
|
||||||
wx.TheClipboard.Close()
|
|
||||||
wx.MessageBox("Exported to Pastebin: " + pasteResult, \
|
|
||||||
"Export to Pastebin", wx.OK|wx.ICON_INFORMATION)
|
|
||||||
else:
|
|
||||||
wx.MessageBox("Failed to export to Pastebin: " + pasteResult, \
|
|
||||||
"Export to Pastebin", wx.OK|wx.ICON_EXCLAMATION)
|
|
||||||
# }}}
|
|
||||||
# {{{ canvasNew(self, newCanvasSize=None): XXX
|
|
||||||
def canvasNew(self, newCanvasSize=None):
|
|
||||||
if self.canvasPathName != None:
|
|
||||||
saveChanges = self._dialogSaveChanges()
|
|
||||||
if saveChanges == wx.ID_CANCEL:
|
|
||||||
return
|
|
||||||
elif saveChanges == wx.ID_NO:
|
|
||||||
pass
|
|
||||||
elif saveChanges == wx.ID_YES:
|
|
||||||
self.canvasSave()
|
|
||||||
self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
||||||
if newCanvasSize == None:
|
|
||||||
newCanvasSize = (100, 30)
|
|
||||||
self.panelCanvas.canvasImportStore.importNew(newCanvasSize)
|
|
||||||
self.canvasPathName = None
|
|
||||||
self.SetCursor(wx.Cursor(wx.NullCursor))
|
|
||||||
self._updateStatusBar(); self.onCanvasUpdate();
|
|
||||||
# }}}
|
|
||||||
# {{{ canvasOpen(self): XXX
|
|
||||||
def canvasOpen(self):
|
|
||||||
if self.canvasPathName != None:
|
|
||||||
saveChanges = self._dialogSaveChanges()
|
|
||||||
if saveChanges == wx.ID_CANCEL:
|
|
||||||
return
|
|
||||||
elif saveChanges == wx.ID_NO:
|
|
||||||
pass
|
|
||||||
elif saveChanges == wx.ID_YES:
|
|
||||||
self.canvasSave()
|
|
||||||
with wx.FileDialog(self, self.CID_OPEN[2], os.getcwd(), "", \
|
|
||||||
"*.txt", wx.FD_OPEN) as dialog:
|
|
||||||
if dialog.ShowModal() == wx.ID_CANCEL:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
self.canvasPathName = dialog.GetPath()
|
|
||||||
self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
||||||
self.panelCanvas.canvasImportStore.importTextFile(self.canvasPathName)
|
|
||||||
self.panelCanvas.canvasImportStore.importIntoPanel()
|
|
||||||
self.SetCursor(wx.Cursor(wx.NullCursor))
|
|
||||||
self._updateStatusBar(); self.onCanvasUpdate();
|
|
||||||
return True
|
|
||||||
# }}}
|
|
||||||
# {{{ canvasSave(self): XXX
|
|
||||||
def canvasSave(self):
|
|
||||||
if self.canvasPathName == None:
|
|
||||||
if self.canvasSaveAs() == False:
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
with open(self.canvasPathName, "w") as outFile:
|
|
||||||
self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
|
||||||
self.panelCanvas.canvasExportStore.exportTextFile( \
|
|
||||||
self.panelCanvas.canvasMap, \
|
|
||||||
self.panelCanvas.canvasSize, outFile)
|
|
||||||
self.SetCursor(wx.Cursor(wx.NullCursor))
|
|
||||||
return True
|
|
||||||
except IOError as error:
|
|
||||||
return False
|
|
||||||
# }}}
|
|
||||||
# {{{ canvasSaveAs(self): XXX
|
|
||||||
def canvasSaveAs(self):
|
|
||||||
with wx.FileDialog(self, self.CID_SAVEAS[2], os.getcwd(), "", \
|
|
||||||
"*.txt", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
|
||||||
if dialog.ShowModal() == wx.ID_CANCEL:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
self.canvasPathName = dialog.GetPath()
|
|
||||||
return self.canvasSave()
|
|
||||||
# }}}
|
|
||||||
# {{{ onCanvasMotion(self, event): XXX
|
|
||||||
def onCanvasMotion(self, event, atPoint=None):
|
|
||||||
eventType = event.GetEventType()
|
|
||||||
if eventType == wx.wxEVT_ENTER_WINDOW:
|
|
||||||
self.SetFocus()
|
|
||||||
elif eventType == wx.wxEVT_MOTION:
|
|
||||||
self._updateStatusBar(showPos=atPoint)
|
|
||||||
elif eventType == wx.wxEVT_LEAVE_WINDOW:
|
|
||||||
pass
|
|
||||||
# }}}
|
|
||||||
# {{{ onCanvasUpdate(self): XXX
|
|
||||||
def onCanvasUpdate(self):
|
|
||||||
if self.panelCanvas.canvasJournal.patchesUndo[self.panelCanvas.canvasJournal.patchesUndoLevel] != None:
|
if self.panelCanvas.canvasJournal.patchesUndo[self.panelCanvas.canvasJournal.patchesUndoLevel] != None:
|
||||||
self.menuItemsById[self.CID_UNDO[0]].Enable(True)
|
self.menuItemsById[self.CID_UNDO[0]].Enable(True)
|
||||||
self.toolBar.EnableTool(self.CID_UNDO[0], True)
|
self.toolBar.EnableTool(self.CID_UNDO[0], True)
|
||||||
@ -325,106 +190,14 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
|
|||||||
self.menuItemsById[self.CID_REDO[0]].Enable(False)
|
self.menuItemsById[self.CID_REDO[0]].Enable(False)
|
||||||
self.toolBar.EnableTool(self.CID_REDO[0], False)
|
self.toolBar.EnableTool(self.CID_REDO[0], False)
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onFrameCommand(self, event): XXX
|
|
||||||
def onFrameCommand(self, event):
|
|
||||||
cid = event.GetId()
|
|
||||||
if cid == self.CID_NEW[0]:
|
|
||||||
self.canvasNew()
|
|
||||||
elif cid == self.CID_OPEN[0]:
|
|
||||||
self.canvasOpen()
|
|
||||||
elif cid == self.CID_SAVE[0]:
|
|
||||||
self.canvasSave()
|
|
||||||
elif cid == self.CID_SAVEAS[0]:
|
|
||||||
self.canvasSaveAs()
|
|
||||||
elif cid == self.CID_EXPORT_AS_PNG[0]:
|
|
||||||
self.canvasExportAsPng()
|
|
||||||
elif cid == self.CID_EXPORT_IMGUR[0]:
|
|
||||||
self.canvasExportImgur()
|
|
||||||
elif cid == self.CID_EXPORT_PASTEBIN[0]:
|
|
||||||
self.canvasExportPastebin()
|
|
||||||
elif cid == self.CID_EXIT[0]:
|
|
||||||
self.Close(True)
|
|
||||||
elif cid == self.CID_UNDO[0]:
|
|
||||||
self.panelCanvas.popUndo()
|
|
||||||
elif cid == self.CID_REDO[0]:
|
|
||||||
self.panelCanvas.popRedo()
|
|
||||||
elif cid == self.CID_CUT[0]:
|
|
||||||
pass
|
|
||||||
elif cid == self.CID_COPY[0]:
|
|
||||||
pass
|
|
||||||
elif cid == self.CID_PASTE[0]:
|
|
||||||
pass
|
|
||||||
elif cid == self.CID_DELETE[0]:
|
|
||||||
pass
|
|
||||||
elif cid == self.CID_INCR_CANVAS[0] \
|
|
||||||
or cid == self.CID_DECR_CANVAS[0]:
|
|
||||||
eventDc = self.panelCanvas.canvasBackend.getDeviceContext(self)
|
|
||||||
if cid == self.CID_INCR_CANVAS[0]:
|
|
||||||
newCanvasSize = [a+1 for a in self.panelCanvas.canvasSize]
|
|
||||||
else:
|
|
||||||
newCanvasSize = [a-1 if a > 1 else a for a in self.panelCanvas.canvasSize]
|
|
||||||
self.panelCanvas.resize(newCanvasSize)
|
|
||||||
self.panelCanvas.canvasBackend.resize( \
|
|
||||||
newCanvasSize, \
|
|
||||||
self.panelCanvas.canvasBackend.cellSize)
|
|
||||||
for numRow in range(self.panelCanvas.canvasSize[1] - 1):
|
|
||||||
self.panelCanvas.canvasMap.append([[1, 1], 0, " "])
|
|
||||||
self.panelCanvas.canvasMap.append([])
|
|
||||||
for numCol in range(self.panelCanvas.canvasSize[0]):
|
|
||||||
self.panelCanvas.canvasMap[-1].append([[1, 1], 0, " "])
|
|
||||||
self.panelCanvas.canvasBackend.drawPatch(eventDc, \
|
|
||||||
([numCol, self.panelCanvas.canvasSize[1] - 1], *[[1, 1], 0, " "]))
|
|
||||||
wx.SafeYield()
|
|
||||||
elif cid == self.CID_INCR_BRUSH[0]:
|
|
||||||
self.panelCanvas.brushSize = \
|
|
||||||
[a+1 for a in self.panelCanvas.brushSize]
|
|
||||||
elif cid == self.CID_DECR_BRUSH[0] \
|
|
||||||
and self.panelCanvas.brushSize[0] > 1 \
|
|
||||||
and self.panelCanvas.brushSize[1] > 1:
|
|
||||||
self.panelCanvas.brushSize = \
|
|
||||||
[a-1 for a in self.panelCanvas.brushSize]
|
|
||||||
elif cid == self.CID_SOLID_BRUSH[0]:
|
|
||||||
pass
|
|
||||||
elif cid == self.CID_RECT[0]:
|
|
||||||
self.menuItemsById[cid].Check(True)
|
|
||||||
self.panelCanvas.canvasCurTool = \
|
|
||||||
MiRCARTToolRect(self.panelCanvas)
|
|
||||||
elif cid == self.CID_CIRCLE[0]:
|
|
||||||
self.menuItemsById[cid].Check(True)
|
|
||||||
self.panelCanvas.canvasCurTool = \
|
|
||||||
MiRCARTToolCircle(self.panelCanvas)
|
|
||||||
elif cid == self.CID_LINE[0]:
|
|
||||||
self.menuItemsById[cid].Check(True)
|
|
||||||
self.panelCanvas.canvasCurTool = \
|
|
||||||
MiRCARTToolLine(self.panelCanvas)
|
|
||||||
elif cid == self.CID_TEXT[0]:
|
|
||||||
self.menuItemsById[cid].Check(True)
|
|
||||||
self.panelCanvas.canvasCurTool = \
|
|
||||||
MiRCARTToolText(self.panelCanvas)
|
|
||||||
elif cid >= self.CID_COLOUR00[0] \
|
|
||||||
and cid <= self.CID_COLOUR15[0]:
|
|
||||||
numColour = cid - self.CID_COLOUR00[0]
|
|
||||||
if event.GetEventType() == wx.wxEVT_TOOL:
|
|
||||||
self.panelCanvas.brushColours[0] = numColour
|
|
||||||
elif event.GetEventType() == wx.wxEVT_TOOL_RCLICKED:
|
|
||||||
self.panelCanvas.brushColours[1] = numColour
|
|
||||||
self._updateStatusBar()
|
|
||||||
# }}}
|
|
||||||
# {{{ __del__(self): destructor method
|
|
||||||
def __del__(self):
|
|
||||||
if self.panelCanvas != None:
|
|
||||||
self.panelCanvas.Close(); self.panelCanvas = None;
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# __init__(self, parent, appSize=(840, 630), canvasPos=(25, 50), canvasSize=(125, 35), cellSize=(7, 14)): initialisation method
|
# __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)):
|
def __init__(self, parent, appSize=(840, 630), canvasPos=(25, 50), canvasSize=(125, 35), cellSize=(7, 14)):
|
||||||
self._initPaletteToolBitmaps()
|
self._initPaletteToolBitmaps()
|
||||||
panelSkin = super().__init__(parent, wx.ID_ANY, "MiRCART", size=appSize)
|
panelSkin = super().__init__(parent, wx.ID_ANY, "MiRCART", size=appSize)
|
||||||
self.canvasPathName = None
|
|
||||||
self.panelCanvas = MiRCARTCanvas(panelSkin, parentFrame=self, \
|
self.panelCanvas = MiRCARTCanvas(panelSkin, parentFrame=self, \
|
||||||
canvasPos=canvasPos, canvasSize=canvasSize, cellSize=cellSize)
|
canvasPos=canvasPos, canvasSize=canvasSize, cellSize=cellSize)
|
||||||
self.panelCanvas.canvasCurTool = MiRCARTToolRect(self.panelCanvas)
|
self.panelCanvas.canvasInterface.canvasNew(None)
|
||||||
self.canvasNew()
|
|
||||||
|
|
||||||
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|
||||||
|
@ -34,68 +34,77 @@ TID_NOTHING = (0x005)
|
|||||||
TID_SELECT = (0x006)
|
TID_SELECT = (0x006)
|
||||||
TID_TOOLBAR = (0x007)
|
TID_TOOLBAR = (0x007)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Non-items
|
||||||
|
NID_MENU_SEP = (0x200, TID_NOTHING)
|
||||||
|
NID_TOOLBAR_SEP = (0x201, TID_NOTHING)
|
||||||
|
|
||||||
class MiRCARTGeneralFrame(wx.Frame):
|
class MiRCARTGeneralFrame(wx.Frame):
|
||||||
"""XXX"""
|
"""XXX"""
|
||||||
menuItemsById = toolBarItemsById = None
|
itemsById = menuItemsById = toolBarItemsById = None
|
||||||
statusBar = toolBar = None
|
statusBar = toolBar = None
|
||||||
|
|
||||||
# {{{ _initAccelTable(self, accelsDescr, handler): XXX
|
# {{{ _initAccelTable(self, accelsDescr): XXX
|
||||||
def _initAccelTable(self, accelsDescr, handler):
|
def _initAccelTable(self, accelsDescr):
|
||||||
accelTableEntries = [wx.AcceleratorEntry() for n in range(len(accelsDescr[2]))]
|
accelTableEntries = [wx.AcceleratorEntry() for n in range(len(accelsDescr[2]))]
|
||||||
for numAccel in range(len(accelsDescr[2])):
|
for numAccel in range(len(accelsDescr[2])):
|
||||||
accelDescr = accelsDescr[2][numAccel]
|
accelDescr = accelsDescr[2][numAccel]
|
||||||
if accelDescr[5] != None:
|
if accelDescr[5] != None:
|
||||||
|
self.itemsById[accelDescr[0]] = accelDescr
|
||||||
accelTableEntries[numAccel].Set(*accelDescr[5], accelDescr[0])
|
accelTableEntries[numAccel].Set(*accelDescr[5], accelDescr[0])
|
||||||
self.Bind(wx.EVT_MENU, handler, id=accelDescr[0])
|
self.Bind(wx.EVT_MENU, self.onInput, id=accelDescr[0])
|
||||||
return accelTableEntries
|
return accelTableEntries
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _initMenus(self, menusDescr, handler): XXX
|
# {{{ _initMenus(self, menusDescr): XXX
|
||||||
def _initMenus(self, menusDescr, handler):
|
def _initMenus(self, menusDescr):
|
||||||
self.menuItemsById = {}; menuBar = wx.MenuBar();
|
self.menuItemsById = {}; menuBar = wx.MenuBar();
|
||||||
for menuDescr in menusDescr:
|
for menuDescr in menusDescr:
|
||||||
menuWindow = wx.Menu()
|
menuWindow = wx.Menu()
|
||||||
for menuItem in menuDescr[4]:
|
for menuItem in menuDescr[4]:
|
||||||
if menuItem == self.NID_MENU_SEP:
|
if menuItem == NID_MENU_SEP:
|
||||||
menuWindow.AppendSeparator()
|
menuWindow.AppendSeparator()
|
||||||
elif menuItem[1] == TID_SELECT:
|
elif menuItem[1] == TID_SELECT:
|
||||||
|
self.itemsById[menuItem[0]] = menuItem
|
||||||
menuItemWindow = menuWindow.AppendRadioItem(menuItem[0], menuItem[3], menuItem[2])
|
menuItemWindow = menuWindow.AppendRadioItem(menuItem[0], menuItem[3], menuItem[2])
|
||||||
self.menuItemsById[menuItem[0]] = menuItemWindow
|
self.menuItemsById[menuItem[0]] = menuItemWindow
|
||||||
self.Bind(wx.EVT_MENU, handler, menuItemWindow)
|
self.Bind(wx.EVT_MENU, self.onInput, menuItemWindow)
|
||||||
if len(menuItem) == 7:
|
if menuItem[6] != None:
|
||||||
menuItemWindow.Check(menuItem[6])
|
menuItemWindow.Check(menuItem[6])
|
||||||
else:
|
else:
|
||||||
|
self.itemsById[menuItem[0]] = menuItem
|
||||||
menuItemWindow = menuWindow.Append(menuItem[0], menuItem[3], menuItem[2])
|
menuItemWindow = menuWindow.Append(menuItem[0], menuItem[3], menuItem[2])
|
||||||
self.menuItemsById[menuItem[0]] = menuItemWindow
|
self.menuItemsById[menuItem[0]] = menuItemWindow
|
||||||
self.Bind(wx.EVT_MENU, handler, menuItemWindow)
|
self.Bind(wx.EVT_MENU, self.onInput, menuItemWindow)
|
||||||
if len(menuItem) == 7:
|
if menuItem[6] != None:
|
||||||
menuItemWindow.Enable(menuItem[6])
|
menuItemWindow.Enable(menuItem[6])
|
||||||
menuBar.Append(menuWindow, menuDescr[3])
|
menuBar.Append(menuWindow, menuDescr[3])
|
||||||
return menuBar
|
return menuBar
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _initToolBars(self, toolBarsDescr, handler): XXX
|
# {{{ _initToolBars(self, toolBarsDescr, panelSkin): XXX
|
||||||
def _initToolBars(self, toolBarsDescr, handler, panelSkin):
|
def _initToolBars(self, toolBarsDescr, panelSkin):
|
||||||
self.toolBarItemsById = {}
|
self.toolBarItemsById = {}
|
||||||
self.toolBar = wx.ToolBar(panelSkin, -1, \
|
self.toolBar = wx.ToolBar(panelSkin, -1, \
|
||||||
style=wx.HORIZONTAL|wx.TB_FLAT|wx.TB_NODIVIDER)
|
style=wx.HORIZONTAL|wx.TB_FLAT|wx.TB_NODIVIDER)
|
||||||
self.toolBar.SetToolBitmapSize((16,16))
|
self.toolBar.SetToolBitmapSize((16,16))
|
||||||
for toolBarItem in toolBarsDescr[2]:
|
for toolBarItem in toolBarsDescr[2]:
|
||||||
if toolBarItem == self.NID_TOOLBAR_SEP:
|
if toolBarItem == NID_TOOLBAR_SEP:
|
||||||
self.toolBar.AddSeparator()
|
self.toolBar.AddSeparator()
|
||||||
else:
|
else:
|
||||||
|
self.itemsById[toolBarItem[0]] = toolBarItem
|
||||||
toolBarItemWindow = self.toolBar.AddTool( \
|
toolBarItemWindow = self.toolBar.AddTool( \
|
||||||
toolBarItem[0], toolBarItem[2], toolBarItem[4][2])
|
toolBarItem[0], toolBarItem[2], toolBarItem[4][2])
|
||||||
self.toolBarItemsById[toolBarItem[0]] = toolBarItemWindow
|
self.toolBarItemsById[toolBarItem[0]] = toolBarItemWindow
|
||||||
if len(toolBarItem) == 7 \
|
if toolBarItem[6] != None \
|
||||||
and toolBarItem[1] == TID_COMMAND:
|
and toolBarItem[1] == TID_COMMAND:
|
||||||
toolBarItemWindow.Enable(toolBarItem[6])
|
toolBarItemWindow.Enable(toolBarItem[6])
|
||||||
self.Bind(wx.EVT_TOOL, handler, toolBarItemWindow)
|
self.Bind(wx.EVT_TOOL, self.onInput, toolBarItemWindow)
|
||||||
self.Bind(wx.EVT_TOOL_RCLICKED, handler, toolBarItemWindow)
|
self.Bind(wx.EVT_TOOL_RCLICKED, self.onInput, toolBarItemWindow)
|
||||||
self.toolBar.Realize(); self.toolBar.Fit();
|
self.toolBar.Realize(); self.toolBar.Fit();
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ _initToolBitmaps(self): XXX
|
# {{{ _initToolBitmaps(self, toolBarsDescr): XXX
|
||||||
def _initToolBitmaps(self, toolBarsDescr):
|
def _initToolBitmaps(self, toolBarsDescr):
|
||||||
for toolBarItem in toolBarsDescr[2]:
|
for toolBarItem in toolBarsDescr[2]:
|
||||||
if toolBarItem == self.NID_TOOLBAR_SEP:
|
if toolBarItem == NID_TOOLBAR_SEP:
|
||||||
continue
|
continue
|
||||||
elif toolBarItem[4] == None:
|
elif toolBarItem[4] == None:
|
||||||
toolBarItem[4] = ["", None, wx.ArtProvider.GetBitmap( \
|
toolBarItem[4] = ["", None, wx.ArtProvider.GetBitmap( \
|
||||||
@ -115,42 +124,32 @@ class MiRCARTGeneralFrame(wx.Frame):
|
|||||||
toolBitmap.LoadFile(toolBitmapPathName, wx.BITMAP_TYPE_ANY)
|
toolBitmap.LoadFile(toolBitmapPathName, wx.BITMAP_TYPE_ANY)
|
||||||
toolBarItem[4] = ["", None, toolBitmap]
|
toolBarItem[4] = ["", None, toolBitmap]
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ onClose(self, event): XXX
|
# {{{ onInput(self, event): XXX
|
||||||
def onClose(self, event):
|
def onInput(self, event):
|
||||||
self.Destroy(); self.__del__();
|
|
||||||
# }}}
|
|
||||||
# {{{ onFrameCommand(self, event): XXX
|
|
||||||
def onFrameCommand(self, event):
|
|
||||||
pass
|
pass
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
#
|
#
|
||||||
# __init__(self, *args, **kwargs): initialisation method
|
# __init__(self, *args, **kwargs): initialisation method
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs); self.itemsById = {};
|
||||||
panelSkin = wx.Panel(self, wx.ID_ANY)
|
panelSkin = wx.Panel(self, wx.ID_ANY)
|
||||||
|
|
||||||
# Initialise menu bar, menus & menu items
|
# Initialise menu bar, menus & menu items
|
||||||
# Initialise toolbar & toolbar items
|
# Initialise toolbar & toolbar items
|
||||||
menuBar = self._initMenus(self.LID_MENUS[2], \
|
menuBar = self._initMenus(self.LID_MENUS[2])
|
||||||
self.onFrameCommand)
|
|
||||||
self.SetMenuBar(menuBar)
|
self.SetMenuBar(menuBar)
|
||||||
self._initToolBitmaps(self.LID_TOOLBARS[2])
|
self._initToolBitmaps(self.LID_TOOLBARS[2])
|
||||||
toolBar = self._initToolBars(self.LID_TOOLBARS[2], \
|
toolBar = self._initToolBars(self.LID_TOOLBARS[2], panelSkin)
|
||||||
self.onFrameCommand, panelSkin)
|
|
||||||
|
|
||||||
# Initialise accelerators (hotkeys)
|
# Initialise accelerators (hotkeys)
|
||||||
accelTable = wx.AcceleratorTable( \
|
accelTable = wx.AcceleratorTable( \
|
||||||
self._initAccelTable(self.LID_ACCELS[2], \
|
self._initAccelTable(self.LID_ACCELS[2]))
|
||||||
self.onFrameCommand))
|
|
||||||
self.SetAcceleratorTable(accelTable)
|
self.SetAcceleratorTable(accelTable)
|
||||||
|
|
||||||
# Initialise status bar
|
# Initialise status bar
|
||||||
self.statusBar = self.CreateStatusBar()
|
self.statusBar = self.CreateStatusBar()
|
||||||
|
|
||||||
# Bind event handlers
|
|
||||||
self.Bind(wx.EVT_CLOSE, self.onClose)
|
|
||||||
|
|
||||||
# Set focus on & show window
|
# Set focus on & show window
|
||||||
self.SetFocus(); self.Show(True);
|
self.SetFocus(); self.Show(True);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user