2019-09-01 14:34:00 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
2019-09-09 10:46:52 +00:00
|
|
|
# ToolText.py
|
2019-09-04 14:23:59 +00:00
|
|
|
# Copyright (c) 2018, 2019 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
|
2019-09-01 14:34:00 +00:00
|
|
|
#
|
|
|
|
|
2019-09-03 16:58:50 +00:00
|
|
|
from Tool import Tool
|
2019-09-01 14:34:00 +00:00
|
|
|
import wx
|
|
|
|
|
2019-09-03 16:58:50 +00:00
|
|
|
class ToolText(Tool):
|
2019-09-01 14:34:00 +00:00
|
|
|
name = "Text"
|
|
|
|
|
|
|
|
#
|
2019-09-12 08:08:14 +00:00
|
|
|
# onKeyboardEvent(self, brushColours, brushSize, canvas, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect)
|
2019-09-10 10:12:12 +00:00
|
|
|
def onKeyboardEvent(self, brushColours, brushSize, canvas, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect):
|
2019-09-10 10:20:23 +00:00
|
|
|
if keyModifiers in (wx.MOD_NONE, wx.MOD_SHIFT):
|
|
|
|
rc, dirty = True, True
|
2019-09-01 14:34:00 +00:00
|
|
|
if self.textPos == None:
|
libgui/GuiCanvasInterface.py:canvasTool(): call applyTool() w/ new tool post-selection.
libgui/GuiCanvasPanel.py:{applyTool,onPanelInput}(): split from onPanelInput().
libtools/Tool{,Circle,Fill,Line,Rect,Select,Text}.py:on{Keyboard,Mouse}Event(): updated.
libtools/ToolFill.py:onMouseEvent(): display cursor.
libtools/ToolSelect{,Clone,Move}.py:onSelectEvent(): updated.
2019-09-09 16:18:54 +00:00
|
|
|
self.textPos = list(mapPoint)
|
2019-09-10 10:20:23 +00:00
|
|
|
dispatchFn(eventDc, False, [*self.textPos, *brushColours, 0, keyChar], viewRect)
|
|
|
|
if self.textPos[0] < (canvas.size[0] - 1):
|
|
|
|
self.textPos[0] += 1
|
|
|
|
elif self.textPos[1] < (canvas.size[1] - 1):
|
|
|
|
self.textPos[0] = 0; self.textPos[1] += 1;
|
|
|
|
else:
|
|
|
|
self.textPos = [0, 0]
|
2019-09-01 14:34:00 +00:00
|
|
|
else:
|
2019-09-10 10:20:23 +00:00
|
|
|
rc, dirty = False, False
|
|
|
|
return rc, dirty
|
2019-09-01 14:34:00 +00:00
|
|
|
|
|
|
|
#
|
2019-09-12 08:08:14 +00:00
|
|
|
# onMouseEvent(self, brushColours, brushSize, canvas, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect)
|
2019-09-10 10:12:12 +00:00
|
|
|
def onMouseEvent(self, brushColours, brushSize, canvas, dispatchFn, eventDc, mapPoint, mouseDragging, mouseLeftDown, mouseRightDown, viewRect):
|
libgui/GuiCanvasInterface.py:canvasTool(): call applyTool() w/ new tool post-selection.
libgui/GuiCanvasPanel.py:{applyTool,onPanelInput}(): split from onPanelInput().
libtools/Tool{,Circle,Fill,Line,Rect,Select,Text}.py:on{Keyboard,Mouse}Event(): updated.
libtools/ToolFill.py:onMouseEvent(): display cursor.
libtools/ToolSelect{,Clone,Move}.py:onSelectEvent(): updated.
2019-09-09 16:18:54 +00:00
|
|
|
if mouseLeftDown or mouseRightDown:
|
|
|
|
self.textPos = list(mapPoint)
|
|
|
|
dispatchFn(eventDc, True, [*mapPoint, *brushColours, 0, "_"], viewRect)
|
libcanvas/Canvas.py:dispatchPatchSingle(): cloned from dispatchPatch().
lib{canvas/Canvas{,Journal},gui/GuiCanvasPanel}.py: replace dirtyJournal & pushDeltas() w/ explicit {begin,end}().
libgui/GuiCanvasPanel.py:applyTool(): updated.
libgui/GuiCanvasPanel.py:dispatchPatchSingle(): cloned from dispatchPatch().
libtools/Tool{,Circle,Fill,Line,Rect,Select{,Clone,Move},Text}.py:on{Mouse,Keyboard}Event(): return rc, dirty.
libtools/ToolSelect{Clone,Move}.py:onSelectEvent(): return rc, dirty.
2019-09-09 16:43:33 +00:00
|
|
|
return True, False
|
2019-09-01 14:34:00 +00:00
|
|
|
|
2019-09-03 16:58:50 +00:00
|
|
|
# __init__(self, *args): initialisation method
|
|
|
|
def __init__(self, *args):
|
|
|
|
super().__init__(*args)
|
|
|
|
self.textColours = self.textPos = None
|
|
|
|
|
2019-09-01 14:34:00 +00:00
|
|
|
# vim:expandtab foldmethod=marker sw=4 ts=4 tw=120
|