]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
For ControlWindow there is a new method do_rawcontrolhit(), which gets
authorJack Jansen <jack.jansen@cwi.nl>
Thu, 28 May 1998 14:22:48 +0000 (14:22 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Thu, 28 May 1998 14:22:48 +0000 (14:22 +0000)
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.

Mac/Lib/FrameWork.py

index 69378b5c0d86b4423b6f132c33775c8681650fb9..647d9e4e469dedd866d133c9d2a5eae39a20ec6f 100644 (file)
@@ -803,16 +803,19 @@ class ControlsWindow(Window):
                (what, message, when, where, modifiers) = event
                SetPort(window)  # XXXX Needed?
                local = GlobalToLocal(where)
-               ctltype, control = FindControl(local, window)
-               if ctltype and control:
-                       pcode = control.TrackControl(local)
-                       if pcode:
-                               self.do_controlhit(window, control, pcode, event)
+               pcode, control = FindControl(local, window)
+               if pcode and control:
+                       self.do_rawcontrolhit(window, control, pcode, local, event)
                else:
                        if DEBUG: print "FindControl(%s, %s) -> (%s, %s)" % \
-                               (local, window, ctltype, control)
+                               (local, window, pcode, control)
                        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):
        def __init__(self, parent):
                self.barx = self.bary = None
@@ -878,16 +881,37 @@ class ScrolledWindow(ControlsWindow):
                        ValidRect((r - SCROLLBARWIDTH + 1, t, r, b - SCROLLBARWIDTH + 2))       # jvr
                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:
-                       bar = self.barx
                        which = 'x'
                elif control == self.bary:
-                       bar = self.bary
                        which = 'y'
                else:
                        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:
                        what = '-'
                elif pcode == inDownButton:
@@ -897,11 +921,9 @@ class ScrolledWindow(ControlsWindow):
                elif pcode == inPageDown:
                        what = '++'
                else:
-                       what = 'set'
-                       value = bar.GetControlValue()
-               self.scrollbar_callback(which, what, value)
+                       return
+               self.scrollbar_callback(which, what, None)
                self.updatescrollbars()
-               return 1
                
        def updatescrollbars(self):
                SetPort(self.wid)