2018-01-02 15:19:07 +00:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
#
|
2018-01-05 16:21:14 +00:00
|
|
|
|
# MiRCART.py -- mIRC art editor for Windows & Linux
|
2018-01-02 15:19:07 +00:00
|
|
|
|
# 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.
|
|
|
|
|
#
|
|
|
|
|
|
2018-01-04 15:24:06 +00:00
|
|
|
|
import wx
|
2018-01-04 17:11:57 +00:00
|
|
|
|
import os, sys
|
2018-01-02 15:19:07 +00:00
|
|
|
|
|
2018-01-04 16:26:12 +00:00
|
|
|
|
# {{{ mircColours: mIRC colour number to RGBA map given none of ^[BFV_] (bold, italic, reverse, underline)
|
|
|
|
|
mircColours = [
|
|
|
|
|
(255, 255, 255, 255), # White
|
|
|
|
|
(0, 0, 0, 255), # Black
|
|
|
|
|
(0, 0, 187, 255), # Blue
|
|
|
|
|
(0, 187, 0, 255), # Green
|
|
|
|
|
(255, 85, 85, 255), # Light Red
|
|
|
|
|
(187, 0, 0, 255), # Red
|
|
|
|
|
(187, 0, 187, 255), # Purple
|
|
|
|
|
(187, 187, 0, 255), # Yellow
|
|
|
|
|
(255, 255, 85, 255), # Light Yellow
|
|
|
|
|
(85, 255, 85, 255), # Light Green
|
|
|
|
|
(0, 187, 187, 255), # Cyan
|
|
|
|
|
(85, 255, 255, 255), # Light Cyan
|
|
|
|
|
(85, 85, 255, 255), # Light Blue
|
|
|
|
|
(255, 85, 255, 255), # Pink
|
|
|
|
|
(85, 85, 85, 255), # Grey
|
|
|
|
|
(187, 187, 187, 255), # Light Grey
|
|
|
|
|
]
|
|
|
|
|
# }}}
|
|
|
|
|
|
2018-01-04 15:24:06 +00:00
|
|
|
|
class MiRCARTCanvas(wx.Panel):
|
|
|
|
|
"""XXX"""
|
2018-01-05 17:21:38 +00:00
|
|
|
|
parentFrame = None
|
2018-01-04 22:22:09 +00:00
|
|
|
|
canvasPos = canvasSize = canvasWinSize = cellPos = cellSize = None
|
|
|
|
|
canvasBitmap = canvasMap = canvasTools = None
|
|
|
|
|
mircBg = mircFg = mircBrushes = mircPens = None
|
2018-01-05 16:21:14 +00:00
|
|
|
|
patchesTmp = patchesUndo = patchesUndoLevel = None
|
2018-01-02 15:19:07 +00:00
|
|
|
|
|
2018-01-04 22:22:09 +00:00
|
|
|
|
# {{{ _drawPatch(): XXX
|
|
|
|
|
def _drawPatch(self, patch, eventDc, tmpDc, atX, atY):
|
|
|
|
|
patchXabs = (atX + patch[0]) * self.getCellWidth()
|
|
|
|
|
patchYabs = (atY + patch[1]) * self.getCellHeight()
|
|
|
|
|
brushFg = self.mircBrushes[patch[2]]
|
|
|
|
|
brushBg = self.mircBrushes[patch[3]]
|
|
|
|
|
pen = self.mircPens[patch[2]]
|
|
|
|
|
for dc in (eventDc, tmpDc):
|
|
|
|
|
dc.SetBrush(brushFg); dc.SetBackground(brushBg); dc.SetPen(pen);
|
|
|
|
|
dc.DrawRectangle(patchXabs, patchYabs, \
|
|
|
|
|
self.getCellWidth(), self.getCellHeight())
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ _eventPointToMapX(): XXX
|
|
|
|
|
def _eventPointToMapX(self, eventPoint):
|
|
|
|
|
rectX = eventPoint.x - (eventPoint.x % self.getCellWidth())
|
|
|
|
|
return int(rectX / self.getCellWidth() if rectX else 0)
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ _eventPointToMapY(): XXX
|
|
|
|
|
def _eventPointToMapY(self, eventPoint):
|
|
|
|
|
rectY = eventPoint.y - (eventPoint.y % self.getCellHeight())
|
|
|
|
|
return int(rectY / self.getCellHeight() if rectY else 0)
|
|
|
|
|
# }}}
|
2018-01-04 15:24:06 +00:00
|
|
|
|
# {{{ _onMouseEvent(): XXX
|
|
|
|
|
def _onMouseEvent(self, event):
|
|
|
|
|
eventObject = event.GetEventObject()
|
2018-01-04 22:22:09 +00:00
|
|
|
|
eventDc = wx.ClientDC(self); tmpDc = wx.MemoryDC();
|
|
|
|
|
tmpDc.SelectObject(self.canvasBitmap)
|
|
|
|
|
eventPoint = event.GetLogicalPosition(eventDc)
|
|
|
|
|
mapX = self._eventPointToMapX(eventPoint)
|
|
|
|
|
mapY = self._eventPointToMapY(eventPoint)
|
|
|
|
|
for tool in self.canvasTools:
|
|
|
|
|
if event.Dragging():
|
|
|
|
|
mapPatches = tool.onMouseMotion(event, mapX, mapY, event.LeftIsDown(), event.RightIsDown())
|
|
|
|
|
else:
|
|
|
|
|
mapPatches = tool.onMouseDown(event, mapX, mapY, event.LeftIsDown(), event.RightIsDown())
|
|
|
|
|
self._processMapPatches(mapPatches, eventDc, tmpDc, mapX, mapY)
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ _processMapPatches(): XXX
|
|
|
|
|
def _processMapPatches(self, mapPatches, eventDc, tmpDc, atX, atY):
|
|
|
|
|
for mapPatch in mapPatches:
|
|
|
|
|
mapPatchTmp = mapPatch[0]; mapPatchW = mapPatch[1]; mapPatchH = mapPatch[2];
|
|
|
|
|
if mapPatchTmp and self.patchesTmp:
|
|
|
|
|
for patch in self.patchesTmp:
|
2018-01-05 02:27:57 +00:00
|
|
|
|
patch[2] = self.canvasMap[patch[1]][patch[0]][0]
|
|
|
|
|
patch[3] = self.canvasMap[patch[1]][patch[0]][1]
|
|
|
|
|
patch[4] = self.canvasMap[patch[1]][patch[0]][2]
|
2018-01-04 22:22:09 +00:00
|
|
|
|
self._drawPatch(patch, eventDc, tmpDc, 0, 0)
|
|
|
|
|
self.patchesTmp = []
|
|
|
|
|
for patch in mapPatch[3]:
|
|
|
|
|
if mapPatchTmp:
|
|
|
|
|
mapItem = self.canvasMap[atY + patch[1]][atX + patch[0]]
|
2018-01-05 16:21:14 +00:00
|
|
|
|
self.patchesTmp.append([atX + patch[0], atY + patch[1], None, None, None])
|
2018-01-04 22:22:09 +00:00
|
|
|
|
self._drawPatch(patch, eventDc, tmpDc, atX, atY)
|
|
|
|
|
else:
|
2018-01-05 00:34:57 +00:00
|
|
|
|
mapItem = self.canvasMap[atY + patch[1]][atX + patch[0]]
|
|
|
|
|
if mapItem != [patch[2], patch[3], patch[4]]:
|
2018-01-05 16:21:14 +00:00
|
|
|
|
if self.patchesUndoLevel > 0:
|
|
|
|
|
del self.patchesUndo[0:self.patchesUndoLevel]
|
|
|
|
|
self.patchesUndoLevel = 0
|
|
|
|
|
self.patchesUndo.insert(0, ( \
|
|
|
|
|
(atX + patch[0], atY + patch[1], mapItem[0], mapItem[1], mapItem[2]), \
|
|
|
|
|
(atX + patch[0], atY + patch[1], patch[2], patch[3], " ")))
|
|
|
|
|
self.canvasMap[atY + patch[1]][atX + patch[0]] = [patch[2], patch[3], " "];
|
2018-01-05 00:34:57 +00:00
|
|
|
|
self._drawPatch(patch, eventDc, tmpDc, atX, atY)
|
2018-01-05 17:21:38 +00:00
|
|
|
|
if len(mapPatch[3]):
|
|
|
|
|
self.parentFrame.onCanvasUpdate()
|
2018-01-04 15:24:06 +00:00
|
|
|
|
# }}}
|
2018-01-04 16:26:12 +00:00
|
|
|
|
# {{{ getBackgroundColour(): XXX
|
|
|
|
|
def getBackgroundColour(self):
|
|
|
|
|
return self.mircBg
|
|
|
|
|
# }}}
|
2018-01-04 22:22:09 +00:00
|
|
|
|
# {{{ getCellHeight(): XXX
|
|
|
|
|
def getCellHeight(self):
|
|
|
|
|
return self.cellSize[1]
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ getCellWidth(): XXX
|
|
|
|
|
def getCellWidth(self):
|
|
|
|
|
return self.cellSize[0]
|
|
|
|
|
# }}}
|
2018-01-04 16:26:12 +00:00
|
|
|
|
# {{{ getForegroundColour(): XXX
|
|
|
|
|
def getForegroundColour(self):
|
|
|
|
|
return self.mircFg
|
|
|
|
|
# }}}
|
2018-01-04 17:11:57 +00:00
|
|
|
|
# {{{ getHeight(): XXX
|
|
|
|
|
def getHeight(self):
|
|
|
|
|
return self.canvasSize[1]
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ getMap(): XXX
|
|
|
|
|
def getMap(self):
|
|
|
|
|
return self.canvasMap
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ getWidth(): XXX
|
|
|
|
|
def getWidth(self):
|
|
|
|
|
return self.canvasSize[0]
|
|
|
|
|
# }}}
|
2018-01-04 15:24:06 +00:00
|
|
|
|
# {{{ onLeftDown(): XXX
|
|
|
|
|
def onLeftDown(self, event):
|
|
|
|
|
self._onMouseEvent(event)
|
2018-01-02 15:19:07 +00:00
|
|
|
|
# }}}
|
2018-01-04 15:24:06 +00:00
|
|
|
|
# {{{ onMotion(): XXX
|
|
|
|
|
def onMotion(self, event):
|
|
|
|
|
self._onMouseEvent(event)
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onPaint(): XXX
|
|
|
|
|
def onPaint(self, event):
|
2018-01-04 19:22:15 +00:00
|
|
|
|
eventDc = wx.BufferedPaintDC(self, self.canvasBitmap)
|
2018-01-04 15:24:06 +00:00
|
|
|
|
# }}}
|
2018-01-04 16:26:12 +00:00
|
|
|
|
# {{{ onPaletteEvent(): XXX
|
|
|
|
|
def onPaletteEvent(self, leftDown, rightDown, numColour):
|
|
|
|
|
if leftDown:
|
|
|
|
|
self.mircFg = numColour
|
|
|
|
|
elif rightDown:
|
|
|
|
|
self.mircBg = numColour
|
|
|
|
|
# }}}
|
2018-01-04 15:24:06 +00:00
|
|
|
|
# {{{ onRightDown(): XXX
|
|
|
|
|
def onRightDown(self, event):
|
|
|
|
|
self._onMouseEvent(event)
|
|
|
|
|
# }}}
|
2018-01-05 16:21:14 +00:00
|
|
|
|
# {{{ redo(): XXX
|
|
|
|
|
def redo(self):
|
|
|
|
|
if self.patchesUndoLevel > 0:
|
|
|
|
|
self.patchesUndoLevel -= 1
|
|
|
|
|
redoPatch = self.patchesUndo[self.patchesUndoLevel][1]
|
|
|
|
|
self.canvasMap[redoPatch[1]][redoPatch[0]] = \
|
|
|
|
|
[redoPatch[2], redoPatch[3], redoPatch[4]]
|
|
|
|
|
eventDc = wx.ClientDC(self); tmpDc = wx.MemoryDC();
|
|
|
|
|
tmpDc.SelectObject(self.canvasBitmap)
|
|
|
|
|
self._drawPatch(redoPatch, eventDc, tmpDc, 0, 0)
|
2018-01-05 17:21:38 +00:00
|
|
|
|
self.parentFrame.onCanvasUpdate()
|
2018-01-05 16:21:14 +00:00
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
# }}}
|
2018-01-05 00:34:57 +00:00
|
|
|
|
# {{{ undo(): XXX
|
|
|
|
|
def undo(self):
|
2018-01-05 16:21:14 +00:00
|
|
|
|
if self.patchesUndo[self.patchesUndoLevel] != None:
|
|
|
|
|
undoPatch = self.patchesUndo[self.patchesUndoLevel][0]
|
|
|
|
|
self.canvasMap[undoPatch[1]][undoPatch[0]] = \
|
|
|
|
|
[undoPatch[2], undoPatch[3], undoPatch[4]]
|
2018-01-05 00:34:57 +00:00
|
|
|
|
eventDc = wx.ClientDC(self); tmpDc = wx.MemoryDC();
|
|
|
|
|
tmpDc.SelectObject(self.canvasBitmap)
|
2018-01-05 16:21:14 +00:00
|
|
|
|
self._drawPatch(undoPatch, eventDc, tmpDc, 0, 0)
|
|
|
|
|
self.patchesUndoLevel += 1
|
2018-01-05 17:21:38 +00:00
|
|
|
|
self.parentFrame.onCanvasUpdate()
|
2018-01-05 16:21:14 +00:00
|
|
|
|
return True
|
2018-01-05 00:34:57 +00:00
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
# }}}
|
2018-01-04 16:26:12 +00:00
|
|
|
|
# {{{ Initialisation method
|
2018-01-05 17:21:38 +00:00
|
|
|
|
def __init__(self, parent, parentFrame, canvasPos, cellSize, canvasSize, canvasTools):
|
|
|
|
|
self.parentFrame = parentFrame
|
2018-01-04 22:22:09 +00:00
|
|
|
|
canvasWinSize = (cellSize[0] * canvasSize[0], cellSize[1] * canvasSize[1])
|
|
|
|
|
super().__init__(parent, pos=canvasPos, size=canvasWinSize)
|
|
|
|
|
self.canvasPos = canvasPos; self.canvasSize = canvasSize; self.canvasWinSize = canvasWinSize;
|
|
|
|
|
self.cellPos = (0, 0); self.cellSize = cellSize;
|
2018-01-04 15:24:06 +00:00
|
|
|
|
|
2018-01-04 22:22:09 +00:00
|
|
|
|
self.canvasBitmap = wx.Bitmap(canvasWinSize)
|
2018-01-04 17:11:57 +00:00
|
|
|
|
self.canvasMap = [[[1, 1, " "] for x in range(canvasSize[0])] for y in range(canvasSize[1])]
|
2018-01-04 22:22:09 +00:00
|
|
|
|
self.canvasTools = []
|
|
|
|
|
for canvasTool in canvasTools:
|
|
|
|
|
self.canvasTools.append(canvasTool(self))
|
|
|
|
|
|
2018-01-04 15:24:06 +00:00
|
|
|
|
self.mircBg = 1; self.mircFg = 4;
|
2018-01-04 22:22:09 +00:00
|
|
|
|
self.mircBrushes = [None for x in range(len(mircColours))]
|
|
|
|
|
self.mircPens = [None for x in range(len(mircColours))]
|
|
|
|
|
for mircColour in range(0, len(mircColours)):
|
|
|
|
|
self.mircBrushes[mircColour] = wx.Brush( \
|
|
|
|
|
wx.Colour(mircColours[mircColour]), wx.BRUSHSTYLE_SOLID)
|
|
|
|
|
self.mircPens[mircColour] = wx.Pen( \
|
|
|
|
|
wx.Colour(mircColours[mircColour]), 1)
|
|
|
|
|
|
2018-01-05 16:21:14 +00:00
|
|
|
|
self.patchesTmp = []
|
|
|
|
|
self.patchesUndo = [None]; self.patchesUndoLevel = 0;
|
2018-01-04 15:24:06 +00:00
|
|
|
|
|
|
|
|
|
self.Bind(wx.EVT_LEFT_DOWN, self.onLeftDown)
|
|
|
|
|
self.Bind(wx.EVT_MOTION, self.onMotion)
|
|
|
|
|
self.Bind(wx.EVT_PAINT, self.onPaint)
|
|
|
|
|
self.Bind(wx.EVT_RIGHT_DOWN, self.onRightDown)
|
2018-01-04 16:26:12 +00:00
|
|
|
|
# }}}
|
|
|
|
|
|
2018-01-04 22:22:09 +00:00
|
|
|
|
class MiRCARTTool():
|
|
|
|
|
"""XXX"""
|
|
|
|
|
parentCanvas = None
|
|
|
|
|
|
|
|
|
|
# {{{ onMouseDown(): XXX
|
|
|
|
|
def onMouseDown(self, event, mapX, mapY, isLeftDown, isRightDown):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onMouseMotion(): XXX
|
|
|
|
|
def onMouseMotion(self, event, mapX, mapY, isLeftDown, isRightDown):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ Initialisation method
|
|
|
|
|
def __init__(self, parentCanvas):
|
|
|
|
|
self.parentCanvas = parentCanvas
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
|
|
class MiRCARTToolRect(MiRCARTTool):
|
|
|
|
|
"""XXX"""
|
|
|
|
|
|
|
|
|
|
# {{{ _draw(): XXX
|
|
|
|
|
def _draw(self, event, mapX, mapY, isLeftDown, isRightDown):
|
|
|
|
|
if isLeftDown:
|
|
|
|
|
return [[False, 1, 1, [[0, 0, \
|
|
|
|
|
self.parentCanvas.getForegroundColour(), \
|
|
|
|
|
self.parentCanvas.getForegroundColour(), " "]]],
|
|
|
|
|
[True, 1, 1, [[0, 0, \
|
|
|
|
|
self.parentCanvas.getForegroundColour(), \
|
|
|
|
|
self.parentCanvas.getForegroundColour(), " "]]]]
|
|
|
|
|
elif isRightDown:
|
|
|
|
|
return [[False, 1, 1, [[0, 0, \
|
|
|
|
|
self.parentCanvas.getBackgroundColour(), \
|
|
|
|
|
self.parentCanvas.getBackgroundColour(), " "]]], \
|
|
|
|
|
[True, 1, 1, [[0, 0, \
|
2018-01-05 02:27:57 +00:00
|
|
|
|
self.parentCanvas.getBackgroundColour(), \
|
|
|
|
|
self.parentCanvas.getBackgroundColour(), " "]]]]
|
2018-01-04 22:22:09 +00:00
|
|
|
|
else:
|
|
|
|
|
return [[True, 1, 1, [[0, 0, \
|
|
|
|
|
self.parentCanvas.getForegroundColour(), \
|
|
|
|
|
self.parentCanvas.getForegroundColour(), " "]]]]
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onMouseDown(): XXX
|
|
|
|
|
def onMouseDown(self, event, mapX, mapY, isLeftDown, isRightDown):
|
|
|
|
|
return self._draw(event, mapX, mapY, isLeftDown, isRightDown)
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onMouseMotion(): XXX
|
|
|
|
|
def onMouseMotion(self, event, mapX, mapY, isLeftDown, isRightDown):
|
|
|
|
|
return self._draw(event, mapX, mapY, isLeftDown, isRightDown)
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ Initialisation method
|
|
|
|
|
def __init__(self, parentCanvas):
|
|
|
|
|
super().__init__(parentCanvas)
|
|
|
|
|
# }}}
|
|
|
|
|
|
2018-01-04 15:24:06 +00:00
|
|
|
|
class MiRCARTFrame(wx.Frame):
|
|
|
|
|
"""XXX"""
|
2018-01-05 17:08:10 +00:00
|
|
|
|
menuFile = None
|
|
|
|
|
menuFileNew = menuFileOpen = menuFileSave = menuFileSaveAs = None
|
|
|
|
|
menuFileExportPastebin = menuFileExportPng = None
|
|
|
|
|
menuFileExit = None
|
|
|
|
|
menuEdit = None
|
|
|
|
|
menuEditRedo = menuEditUndo = None
|
|
|
|
|
menuEditCopy = menuEditCut = menuEditDelete = menuEditPaste = None
|
|
|
|
|
menuEditDecrBrush = menuEditIncrBrush = menuEditSolidBrush = None
|
|
|
|
|
menuTools = menuToolsCircle = menuToolsLine = menuToolsRect = None
|
|
|
|
|
menuBar = None
|
2018-01-05 19:45:21 +00:00
|
|
|
|
panelSkin = panelCanvas = None
|
|
|
|
|
toolBar = None
|
|
|
|
|
toolBarIdNew = toolBarIdOpen = toolBarIdSave = toolBarIdSaveAs = None
|
|
|
|
|
toolBarIdUndo = toolBarIdRedo = None
|
|
|
|
|
toolBarIdCut = toolBarIdCopy = toolBarIdPaste = toolBarIdDelete = None
|
|
|
|
|
toolBarIdIncrBrush = toolBarIdDecrBrush = toolBarIdSolidBrush = None
|
|
|
|
|
toolBarIdRect = toolBarIdCircle = toolBarIdLine = None
|
|
|
|
|
toolBarIdColours = toolBarBitmapColours = None
|
2018-01-05 16:21:14 +00:00
|
|
|
|
accelRedoId = accelUndoId = accelTable = statusBar = None
|
2018-01-04 15:24:06 +00:00
|
|
|
|
|
2018-01-04 16:26:12 +00:00
|
|
|
|
# {{{ _updateStatusBar(): XXX
|
|
|
|
|
def _updateStatusBar(self):
|
|
|
|
|
text = "Foreground colour:"
|
|
|
|
|
text += " " + str(self.panelCanvas.getForegroundColour())
|
|
|
|
|
text += " | "
|
|
|
|
|
text += "Background colour:"
|
|
|
|
|
text += " " + str(self.panelCanvas.getBackgroundColour())
|
|
|
|
|
self.statusBar.SetStatusText(text)
|
|
|
|
|
# }}}
|
2018-01-05 16:21:14 +00:00
|
|
|
|
# {{{ onAccelRedo(): XXX
|
|
|
|
|
def onAccelRedo(self, event):
|
|
|
|
|
self.panelCanvas.redo()
|
|
|
|
|
# }}}
|
2018-01-05 00:59:04 +00:00
|
|
|
|
# {{{ onAccelUndo(): XXX
|
|
|
|
|
def onAccelUndo(self, event):
|
|
|
|
|
self.panelCanvas.undo()
|
|
|
|
|
# }}}
|
2018-01-05 17:21:38 +00:00
|
|
|
|
# {{{ onCanvasUpdate(): XXX
|
|
|
|
|
def onCanvasUpdate(self):
|
|
|
|
|
if self.panelCanvas.patchesUndo[self.panelCanvas.patchesUndoLevel] != None:
|
|
|
|
|
self.menuEditUndo.Enable(True)
|
|
|
|
|
else:
|
|
|
|
|
self.menuEditUndo.Enable(False)
|
|
|
|
|
if self.panelCanvas.patchesUndoLevel > 0:
|
|
|
|
|
self.menuEditRedo.Enable(True)
|
|
|
|
|
else:
|
|
|
|
|
self.menuEditRedo.Enable(False)
|
|
|
|
|
# }}}
|
2018-01-05 17:08:10 +00:00
|
|
|
|
# {{{ onEditCopy(): XXX
|
|
|
|
|
def onEditCopy(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onEditCut(): XXX
|
|
|
|
|
def onEditCut(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onEditDecrBrush(): XXX
|
|
|
|
|
def onEditDecrBrush(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onEditDelete(): XXX
|
|
|
|
|
def onEditDelete(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onEditIncrBrush(): XXX
|
|
|
|
|
def onEditIncrBrush(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onEditPaste(): XXX
|
|
|
|
|
def onEditPaste(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onEditRedo(): XXX
|
|
|
|
|
def onEditRedo(self, event):
|
2018-01-05 16:21:14 +00:00
|
|
|
|
self.panelCanvas.redo()
|
|
|
|
|
# }}}
|
2018-01-05 17:08:10 +00:00
|
|
|
|
# {{{ onEditSolidBrush(): XXX
|
|
|
|
|
def onEditSolidBrush(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onEditUndo(): XXX
|
|
|
|
|
def onEditUndo(self, event):
|
2018-01-05 00:34:57 +00:00
|
|
|
|
self.panelCanvas.undo()
|
|
|
|
|
# }}}
|
2018-01-05 17:08:10 +00:00
|
|
|
|
# {{{ onFileExit(): XXX
|
|
|
|
|
def onFileExit(self, event):
|
|
|
|
|
self.Close(True)
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onFileExportPastebin(): XXX
|
|
|
|
|
def onFileExportPastebin(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onFileExportPng(): XXX
|
|
|
|
|
def onFileExportPng(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onFileNew(): XXX
|
|
|
|
|
def onFileNew(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onFileOpen(): XXX
|
|
|
|
|
def onFileOpen(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onFileSave(): XXX
|
|
|
|
|
def onFileSave(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
2018-01-04 15:24:06 +00:00
|
|
|
|
# {{{ onFileSaveAs(): XXX
|
|
|
|
|
def onFileSaveAs(self, event):
|
2018-01-04 22:22:09 +00:00
|
|
|
|
with wx.FileDialog(self, "Save As...", os.getcwd(), "", \
|
2018-01-04 17:11:57 +00:00
|
|
|
|
"*.txt", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog:
|
|
|
|
|
if dialog.ShowModal() == wx.ID_CANCEL:
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
with open(dialog.GetPath(), "w") as file:
|
|
|
|
|
canvasMap = self.panelCanvas.getMap()
|
|
|
|
|
canvasHeight = self.panelCanvas.getHeight()
|
|
|
|
|
canvasWidth = self.panelCanvas.getWidth()
|
|
|
|
|
for canvasRow in range(0, canvasHeight):
|
|
|
|
|
colourLastBg = colourLastFg = None;
|
|
|
|
|
for canvasCol in range(0, canvasWidth):
|
|
|
|
|
canvasColBg = canvasMap[canvasRow][canvasCol][0]
|
|
|
|
|
canvasColFg = canvasMap[canvasRow][canvasCol][1]
|
|
|
|
|
canvasColText = canvasMap[canvasRow][canvasCol][2]
|
2018-01-04 22:22:09 +00:00
|
|
|
|
if colourLastBg != canvasColBg \
|
2018-01-04 17:11:57 +00:00
|
|
|
|
or colourLastFg != canvasColFg:
|
|
|
|
|
colourLastBg = canvasColBg; colourLastFg = canvasColFg;
|
|
|
|
|
file.write("" + str(canvasColFg) + "," + str(canvasColBg))
|
|
|
|
|
file.write(canvasColText)
|
|
|
|
|
file.write("\n")
|
|
|
|
|
except IOError as error:
|
|
|
|
|
wx.LogError("IOError {}".format(error))
|
2018-01-02 15:19:07 +00:00
|
|
|
|
# }}}
|
2018-01-05 17:21:38 +00:00
|
|
|
|
# {{{ onPaletteEvent(): XXX
|
|
|
|
|
def onPaletteEvent(self, leftDown, rightDown, numColour):
|
|
|
|
|
self.panelCanvas.onPaletteEvent(leftDown, rightDown, numColour)
|
|
|
|
|
self._updateStatusBar()
|
|
|
|
|
# }}}
|
2018-01-05 19:45:21 +00:00
|
|
|
|
# {{{ onToolColourBg(): XXX
|
|
|
|
|
def onToolColourBg(self, event):
|
|
|
|
|
itemId = event.GetId()
|
|
|
|
|
for numColour in range(0, len(mircColours)):
|
|
|
|
|
if self.toolBarIdColours[numColour] == itemId:
|
|
|
|
|
self.onPaletteEvent(False, True, numColour)
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onToolColourFg(): XXX
|
|
|
|
|
def onToolColourFg(self, event):
|
|
|
|
|
itemId = event.GetId()
|
|
|
|
|
for numColour in range(0, len(mircColours)):
|
|
|
|
|
if self.toolBarIdColours[numColour] == itemId:
|
|
|
|
|
self.onPaletteEvent(True, False, numColour)
|
|
|
|
|
# }}}
|
2018-01-05 17:08:10 +00:00
|
|
|
|
# {{{ onToolsRect(): XXX
|
|
|
|
|
def onToolsRect(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onToolsCircle(): XXX
|
|
|
|
|
def onToolsCircle(self, event):
|
|
|
|
|
pass
|
|
|
|
|
# }}}
|
|
|
|
|
# {{{ onToolsLine(): XXX
|
|
|
|
|
def onToolsLine(self, event):
|
|
|
|
|
pass
|
2018-01-02 15:19:07 +00:00
|
|
|
|
# }}}
|
2018-01-04 16:26:12 +00:00
|
|
|
|
# {{{ Initialisation method
|
2018-01-05 19:45:21 +00:00
|
|
|
|
def __init__(self, parent, appSize=(800, 600), canvasPos=(25, 50), cellSize=(7, 14), canvasSize=(80, 25)):
|
2018-01-04 15:24:06 +00:00
|
|
|
|
super().__init__(parent, wx.ID_ANY, "MiRCART", size=appSize)
|
|
|
|
|
|
|
|
|
|
self.panelSkin = wx.Panel(self, wx.ID_ANY)
|
2018-01-05 19:45:21 +00:00
|
|
|
|
self.panelCanvas = MiRCARTCanvas(self.panelSkin, \
|
|
|
|
|
parentFrame=self, canvasPos=canvasPos, cellSize=cellSize, \
|
2018-01-04 22:22:09 +00:00
|
|
|
|
canvasSize=canvasSize, canvasTools=[MiRCARTToolRect])
|
2018-01-04 16:26:12 +00:00
|
|
|
|
|
2018-01-05 17:08:10 +00:00
|
|
|
|
self.menuFile = wx.Menu()
|
|
|
|
|
self.menuFileNew = self.menuFile.Append(wx.ID_NEW, "&New", "New")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onFileNew, self.menuFileNew)
|
|
|
|
|
self.menuFileOpen = self.menuFile.Append(wx.ID_OPEN, "&Open...", "Open...")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onFileOpen, self.menuFileOpen)
|
|
|
|
|
self.menuFileSave = self.menuFile.Append(wx.ID_SAVE, "&Save", "Save")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onFileSave, self.menuFileSave)
|
|
|
|
|
self.menuFileSaveAs = self.menuFile.Append(wx.ID_SAVEAS, "Save &As...", "Save As...")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onFileSaveAs, self.menuFileSaveAs)
|
|
|
|
|
self.menuFile.AppendSeparator()
|
2018-01-05 17:27:01 +00:00
|
|
|
|
self.menuFileExportPastebin = self.menuFile.Append(wx.NewId(), "Export to Pasteb&in...", "Export to Pastebin...")
|
2018-01-05 17:08:10 +00:00
|
|
|
|
self.Bind(wx.EVT_MENU, self.onFileExportPastebin, self.menuFileExportPastebin)
|
2018-01-05 17:27:01 +00:00
|
|
|
|
self.menuFileExportPng = self.menuFile.Append(wx.NewId(), "Export as PN&G...", "Export as PNG...")
|
2018-01-05 17:08:10 +00:00
|
|
|
|
self.Bind(wx.EVT_MENU, self.onFileExportPng, self.menuFileExportPng)
|
|
|
|
|
self.menuFile.AppendSeparator()
|
|
|
|
|
self.menuFileExit = self.menuFile.Append(wx.ID_EXIT, "E&xit", "Exit")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onFileExit, self.menuFileExit)
|
|
|
|
|
|
|
|
|
|
self.menuEdit = wx.Menu()
|
|
|
|
|
self.menuEditUndo = self.menuEdit.Append(wx.ID_UNDO, "&Undo", "Undo")
|
2018-01-05 17:12:02 +00:00
|
|
|
|
self.menuEditUndo.Enable(False)
|
2018-01-05 17:08:10 +00:00
|
|
|
|
self.Bind(wx.EVT_MENU, self.onEditUndo, self.menuEditUndo)
|
|
|
|
|
self.menuEditRedo = self.menuEdit.Append(wx.ID_REDO, "&Redo", "Redo")
|
2018-01-05 17:12:02 +00:00
|
|
|
|
self.menuEditRedo.Enable(False)
|
2018-01-05 17:08:10 +00:00
|
|
|
|
self.Bind(wx.EVT_MENU, self.onEditRedo, self.menuEditRedo)
|
|
|
|
|
self.menuEdit.AppendSeparator()
|
|
|
|
|
self.menuEditCut = self.menuEdit.Append(wx.ID_CUT, "Cu&t", "Cut")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onEditCut, self.menuEditCut)
|
|
|
|
|
self.menuEditCopy = self.menuEdit.Append(wx.ID_COPY, "&Copy", "Copy")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onEditCopy, self.menuEditCopy)
|
|
|
|
|
self.menuEditPaste = self.menuEdit.Append(wx.ID_PASTE, "&Paste", "Paste")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onEditPaste, self.menuEditPaste)
|
|
|
|
|
self.menuEditDelete = self.menuEdit.Append(wx.ID_DELETE, "De&lete", "Delete")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onEditDelete, self.menuEditDelete)
|
|
|
|
|
self.menuEdit.AppendSeparator()
|
|
|
|
|
self.menuEditIncrBrush = self.menuEdit.Append(wx.NewId(), "&Increase brush size", "Increase brush size")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onEditIncrBrush, self.menuEditIncrBrush)
|
|
|
|
|
self.menuEditDecrBrush = self.menuEdit.Append(wx.NewId(), "&Decrease brush size", "Decrease brush size")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onEditDecrBrush, self.menuEditDecrBrush)
|
|
|
|
|
self.menuEditSolidBrush = self.menuEdit.AppendRadioItem(wx.NewId(), "&Solid brush", "Solid brush")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onEditSolidBrush, self.menuEditSolidBrush)
|
|
|
|
|
|
|
|
|
|
self.menuTools = wx.Menu()
|
|
|
|
|
self.menuToolsRect = self.menuTools.AppendRadioItem(wx.NewId(), "&Rectangle", "Rectangle")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onToolsRect, self.menuToolsRect)
|
|
|
|
|
self.menuToolsCircle = self.menuTools.AppendRadioItem(wx.NewId(), "&Circle", "Circle")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onToolsCircle, self.menuToolsCircle)
|
|
|
|
|
self.menuToolsLine = self.menuTools.AppendRadioItem(wx.NewId(), "&Line", "Line")
|
|
|
|
|
self.Bind(wx.EVT_MENU, self.onToolsLine, self.menuToolsLine)
|
|
|
|
|
|
|
|
|
|
self.menuBar = wx.MenuBar()
|
|
|
|
|
self.menuBar.Append(self.menuFile, "&File")
|
|
|
|
|
self.menuBar.Append(self.menuEdit, "&Edit")
|
|
|
|
|
self.menuBar.Append(self.menuTools, "&Tools")
|
|
|
|
|
self.SetMenuBar(self.menuBar)
|
|
|
|
|
|
2018-01-05 16:21:14 +00:00
|
|
|
|
accelTableEntries = [wx.AcceleratorEntry() for n in range(2)]
|
2018-01-05 17:08:10 +00:00
|
|
|
|
self.accelRedoId = wx.NewId()
|
2018-01-05 16:21:14 +00:00
|
|
|
|
accelTableEntries[0].Set(wx.ACCEL_CTRL, ord('Y'), self.accelRedoId)
|
2018-01-05 17:08:10 +00:00
|
|
|
|
self.Bind(wx.EVT_MENU, self.onAccelRedo, id=self.accelRedoId)
|
|
|
|
|
self.accelUndoId = wx.NewId()
|
2018-01-05 16:21:14 +00:00
|
|
|
|
accelTableEntries[1].Set(wx.ACCEL_CTRL, ord('Z'), self.accelUndoId)
|
2018-01-05 17:08:10 +00:00
|
|
|
|
self.Bind(wx.EVT_MENU, self.onAccelUndo, id=self.accelUndoId)
|
2018-01-05 16:21:14 +00:00
|
|
|
|
self.accelTable = wx.AcceleratorTable(accelTableEntries)
|
2018-01-05 00:59:04 +00:00
|
|
|
|
self.SetAcceleratorTable(self.accelTable)
|
2018-01-05 17:08:10 +00:00
|
|
|
|
|
2018-01-04 16:26:12 +00:00
|
|
|
|
self.statusBar = self.CreateStatusBar()
|
|
|
|
|
self._updateStatusBar()
|
2018-01-04 15:24:06 +00:00
|
|
|
|
|
2018-01-05 19:45:21 +00:00
|
|
|
|
self.toolBar = wx.ToolBar(self.panelSkin, -1, style=wx.HORIZONTAL|wx.TB_FLAT|wx.TB_NODIVIDER)
|
|
|
|
|
self.toolBar.SetToolBitmapSize((16,16))
|
|
|
|
|
self.toolNew = self.toolBar.AddTool(wx.NewId(), "New", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onFileNew, self.toolNew)
|
|
|
|
|
self.toolOpen = self.toolBar.AddTool(wx.NewId(), "Open", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onFileOpen, self.toolOpen)
|
|
|
|
|
self.toolSave = self.toolBar.AddTool(wx.NewId(), "Save", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onFileSave, self.toolSave)
|
|
|
|
|
self.toolSaveAs = self.toolBar.AddTool(wx.NewId(), "Save As...", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onFileSaveAs, self.toolSaveAs)
|
|
|
|
|
self.toolUndo = self.toolBar.AddTool(wx.NewId(), "Undo", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onEditUndo, self.toolUndo)
|
|
|
|
|
self.toolRedo = self.toolBar.AddTool(wx.NewId(), "Redo", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_REDO, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onEditRedo, self.toolRedo)
|
|
|
|
|
self.toolBar.AddSeparator()
|
|
|
|
|
self.toolCut = self.toolBar.AddTool(wx.NewId(), "Cut", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_CUT, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onEditCut, self.toolCut)
|
|
|
|
|
self.toolCopy = self.toolBar.AddTool(wx.NewId(), "Copy", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onEditCopy, self.toolCopy)
|
|
|
|
|
self.toolPaste = self.toolBar.AddTool(wx.NewId(), "Paste", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_PASTE, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onEditPaste, self.toolPaste)
|
|
|
|
|
self.toolDelete = self.toolBar.AddTool(wx.NewId(), "Delete", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onEditDelete, self.toolDelete)
|
|
|
|
|
self.toolBar.AddSeparator()
|
|
|
|
|
self.toolIncrBrush = self.toolBar.AddTool(wx.NewId(), "Increase brush size", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_PLUS, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onEditIncrBrush, self.toolIncrBrush)
|
|
|
|
|
self.toolDecrBrush = self.toolBar.AddTool(wx.NewId(), "Decrease brush size", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_MINUS, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onEditDecrBrush, self.toolDecrBrush)
|
|
|
|
|
self.toolSolidBrush = self.toolBar.AddTool(wx.NewId(), "Solid brush", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_HELP, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onEditSolidBrush, self.toolSolidBrush)
|
|
|
|
|
self.toolBar.AddSeparator()
|
|
|
|
|
self.toolRect = self.toolBar.AddTool(wx.NewId(), "Rectangle", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_HELP, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onToolsRect, self.toolRect)
|
|
|
|
|
self.toolCircle = self.toolBar.AddTool(wx.NewId(), "Circle", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_HELP, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onToolsCircle, self.toolCircle)
|
|
|
|
|
self.toolLine = self.toolBar.AddTool(wx.NewId(), "Line", \
|
|
|
|
|
wx.ArtProvider.GetBitmap(wx.ART_HELP, wx.ART_TOOLBAR, (16,16)))
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onToolsLine, self.toolLine)
|
|
|
|
|
self.toolBar.AddSeparator()
|
|
|
|
|
self.toolBarIdColours = [None for x in range(0, len(mircColours))]
|
|
|
|
|
self.toolBarBitmapColours = [None for x in range(0, len(mircColours))]
|
|
|
|
|
for numColour in range(0, len(mircColours)):
|
|
|
|
|
self.toolBarBitmapColours[numColour] = wx.Bitmap((16,16))
|
|
|
|
|
tmpDc = wx.MemoryDC(); tmpDc.SelectObject(self.toolBarBitmapColours[numColour]);
|
|
|
|
|
tmpDc.SetBrush(self.panelCanvas.mircBrushes[numColour])
|
|
|
|
|
tmpDc.SetBackground(self.panelCanvas.mircBrushes[numColour])
|
|
|
|
|
tmpDc.SetPen(self.panelCanvas.mircPens[numColour])
|
|
|
|
|
tmpDc.DrawRectangle(0, 0, 16, 16)
|
|
|
|
|
self.toolBarIdColours[numColour] = wx.NewId()
|
|
|
|
|
print(self.toolBarIdColours[numColour])
|
|
|
|
|
self.toolBar.AddTool(self.toolBarIdColours[numColour], \
|
|
|
|
|
"mIRC colour #" + str(numColour), self.toolBarBitmapColours[numColour])
|
|
|
|
|
self.Bind(wx.EVT_TOOL, self.onToolColourFg, id=self.toolBarIdColours[numColour])
|
|
|
|
|
self.Bind(wx.EVT_TOOL_RCLICKED, self.onToolColourBg, id=self.toolBarIdColours[numColour])
|
|
|
|
|
self.toolBar.Realize(); self.toolBar.Fit();
|
|
|
|
|
|
2018-01-05 17:08:10 +00:00
|
|
|
|
self.SetFocus()
|
2018-01-04 15:24:06 +00:00
|
|
|
|
self.Show(True)
|
2018-01-04 16:26:12 +00:00
|
|
|
|
# }}}
|
2018-01-02 15:19:07 +00:00
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Entry point
|
2018-01-02 21:24:21 +00:00
|
|
|
|
def main(*argv):
|
2018-01-04 15:24:06 +00:00
|
|
|
|
wxApp = wx.App(False)
|
|
|
|
|
MiRCARTFrame(None)
|
|
|
|
|
wxApp.MainLoop()
|
2018-01-02 15:19:07 +00:00
|
|
|
|
if __name__ == "__main__":
|
2018-01-04 15:24:06 +00:00
|
|
|
|
main(*sys.argv)
|
2018-01-02 15:19:07 +00:00
|
|
|
|
|
2018-01-04 15:24:06 +00:00
|
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|