summaryrefslogtreecommitdiffstats
path: root/Lib/stdwin/TextEdit.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-04-07 13:41:50 (GMT)
committerGuido van Rossum <guido@python.org>1991-04-07 13:41:50 (GMT)
commit2d844d1ddc581c80116c88be5854720bcf84f3e0 (patch)
tree7aaca4e789dd1394d8eff7484dfced08a635983f /Lib/stdwin/TextEdit.py
parentfa5406496750f9f0717457341041297b4173430f (diff)
downloadcpython-2d844d1ddc581c80116c88be5854720bcf84f3e0.zip
cpython-2d844d1ddc581c80116c88be5854720bcf84f3e0.tar.gz
cpython-2d844d1ddc581c80116c88be5854720bcf84f3e0.tar.bz2
Initial revision
Diffstat (limited to 'Lib/stdwin/TextEdit.py')
-rwxr-xr-xLib/stdwin/TextEdit.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/Lib/stdwin/TextEdit.py b/Lib/stdwin/TextEdit.py
new file mode 100755
index 0000000..8d12465
--- /dev/null
+++ b/Lib/stdwin/TextEdit.py
@@ -0,0 +1,58 @@
+# Text editing widget
+
+from stdwinevents import *
+
+class TextEdit():
+ #
+ def create(self, (parent, (cols, rows))):
+ parent.addchild(self)
+ self.parent = parent
+ self.cols = cols
+ self.rows = rows
+ self.text = ''
+ # Creation of the editor is done in realize()
+ self.editor = 0
+ return self
+ #
+ # Downcalls from parent to child
+ #
+ def destroy(self):
+ del self.parent
+ del self.editor
+ del self.window
+ #
+ def minsize(self, m):
+ return self.cols*m.textwidth('n'), self.rows*m.lineheight()
+ def setbounds(self, bounds):
+ self.bounds = bounds
+ if self.editor:
+ self.editor.move(bounds)
+ def getbounds(self, bounds):
+ if self.editor:
+ return self.editor.getrect()
+ else:
+ return self.bounds
+ def realize(self):
+ self.window = self.parent.getwindow()
+ self.editor = self.window.textcreate(self.bounds)
+ self.editor.replace(self.text)
+ self.parent.need_mouse(self)
+ self.parent.need_keybd(self)
+ self.parent.need_altdraw(self)
+ def draw(self, (d, area)):
+ pass
+ def altdraw(self, area):
+ self.editor.draw(area)
+ #
+ # Event downcalls
+ #
+ def mouse_down(self, detail):
+ x = self.editor.event(WE_MOUSE_DOWN, self.window, detail)
+ def mouse_move(self, detail):
+ x = self.editor.event(WE_MOUSE_MOVE, self.window, detail)
+ def mouse_up(self, detail):
+ x = self.editor.event(WE_MOUSE_UP, self.window, detail)
+ #
+ def keybd(self, (type, detail)):
+ x = self.editor.event(type, self.window, detail)
+ #