From b83684073eb771806a53b48eb91a598e827f243b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Sun, 8 Sep 2019 19:02:19 +0200 Subject: [PATCH] libgui/GuiCanvasInterface.py: minor cleanup. --- libgui/GuiCanvasInterface.py | 276 +++++++++++++++++------------------ 1 file changed, 130 insertions(+), 146 deletions(-) diff --git a/libgui/GuiCanvasInterface.py b/libgui/GuiCanvasInterface.py index 266f11e..a8fc3ee 100644 --- a/libgui/GuiCanvasInterface.py +++ b/libgui/GuiCanvasInterface.py @@ -24,29 +24,6 @@ from GuiFrame import NID_MENU_SEP, NID_TOOLBAR_HSEP from ImgurApiKey import ImgurApiKey import io, os, sys, wx -def GuiCanvasCommandDecorator(caption, label, icon, accel, initialState): - # {{{ GuiCanvasCommandDecoratorOuter(targetObject) - def GuiCanvasCommandDecoratorOuter(targetObject): - if callable(targetObject): - if not hasattr(targetObject, "attrDict"): - setattr(targetObject, "attrDict", []) - targetObject.attrDict = {"caption": caption, "label": label, "icon": icon, "accel": accel, "initialState": initialState, "id": None} - return targetObject - return GuiCanvasCommandDecoratorOuter - # }}} - -def GuiCanvasSelectDecorator(idx, caption, label, icon, accel, initialState): - # {{{ GuiCanvasSelectDecoratorOuter(targetObject) - def GuiCanvasSelectDecoratorOuter(targetObject): - if callable(targetObject): - if not hasattr(targetObject, "attrList"): - setattr(targetObject, "attrList", []) - setattr(targetObject, "isSelect", True) - targetObject.attrList.insert(0, {"caption": caption, "label": label, "icon": icon, "accel": accel, "initialState": initialState, "id": None, "idx": idx}) - return targetObject - return GuiCanvasSelectDecoratorOuter - # }}} - class GuiCanvasInterface(): # {{{ _import(self, f, newDirty, pathName) def _import(self, f, newDirty, pathName): @@ -114,13 +91,45 @@ class GuiCanvasInterface(): return True # }}} + # {{{ CommandDecoratorOuter(targetObject) + def CommandDecorator(caption, label, icon, accel, initialState): + def CommandDecoratorOuter(targetObject): + if callable(targetObject): + if not hasattr(targetObject, "attrDict"): + setattr(targetObject, "attrDict", []) + targetObject.attrDict = {"caption": caption, "label": label, "icon": icon, "accel": accel, "initialState": initialState, "id": None} + return targetObject + return CommandDecoratorOuter + # }}} + # {{{ CommandListDecoratorOuter(targetObject) + def CommandListDecorator(idx, caption, label, icon, accel, initialState): + def CommandListDecoratorOuter(targetObject): + if callable(targetObject): + if not hasattr(targetObject, "attrList"): + setattr(targetObject, "attrList", []) + targetObject.attrList.insert(0, {"caption": caption, "label": label, "icon": icon, "accel": accel, "initialState": initialState, "id": None, "idx": idx}) + return targetObject + return CommandListDecoratorOuter + # }}} + # {{{ SelectDecoratorOuter(targetObject) + def SelectDecorator(idx, caption, label, icon, accel, initialState): + def SelectDecoratorOuter(targetObject): + if callable(targetObject): + if not hasattr(targetObject, "attrList"): + setattr(targetObject, "attrList", []) + setattr(targetObject, "isSelect", True) + targetObject.attrList.insert(0, {"caption": caption, "label": label, "icon": icon, "accel": accel, "initialState": initialState, "id": None, "idx": idx}) + return targetObject + return SelectDecoratorOuter + # }}} + # {{{ canvasAbout(self, event) - @GuiCanvasCommandDecorator("About", "&About", None, None, True) + @CommandDecorator("About", "&About", None, None, True) def canvasAbout(self, event): GuiCanvasInterfaceAbout(self.parentFrame) # }}} # {{{ canvasBrush(self, f, idx) - @GuiCanvasSelectDecorator(0, "Solid brush", "Solid brush", None, None, True) + @SelectDecorator(0, "Solid brush", "Solid brush", None, None, True) def canvasBrush(self, f, idx): def canvasBrush_(self, event): pass @@ -129,22 +138,22 @@ class GuiCanvasInterface(): return canvasBrush_ # }}} # {{{ canvasColour(self, f, idx) - @GuiCanvasSelectDecorator(0, "Colour #00", "Colour #00 (Bright White)", None, None, False) - @GuiCanvasSelectDecorator(1, "Colour #01", "Colour #01 (Black)", None, None, False) - @GuiCanvasSelectDecorator(2, "Colour #02", "Colour #02 (Blue)", None, None, False) - @GuiCanvasSelectDecorator(3, "Colour #03", "Colour #03 (Green)", None, None, False) - @GuiCanvasSelectDecorator(4, "Colour #04", "Colour #04 (Red)", None, None, False) - @GuiCanvasSelectDecorator(5, "Colour #05", "Colour #05 (Light Red)", None, None, False) - @GuiCanvasSelectDecorator(6, "Colour #06", "Colour #06 (Pink)", None, None, False) - @GuiCanvasSelectDecorator(7, "Colour #07", "Colour #07 (Yellow)", None, None, False) - @GuiCanvasSelectDecorator(8, "Colour #08", "Colour #08 (Light Yellow)", None, None, False) - @GuiCanvasSelectDecorator(9, "Colour #09", "Colour #09 (Light Green)", None, None, False) - @GuiCanvasSelectDecorator(10, "Colour #10", "Colour #10 (Cyan)", None, None, False) - @GuiCanvasSelectDecorator(11, "Colour #11", "Colour #11 (Light Cyan)", None, None, False) - @GuiCanvasSelectDecorator(12, "Colour #12", "Colour #12 (Light Blue)", None, None, False) - @GuiCanvasSelectDecorator(13, "Colour #13", "Colour #13 (Light Pink)", None, None, False) - @GuiCanvasSelectDecorator(14, "Colour #14", "Colour #14 (Grey)", None, None, False) - @GuiCanvasSelectDecorator(15, "Colour #15", "Colour #15 (Light Grey)", None, None, False) + @SelectDecorator(0, "Colour #00", "Colour #00 (Bright White)", None, None, False) + @SelectDecorator(1, "Colour #01", "Colour #01 (Black)", None, None, False) + @SelectDecorator(2, "Colour #02", "Colour #02 (Blue)", None, None, False) + @SelectDecorator(3, "Colour #03", "Colour #03 (Green)", None, None, False) + @SelectDecorator(4, "Colour #04", "Colour #04 (Red)", None, None, False) + @SelectDecorator(5, "Colour #05", "Colour #05 (Light Red)", None, None, False) + @SelectDecorator(6, "Colour #06", "Colour #06 (Pink)", None, None, False) + @SelectDecorator(7, "Colour #07", "Colour #07 (Yellow)", None, None, False) + @SelectDecorator(8, "Colour #08", "Colour #08 (Light Yellow)", None, None, False) + @SelectDecorator(9, "Colour #09", "Colour #09 (Light Green)", None, None, False) + @SelectDecorator(10, "Colour #10", "Colour #10 (Cyan)", None, None, False) + @SelectDecorator(11, "Colour #11", "Colour #11 (Light Cyan)", None, None, False) + @SelectDecorator(12, "Colour #12", "Colour #12 (Light Blue)", None, None, False) + @SelectDecorator(13, "Colour #13", "Colour #13 (Light Pink)", None, None, False) + @SelectDecorator(14, "Colour #14", "Colour #14 (Grey)", None, None, False) + @SelectDecorator(15, "Colour #15", "Colour #15 (Light Grey)", None, None, False) def canvasColour(self, f, idx): def canvasColour_(self, event): if event.GetEventType() == wx.wxEVT_TOOL: @@ -157,7 +166,7 @@ class GuiCanvasInterface(): return canvasColour_ # }}} # {{{ canvasColourAlpha(self, f, idx) - @GuiCanvasSelectDecorator(0, "Transparent colour", "Transparent colour", None, None, False) + @SelectDecorator(0, "Transparent colour", "Transparent colour", None, None, False) def canvasColourAlpha(self, f, idx): def canvasColourAlpha_(self, event): if event.GetEventType() == wx.wxEVT_TOOL: @@ -170,28 +179,28 @@ class GuiCanvasInterface(): return canvasColourAlpha_ # }}} # {{{ canvasCopy(self, event) - @GuiCanvasCommandDecorator("Copy", "&Copy", ["", wx.ART_COPY], None, False) + @CommandDecorator("Copy", "&Copy", ["", wx.ART_COPY], None, False) def canvasCopy(self, event): pass # }}} # {{{ canvasCut(self, event) - @GuiCanvasCommandDecorator("Cut", "Cu&t", ["", wx.ART_CUT], None, False) + @CommandDecorator("Cut", "Cu&t", ["", wx.ART_CUT], None, False) def canvasCut(self, event): pass # }}} # {{{ canvasDelete(self, event) - @GuiCanvasCommandDecorator("Delete", "De&lete", ["", wx.ART_DELETE], None, False) + @CommandDecorator("Delete", "De&lete", ["", wx.ART_DELETE], None, False) def canvasDelete(self, event): pass # }}} # {{{ canvasExit(self, event) - @GuiCanvasCommandDecorator("Exit", "E&xit", None, [wx.ACCEL_CTRL, ord("X")], None) + @CommandDecorator("Exit", "E&xit", None, [wx.ACCEL_CTRL, ord("X")], None) def canvasExit(self, event): if self._promptSaveChanges(): self.parentFrame.Close(True) # }}} # {{{ canvasNew(self, event, newCanvasSize=None) - @GuiCanvasCommandDecorator("New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None) + @CommandDecorator("New", "&New", ["", wx.ART_NEW], [wx.ACCEL_CTRL, ord("N")], None) def canvasNew(self, event, newCanvasSize=None): def canvasImportEmpty(pathName): nonlocal newCanvasSize @@ -203,7 +212,7 @@ class GuiCanvasInterface(): self._import(canvasImportEmpty, False, None) # }}} # {{{ canvasOpen(self, event) - @GuiCanvasCommandDecorator("Open", "&Open", ["", wx.ART_FILE_OPEN], [wx.ACCEL_CTRL, ord("O")], None) + @CommandDecorator("Open", "&Open", ["", wx.ART_FILE_OPEN], [wx.ACCEL_CTRL, ord("O")], None) def canvasOpen(self, event): def canvasImportmIRC(pathName): rc, error = self.parentCanvas.canvas.importStore.importTextFile(pathName) @@ -211,18 +220,18 @@ class GuiCanvasInterface(): self._importFile(canvasImportmIRC, False, "mIRC art files (*.txt)|*.txt|All Files (*.*)|*.*") # }}} # {{{ canvasPaste(self, event) - @GuiCanvasCommandDecorator("Paste", "&Paste", ["", wx.ART_PASTE], None, False) + @CommandDecorator("Paste", "&Paste", ["", wx.ART_PASTE], None, False) def canvasPaste(self, event): pass # }}} # {{{ canvasRedo(self, event) - @GuiCanvasCommandDecorator("Redo", "&Redo", ["", wx.ART_REDO], [wx.ACCEL_CTRL, ord("Y")], False) + @CommandDecorator("Redo", "&Redo", ["", wx.ART_REDO], [wx.ACCEL_CTRL, ord("Y")], False) def canvasRedo(self, event): self.parentCanvas.dispatchDeltaPatches(self.parentCanvas.canvas.journal.popRedo()) self.update(size=self.parentCanvas.canvas.size, undoLevel=self.parentCanvas.canvas.journal.patchesUndoLevel) # }}} # {{{ canvasSave(self, event) - @GuiCanvasCommandDecorator("Save", "&Save", ["", wx.ART_FILE_SAVE], [wx.ACCEL_CTRL, ord("S")], None) + @CommandDecorator("Save", "&Save", ["", wx.ART_FILE_SAVE], [wx.ACCEL_CTRL, ord("S")], None) def canvasSave(self, event): if self.canvasPathName == None: if self.canvasSaveAs(event) == False: @@ -239,7 +248,7 @@ class GuiCanvasInterface(): return False # }}} # {{{ canvasSaveAs(self, event) - @GuiCanvasCommandDecorator("Save As...", "Save &As...", ["", wx.ART_FILE_SAVE_AS], None, None) + @CommandDecorator("Save As...", "Save &As...", ["", wx.ART_FILE_SAVE_AS], None, None) def canvasSaveAs(self, event): with wx.FileDialog(self.parentCanvas, "Save As", os.getcwd(), "", "mIRC art files (*.txt)|*.txt|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog: if dialog.ShowModal() == wx.ID_CANCEL: @@ -249,92 +258,67 @@ class GuiCanvasInterface(): return self.canvasSave(event) # }}} # {{{ canvasUndo(self, event) - @GuiCanvasCommandDecorator("Undo", "&Undo", ["", wx.ART_UNDO], [wx.ACCEL_CTRL, ord("Z")], False) + @CommandDecorator("Undo", "&Undo", ["", wx.ART_UNDO], [wx.ACCEL_CTRL, ord("Z")], False) def canvasUndo(self, event): self.parentCanvas.dispatchDeltaPatches(self.parentCanvas.canvas.journal.popUndo()) self.update(size=self.parentCanvas.canvas.size, undoLevel=self.parentCanvas.canvas.journal.patchesUndoLevel) # }}} - # {{{ canvasDecrBrushHeight(self, event) - @GuiCanvasCommandDecorator("Decrease brush height", "Decrease brush height", ["toolDecrBrushH.png"], None, None) - def canvasDecrBrushHeight(self, event): - if self.parentCanvas.brushSize[1] > 1: - self.parentCanvas.brushSize[1] -= 1 - self.update(brushSize=self.parentCanvas.brushSize) + # {{{ canvasBrushSize(self, f, dimension, incrFlag) + @CommandListDecorator(0, "Decrease brush width", "Decrease brush width", ["toolDecrBrushW.png"], None, None) + @CommandListDecorator(1, "Decrease brush height", "Decrease brush height", ["toolDecrBrushH.png"], None, None) + @CommandListDecorator(2, "Decrease brush size", "Decrease brush size", ["toolDecrBrushHW.png"], None, None) + @CommandListDecorator(3, "Increase brush width", "Increase brush width", ["toolIncrBrushW.png"], None, None) + @CommandListDecorator(4, "Increase brush height", "Increase brush height", ["toolIncrBrushH.png"], None, None) + @CommandListDecorator(5, "Increase brush size", "Increase brush size", ["toolIncrBrushHW.png"], None, None) + def canvasBrushSize(self, f, dimension, incrFlag): + def canvasBrushSize_(self, event): + if (dimension < 2) and not incrFlag: + if self.parentCanvas.brushSize[dimension] > 1: + self.parentCanvas.brushSize[dimension] -= 1 + self.update(brushSize=self.parentCanvas.brushSize) + elif (dimension < 2) and incrFlag: + self.parentCanvas.brushSize[dimension] += 1 + self.update(brushSize=self.parentCanvas.brushSize) + elif dimension == 2: + [self.canvasBrushSize(f, dimension_, incrFlag) for dimension_ in [0, 1]] + setattr(canvasBrushSize_, "attrDict", f.attrList[dimension + (0 if not incrFlag else 3)]) + return canvasBrushSize_ # }}} - # {{{ canvasDecrBrushHeightWidth(self, event) - @GuiCanvasCommandDecorator("Decrease brush size", "Decrease brush size", ["toolDecrBrushHW.png"], None, None) - def canvasDecrBrushHeightWidth(self, event): - self.canvasDecrBrushHeight(event) - self.canvasDecrBrushWidth(event) - # }}} - # {{{ canvasDecrBrushWidth(self, event) - @GuiCanvasCommandDecorator("Decrease brush width", "Decrease brush width", ["toolDecrBrushW.png"], None, None) - def canvasDecrBrushWidth(self, event): - if self.parentCanvas.brushSize[0] > 1: - self.parentCanvas.brushSize[0] -= 1 - self.update(brushSize=self.parentCanvas.brushSize) - # }}} - # {{{ canvasDecrCanvasHeight(self, event) - @GuiCanvasCommandDecorator("Decrease canvas height", "Decrease canvas height", ["toolDecrCanvasH.png"], None, None) - def canvasDecrCanvasHeight(self, event): - if self.parentCanvas.canvas.size[1] > 1: - self.parentCanvas.resize([self.parentCanvas.canvas.size[0], self.parentCanvas.canvas.size[1] - 1]) - # }}} - # {{{ canvasDecrCanvasHeightWidth(self, event) - @GuiCanvasCommandDecorator("Decrease canvas size", "Decrease canvas size", ["toolDecrCanvasHW.png"], None, None) - def canvasDecrCanvasHeightWidth(self, event): - self.canvasDecrCanvasHeight(event) - self.canvasDecrCanvasWidth(event) - # }}} - # {{{ canvasDecrCanvasWidth(self, event) - @GuiCanvasCommandDecorator("Decrease canvas width", "Decrease canvas width", ["toolDecrCanvasW.png"], None, None) - def canvasDecrCanvasWidth(self, event): - if self.parentCanvas.canvas.size[0] > 1: - self.parentCanvas.resize([self.parentCanvas.canvas.size[0] - 1, self.parentCanvas.canvas.size[1]]) - # }}} - # {{{ canvasIncrBrushHeight(self, event) - @GuiCanvasCommandDecorator("Increase brush height", "Increase brush height", ["toolIncrBrushH.png"], None, None) - def canvasIncrBrushHeight(self, event): - self.parentCanvas.brushSize[1] += 1 - self.update(brushSize=self.parentCanvas.brushSize) - # }}} - # {{{ canvasIncrBrushHeightWidth(self, event) - @GuiCanvasCommandDecorator("Increase brush size", "Increase brush size", ["toolIncrBrushHW.png"], None, None) - def canvasIncrBrushHeightWidth(self, event): - self.canvasIncrBrushHeight(event) - self.canvasIncrBrushWidth(event) - # }}} - # {{{ canvasIncrBrushWidth(self, event) - @GuiCanvasCommandDecorator("Increase brush width", "Increase brush width", ["toolIncrBrushW.png"], None, None) - def canvasIncrBrushWidth(self, event): - self.parentCanvas.brushSize[0] += 1 - self.update(brushSize=self.parentCanvas.brushSize) - # }}} - # {{{ canvasIncrCanvasHeight(self, event) - @GuiCanvasCommandDecorator("Increase canvas height", "Increase canvas height", ["toolIncrCanvasH.png"], None, None) - def canvasIncrCanvasHeight(self, event): - self.parentCanvas.resize([self.parentCanvas.canvas.size[0], self.parentCanvas.canvas.size[1] + 1]) - # }}} - # {{{ canvasIncrCanvasHeightWidth(self, event) - @GuiCanvasCommandDecorator("Increase canvas size", "Increase canvas size", ["toolIncrCanvasHW.png"], None, None) - def canvasIncrCanvasHeightWidth(self, event): - self.canvasIncrCanvasHeight(event) - self.canvasIncrCanvasWidth(event) - # }}} - # {{{ canvasIncrCanvasWidth(self, event) - @GuiCanvasCommandDecorator("Increase canvas width", "Increase canvas width", ["toolIncrCanvasW.png"], None, None) - def canvasIncrCanvasWidth(self, event): - self.parentCanvas.resize([self.parentCanvas.canvas.size[0] + 1, self.parentCanvas.canvas.size[1]]) + # {{{ canvasCanvasSize(self, f, dimension, incrFlag) + @CommandListDecorator(0, "Decrease canvas height", "Decrease canvas height", ["toolDecrCanvasH.png"], None, None) + @CommandListDecorator(1, "Decrease canvas width", "Decrease canvas width", ["toolDecrCanvasW.png"], None, None) + @CommandListDecorator(2, "Decrease canvas size", "Decrease canvas size", ["toolDecrCanvasHW.png"], None, None) + @CommandListDecorator(3, "Increase canvas height", "Increase canvas height", ["toolIncrCanvasH.png"], None, None) + @CommandListDecorator(4, "Increase canvas width", "Increase canvas width", ["toolIncrCanvasW.png"], None, None) + @CommandListDecorator(5, "Increase canvas size", "Increase canvas size", ["toolIncrCanvasHW.png"], None, None) + def canvasCanvasSize(self, f, dimension, incrFlag): + def canvasCanvasSize_(self, event): + if (dimension < 2) and not incrFlag: + if dimension == 0: + if self.parentCanvas.canvas.size[1] > 1: + self.parentCanvas.resize([self.parentCanvas.canvas.size[0], self.parentCanvas.canvas.size[1] - 1]) + elif dimension == 1: + if self.parentCanvas.canvas.size[0] > 1: + self.parentCanvas.resize([self.parentCanvas.canvas.size[0] - 1, self.parentCanvas.canvas.size[1]]) + elif (dimension < 2) and incrFlag: + if dimension == 0: + self.parentCanvas.resize([self.parentCanvas.canvas.size[0], self.parentCanvas.canvas.size[1] + 1]) + elif dimension == 1: + self.parentCanvas.resize([self.parentCanvas.canvas.size[0] + 1, self.parentCanvas.canvas.size[1]]) + elif dimension == 2: + [self.canvasCanvasSize(f, dimension_, incrFlag) for dimension_ in [0, 1]] + setattr(canvasCanvasSize_, "attrDict", f.attrList[dimension + (0 if not incrFlag else 3)]) + return canvasCanvasSize_ # }}} # {{{ canvasTool(self, f, idx) - @GuiCanvasSelectDecorator(0, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False) - @GuiCanvasSelectDecorator(1, "Clone", "Cl&one", ["toolClone.png"], [wx.ACCEL_CTRL, ord("E")], False) - @GuiCanvasSelectDecorator(2, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False) - @GuiCanvasSelectDecorator(3, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False) - @GuiCanvasSelectDecorator(4, "Move", "&Move", ["toolMove.png"], [wx.ACCEL_CTRL, ord("M")], False) - @GuiCanvasSelectDecorator(5, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True) - @GuiCanvasSelectDecorator(6, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False) + @SelectDecorator(0, "Circle", "&Circle", ["toolCircle.png"], [wx.ACCEL_CTRL, ord("C")], False) + @SelectDecorator(1, "Clone", "Cl&one", ["toolClone.png"], [wx.ACCEL_CTRL, ord("E")], False) + @SelectDecorator(2, "Fill", "&Fill", ["toolFill.png"], [wx.ACCEL_CTRL, ord("F")], False) + @SelectDecorator(3, "Line", "&Line", ["toolLine.png"], [wx.ACCEL_CTRL, ord("L")], False) + @SelectDecorator(4, "Move", "&Move", ["toolMove.png"], [wx.ACCEL_CTRL, ord("M")], False) + @SelectDecorator(5, "Rectangle", "&Rectangle", ["toolRect.png"], [wx.ACCEL_CTRL, ord("R")], True) + @SelectDecorator(6, "Text", "&Text", ["toolText.png"], [wx.ACCEL_CTRL, ord("T")], False) def canvasTool(self, f, idx): def canvasTool_(self, event): self.currentTool = [ToolCircle, ToolSelectClone, ToolFill, ToolLine, ToolSelectMove, ToolRect, ToolText][idx](self.parentCanvas) @@ -348,7 +332,7 @@ class GuiCanvasInterface(): # }}} # {{{ canvasExportAsAnsi(self, event) - @GuiCanvasCommandDecorator("Export as ANSI...", "Export as ANSI...", None, None, None) + @CommandDecorator("Export as ANSI...", "Export as ANSI...", None, None, None) def canvasExportAsAnsi(self, event): with wx.FileDialog(self.parentFrame, "Save As...", os.getcwd(), "", "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog: if dialog.ShowModal() == wx.ID_CANCEL: @@ -362,7 +346,7 @@ class GuiCanvasInterface(): return True # }}} # {{{ canvasExportAsPng(self, event) - @GuiCanvasCommandDecorator("Export as PNG...", "Export as PN&G...", None, None, None) + @CommandDecorator("Export as PNG...", "Export as PN&G...", None, None, None) def canvasExportAsPng(self, event): with wx.FileDialog(self.parentFrame, "Save As...", os.getcwd(), "", "PNG (*.png)|*.png|All Files (*.*)|*.*", wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dialog: if dialog.ShowModal() == wx.ID_CANCEL: @@ -375,7 +359,7 @@ class GuiCanvasInterface(): return True # }}} # {{{ canvasExportImgur(self, event) - @GuiCanvasCommandDecorator("Export to Imgur...", "Export to I&mgur...", None, None, haveUrllib) + @CommandDecorator("Export to Imgur...", "Export to I&mgur...", None, None, haveUrllib) def canvasExportImgur(self, event): self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT)) rc, status, result = self.parentCanvas.canvas.exportStore.exportBitmapToImgur(self.imgurApiKey, self.parentCanvas.backend.canvasBitmap, "", "", wx.BITMAP_TYPE_PNG) @@ -388,7 +372,7 @@ class GuiCanvasInterface(): wx.MessageBox("Failed to export to Imgur: {}".format(result), "Export to Imgur", wx.ICON_EXCLAMATION | wx.OK) # }}} # {{{ canvasExportPastebin(self, event) - @GuiCanvasCommandDecorator("Export to Pastebin...", "Export to Pasteb&in...", None, None, haveUrllib) + @CommandDecorator("Export to Pastebin...", "Export to Pasteb&in...", None, None, haveUrllib) def canvasExportPastebin(self, event): self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT)) pasteStatus, pasteResult = self.parentCanvas.canvas.exportStore.exportPastebin("", self.parentCanvas.canvas.map, self.parentCanvas.canvas.size) @@ -403,7 +387,7 @@ class GuiCanvasInterface(): wx.MessageBox("Failed to export to Pastebin: " + pasteResult, "Export to Pastebin", wx.OK|wx.ICON_EXCLAMATION) # }}} # {{{ canvasExportToClipboard(self, event) - @GuiCanvasCommandDecorator("Export to clipboard", "&Export to clipboard", None, None, None) + @CommandDecorator("Export to clipboard", "&Export to clipboard", None, None, None) def canvasExportToClipboard(self, event): self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT)) rc, outBuffer = self.parentCanvas.canvas.exportStore.exportTextBuffer(self.parentCanvas.canvas.map, self.parentCanvas.canvas.size) @@ -414,7 +398,7 @@ class GuiCanvasInterface(): return True # }}} # {{{ canvasImportAnsi(self, event) - @GuiCanvasCommandDecorator("Import ANSI...", "Import ANSI...", None, None, None) + @CommandDecorator("Import ANSI...", "Import ANSI...", None, None, None) def canvasImportAnsi(self, event): def canvasImportAnsi_(pathName): rc, error = self.parentCanvas.canvas.importStore.importAnsiFile(pathName) @@ -422,7 +406,7 @@ class GuiCanvasInterface(): self._importFile(canvasImportAnsi_, True, "ANSI files (*.ans;*.txt)|*.ans;*.txt|All Files (*.*)|*.*") # }}} # {{{ canvasImportFromClipboard(self, event) - @GuiCanvasCommandDecorator("Import from clipboard", "&Import from clipboard", None, None, None) + @CommandDecorator("Import from clipboard", "&Import from clipboard", None, None, None) def canvasImportFromClipboard(self, event): def canvasImportFromClipboard_(pathName): if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)) \ @@ -439,7 +423,7 @@ class GuiCanvasInterface(): self._import(canvasImportFromClipboard_, True, None) # }}} # {{{ canvasImportSauce(self, event) - @GuiCanvasCommandDecorator("Import SAUCE...", "Import SAUCE...", None, None, None) + @CommandDecorator("Import SAUCE...", "Import SAUCE...", None, None, None) def canvasImportSauce(self, event): def canvasImportSauce_(pathName): rc, error = self.parentCanvas.canvas.importStore.importSauceFile(pathName) @@ -511,10 +495,10 @@ class GuiCanvasInterface(): canvasUndo, canvasRedo, NID_MENU_SEP, canvasCut, canvasCopy, canvasPaste, canvasDelete, NID_MENU_SEP, - canvasIncrCanvasWidth, canvasDecrCanvasWidth, canvasIncrCanvasHeight, canvasDecrCanvasHeight, NID_MENU_SEP, - canvasIncrCanvasHeightWidth, canvasDecrBrushHeightWidth, NID_MENU_SEP, - canvasIncrBrushWidth, canvasDecrBrushWidth, canvasIncrBrushHeight, canvasDecrBrushHeight, NID_MENU_SEP, - canvasIncrBrushHeightWidth, canvasDecrBrushHeightWidth, NID_MENU_SEP, + canvasCanvasSize(None, canvasCanvasSize, 1, True), canvasCanvasSize(None, canvasCanvasSize, 1, False), canvasCanvasSize(None, canvasCanvasSize, 0, True), canvasCanvasSize(None, canvasCanvasSize, 0, False), NID_MENU_SEP, + canvasCanvasSize(None, canvasCanvasSize, 2, True), canvasCanvasSize(None, canvasCanvasSize, 2, False), NID_MENU_SEP, + canvasBrushSize(None, canvasBrushSize, 0, True), canvasBrushSize(None, canvasBrushSize, 0, False), canvasBrushSize(None, canvasBrushSize, 1, True), canvasBrushSize(None, canvasBrushSize, 1, False), NID_MENU_SEP, + canvasBrushSize(None, canvasBrushSize, 2, True), canvasBrushSize(None, canvasBrushSize, 2, False), NID_MENU_SEP, canvasBrush(None, canvasBrush, 0), ), ("&Tools", @@ -528,8 +512,8 @@ class GuiCanvasInterface(): (canvasNew, canvasOpen, canvasSave, canvasSaveAs, NID_TOOLBAR_HSEP, canvasUndo, canvasRedo, NID_TOOLBAR_HSEP, canvasCut, canvasCopy, canvasPaste, canvasDelete, NID_TOOLBAR_HSEP, - canvasIncrCanvasWidth, canvasDecrCanvasWidth, canvasIncrCanvasHeight, canvasDecrCanvasHeight, NID_TOOLBAR_HSEP, - canvasIncrCanvasHeightWidth, canvasDecrCanvasHeightWidth, NID_TOOLBAR_HSEP, + canvasCanvasSize(None, canvasCanvasSize, 1, True), canvasCanvasSize(None, canvasCanvasSize, 1, False), canvasCanvasSize(None, canvasCanvasSize, 0, True), canvasCanvasSize(None, canvasCanvasSize, 0, False), NID_TOOLBAR_HSEP, + canvasCanvasSize(None, canvasCanvasSize, 2, True), canvasCanvasSize(None, canvasCanvasSize, 2, False), NID_TOOLBAR_HSEP, canvasTool(None, canvasTool, 5), canvasTool(None, canvasTool, 0), canvasTool(None, canvasTool, 2), canvasTool(None, canvasTool, 3), canvasTool(None, canvasTool, 6), canvasTool(None, canvasTool, 1), canvasTool(None, canvasTool, 4), ), (canvasColour(None, canvasColour, 0), canvasColour(None, canvasColour, 1), canvasColour(None, canvasColour, 2), canvasColour(None, canvasColour, 3), @@ -537,8 +521,8 @@ class GuiCanvasInterface(): canvasColour(None, canvasColour, 8), canvasColour(None, canvasColour, 9), canvasColour(None, canvasColour, 10), canvasColour(None, canvasColour, 11), canvasColour(None, canvasColour, 12), canvasColour(None, canvasColour, 13), canvasColour(None, canvasColour, 14), canvasColour(None, canvasColour, 15), canvasColourAlpha(None, canvasColourAlpha, 0), NID_TOOLBAR_HSEP, - canvasIncrBrushWidth, canvasDecrBrushWidth, canvasIncrBrushHeight, canvasDecrBrushHeight, NID_TOOLBAR_HSEP, - canvasIncrBrushHeightWidth, canvasDecrBrushHeightWidth, + canvasBrushSize(None, canvasBrushSize, 1, True), canvasBrushSize(None, canvasBrushSize, 0, False), canvasBrushSize(None, canvasBrushSize, 1, True), canvasBrushSize(None, canvasBrushSize, 1, False), NID_TOOLBAR_HSEP, + canvasBrushSize(None, canvasBrushSize, 2, True), canvasBrushSize(None, canvasBrushSize, 2, False), ), ) # }}}