diff options
Diffstat (limited to 'macosx/tkMacOSXScrlbr.c')
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 2b5f094..820bec3 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -649,7 +649,7 @@ ThumbActionProc(ControlRef theControl, ControlPartCode partCode) * for the display to update. */ - sprintf(valueString, "%g", newFirstFraction); + Tcl_PrintDouble(NULL, newFirstFraction, valueString); Tcl_DStringSetLength(&cmdString, 0); Tcl_DStringAppend(&cmdString, scrollPtr->command, scrollPtr->commandSize); @@ -691,8 +691,8 @@ ScrollbarActionProc( ControlRef theControl, /* Handle to scrollbat control */ ControlPartCode partCode) /* Part of scrollbar that was "hit" */ { - TkScrollbar *scrollPtr = (TkScrollbar *)(intptr_t)GetControlReference( - theControl); + TkScrollbar *scrollPtr = (TkScrollbar *)(intptr_t) + GetControlReference(theControl); MacScrollbar *macScrollPtr = (MacScrollbar *) scrollPtr; Tcl_DString cmdString; @@ -700,7 +700,7 @@ ScrollbarActionProc( Tcl_DStringAppend(&cmdString, scrollPtr->command, scrollPtr->commandSize); - if ( partCode == kAppearancePartUpButton || + if (partCode == kAppearancePartUpButton || partCode == kAppearancePartDownButton ) { Tcl_DStringAppendElement(&cmdString, "scroll"); Tcl_DStringAppendElement(&cmdString, @@ -715,16 +715,16 @@ ScrollbarActionProc( } else if (partCode == kAppearancePartIndicator) { char valueString[TCL_DOUBLE_SPACE]; - sprintf(valueString, "%g", + Tcl_PrintDouble(NULL, (GetControl32BitValue(macScrollPtr->sbHandle) - - MIN_SCROLLBAR_VALUE) / SCROLLBAR_SCALING_VALUE); + MIN_SCROLLBAR_VALUE) / SCROLLBAR_SCALING_VALUE, valueString); Tcl_DStringAppendElement(&cmdString, "moveto"); Tcl_DStringAppendElement(&cmdString, valueString); } - Tcl_Preserve((ClientData) scrollPtr->interp); + Tcl_Preserve(scrollPtr->interp); Tcl_EvalEx(scrollPtr->interp, Tcl_DStringValue(&cmdString), Tcl_DStringLength(&cmdString), TCL_EVAL_GLOBAL); - Tcl_Release((ClientData) scrollPtr->interp); + Tcl_Release(scrollPtr->interp); Tcl_DStringFree(&cmdString); TkMacOSXRunTclEventLoop(); } @@ -754,11 +754,11 @@ ScrollbarBindProc( Tk_Window tkwin, /* Target window for event. */ KeySym keySym) /* The KeySym if a key event. */ { - TkWindow *winPtr = (TkWindow*)tkwin; + TkWindow *winPtr = (TkWindow *) tkwin; TkScrollbar *scrollPtr = (TkScrollbar *) winPtr->instanceData; MacScrollbar *macScrollPtr = (MacScrollbar *) winPtr->instanceData; - Tcl_Preserve((ClientData)scrollPtr); + Tcl_Preserve(scrollPtr); macScrollPtr->macFlags |= IN_MODAL_LOOP; if (eventPtr->type == ButtonPress) { @@ -770,10 +770,11 @@ ScrollbarBindProc( Window window; /* - * To call Macintosh control routines we must have the port - * set to the window containing the control. We will then test - * which part of the control was hit and act accordingly. + * To call Macintosh control routines we must have the port set to the + * window containing the control. We will then test which part of the + * control was hit and act accordingly. */ + destPort = TkMacOSXGetDrawablePort(Tk_WindowId(scrollPtr->tkwin)); portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(scrollPtr->tkwin)); @@ -785,9 +786,10 @@ ScrollbarBindProc( TkMacOSXTrackingLoop(1); if (part == kAppearancePartIndicator && scrollPtr->jump == false) { /* - * Case 1: In thumb, no jump scrolling. Call track control - * with the thumb action proc which will do most of the work. + * Case 1: In thumb, no jump scrolling. Call track control with + * the thumb action proc which will do most of the work. */ + mouseDownPoint.h = where.h; mouseDownPoint.v = where.v; part = HandleControlClick(macScrollPtr->sbHandle, where, @@ -795,18 +797,20 @@ ScrollbarBindProc( } else if (part == kAppearancePartIndicator) { /* * Case 2: in thumb with jump scrolling. Call HandleControlClick - * with a NULL action proc. Use the new value of the control - * to set update the control. + * with a NULL action proc. Use the new value of the control to + * set update the control. */ + part = HandleControlClick(macScrollPtr->sbHandle, where, TkMacOSXModifierState(), NULL); if (part == kAppearancePartIndicator) { Tcl_DString cmdString; char valueString[TCL_DOUBLE_SPACE]; - sprintf(valueString, "%g", + Tcl_PrintDouble(NULL, (GetControl32BitValue(macScrollPtr->sbHandle) - - MIN_SCROLLBAR_VALUE) / SCROLLBAR_SCALING_VALUE); + MIN_SCROLLBAR_VALUE) / SCROLLBAR_SCALING_VALUE, + valueString); Tcl_DStringInit(&cmdString); Tcl_DStringAppend(&cmdString, scrollPtr->command, strlen(scrollPtr->command)); @@ -814,10 +818,10 @@ ScrollbarBindProc( Tcl_DStringAppendElement(&cmdString, valueString); interp = scrollPtr->interp; - Tcl_Preserve((ClientData) interp); + Tcl_Preserve(interp); Tcl_EvalEx(interp, Tcl_DStringValue(&cmdString), Tcl_DStringLength(&cmdString), TCL_EVAL_GLOBAL); - Tcl_Release((ClientData) interp); + Tcl_Release(interp); Tcl_DStringFree(&cmdString); TkMacOSXRunTclEventLoop(); } @@ -827,12 +831,15 @@ ScrollbarBindProc( * HandleControlClick with the scrollActionProc which will do * most all the work. */ + HandleControlClick(macScrollPtr->sbHandle, where, TkMacOSXModifierState(), scrollActionProc); + /* * Workaround for Carbon bug where the scrollbar down arrow * sometimes gets "stuck" after the mousebutton has been released. */ + if (scrollPtr->tkwin) { TkMacOSXSetUpClippingRgn(Tk_WindowId(scrollPtr->tkwin)); } @@ -860,7 +867,7 @@ ScrollbarBindProc( macScrollPtr->sbHandle = NULL; } macScrollPtr->macFlags &= ~IN_MODAL_LOOP; - Tcl_Release((ClientData)scrollPtr); + Tcl_Release(scrollPtr); return TCL_OK; } |