]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/frogedit/FrogEditor.py
Allow art provider IDs for the extra bitmaps in a wxBitmapButton. (The
[wxWidgets.git] / wxPython / samples / frogedit / FrogEditor.py
1
2 # simple text editor
3 #
4 # Copyright 2001 Adam Feuer and Steve Howell
5 #
6 # License: Python
7
8 import re
9 import wx
10
11 from wx.lib.editor import Editor
12
13 #---------------------------------------------------------------------
14
15 class FrogEditor(Editor):
16 def __init__(self, parent, id,
17 pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, statusBar=None):
18 self.StatusBar = statusBar
19 Editor.__init__(self, parent, id, pos, size, style)
20 self.parent = parent
21
22 ##------------------------------------
23
24 def TouchBuffer(self):
25 Editor.TouchBuffer(self)
26 self.StatusBar.setDirty(1)
27
28 def UnTouchBuffer(self):
29 Editor.UnTouchBuffer(self)
30 self.StatusBar.setDirty(0)
31
32
33 #--------- utility function -------------
34
35 # override our base class method
36 def DrawCursor(self, dc = None):
37 Editor.DrawCursor(self,dc)
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]
71 wx.LogMessage(data)
72
73 #--------- wxEditor keyboard overrides
74
75 def SetControlFuncs(self, action):
76 Editor.SetControlFuncs(self, action)
77 action['-'] = self.PrintSeparator
78
79 def SetAltFuncs(self, action):
80 Editor.SetAltFuncs(self, action)
81 action['x'] = self.Exit
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