MiRCART{General,}Frame.py, assets/*.png: adds icons for tools.

MiRCART{Frame,ToolText}.py: initial implementation of Text tool.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-01-08 20:28:43 +01:00
parent f431adb381
commit 2a7f281d29
7 changed files with 144 additions and 68 deletions

View File

@ -29,6 +29,7 @@ from MiRCARTGeneralFrame import MiRCARTGeneralFrame, \
from MiRCARTToolCircle import MiRCARTToolCircle from MiRCARTToolCircle import MiRCARTToolCircle
from MiRCARTToolLine import MiRCARTToolLine from MiRCARTToolLine import MiRCARTToolLine
from MiRCARTToolRect import MiRCARTToolRect from MiRCARTToolRect import MiRCARTToolRect
from MiRCARTToolText import MiRCARTToolText
import os, wx import os, wx
@ -38,48 +39,51 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
canvasPos = canvasSize = cellSize = None canvasPos = canvasSize = cellSize = 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")]]
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")]]
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")]]
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]
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]
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]
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]
CID_EXIT = (0x107, TID_COMMAND, "Exit", "E&xit", None, None) CID_EXIT = [0x107, TID_COMMAND, "Exit", "E&xit", None, None]
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]
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]
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]
CID_COPY = (0x10b, TID_COMMAND, "Copy", "&Copy", wx.ART_COPY, None, False) CID_COPY = [0x10b, TID_COMMAND, "Copy", "&Copy", ["", wx.ART_COPY], None, False]
CID_PASTE = (0x10c, TID_COMMAND, "Paste", "&Paste", wx.ART_PASTE, None, False) CID_PASTE = [0x10c, TID_COMMAND, "Paste", "&Paste", ["", wx.ART_PASTE], None, False]
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]
CID_INCRBRUSH = (0x10e, TID_COMMAND, "Increase brush size", \ CID_INCRBRUSH = [0x10e, 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("+")]]
CID_DECRBRUSH = (0x10f, TID_COMMAND, "Decrease brush size", \ CID_DECRBRUSH = [0x10f, 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("-")]]
CID_SOLID_BRUSH = (0x110, TID_SELECT, "Solid brush", "&Solid brush", None, None, True) CID_SOLID_BRUSH = [0x110, TID_SELECT, "Solid brush", "&Solid brush", None, None, True]
CID_RECT = (0x111, TID_SELECT, "Rectangle", "&Rectangle", None, None, True)
CID_CIRCLE = (0x112, TID_SELECT, "Circle", "&Circle", None, None, False) CID_RECT = [0x150, TID_SELECT, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True]
CID_LINE = (0x113, TID_SELECT, "Line", "&Line", None, None, False) CID_CIRCLE = [0x151, TID_SELECT, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False]
CID_COLOUR00 = (0x114, TID_COMMAND, "Colour #00", "Colour #00", None, None) CID_LINE = [0x152, TID_SELECT, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False]
CID_COLOUR01 = (0x115, TID_COMMAND, "Colour #01", "Colour #01", None, None) CID_TEXT = [0x153, TID_SELECT, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False]
CID_COLOUR02 = (0x116, TID_COMMAND, "Colour #02", "Colour #02", None, None)
CID_COLOUR03 = (0x117, TID_COMMAND, "Colour #03", "Colour #03", None, None) CID_COLOUR00 = [0x1a0, TID_COMMAND, "Colour #00", "Colour #00", None, None]
CID_COLOUR04 = (0x118, TID_COMMAND, "Colour #04", "Colour #04", None, None) CID_COLOUR01 = [0x1a1, TID_COMMAND, "Colour #01", "Colour #01", None, None]
CID_COLOUR05 = (0x119, TID_COMMAND, "Colour #05", "Colour #05", None, None) CID_COLOUR02 = [0x1a2, TID_COMMAND, "Colour #02", "Colour #02", None, None]
CID_COLOUR06 = (0x11a, TID_COMMAND, "Colour #06", "Colour #06", None, None) CID_COLOUR03 = [0x1a3, TID_COMMAND, "Colour #03", "Colour #03", None, None]
CID_COLOUR07 = (0x11b, TID_COMMAND, "Colour #07", "Colour #07", None, None) CID_COLOUR04 = [0x1a4, TID_COMMAND, "Colour #04", "Colour #04", None, None]
CID_COLOUR08 = (0x11c, TID_COMMAND, "Colour #08", "Colour #08", None, None) CID_COLOUR05 = [0x1a5, TID_COMMAND, "Colour #05", "Colour #05", None, None]
CID_COLOUR09 = (0x11d, TID_COMMAND, "Colour #09", "Colour #09", None, None) CID_COLOUR06 = [0x1a6, TID_COMMAND, "Colour #06", "Colour #06", None, None]
CID_COLOUR10 = (0x11e, TID_COMMAND, "Colour #10", "Colour #10", None, None) CID_COLOUR07 = [0x1a7, TID_COMMAND, "Colour #07", "Colour #07", None, None]
CID_COLOUR11 = (0x11f, TID_COMMAND, "Colour #11", "Colour #11", None, None) CID_COLOUR08 = [0x1a8, TID_COMMAND, "Colour #08", "Colour #08", None, None]
CID_COLOUR12 = (0x120, TID_COMMAND, "Colour #12", "Colour #12", None, None) CID_COLOUR09 = [0x1a9, TID_COMMAND, "Colour #09", "Colour #09", None, None]
CID_COLOUR13 = (0x121, TID_COMMAND, "Colour #13", "Colour #13", None, None) CID_COLOUR10 = [0x1aa, TID_COMMAND, "Colour #10", "Colour #10", None, None]
CID_COLOUR14 = (0x122, TID_COMMAND, "Colour #14", "Colour #14", None, None) CID_COLOUR11 = [0x1ab, TID_COMMAND, "Colour #11", "Colour #11", None, None]
CID_COLOUR15 = (0x123, TID_COMMAND, "Colour #15", "Colour #15", None, None) CID_COLOUR12 = [0x1ac, TID_COMMAND, "Colour #12", "Colour #12", None, None]
CID_COLOUR13 = [0x1ad, TID_COMMAND, "Colour #13", "Colour #13", None, None]
CID_COLOUR14 = [0x1ae, TID_COMMAND, "Colour #14", "Colour #14", None, None]
CID_COLOUR15 = [0x1af, TID_COMMAND, "Colour #15", "Colour #15", None, None]
# }}} # }}}
# {{{ Non-items # {{{ Non-items
NID_MENU_SEP = (0x200, TID_NOTHING) NID_MENU_SEP = (0x200, TID_NOTHING)
@ -95,7 +99,7 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
CID_CUT, CID_COPY, CID_PASTE, CID_DELETE, NID_MENU_SEP, \ CID_CUT, CID_COPY, CID_PASTE, CID_DELETE, NID_MENU_SEP, \
CID_INCRBRUSH, CID_DECRBRUSH, CID_SOLID_BRUSH)) CID_INCRBRUSH, CID_DECRBRUSH, CID_SOLID_BRUSH))
MID_TOOLS = (0x302, TID_MENU, "Tools", "&Tools", ( \ MID_TOOLS = (0x302, TID_MENU, "Tools", "&Tools", ( \
CID_RECT, CID_CIRCLE, CID_LINE)) CID_RECT, CID_CIRCLE, CID_LINE, CID_TEXT))
# }}} # }}}
# {{{ Toolbars # {{{ Toolbars
BID_TOOLBAR = (0x400, TID_TOOLBAR, ( \ BID_TOOLBAR = (0x400, TID_TOOLBAR, ( \
@ -103,7 +107,7 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
CID_UNDO, CID_REDO, NID_TOOLBAR_SEP, \ CID_UNDO, CID_REDO, NID_TOOLBAR_SEP, \
CID_CUT, CID_COPY, CID_PASTE, CID_DELETE, NID_TOOLBAR_SEP, \ CID_CUT, CID_COPY, CID_PASTE, CID_DELETE, NID_TOOLBAR_SEP, \
CID_INCRBRUSH, CID_DECRBRUSH, CID_SOLID_BRUSH, NID_TOOLBAR_SEP, \ CID_INCRBRUSH, CID_DECRBRUSH, CID_SOLID_BRUSH, NID_TOOLBAR_SEP, \
CID_RECT, CID_CIRCLE, CID_LINE, NID_TOOLBAR_SEP, \ CID_RECT, CID_CIRCLE, CID_LINE, CID_TEXT, NID_TOOLBAR_SEP, \
CID_COLOUR00, CID_COLOUR01, CID_COLOUR02, CID_COLOUR03, CID_COLOUR04, \ CID_COLOUR00, CID_COLOUR01, CID_COLOUR02, CID_COLOUR03, CID_COLOUR04, \
CID_COLOUR05, CID_COLOUR06, CID_COLOUR07, CID_COLOUR08, CID_COLOUR09, \ CID_COLOUR05, CID_COLOUR06, CID_COLOUR07, CID_COLOUR08, CID_COLOUR09, \
CID_COLOUR10, CID_COLOUR11, CID_COLOUR12, CID_COLOUR13, CID_COLOUR14, \ CID_COLOUR10, CID_COLOUR11, CID_COLOUR12, CID_COLOUR13, CID_COLOUR14, \
@ -119,17 +123,8 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
LID_TOOLBARS = (0x602, TID_LIST, (BID_TOOLBAR)) LID_TOOLBARS = (0x602, TID_LIST, (BID_TOOLBAR))
# }}} # }}}
# {{{ _dialogSaveChanges(self) # {{{ _initPaletteToolBitmaps(self): XXX
def _dialogSaveChanges(self): def _initPaletteToolBitmaps(self):
with wx.MessageDialog(self, \
"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
# }}}
# {{{ _setPaletteToolBitmaps(self): XXX
def _setPaletteToolBitmaps(self):
paletteDescr = ( \ paletteDescr = ( \
self.CID_COLOUR00, self.CID_COLOUR01, self.CID_COLOUR02, self.CID_COLOUR03, self.CID_COLOUR04, \ self.CID_COLOUR00, self.CID_COLOUR01, self.CID_COLOUR02, self.CID_COLOUR03, self.CID_COLOUR04, \
self.CID_COLOUR05, self.CID_COLOUR06, self.CID_COLOUR07, self.CID_COLOUR08, self.CID_COLOUR09, \ self.CID_COLOUR05, self.CID_COLOUR06, self.CID_COLOUR07, self.CID_COLOUR08, self.CID_COLOUR09, \
@ -145,8 +140,16 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
toolBitmapDc.SetBackground(toolBitmapBrush) toolBitmapDc.SetBackground(toolBitmapBrush)
toolBitmapDc.SetPen(wx.Pen(wx.Colour(toolBitmapColour), 1)) toolBitmapDc.SetPen(wx.Pen(wx.Colour(toolBitmapColour), 1))
toolBitmapDc.DrawRectangle(0, 0, 16, 16) toolBitmapDc.DrawRectangle(0, 0, 16, 16)
self.toolBar.SetToolNormalBitmap( \ paletteDescr[numColour][4] = ["", None, toolBitmap]
paletteDescr[numColour][0], toolBitmap) # }}}
# {{{ _dialogSaveChanges(self)
def _dialogSaveChanges(self):
with wx.MessageDialog(self, \
"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
# }}} # }}}
# {{{ _updateStatusBar(self, showColours=None, showFileName=True, showPos=None): XXX # {{{ _updateStatusBar(self, showColours=None, showFileName=True, showPos=None): XXX
def _updateStatusBar(self, showColours=True, showFileName=True, showPos=True): def _updateStatusBar(self, showColours=True, showFileName=True, showPos=True):
@ -369,6 +372,10 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
self.menuItemsById[cid].Check(True) self.menuItemsById[cid].Check(True)
self.panelCanvas.canvasCurTool = \ self.panelCanvas.canvasCurTool = \
MiRCARTToolLine(self.panelCanvas) 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] \ elif cid >= self.CID_COLOUR00[0] \
and cid <= self.CID_COLOUR15[0]: and cid <= self.CID_COLOUR15[0]:
numColour = cid - self.CID_COLOUR00[0] numColour = cid - self.CID_COLOUR00[0]
@ -387,8 +394,8 @@ class MiRCARTFrame(MiRCARTGeneralFrame):
# #
# __init__(self, parent, appSize=(800, 600), canvasPos=(25, 50), canvasSize=(100, 30), cellSize=(7, 14)): initialisation method # __init__(self, parent, appSize=(800, 600), canvasPos=(25, 50), canvasSize=(100, 30), cellSize=(7, 14)): initialisation method
def __init__(self, parent, appSize=(800, 600), canvasPos=(25, 50), canvasSize=(100, 30), cellSize=(7, 14)): def __init__(self, parent, appSize=(800, 600), canvasPos=(25, 50), canvasSize=(100, 30), cellSize=(7, 14)):
self._initPaletteToolBitmaps()
panelSkin = super().__init__(parent, wx.ID_ANY, "MiRCART", size=appSize) panelSkin = super().__init__(parent, wx.ID_ANY, "MiRCART", size=appSize)
self._setPaletteToolBitmaps()
self.canvasPos = canvasPos; self.cellSize = cellSize; self.canvasSize = canvasSize; self.canvasPos = canvasPos; self.cellSize = cellSize; self.canvasSize = canvasSize;
self.canvasPathName = None self.canvasPathName = None
self.panelCanvas = MiRCARTCanvas(panelSkin, parentFrame=self, \ self.panelCanvas = MiRCARTCanvas(panelSkin, parentFrame=self, \

View File

@ -75,29 +75,45 @@ class MiRCARTGeneralFrame(wx.Frame):
# {{{ _initToolBars(self, toolBarsDescr, handler): XXX # {{{ _initToolBars(self, toolBarsDescr, handler): XXX
def _initToolBars(self, toolBarsDescr, handler, panelSkin): def _initToolBars(self, toolBarsDescr, handler, 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 == self.NID_TOOLBAR_SEP:
self.toolBar.AddSeparator() self.toolBar.AddSeparator()
else: else:
if toolBarItem[4] != None: toolBarItemWindow = self.toolBar.AddTool( \
toolBarItemIcon = wx.ArtProvider.GetBitmap( \ toolBarItem[0], toolBarItem[2], toolBarItem[4][2])
toolBarItem[4], wx.ART_TOOLBAR, (16,16))
else:
toolBarItemIcon = wx.ArtProvider.GetBitmap( \
wx.ART_HELP, wx.ART_TOOLBAR, (16,16))
toolBarItemWindow = self.toolBar.AddTool( \
toolBarItem[0], toolBarItem[2], toolBarItemIcon)
self.toolBarItemsById[toolBarItem[0]] = toolBarItemWindow self.toolBarItemsById[toolBarItem[0]] = toolBarItemWindow
if len(toolBarItem) == 7 \ if len(toolBarItem) == 7 \
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, handler, toolBarItemWindow)
self.Bind(wx.EVT_TOOL_RCLICKED, handler, toolBarItemWindow) self.Bind(wx.EVT_TOOL_RCLICKED, handler, toolBarItemWindow)
self.toolBar.Realize(); self.toolBar.Fit(); self.toolBar.Realize(); self.toolBar.Fit();
# }}} # }}}
# {{{ _initToolBitmaps(self): XXX
def _initToolBitmaps(self, toolBarsDescr):
for toolBarItem in toolBarsDescr[2]:
if toolBarItem == self.NID_TOOLBAR_SEP:
continue
elif toolBarItem[4] == None:
toolBarItem[4] = ["", None, wx.ArtProvider.GetBitmap( \
wx.ART_HELP, wx.ART_TOOLBAR, (16,16))]
elif toolBarItem[4][0] == "" \
and toolBarItem[4][1] != None:
toolBarItem[4] = ["", None, wx.ArtProvider.GetBitmap( \
toolBarItem[4][1], wx.ART_TOOLBAR, (16,16))]
elif toolBarItem[4][0] == "" \
and toolBarItem[4][1] == None:
toolBarItem[4] = ["", None, toolBarItem[4][2]]
elif toolBarItem[4][0] != "":
toolBitmap = wx.Bitmap((16,16))
toolBitmap.LoadFile( \
os.path.join("assets", toolBarItem[4][0]), \
wx.BITMAP_TYPE_ANY)
toolBarItem[4] = ["", None, toolBitmap]
# }}}
# {{{ onClose(self, event): XXX # {{{ onClose(self, event): XXX
def onClose(self, event): def onClose(self, event):
self.Destroy(); self.__del__(); self.Destroy(); self.__del__();
@ -118,6 +134,7 @@ class MiRCARTGeneralFrame(wx.Frame):
menuBar = self._initMenus(self.LID_MENUS[2], \ menuBar = self._initMenus(self.LID_MENUS[2], \
self.onFrameCommand) self.onFrameCommand)
self.SetMenuBar(menuBar) self.SetMenuBar(menuBar)
self._initToolBitmaps(self.LID_TOOLBARS[2])
toolBar = self._initToolBars(self.LID_TOOLBARS[2], \ toolBar = self._initToolBars(self.LID_TOOLBARS[2], \
self.onFrameCommand, panelSkin) self.onFrameCommand, panelSkin)

52
MiRCARTToolText.py Normal file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env python3
#
# MiRCARTToolText.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 MiRCARTTool import MiRCARTTool
class MiRCARTToolText(MiRCARTTool):
"""XXX"""
#
# onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown): XXX
def onMouseEvent(self, event, atPoint, brushColours, brushSize, isDragging, isLeftDown, isRightDown):
brushColours = brushColours.copy()
if isLeftDown:
brushColours[1] = brushColours[0]
elif isRightDown:
brushColours[0] = brushColours[1]
else:
brushColours[1] = brushColours[0]
brushPatches = []
for brushRow in range(brushSize[1]):
for brushCol in range(brushSize[0] * 2):
brushPatches.append([[ \
atPoint[0] + brushCol, \
atPoint[1] + brushRow], \
brushColours, 0, " "])
if isLeftDown or isRightDown:
return [[False, brushPatches], [True, brushPatches]]
else:
return [[True, brushPatches]]
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120

BIN
assets/toolCircle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

BIN
assets/toolLine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

BIN
assets/toolRect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

BIN
assets/toolText.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B