For ControlWindow there is a new method do_rawcontrolhit(), which gets

control before TrackControl is called. The default implementation
calls TrackControl and then do_controlhit().

For ScrolledWindow, do_rawcontrol passes a tracker function to
TrackControl if the mouse is in one of the arrows or grey areas, and
the tracker handles scrolling. For the thumb part nothing has changed.
This commit is contained in:
Jack Jansen 1998-05-28 14:22:48 +00:00
parent 848250c15b
commit 41e825a8f4

View file

@ -803,16 +803,19 @@ class ControlsWindow(Window):
(what, message, when, where, modifiers) = event (what, message, when, where, modifiers) = event
SetPort(window) # XXXX Needed? SetPort(window) # XXXX Needed?
local = GlobalToLocal(where) local = GlobalToLocal(where)
ctltype, control = FindControl(local, window) pcode, control = FindControl(local, window)
if ctltype and control: if pcode and control:
pcode = control.TrackControl(local) self.do_rawcontrolhit(window, control, pcode, local, event)
if pcode:
self.do_controlhit(window, control, pcode, event)
else: else:
if DEBUG: print "FindControl(%s, %s) -> (%s, %s)" % \ if DEBUG: print "FindControl(%s, %s) -> (%s, %s)" % \
(local, window, ctltype, control) (local, window, pcode, control)
self.do_contentclick(local, modifiers, event) self.do_contentclick(local, modifiers, event)
def do_rawcontrolhit(self, window, control, pcode, local, event):
pcode = control.TrackControl(local)
if pcode:
self.do_controlhit(window, control, pcode, event)
class ScrolledWindow(ControlsWindow): class ScrolledWindow(ControlsWindow):
def __init__(self, parent): def __init__(self, parent):
self.barx = self.bary = None self.barx = self.bary = None
@ -878,16 +881,37 @@ class ScrolledWindow(ControlsWindow):
ValidRect((r - SCROLLBARWIDTH + 1, t, r, b - SCROLLBARWIDTH + 2)) # jvr ValidRect((r - SCROLLBARWIDTH + 1, t, r, b - SCROLLBARWIDTH + 2)) # jvr
InvalRect((r - SCROLLBARWIDTH + 1, b - SCROLLBARWIDTH + 1, r, b)) # jvr, growicon InvalRect((r - SCROLLBARWIDTH + 1, b - SCROLLBARWIDTH + 1, r, b)) # jvr, growicon
def do_controlhit(self, window, control, pcode, event):
def do_rawcontrolhit(self, window, control, pcode, local, event):
if control == self.barx: if control == self.barx:
bar = self.barx
which = 'x' which = 'x'
elif control == self.bary: elif control == self.bary:
bar = self.bary
which = 'y' which = 'y'
else: else:
return 0 return 0
value = None if pcode in (inUpButton, inDownButton, inPageUp, inPageDown):
# We do the work for the buttons and grey area in the tracker
dummy = control.TrackControl(local, self.do_controltrack)
else:
# but the thumb is handled here
pcode = control.TrackControl(local)
if pcode == inThumb:
value = control.GetControlValue()
print 'setbars', which, value #DBG
self.scrollbar_callback(which, 'set', value)
self.updatescrollbars()
else:
print 'funny part', pcode #DBG
return 1
def do_controltrack(self, control, pcode):
if control == self.barx:
which = 'x'
elif control == self.bary:
which = 'y'
else:
return
if pcode == inUpButton: if pcode == inUpButton:
what = '-' what = '-'
elif pcode == inDownButton: elif pcode == inDownButton:
@ -897,11 +921,9 @@ class ScrolledWindow(ControlsWindow):
elif pcode == inPageDown: elif pcode == inPageDown:
what = '++' what = '++'
else: else:
what = 'set' return
value = bar.GetControlValue() self.scrollbar_callback(which, what, None)
self.scrollbar_callback(which, what, value)
self.updatescrollbars() self.updatescrollbars()
return 1
def updatescrollbars(self): def updatescrollbars(self):
SetPort(self.wid) SetPort(self.wid)