]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/frogedit/FrogEditor.py
1 #!/usr/local/bin/python
5 # Copyright 2001 Adam Feuer and Steve Howell
10 from wxPython
.wx
import *
11 from wxPython
.lib
.editor
import wxEditor
13 #---------------------------------------------------------------------
15 class FrogEditor(wxEditor
):
16 def __init__(self
, parent
, id,
17 pos
=wxDefaultPosition
, size
=wxDefaultSize
, style
=0, statusBar
=None):
18 self
.StatusBar
= statusBar
19 wxEditor
.__init
__(self
, parent
, id, pos
, size
, style
)
22 ##------------------------------------
24 def TouchBuffer(self
):
25 wxEditor
.TouchBuffer(self
)
26 self
.StatusBar
.setDirty(1)
28 def UnTouchBuffer(self
):
29 wxEditor
.UnTouchBuffer(self
)
30 self
.StatusBar
.setDirty(0)
33 #--------- utility function -------------
35 # override our base class method
36 def DrawCursor(self
, dc
= None):
37 wxEditor
.DrawCursor(self
,dc
)
38 self
.StatusBar
.setRowCol(self
.cy
,self
.cx
)
41 lastline
= self
.sy
+ self
.sh
- 1
42 return min(lastline
, self
.LinesInFile() - 1)
45 return [l
.text
for l
in self
.text
]
49 self
.ds
.store(self
.page
,self
.rawLines())
51 def SetRawText(self
, rawtext
=""):
53 self
.SetText(self
.RenderText())
58 #---------- logging -------------
60 def SetStatus(self
, log
):
64 def PrintSeparator(self
, event
):
65 self
.Print("..........................")
67 def Print(self
, data
):
68 self
.status
.append(data
)
73 #--------- wxEditor keyboard overrides
75 def SetControlFuncs(self
, action
):
76 wxEditor
.SetControlFuncs(self
, action
)
77 action
['-'] = self
.PrintSeparator
79 def SetAltFuncs(self
, action
):
80 wxEditor
.SetAltFuncs(self
, action
)
81 action
['x'] = self
.Exit
83 #----------- commands -----------
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.
91 self
.parent
.Close(None)