diff options
author | Just van Rossum <just@letterror.com> | 2001-11-18 14:12:43 (GMT) |
---|---|---|
committer | Just van Rossum <just@letterror.com> | 2001-11-18 14:12:43 (GMT) |
commit | f376ef0996974c30f608020427fead6edb66877d (patch) | |
tree | 35790707ba2d5acde5735c5a4f0e3acf17f2a880 /Mac | |
parent | ebbd14d7c208cda1bfc0f169a48a9dcd54a7dcfd (diff) | |
download | cpython-f376ef0996974c30f608020427fead6edb66877d.zip cpython-f376ef0996974c30f608020427fead6edb66877d.tar.gz cpython-f376ef0996974c30f608020427fead6edb66877d.tar.bz2 |
a whole bunch of OSX tweaks
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Tools/IDE/PyBrowser.py | 3 | ||||
-rw-r--r-- | Mac/Tools/IDE/PyDebugger.py | 1 | ||||
-rw-r--r-- | Mac/Tools/IDE/PyEdit.py | 9 | ||||
-rw-r--r-- | Mac/Tools/IDE/W.py | 3 | ||||
-rw-r--r-- | Mac/Tools/IDE/Wapplication.py | 2 | ||||
-rw-r--r-- | Mac/Tools/IDE/Wbase.py | 12 | ||||
-rw-r--r-- | Mac/Tools/IDE/Wcontrols.py | 59 | ||||
-rw-r--r-- | Mac/Tools/IDE/Widgets.rsrc | bin | 5077 -> 6073 bytes | |||
-rw-r--r-- | Mac/Tools/IDE/Wlists.py | 17 | ||||
-rw-r--r-- | Mac/Tools/IDE/Wtext.py | 68 |
10 files changed, 105 insertions, 69 deletions
diff --git a/Mac/Tools/IDE/PyBrowser.py b/Mac/Tools/IDE/PyBrowser.py index d59fb7e..67831c0 100644 --- a/Mac/Tools/IDE/PyBrowser.py +++ b/Mac/Tools/IDE/PyBrowser.py @@ -143,6 +143,7 @@ class BrowserWidget(W.List): newcol = -1 #W.SetCursor('fist') while Evt.Button(): + Evt.WaitNextEvent(0, 1, None) # needed for OSX (x, y) = Evt.GetMouse() if (x, y) <> lastpoint: newcol = x + diff @@ -307,7 +308,7 @@ class Browser: title = title + ': ' + name self.w = w = W.Window((300, 400), title, minsize = (100, 100)) w.info = W.TextBox((18, 8, -70, 15)) - w.updatebutton = W.Button((-64, 4, 50, 16), 'Update', self.update) + w.updatebutton = W.BevelButton((-64, 4, 50, 16), 'Update', self.update) w.browser = BrowserWidget((-1, 24, 1, -14), None) w.bind('cmdu', w.updatebutton.push) w.open() diff --git a/Mac/Tools/IDE/PyDebugger.py b/Mac/Tools/IDE/PyDebugger.py index 56a0658..4bbac26 100644 --- a/Mac/Tools/IDE/PyDebugger.py +++ b/Mac/Tools/IDE/PyDebugger.py @@ -681,7 +681,6 @@ class BreakpointsViewer: def __init__(self, debugger): self.debugger = debugger - import Lists self.w = W.Window((300, 250), 'Breakpoints', minsize = (200, 200)) self.w.panes = W.HorizontalPanes((8, 8, -8, -32), (0.3, 0.7)) self.w.panes.files = W.List(None, callback = self.filehit) #, flags = Lists.lOnlyOne) diff --git a/Mac/Tools/IDE/PyEdit.py b/Mac/Tools/IDE/PyEdit.py index 1bebe6e..828b697 100644 --- a/Mac/Tools/IDE/PyEdit.py +++ b/Mac/Tools/IDE/PyEdit.py @@ -174,7 +174,7 @@ class Editor(W.Window): return '<%s>' % self.title def setupwidgets(self, text): - topbarheight = 28 + topbarheight = 24 popfieldwidth = 80 self.lastlineno = None @@ -197,9 +197,9 @@ class Editor(W.Window): self.bevelbox = W.BevelBox((0, 0, 0, topbarheight)) self.hline = W.HorizontalLine((0, topbarheight, 0, 0)) - self.infotext = W.TextBox((175, 7, -4, 14), backgroundcolor = (0xe000, 0xe000, 0xe000)) - self.runbutton = W.Button((6, 5, 60, 16), runButtonLabels[0], self.run) - self.runselbutton = W.Button((78, 5, 90, 16), runSelButtonLabels[0], self.runselection) + self.infotext = W.TextBox((175, 6, -4, 14), backgroundcolor = (0xe000, 0xe000, 0xe000)) + self.runbutton = W.BevelButton((6, 4, 80, 16), runButtonLabels[0], self.run) + self.runselbutton = W.BevelButton((90, 4, 80, 16), runSelButtonLabels[0], self.runselection) # bind some keys editor.bind("cmdr", self.runbutton.push) @@ -801,6 +801,7 @@ def _makewholewordpattern(word): pattern = pattern + notwordcharspat return re.compile(pattern) + class SearchEngine: def __init__(self): diff --git a/Mac/Tools/IDE/W.py b/Mac/Tools/IDE/W.py index 22b1ea1..397b211 100644 --- a/Mac/Tools/IDE/W.py +++ b/Mac/Tools/IDE/W.py @@ -31,7 +31,8 @@ def getdefaultfont(): return prefs.defaultfont def Message(text): - import EasyDialogs, Qd, string + import EasyDialogs, string + from Carbon import Qd Qd.InitCursor() text = string.replace(text, "\n", "\r") if not text: diff --git a/Mac/Tools/IDE/Wapplication.py b/Mac/Tools/IDE/Wapplication.py index 136d4ff..8839c90 100644 --- a/Mac/Tools/IDE/Wapplication.py +++ b/Mac/Tools/IDE/Wapplication.py @@ -9,7 +9,7 @@ from types import * from Carbon import Menu; MenuToolbox = Menu; del Menu -KILLUNKNOWNWINDOWS=1 # Set to 0 for debugging. +KILLUNKNOWNWINDOWS = 0 # Set to 0 for debugging. class Application(FrameWork.Application): diff --git a/Mac/Tools/IDE/Wbase.py b/Mac/Tools/IDE/Wbase.py index be75d8a..8019d06 100644 --- a/Mac/Tools/IDE/Wbase.py +++ b/Mac/Tools/IDE/Wbase.py @@ -1,4 +1,4 @@ -from Carbon import Evt, Qd, QuickDraw, Win +from Carbon import App, Evt, Qd, QuickDraw, Win import string from types import * import sys @@ -329,15 +329,7 @@ class SelectableWidget(ClickableWidget): def drawselframe(self, onoff): if not self._parentwindow._hasselframes: return - thickrect = Qd.InsetRect(self._bounds, -3, -3) - state = Qd.GetPenState() - Qd.PenSize(2, 2) - if onoff: - Qd.PenPat(Qd.qd.black) - else: - Qd.PenPat(Qd.qd.white) - Qd.FrameRect(thickrect) - Qd.SetPenState(state) + App.DrawThemeFocusRect(self._bounds, onoff) def adjust(self, oldbounds): self.SetPort() diff --git a/Mac/Tools/IDE/Wcontrols.py b/Mac/Tools/IDE/Wcontrols.py index 879dab5..2579449 100644 --- a/Mac/Tools/IDE/Wcontrols.py +++ b/Mac/Tools/IDE/Wcontrols.py @@ -17,6 +17,7 @@ class ControlWidget(Wbase.ClickableWidget): self._min = min self._max = max self._enabled = 1 + self._viewsize = 0 def open(self): self._calcbounds() @@ -29,8 +30,8 @@ class ControlWidget(Wbase.ClickableWidget): self._max, self._procID, 0) - self.SetPort() - #self.GetWindow().ValidWindowRect(self._bounds) + if self._viewsize: + self._control.SetControlViewSize(self._viewsize) self.enable(self._enabled) def adjust(self, oldbounds): @@ -75,9 +76,11 @@ class ControlWidget(Wbase.ClickableWidget): self._control.Draw1Control() def test(self, point): - ctltype, control = Ctl.FindControl(point, self._parentwindow.wid) - if self._enabled and control == self._control: + if Qd.PtInRect(point, self._bounds) and self._enabled: return 1 + #ctltype, control = Ctl.FindControl(point, self._parentwindow.wid) + #if self._enabled and control == self._control: + # return 1 def click(self, point, modifiers): if not self._enabled: @@ -112,16 +115,19 @@ class Button(ControlWidget): """Standard push button.""" + procID = Controls.pushButProc | Controls.useWFont + def __init__(self, possize, title = "Button", callback = None): - procID = Controls.pushButProc | Controls.useWFont - ControlWidget.__init__(self, possize, title, procID, callback, 0, 0, 1) + ControlWidget.__init__(self, possize, title, self.procID, callback, 0, 0, 1) self._isdefault = 0 def push(self): if not self._enabled: return + # emulate the pushing of the button import time self._control.HiliteControl(Controls.kControlButtonPart) + Qd.QDFlushPortBuffer(self._parentwindow.wid, None) # needed under OSX time.sleep(0.1) self._control.HiliteControl(0) if self._callback: @@ -139,7 +145,25 @@ class Button(ControlWidget): if self._visible: self._control.Draw1Control() + def open(self): + ControlWidget.open(self) + if self._isdefault: + self._setdefault(self._isdefault) + def _setdefault(self, onoff): + c = self._control + if c is not None: + if onoff: + data = "\xFF" + else: + data = "\0" + # hide before changing state, otherwise the button isn't always + # redrawn correctly, although it's quite different under Aqua + # and Classic... + c.HideControl() + c.SetControlData(Controls.kControlNoPart, + Controls.kControlPushButtonDefaultTag, data) + c.ShowControl() self._isdefault = onoff def adjust(self, oldbounds): @@ -152,6 +176,10 @@ class Button(ControlWidget): ControlWidget.adjust(self, oldbounds) +class BevelButton(Button): + procID = Controls.kControlBevelButtonNormalBevelProc | Controls.useWFont + + class CheckBox(ControlWidget): """Standard checkbox.""" @@ -250,13 +278,22 @@ class Scrollbar(ControlWidget): Wbase.CallbackCall(self._callback, 1, '--') def setmin(self, min): - self._control.SetControl32BitMinimum(min) + if self._control is not None: + self._control.SetControl32BitMinimum(min) + else: + self._min = min def setmax(self, max): - self._control.SetControl32BitMaximum(max) + if self._control is not None: + self._control.SetControl32BitMaximum(max) + else: + self._max = max - def setviewsize(self, view): - self._control.SetControlViewSize(view) + def setviewsize(self, viewsize): + if self._control is not None: + self._control.SetControlViewSize(viewsize) + else: + self._viewsize = viewsize def getmin(self): return self._control.GetControl32BitMinimum() @@ -312,7 +349,7 @@ class Scrollbar(ControlWidget): def draw(self, visRgn = None): if self._visible: self._control.Draw1Control() - Qd.FrameRect(self._bounds) + #Qd.FrameRect(self._bounds) def adjust(self, oldbounds): self.SetPort() diff --git a/Mac/Tools/IDE/Widgets.rsrc b/Mac/Tools/IDE/Widgets.rsrc Binary files differindex ea2d55c..ddeab7c 100644 --- a/Mac/Tools/IDE/Widgets.rsrc +++ b/Mac/Tools/IDE/Widgets.rsrc diff --git a/Mac/Tools/IDE/Wlists.py b/Mac/Tools/IDE/Wlists.py index 4cb3cf2..a05b804 100644 --- a/Mac/Tools/IDE/Wlists.py +++ b/Mac/Tools/IDE/Wlists.py @@ -5,6 +5,8 @@ from Carbon import Evt, Events, Fm, Lists, Qd, Scrap, Win from Carbon.List import LNew, CreateCustomList, GetListPort from Carbon.Lists import kListDefUserProcType, lInitMsg, lDrawMsg, lHiliteMsg, lCloseMsg from Carbon.QuickDraw import hilitetransfermode +from Carbon import App +from Carbon.Appearance import kThemeStateActive, kThemeStateInactive, kThemeStatePressed class List(Wbase.SelectableWidget): @@ -253,22 +255,24 @@ class List(Wbase.SelectableWidget): if not visRgn: visRgn = self._parentwindow.wid.GetWindowPort().visRgn self._list.LUpdate(visRgn) - Qd.FrameRect(self._bounds) - if self._selected and self._activated: - self.drawselframe(1) + App.DrawThemeListBoxFrame(self._bounds, kThemeStateActive) + #if self._selected and self._activated: + # self.drawselframe(1) def select(self, onoff, isclick = 0): if Wbase.SelectableWidget.select(self, onoff): return self.SetPort() - self.drawselframe(onoff) + state = [kThemeStateActive, kThemeStatePressed][onoff] + App.DrawThemeListBoxFrame(self._bounds, kThemeStateActive) + #self.drawselframe(onoff) def activate(self, onoff): self._activated = onoff if self._visible: self._list.LActivate(onoff) - if self._selected: - self.drawselframe(onoff) + #if self._selected: + # self.drawselframe(onoff) def get(self): return self.items @@ -449,6 +453,7 @@ class TwoLineList(CustomList): Qd.MoveTo(left + 4, top + ascent + linefeed) Qd.DrawText(line2, 0, len(line2)) Qd.PenPat("\x11\x11\x11\x11\x11\x11\x11\x11") + bottom = top + theList.cellSize[1] Qd.MoveTo(left, bottom - 1) Qd.LineTo(right, bottom - 1) if selected: diff --git a/Mac/Tools/IDE/Wtext.py b/Mac/Tools/IDE/Wtext.py index 0d9203d..183f4d8 100644 --- a/Mac/Tools/IDE/Wtext.py +++ b/Mac/Tools/IDE/Wtext.py @@ -1,6 +1,8 @@ from Carbon import Evt, Events, Fm, Fonts from Carbon import Qd, Res, Scrap from Carbon import TE, TextEdit, Win +from Carbon import App +from Carbon.Appearance import kThemeStateActive, kThemeStateInactive import waste import WASTEconst import Wbase @@ -55,25 +57,29 @@ class TextBox(Wbase.Widget): class _ScrollWidget: # to be overridden - def getscrollbarvalues(self): + def getscrollrects(self): + """Return (destrect, viewrect).""" return None, None # internal method + def updatescrollbars(self): - vx, vy = self.getscrollbarvalues() + (dl, dt, dr, db), (vl, vt, vr, vb) = self.getscrollrects() if self._parent._barx: - if vx <> None: - self._parent._barx.enable(1) - self._parent._barx.set(vx) - else: - self._parent._barx.enable(0) + viewwidth = vr - vl + destwidth = dr - dl + bar = self._parent._barx + bar.setmax(destwidth - viewwidth) + bar.setviewsize(viewwidth) + bar.set(vl - dl) if self._parent._bary: - if vy <> None: - self._parent._bary.enable(1) - self._parent._bary.set(vy) - else: - self._parent._bary.enable(0) - + viewheight = vb - vt + destheight = db - dt + bar = self._parent._bary + bar.setmax(destheight - viewheight) + bar.setviewsize(viewheight) + bar.set(vt - dt) + UNDOLABELS = [ # Indexed by WEGetUndoInfo() value None, "", "typing", "Cut", "Paste", "Clear", "Drag", "Style", @@ -373,6 +379,7 @@ class EditText(Wbase.SelectableWidget, _ScrollWidget): if self._selected and self._activated: self.drawselframe(1) Qd.FrameRect(self._bounds) + #App.DrawThemeEditTextFrame(self._bounds, kThemeStateActive) # scrolling def scrollpageup(self): @@ -385,13 +392,13 @@ class EditText(Wbase.SelectableWidget, _ScrollWidget): def scrolltop(self): if self._parent._bary and self._parent._bary._enabled: - self.vscroll(0) + self.vscroll(self._parent._bary.getmin()) if self._parent._barx and self._parent._barx._enabled: - self.hscroll(0) + self.hscroll(self._parent._barx.getmin()) def scrollbottom(self): if self._parent._bary and self._parent._bary._enabled: - self.vscroll(32767) + self.vscroll(self._parent._bary.getmax()) # menu handlers def domenu_copy(self, *args): @@ -469,20 +476,15 @@ class EditText(Wbase.SelectableWidget, _ScrollWidget): self.selectall() # private - def getscrollbarvalues(self): - dr = self.ted.WEGetDestRect() - vr = self.ted.WEGetViewRect() - vx = Wcontrols._scalebarvalue(dr[0], dr[2], vr[0], vr[2]) - vy = Wcontrols._scalebarvalue(dr[1], dr[3], vr[1], vr[3]) - return vx, vy + def getscrollrects(self): + return self.ted.WEGetDestRect(), self.ted.WEGetViewRect() def vscroll(self, value): lineheight = self.ted.WEGetHeight(0, 1) dr = self.ted.WEGetDestRect() vr = self.ted.WEGetViewRect() - destheight = dr[3] - dr[1] viewheight = vr[3] - vr[1] - viewoffset = maxdelta = vr[1] - dr[1] + maxdelta = vr[1] - dr[1] mindelta = vr[3] - dr[3] if value == "+": delta = lineheight @@ -493,11 +495,7 @@ class EditText(Wbase.SelectableWidget, _ScrollWidget): elif value == "--": delta = lineheight - viewheight else: # in thumb - cur = (32767L * viewoffset) / (destheight - viewheight) - delta = (cur-value)*(destheight - viewheight)/32767 - if abs(delta - viewoffset) <=2: - # compensate for irritating rounding error - delta = viewoffset + delta = vr[1] - dr[1] - value delta = min(maxdelta, delta) delta = max(mindelta, delta) self.ted.WEScroll(0, delta) @@ -519,11 +517,12 @@ class EditText(Wbase.SelectableWidget, _ScrollWidget): elif value == "--": delta = 0.5 * (vr[0] - vr[2]) else: # in thumb - cur = (32767 * viewoffset) / (destwidth - viewwidth) - delta = (cur-value)*(destwidth - viewwidth)/32767 - if abs(delta - viewoffset) <=2: - # compensate for irritating rounding error - delta = viewoffset + delta = vr[0] - dr[0] - value + #cur = (32767 * viewoffset) / (destwidth - viewwidth) + #delta = (cur-value)*(destwidth - viewwidth)/32767 + #if abs(delta - viewoffset) <=2: + # # compensate for irritating rounding error + # delta = viewoffset delta = min(maxdelta, delta) delta = max(mindelta, delta) self.ted.WEScroll(delta, 0) @@ -923,6 +922,7 @@ class PyEditor(TextEditor): if autoscroll: self.ted.WEFeatureFlag(WASTEconst.weFAutoScroll, 0) self.ted.WESetSelection(count, count + 1) + Qd.QDFlushPortBuffer(self._parentwindow.wid, None) # needed under OSX time.sleep(0.2) self.ted.WESetSelection(selstart, selend) if autoscroll: |