X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7722248d7510121367c9d4db7af1156197c26e82..81cfe5e13e9b8a2ec8374af1f7806b05a86d4d4b:/wxPython/wx/lib/editor/editor.py?ds=sidebyside diff --git a/wxPython/wx/lib/editor/editor.py b/wxPython/wx/lib/editor/editor.py index 57f1d77870..ef709333b0 100644 --- a/wxPython/wx/lib/editor/editor.py +++ b/wxPython/wx/lib/editor/editor.py @@ -20,13 +20,18 @@ # Copyright: (c) 1999 by Dirk Holtwick, 1999 # Licence: wxWindows license #---------------------------------------------------------------------- +# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o 2.5 compatability update. +# -import os, time +import os +import time -from wxPython.wx import * +import wx -import selection -import images +import selection +import images #---------------------------- @@ -70,14 +75,14 @@ class Scroller: #---------------------------------------------------------------------- -class wxEditor(wxScrolledWindow): +class wxEditor(wx.ScrolledWindow): def __init__(self, parent, id, - pos=wxDefaultPosition, size=wxDefaultSize, style=0): + pos=wx.DefaultPosition, size=wx.DefaultSize, style=0): - wxScrolledWindow.__init__(self, parent, id, + wx.ScrolledWindow.__init__(self, parent, id, pos, size, - style|wxWANTS_CHARS) + style|wx.WANTS_CHARS) self.isDrawing = False @@ -108,26 +113,33 @@ class wxEditor(wxScrolledWindow): self.sco_y = 0 def MapEvents(self): - EVT_LEFT_DOWN(self, self.OnLeftDown) - EVT_LEFT_UP(self, self.OnLeftUp) - EVT_MOTION(self, self.OnMotion) - EVT_SCROLLWIN(self, self.OnScroll) - EVT_CHAR(self, self.OnChar) - EVT_PAINT(self, self.OnPaint) - EVT_SIZE(self, self.OnSize) - EVT_WINDOW_DESTROY(self, self.OnDestroy) - EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) + self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) + self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) + self.Bind(wx.EVT_MOTION, self.OnMotion) + self.Bind(wx.EVT_SCROLLWIN, self.OnScroll) + self.Bind(wx.EVT_CHAR, self.OnChar) + self.Bind(wx.EVT_PAINT, self.OnPaint) + self.Bind(wx.EVT_SIZE, self.OnSize) + self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy) + self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) ##------------------- Platform-specific stuff def NiceFontForPlatform(self): - if wxPlatform == "__WXMSW__": - return wxFont(10, wxMODERN, wxNORMAL, wxNORMAL) + if wx.Platform == "__WXMSW__": + return wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL) else: - return wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, False) + return wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL, False) def UnixKeyHack(self, key): + # # this will be obsolete when we get the new wxWindows patch + # + # 12/14/03 - jmg + # + # Which patch? I don't know if this is needed, but I don't know + # why it's here either. Play it safe; leave it in. + # if key <= 26: key += ord('a') - 1 return key @@ -141,39 +153,39 @@ class wxEditor(wxScrolledWindow): def SetCharDimensions(self): # TODO: We need a code review on this. It appears that Linux # improperly reports window dimensions when the scrollbar's there. - self.bw, self.bh = self.GetClientSizeTuple() + self.bw, self.bh = self.GetClientSize() - if wxPlatform == "__WXMSW__": + if wx.Platform == "__WXMSW__": self.sh = self.bh / self.fh self.sw = (self.bw / self.fw) - 1 else: self.sh = self.bh / self.fh if self.LinesInFile() >= self.sh: - self.bw = self.bw - wxSystemSettings_GetMetric(wxSYS_VSCROLL_X) + self.bw = self.bw - wx.SystemSettings_GetMetric(wx.SYS_VSCROLL_X) self.sw = (self.bw / self.fw) - 1 self.sw = (self.bw / self.fw) - 1 if self.CalcMaxLineLen() >= self.sw: - self.bh = self.bh - wxSystemSettings_GetMetric(wxSYS_HSCROLL_Y) + self.bh = self.bh - wx.SystemSettings_GetMetric(wx.SYS_HSCROLL_Y) self.sh = self.bh / self.fh def UpdateView(self, dc = None): if dc is None: - dc = wxClientDC(self) + dc = wx.ClientDC(self) if dc.Ok(): self.SetCharDimensions() self.KeepCursorOnScreen() - self.DrawSimpleCursor(0,0,dc, True) + self.DrawSimpleCursor(0,0, dc, True) self.Draw(dc) def OnPaint(self, event): - dc = wxPaintDC(self) + dc = wx.PaintDC(self) if self.isDrawing: return self.isDrawing = True self.UpdateView(dc) - wxCallAfter(self.AdjustScrollbars) + wx.CallAfter(self.AdjustScrollbars) self.isDrawing = False def OnEraseBackground(self, evt): @@ -182,16 +194,16 @@ class wxEditor(wxScrolledWindow): ##-------------------- Drawing code def InitFonts(self): - dc = wxClientDC(self) + dc = wx.ClientDC(self) self.font = self.NiceFontForPlatform() dc.SetFont(self.font) self.fw = dc.GetCharWidth() self.fh = dc.GetCharHeight() def SetColors(self): - self.fgColor = wxNamedColour('black') - self.bgColor = wxNamedColour('white') - self.selectColor = wxColour(238, 220, 120) # r, g, b = emacsOrange + self.fgColor = wx.NamedColour('black') + self.bgColor = wx.NamedColour('white') + self.selectColor = wx.Colour(238, 220, 120) # r, g, b = emacsOrange def InitDoubleBuffering(self): pass @@ -220,13 +232,13 @@ class wxEditor(wxScrolledWindow): def Draw(self, odc=None): if not odc: - odc = wxClientDC(self) + odc = wx.ClientDC(self) - bmp = wxEmptyBitmap(max(1,self.bw), max(1,self.bh)) - dc = wxBufferedDC(odc, bmp) + bmp = wx.EmptyBitmap(max(1,self.bw), max(1,self.bh)) + dc = wx.BufferedDC(odc, bmp) if dc.Ok(): dc.SetFont(self.font) - dc.SetBackgroundMode(wxSOLID) + dc.SetBackgroundMode(wx.SOLID) dc.SetTextBackground(self.bgColor) dc.SetTextForeground(self.fgColor) dc.Clear() @@ -251,7 +263,7 @@ class wxEditor(wxScrolledWindow): def DrawCursor(self, dc = None): if not dc: - dc = wxClientDC(self) + dc = wx.ClientDC(self) if (self.LinesInFile())31) and (key<256): self.InsertChar(chr(key)) else: - wxBell() + wx.Bell() return self.UpdateView() self.AdjustScrollbars()