Patch by Jason Harper to allow IDE to work again under MacOS 8.1. Plus appearance support for Wlist frames and focussing. Plus commented-out appearance support for the same for Wtext, which still needs some work.
This commit is contained in:
parent
f227252c21
commit
b6b6c6c33f
|
@ -7,7 +7,7 @@ class ControlWidget(Wbase.ClickableWidget):
|
||||||
|
|
||||||
"""Baseclass for all native controls."""
|
"""Baseclass for all native controls."""
|
||||||
|
|
||||||
def __init__(self, possize, title = "Control", procID = 0, callback = None, value = 0, min = 0, max = 1):
|
def __init__(self, possize, title = "Control", procID = 0, callback = None, value = 0, min = 0, max = 1, viewsize = 0):
|
||||||
Wbase.ClickableWidget.__init__(self, possize)
|
Wbase.ClickableWidget.__init__(self, possize)
|
||||||
self._control = None
|
self._control = None
|
||||||
self._title = title
|
self._title = title
|
||||||
|
@ -17,21 +17,54 @@ class ControlWidget(Wbase.ClickableWidget):
|
||||||
self._min = min
|
self._min = min
|
||||||
self._max = max
|
self._max = max
|
||||||
self._enabled = 1
|
self._enabled = 1
|
||||||
self._viewsize = 0
|
self._viewsize = viewsize
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
self._calcbounds()
|
self._calcbounds()
|
||||||
|
|
||||||
|
# NewControl doesn't accept 32-bit value, min, or max, so for consistency
|
||||||
|
# with the new 32-bit set/get methods, out-of-range values are initially
|
||||||
|
# set as zero, followed by a 32-bit set of the actual value.
|
||||||
|
# Values not representable in 16 bits will fail on MacOS 8.1, however
|
||||||
|
# the vast majority of control usage should still be compatible.
|
||||||
|
_value, _min, _max = self._value, self._min, self._max
|
||||||
|
if -32768 <= _value <= 32767:
|
||||||
|
bigvalue = None
|
||||||
|
else:
|
||||||
|
bigvalue = _value
|
||||||
|
_value = 0
|
||||||
|
if -32768 <= _min <= 32767:
|
||||||
|
bigmin = None
|
||||||
|
else:
|
||||||
|
bigmin = _min
|
||||||
|
_min = 0
|
||||||
|
if -32768 <= _max <= 32767:
|
||||||
|
bigmax = None
|
||||||
|
else:
|
||||||
|
bigmax = _max
|
||||||
|
_max = 0
|
||||||
self._control = Ctl.NewControl(self._parentwindow.wid,
|
self._control = Ctl.NewControl(self._parentwindow.wid,
|
||||||
self._bounds,
|
self._bounds,
|
||||||
self._title,
|
self._title,
|
||||||
1,
|
1,
|
||||||
self._value,
|
_value,
|
||||||
self._min,
|
_min,
|
||||||
self._max,
|
_max,
|
||||||
self._procID,
|
self._procID,
|
||||||
0)
|
0)
|
||||||
|
if bigvalue:
|
||||||
|
self._control.SetControl32BitValue(bigvalue)
|
||||||
|
if bigmin:
|
||||||
|
self._control.SetControl32BitMinimum(bigmin)
|
||||||
|
if bigmax:
|
||||||
|
self._control.SetControl32BitMaximum(bigmax)
|
||||||
if self._viewsize:
|
if self._viewsize:
|
||||||
self._control.SetControlViewSize(self._viewsize)
|
try:
|
||||||
|
self._control.SetControlViewSize(self._viewsize)
|
||||||
|
# Not available in MacOS 8.1, but that's OK since it only affects
|
||||||
|
# proportional scrollbars which weren't available in 8.1 either.
|
||||||
|
except NotImplementedError:
|
||||||
|
pass
|
||||||
self.enable(self._enabled)
|
self.enable(self._enabled)
|
||||||
|
|
||||||
def adjust(self, oldbounds):
|
def adjust(self, oldbounds):
|
||||||
|
@ -100,13 +133,23 @@ class ControlWidget(Wbase.ClickableWidget):
|
||||||
|
|
||||||
def set(self, value):
|
def set(self, value):
|
||||||
if self._control:
|
if self._control:
|
||||||
self._control.SetControl32BitValue(value)
|
if -32768 <= value <= 32767:
|
||||||
|
# No 32-bit control support in MacOS 8.1, so use
|
||||||
|
# the 16-bit interface when possible.
|
||||||
|
self._control.SetControlValue(value)
|
||||||
|
else:
|
||||||
|
self._control.SetControl32BitValue(value)
|
||||||
else:
|
else:
|
||||||
self._value = value
|
self._value = value
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
if self._control:
|
if self._control:
|
||||||
return self._control.GetControl32BitValue()
|
try:
|
||||||
|
return self._control.GetControl32BitValue()
|
||||||
|
# No 32-bit control support in MacOS 8.1, so fall
|
||||||
|
# back to the 16-bit interface when needed.
|
||||||
|
except NotImplementedError:
|
||||||
|
return self._control.GetControlValue()
|
||||||
else:
|
else:
|
||||||
return self._value
|
return self._value
|
||||||
|
|
||||||
|
@ -279,27 +322,52 @@ class Scrollbar(ControlWidget):
|
||||||
|
|
||||||
def setmin(self, min):
|
def setmin(self, min):
|
||||||
if self._control is not None:
|
if self._control is not None:
|
||||||
self._control.SetControl32BitMinimum(min)
|
if -32768 <= min <= 32767:
|
||||||
|
# No 32-bit control support in MacOS 8.1, so use
|
||||||
|
# the 16-bit interface when possible.
|
||||||
|
self._control.SetControlMinimum(min)
|
||||||
|
else:
|
||||||
|
self._control.SetControl32BitMinimum(min)
|
||||||
else:
|
else:
|
||||||
self._min = min
|
self._min = min
|
||||||
|
|
||||||
def setmax(self, max):
|
def setmax(self, max):
|
||||||
if self._control is not None:
|
if self._control is not None:
|
||||||
self._control.SetControl32BitMaximum(max)
|
if -32768 <= max <= 32767:
|
||||||
|
# No 32-bit control support in MacOS 8.1, so use
|
||||||
|
# the 16-bit interface when possible.
|
||||||
|
self._control.SetControlMaximum(max)
|
||||||
|
else:
|
||||||
|
self._control.SetControl32BitMaximum(max)
|
||||||
else:
|
else:
|
||||||
self._max = max
|
self._max = max
|
||||||
|
|
||||||
def setviewsize(self, viewsize):
|
def setviewsize(self, viewsize):
|
||||||
if self._control is not None:
|
if self._control is not None:
|
||||||
self._control.SetControlViewSize(viewsize)
|
try:
|
||||||
|
self._control.SetControlViewSize(viewsize)
|
||||||
|
# Not available in MacOS 8.1, but that's OK since it only affects
|
||||||
|
# proportional scrollbars which weren't available in 8.1 either.
|
||||||
|
except NotImplementedError:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
self._viewsize = viewsize
|
self._viewsize = viewsize
|
||||||
|
|
||||||
def getmin(self):
|
def getmin(self):
|
||||||
return self._control.GetControl32BitMinimum()
|
try:
|
||||||
|
return self._control.GetControl32BitMinimum()
|
||||||
|
# No 32-bit control support in MacOS 8.1, so fall
|
||||||
|
# back to the 16-bit interface when needed.
|
||||||
|
except NotImplementedError:
|
||||||
|
return self._control.GetControlMinimum()
|
||||||
|
|
||||||
def getmax(self):
|
def getmax(self):
|
||||||
return self._control.GetControl32BitMaximum()
|
try:
|
||||||
|
return self._control.GetControl32BitMaximum()
|
||||||
|
# No 32-bit control support in MacOS 8.1, so fall
|
||||||
|
# back to the 16-bit interface when needed.
|
||||||
|
except NotImplementedError:
|
||||||
|
return self._control.GetControlMaximum()
|
||||||
|
|
||||||
# internals
|
# internals
|
||||||
def click(self, point, modifiers):
|
def click(self, point, modifiers):
|
||||||
|
@ -334,7 +402,12 @@ class Scrollbar(ControlWidget):
|
||||||
|
|
||||||
def _hit(self, part):
|
def _hit(self, part):
|
||||||
if part == Controls.inThumb:
|
if part == Controls.inThumb:
|
||||||
value = self._control.GetControl32BitValue()
|
try:
|
||||||
|
value = self._control.GetControl32BitValue()
|
||||||
|
# No 32-bit control support in MacOS 8.1, so fall
|
||||||
|
# back to the 16-bit interface when needed.
|
||||||
|
except NotImplementedError:
|
||||||
|
value = self._control.GetControlValue()
|
||||||
elif part == Controls.inUpButton:
|
elif part == Controls.inUpButton:
|
||||||
value = "+"
|
value = "+"
|
||||||
elif part == Controls.inDownButton:
|
elif part == Controls.inDownButton:
|
||||||
|
|
|
@ -55,12 +55,11 @@ class List(Wbase.SelectableWidget):
|
||||||
|
|
||||||
def adjust(self, oldbounds):
|
def adjust(self, oldbounds):
|
||||||
self.SetPort()
|
self.SetPort()
|
||||||
if self._selected:
|
# Appearance frames are drawn outside the specified bounds,
|
||||||
self.GetWindow().InvalWindowRect(Qd.InsetRect(oldbounds, -3, -3))
|
# so we always need to outset the invalidated area.
|
||||||
self.GetWindow().InvalWindowRect(Qd.InsetRect(self._bounds, -3, -3))
|
self.GetWindow().InvalWindowRect(Qd.InsetRect(oldbounds, -3, -3))
|
||||||
else:
|
self.GetWindow().InvalWindowRect(Qd.InsetRect(self._bounds, -3, -3))
|
||||||
self.GetWindow().InvalWindowRect(oldbounds)
|
|
||||||
self.GetWindow().InvalWindowRect(self._bounds)
|
|
||||||
if oldbounds[:2] == self._bounds[:2]:
|
if oldbounds[:2] == self._bounds[:2]:
|
||||||
# set visRgn to empty, to prevent nasty drawing side effect of LSize()
|
# set visRgn to empty, to prevent nasty drawing side effect of LSize()
|
||||||
Qd.RectRgn(self._parentwindow.wid.GetWindowPort().visRgn, (0, 0, 0, 0))
|
Qd.RectRgn(self._parentwindow.wid.GetWindowPort().visRgn, (0, 0, 0, 0))
|
||||||
|
@ -255,24 +254,25 @@ class List(Wbase.SelectableWidget):
|
||||||
if not visRgn:
|
if not visRgn:
|
||||||
visRgn = self._parentwindow.wid.GetWindowPort().visRgn
|
visRgn = self._parentwindow.wid.GetWindowPort().visRgn
|
||||||
self._list.LUpdate(visRgn)
|
self._list.LUpdate(visRgn)
|
||||||
App.DrawThemeListBoxFrame(self._bounds, kThemeStateActive)
|
state = [kThemeStateActive, kThemeStateInactive][not self._activated]
|
||||||
#if self._selected and self._activated:
|
App.DrawThemeListBoxFrame(Qd.InsetRect(self._bounds, 1, 1), state)
|
||||||
# self.drawselframe(1)
|
if self._selected and self._activated:
|
||||||
|
self.drawselframe(1)
|
||||||
|
|
||||||
def select(self, onoff, isclick = 0):
|
def select(self, onoff, isclick = 0):
|
||||||
if Wbase.SelectableWidget.select(self, onoff):
|
if Wbase.SelectableWidget.select(self, onoff):
|
||||||
return
|
return
|
||||||
self.SetPort()
|
self.SetPort()
|
||||||
state = [kThemeStateActive, kThemeStatePressed][onoff]
|
self.drawselframe(onoff)
|
||||||
App.DrawThemeListBoxFrame(self._bounds, kThemeStateActive)
|
|
||||||
#self.drawselframe(onoff)
|
|
||||||
|
|
||||||
def activate(self, onoff):
|
def activate(self, onoff):
|
||||||
self._activated = onoff
|
self._activated = onoff
|
||||||
if self._visible:
|
if self._visible:
|
||||||
self._list.LActivate(onoff)
|
self._list.LActivate(onoff)
|
||||||
#if self._selected:
|
state = [kThemeStateActive, kThemeStateInactive][not onoff]
|
||||||
# self.drawselframe(onoff)
|
App.DrawThemeListBoxFrame(Qd.InsetRect(self._bounds, 1, 1), state)
|
||||||
|
if self._selected:
|
||||||
|
self.drawselframe(onoff)
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
return self.items
|
return self.items
|
||||||
|
|
|
@ -70,6 +70,11 @@ class _ScrollWidget:
|
||||||
destwidth = dr - dl
|
destwidth = dr - dl
|
||||||
bar = self._parent._barx
|
bar = self._parent._barx
|
||||||
bar.setmax(destwidth - viewwidth)
|
bar.setmax(destwidth - viewwidth)
|
||||||
|
|
||||||
|
# MacOS 8.1 doesn't automatically disable
|
||||||
|
# scrollbars whose max <= min
|
||||||
|
bar.enable(destwidth > viewwidth)
|
||||||
|
|
||||||
bar.setviewsize(viewwidth)
|
bar.setviewsize(viewwidth)
|
||||||
bar.set(vl - dl)
|
bar.set(vl - dl)
|
||||||
if self._parent._bary:
|
if self._parent._bary:
|
||||||
|
@ -77,6 +82,11 @@ class _ScrollWidget:
|
||||||
destheight = db - dt
|
destheight = db - dt
|
||||||
bar = self._parent._bary
|
bar = self._parent._bary
|
||||||
bar.setmax(destheight - viewheight)
|
bar.setmax(destheight - viewheight)
|
||||||
|
|
||||||
|
# MacOS 8.1 doesn't automatically disable
|
||||||
|
# scrollbars whose max <= min
|
||||||
|
bar.enable(destheight > viewheight)
|
||||||
|
|
||||||
bar.setviewsize(viewheight)
|
bar.setviewsize(viewheight)
|
||||||
bar.set(vt - dt)
|
bar.set(vt - dt)
|
||||||
|
|
||||||
|
@ -218,6 +228,9 @@ class EditText(Wbase.SelectableWidget, _ScrollWidget):
|
||||||
|
|
||||||
def adjust(self, oldbounds):
|
def adjust(self, oldbounds):
|
||||||
self.SetPort()
|
self.SetPort()
|
||||||
|
# Note: if App.DrawThemeEditTextFrame is ever used, it will be necessary
|
||||||
|
# to unconditionally outset the invalidated rectangles, since Appearance
|
||||||
|
# frames are drawn outside the bounds.
|
||||||
if self._selected and self._parentwindow._hasselframes:
|
if self._selected and self._parentwindow._hasselframes:
|
||||||
self.GetWindow().InvalWindowRect(Qd.InsetRect(oldbounds, -3, -3))
|
self.GetWindow().InvalWindowRect(Qd.InsetRect(oldbounds, -3, -3))
|
||||||
self.GetWindow().InvalWindowRect(Qd.InsetRect(self._bounds, -3, -3))
|
self.GetWindow().InvalWindowRect(Qd.InsetRect(self._bounds, -3, -3))
|
||||||
|
@ -351,12 +364,19 @@ class EditText(Wbase.SelectableWidget, _ScrollWidget):
|
||||||
|
|
||||||
def activate(self, onoff):
|
def activate(self, onoff):
|
||||||
self._activated = onoff
|
self._activated = onoff
|
||||||
if self._selected and self._visible:
|
if self._visible:
|
||||||
if onoff:
|
self.SetPort()
|
||||||
self.ted.WEActivate()
|
|
||||||
else:
|
# DISABLED! There are too many places where it is assumed that
|
||||||
self.ted.WEDeactivate()
|
# the frame of an EditText item is 1 pixel, inside the bounds.
|
||||||
|
#state = [kThemeStateActive, kThemeStateInactive][not onoff]
|
||||||
|
#App.DrawThemeEditTextFrame(Qd.InsetRect(self._bounds, 1, 1), state)
|
||||||
|
|
||||||
if self._selected:
|
if self._selected:
|
||||||
|
if onoff:
|
||||||
|
self.ted.WEActivate()
|
||||||
|
else:
|
||||||
|
self.ted.WEDeactivate()
|
||||||
self.drawselframe(onoff)
|
self.drawselframe(onoff)
|
||||||
|
|
||||||
def select(self, onoff, isclick = 0):
|
def select(self, onoff, isclick = 0):
|
||||||
|
@ -376,10 +396,15 @@ class EditText(Wbase.SelectableWidget, _ScrollWidget):
|
||||||
if not visRgn:
|
if not visRgn:
|
||||||
visRgn = self._parentwindow.wid.GetWindowPort().visRgn
|
visRgn = self._parentwindow.wid.GetWindowPort().visRgn
|
||||||
self.ted.WEUpdate(visRgn)
|
self.ted.WEUpdate(visRgn)
|
||||||
|
|
||||||
|
# DISABLED! There are too many places where it is assumed that
|
||||||
|
# the frame of an EditText item is 1 pixel, inside the bounds.
|
||||||
|
#state = [kThemeStateActive, kThemeStateInactive][not self._activated]
|
||||||
|
#App.DrawThemeEditTextFrame(Qd.InsetRect(self._bounds, 1, 1), state)
|
||||||
|
Qd.FrameRect(self._bounds)
|
||||||
|
|
||||||
if self._selected and self._activated:
|
if self._selected and self._activated:
|
||||||
self.drawselframe(1)
|
self.drawselframe(1)
|
||||||
Qd.FrameRect(self._bounds)
|
|
||||||
#App.DrawThemeEditTextFrame(self._bounds, kThemeStateActive)
|
|
||||||
|
|
||||||
# scrolling
|
# scrolling
|
||||||
def scrollpageup(self):
|
def scrollpageup(self):
|
||||||
|
@ -604,6 +629,18 @@ class TextEditor(EditText):
|
||||||
if self._selected and self._activated:
|
if self._selected and self._activated:
|
||||||
self.drawselframe(1)
|
self.drawselframe(1)
|
||||||
|
|
||||||
|
def activate(self, onoff):
|
||||||
|
self._activated = onoff
|
||||||
|
if self._visible:
|
||||||
|
self.SetPort()
|
||||||
|
# doesn't draw frame, as EditText.activate does
|
||||||
|
if self._selected:
|
||||||
|
if onoff:
|
||||||
|
self.ted.WEActivate()
|
||||||
|
else:
|
||||||
|
self.ted.WEDeactivate()
|
||||||
|
self.drawselframe(onoff)
|
||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
commentPat = re.compile("[ \t]*(#)")
|
commentPat = re.compile("[ \t]*(#)")
|
||||||
|
|
Loading…
Reference in New Issue