]> git.saurik.com Git - wxWidgets.git/blame - wxPython/samples/frogedit/FrogEditor.py
GetDefaultAttributes, and other tweaks needed to get up to date with CVS
[wxWidgets.git] / wxPython / samples / frogedit / FrogEditor.py
CommitLineData
1918b6f7
RD
1
2# simple text editor
3#
4# Copyright 2001 Adam Feuer and Steve Howell
5#
6# License: Python
7
8import re
2571247b
RD
9import wx
10
11from wx.lib.editor import Editor
1918b6f7
RD
12
13#---------------------------------------------------------------------
14
2571247b 15class FrogEditor(Editor):
1918b6f7 16 def __init__(self, parent, id,
2571247b 17 pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, statusBar=None):
1918b6f7 18 self.StatusBar = statusBar
2571247b 19 Editor.__init__(self, parent, id, pos, size, style)
1918b6f7
RD
20 self.parent = parent
21
22 ##------------------------------------
23
24 def TouchBuffer(self):
2571247b 25 Editor.TouchBuffer(self)
1918b6f7
RD
26 self.StatusBar.setDirty(1)
27
28 def UnTouchBuffer(self):
2571247b 29 Editor.UnTouchBuffer(self)
1918b6f7
RD
30 self.StatusBar.setDirty(0)
31
32
33 #--------- utility function -------------
34
35 # override our base class method
36 def DrawCursor(self, dc = None):
2571247b 37 Editor.DrawCursor(self,dc)
1918b6f7
RD
38 self.StatusBar.setRowCol(self.cy,self.cx)
39
40 def lastLine(self):
41 lastline = self.sy + self.sh - 1
42 return min(lastline, self.LinesInFile() - 1)
43
44 def rawLines(self):
45 return [l.text for l in self.text]
46
47 def save(self):
48 if self.page:
49 self.ds.store(self.page,self.rawLines())
50
51 def SetRawText(self, rawtext=""):
52 self.rawText= rawtext
53 self.SetText(self.RenderText())
54
55 def RenderText(self):
56 return(self.rawText)
57
58 #---------- logging -------------
59
60 def SetStatus(self, log):
61 self.log = log
62 self.status = []
63
64 def PrintSeparator(self, event):
65 self.Print("..........................")
66
67 def Print(self, data):
68 self.status.append(data)
69 if data[-1:] == '\n':
70 data = data[:-1]
2571247b 71 wx.LogMessage(data)
1918b6f7
RD
72
73 #--------- wxEditor keyboard overrides
74
75 def SetControlFuncs(self, action):
2571247b 76 Editor.SetControlFuncs(self, action)
1918b6f7
RD
77 action['-'] = self.PrintSeparator
78
79 def SetAltFuncs(self, action):
2571247b 80 Editor.SetAltFuncs(self, action)
4491d3ae 81 action['x'] = self.Exit
1918b6f7
RD
82
83 #----------- commands -----------
84
85 def OnCloseWindow(self, event):
86 # xxx - We don't fully understand how exit logic works.
87 # This event is actually called by our parent frame.
88 pass
89
90 def Exit(self,event):
91 self.parent.Close(None)
92