summaryrefslogtreecommitdiffstats
path: root/win/tkWinScrlbr.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tkWinScrlbr.c')
-rw-r--r--win/tkWinScrlbr.c415
1 files changed, 196 insertions, 219 deletions
diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c
index 2145ff0..46aad58 100644
--- a/win/tkWinScrlbr.c
+++ b/win/tkWinScrlbr.c
@@ -1,4 +1,4 @@
-/*
+/*
* tkWinScrollbar.c --
*
* This file implements the Windows specific portion of the scrollbar
@@ -6,19 +6,18 @@
*
* Copyright (c) 1996 by Sun Microsystems, Inc.
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkWinInt.h"
#include "tkScrollbar.h"
-
/*
- * The following constant is used to specify the maximum scroll position.
- * This value is limited by the Win32 API to either 16-bits or 32-bits,
- * depending on the context. For now we'll just use a value small
- * enough to fit in 16-bits, but which gives us 4-digits of precision.
+ * The following constant is used to specify the maximum scroll position. This
+ * value is limited by the Win32 API to either 16-bits or 32-bits, depending
+ * on the context. For now we'll just use a value small enough to fit in
+ * 16-bits, but which gives us 4-digits of precision.
*/
#define MAX_SCROLL 10000
@@ -37,7 +36,7 @@ typedef struct WinScrollbar {
/*
* Flag bits for native scrollbars:
- *
+ *
* IN_MODAL_LOOP: Non-zero means this scrollbar is in the middle
* of a modal loop.
* ALREADY_DEAD: Non-zero means this scrollbar has been
@@ -53,33 +52,24 @@ typedef struct WinScrollbar {
static int initialized = 0;
static int hArrowWidth, hThumb; /* Horizontal control metrics. */
-static int vArrowWidth, vArrowHeight, vThumb; /* Vertical control metrics. */
+static int vArrowHeight, vThumb; /* Vertical control metrics. */
TCL_DECLARE_MUTEX(winScrlbrMutex)
/*
- * This variable holds the default width for a scrollbar in string
- * form for use in a Tk_ConfigSpec.
- */
-
-static char defWidth[TCL_INTEGER_SPACE];
-
-/*
* Declarations for functions defined in this file.
*/
-static Window CreateProc _ANSI_ARGS_((Tk_Window tkwin,
- Window parent, ClientData instanceData));
-static void ModalLoopProc _ANSI_ARGS_((Tk_Window tkwin,
- XEvent *eventPtr));
-static int ScrollbarBindProc _ANSI_ARGS_((ClientData clientData,
+static Window CreateProc(Tk_Window tkwin, Window parent,
+ ClientData instanceData);
+static void ModalLoopProc(Tk_Window tkwin, XEvent *eventPtr);
+static int ScrollbarBindProc(ClientData clientData,
Tcl_Interp *interp, XEvent *eventPtr,
- Tk_Window tkwin, KeySym keySym));
-static LRESULT CALLBACK ScrollbarProc _ANSI_ARGS_((HWND hwnd, UINT message,
- WPARAM wParam, LPARAM lParam));
-static void UpdateScrollbar _ANSI_ARGS_((
- WinScrollbar *scrollPtr));
-static void UpdateScrollbarMetrics _ANSI_ARGS_((void));
+ Tk_Window tkwin, KeySym keySym);
+static LRESULT CALLBACK ScrollbarProc(HWND hwnd, UINT message, WPARAM wParam,
+ LPARAM lParam);
+static void UpdateScrollbar(WinScrollbar *scrollPtr);
+static void UpdateScrollbarMetrics(void);
/*
* The class procedure table for the scrollbar widget.
@@ -110,14 +100,14 @@ Tk_ClassProcs tkpScrollbarProcs = {
*/
TkScrollbar *
-TkpCreateScrollbar(tkwin)
- Tk_Window tkwin;
+TkpCreateScrollbar(
+ Tk_Window tkwin)
{
WinScrollbar *scrollPtr;
TkWindow *winPtr = (TkWindow *)tkwin;
-
+
if (!initialized) {
- Tcl_MutexLock(&winScrlbrMutex);
+ Tcl_MutexLock(&winScrlbrMutex);
UpdateScrollbarMetrics();
initialized = 1;
Tcl_MutexUnlock(&winScrlbrMutex);
@@ -140,7 +130,7 @@ TkpCreateScrollbar(tkwin)
ScrollbarBindProc, NULL, NULL);
}
- return (TkScrollbar*) scrollPtr;
+ return (TkScrollbar *) scrollPtr;
}
/*
@@ -148,8 +138,8 @@ TkpCreateScrollbar(tkwin)
*
* UpdateScrollbar --
*
- * This function updates the position and size of the scrollbar
- * thumb based on the current settings.
+ * This function updates the position and size of the scrollbar thumb
+ * based on the current settings.
*
* Results:
* None.
@@ -161,8 +151,8 @@ TkpCreateScrollbar(tkwin)
*/
static void
-UpdateScrollbar(scrollPtr)
- WinScrollbar *scrollPtr;
+UpdateScrollbar(
+ WinScrollbar *scrollPtr)
{
SCROLLINFO scrollInfo;
double thumbSize;
@@ -179,15 +169,17 @@ UpdateScrollbar(scrollPtr)
scrollInfo.nPage = ((UINT) (thumbSize * (double) MAX_SCROLL)) + 1;
if (thumbSize < 1.0) {
scrollInfo.nPos = (int)
- ((scrollPtr->info.firstFraction / (1.0-thumbSize))
- * (MAX_SCROLL - (scrollInfo.nPage - 1)));
+ ((scrollPtr->info.firstFraction / (1.0-thumbSize))
+ * (MAX_SCROLL - (scrollInfo.nPage - 1)));
} else {
scrollInfo.nPos = 0;
+
/*
- * Disable the scrollbar when there is nothing to scroll.
- * This is standard Windows style (see eg Notepad).
- * Also prevents possible crash on XP+ systems [Bug #624116].
+ * Disable the scrollbar when there is nothing to scroll. This is
+ * standard Windows style (see eg Notepad). Also prevents possible
+ * crash on XP+ systems [Bug #624116].
*/
+
scrollInfo.fMask |= SIF_DISABLENOSCROLL;
}
SetScrollInfo(scrollPtr->hwnd, SB_CTL, &scrollInfo, TRUE);
@@ -198,8 +190,8 @@ UpdateScrollbar(scrollPtr)
*
* CreateProc --
*
- * This function creates a new Scrollbar control, subclasses
- * the instance, and generates a new Window object.
+ * This function creates a new Scrollbar control, subclasses the
+ * instance, and generates a new Window object.
*
* Results:
* Returns the newly allocated Window object, or None on failure.
@@ -211,10 +203,10 @@ UpdateScrollbar(scrollPtr)
*/
static Window
-CreateProc(tkwin, parentWin, instanceData)
- Tk_Window tkwin; /* Token for window. */
- Window parentWin; /* Parent of new window. */
- ClientData instanceData; /* Scrollbar instance data. */
+CreateProc(
+ Tk_Window tkwin, /* Token for window. */
+ Window parentWin, /* Parent of new window. */
+ ClientData instanceData) /* Scrollbar instance data. */
{
DWORD style;
Window window;
@@ -226,10 +218,10 @@ CreateProc(tkwin, parentWin, instanceData)
if (scrollPtr->info.vertical) {
style = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
- | SBS_VERT | SBS_RIGHTALIGN;
+ | SBS_VERT | SBS_RIGHTALIGN;
} else {
style = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
- | SBS_HORZ | SBS_BOTTOMALIGN;
+ | SBS_HORZ | SBS_BOTTOMALIGN;
}
scrollPtr->hwnd = CreateWindow("SCROLLBAR", NULL, style,
@@ -238,14 +230,14 @@ CreateProc(tkwin, parentWin, instanceData)
/*
* Ensure new window is inserted into the stacking order at the correct
- * place.
+ * place.
*/
SetWindowPos(scrollPtr->hwnd, HWND_TOP, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
for (winPtr = ((TkWindow*)tkwin)->nextPtr; winPtr != NULL;
- winPtr = winPtr->nextPtr) {
+ winPtr = winPtr->nextPtr) {
if ((winPtr->window != None) && !(winPtr->flags & TK_TOP_HIERARCHY)) {
TkWinSetWindowPos(scrollPtr->hwnd, Tk_GetHWND(winPtr->window),
Below);
@@ -254,13 +246,8 @@ CreateProc(tkwin, parentWin, instanceData)
}
scrollPtr->lastVertical = scrollPtr->info.vertical;
-#ifdef _WIN64
scrollPtr->oldProc = (WNDPROC)SetWindowLongPtr(scrollPtr->hwnd,
- GWLP_WNDPROC, (LONG_PTR) ScrollbarProc);
-#else
- scrollPtr->oldProc = (WNDPROC)SetWindowLong(scrollPtr->hwnd, GWL_WNDPROC,
- (DWORD) ScrollbarProc);
-#endif
+ GWLP_WNDPROC, (INT_PTR) ScrollbarProc);
window = Tk_AttachHWND(tkwin, scrollPtr->hwnd);
UpdateScrollbar(scrollPtr);
@@ -272,9 +259,9 @@ CreateProc(tkwin, parentWin, instanceData)
*
* TkpDisplayScrollbar --
*
- * This procedure redraws the contents of a scrollbar window.
- * It is invoked as a do-when-idle handler, so it only runs
- * when there's nothing else for the application to do.
+ * This procedure redraws the contents of a scrollbar window. It is
+ * invoked as a do-when-idle handler, so it only runs when there's
+ * nothing else for the application to do.
*
* Results:
* None.
@@ -286,8 +273,8 @@ CreateProc(tkwin, parentWin, instanceData)
*/
void
-TkpDisplayScrollbar(clientData)
- ClientData clientData; /* Information about window. */
+TkpDisplayScrollbar(
+ ClientData clientData) /* Information about window. */
{
WinScrollbar *scrollPtr = (WinScrollbar *) clientData;
Tk_Window tkwin = scrollPtr->info.tkwin;
@@ -298,18 +285,14 @@ TkpDisplayScrollbar(clientData)
}
/*
- * Destroy and recreate the scrollbar control if the orientation
- * has changed.
+ * Destroy and recreate the scrollbar control if the orientation has
+ * changed.
*/
if (scrollPtr->lastVertical != scrollPtr->info.vertical) {
HWND hwnd = Tk_GetHWND(Tk_WindowId(tkwin));
-#ifdef _WIN64
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) scrollPtr->oldProc);
-#else
- SetWindowLong(hwnd, GWL_WNDPROC, (DWORD) scrollPtr->oldProc);
-#endif
+ SetWindowLongPtr(hwnd, GWLP_WNDPROC, (INT_PTR) scrollPtr->oldProc);
DestroyWindow(hwnd);
CreateProc(tkwin, Tk_WindowId(Tk_Parent(tkwin)),
@@ -336,17 +319,14 @@ TkpDisplayScrollbar(clientData)
*/
void
-TkpDestroyScrollbar(scrollPtr)
- TkScrollbar *scrollPtr;
+TkpDestroyScrollbar(
+ TkScrollbar *scrollPtr)
{
WinScrollbar *winScrollPtr = (WinScrollbar *)scrollPtr;
HWND hwnd = winScrollPtr->hwnd;
+
if (hwnd) {
-#ifdef _WIN64
- SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) winScrollPtr->oldProc);
-#else
- SetWindowLong(hwnd, GWL_WNDPROC, (DWORD) winScrollPtr->oldProc);
-#endif
+ SetWindowLongPtr(hwnd, GWLP_WNDPROC, (INT_PTR) winScrollPtr->oldProc);
if (winScrollPtr->winFlags & IN_MODAL_LOOP) {
((TkWindow *)scrollPtr->tkwin)->flags |= TK_DONT_DESTROY_WINDOW;
SetParent(hwnd, NULL);
@@ -360,8 +340,7 @@ TkpDestroyScrollbar(scrollPtr)
*
* UpdateScrollbarMetrics --
*
- * This function retrieves the current system metrics for a
- * scrollbar.
+ * This function retrieves the current system metrics for a scrollbar.
*
* Results:
* None.
@@ -373,23 +352,16 @@ TkpDestroyScrollbar(scrollPtr)
*/
void
-UpdateScrollbarMetrics()
+UpdateScrollbarMetrics(void)
{
- Tk_ConfigSpec *specPtr;
+ int arrowWidth = GetSystemMetrics(SM_CXVSCROLL);
hArrowWidth = GetSystemMetrics(SM_CXHSCROLL);
hThumb = GetSystemMetrics(SM_CXHTHUMB);
- vArrowWidth = GetSystemMetrics(SM_CXVSCROLL);
vArrowHeight = GetSystemMetrics(SM_CYVSCROLL);
vThumb = GetSystemMetrics(SM_CYVTHUMB);
- sprintf(defWidth, "%d", vArrowWidth);
- for (specPtr = tkpScrollbarConfigSpecs; specPtr->type != TK_CONFIG_END;
- specPtr++) {
- if (specPtr->offset == Tk_Offset(TkScrollbar, width)) {
- specPtr->defValue = defWidth;
- }
- }
+ sprintf(tkDefScrollbarWidth, "%d", arrowWidth);
}
/*
@@ -397,9 +369,9 @@ UpdateScrollbarMetrics()
*
* TkpComputeScrollbarGeometry --
*
- * After changes in a scrollbar's size or configuration, this
- * procedure recomputes various geometry information used in
- * displaying the scrollbar.
+ * After changes in a scrollbar's size or configuration, this procedure
+ * recomputes various geometry information used in displaying the
+ * scrollbar.
*
* Results:
* None.
@@ -411,15 +383,16 @@ UpdateScrollbarMetrics()
*/
void
-TkpComputeScrollbarGeometry(scrollPtr)
- register TkScrollbar *scrollPtr; /* Scrollbar whose geometry may
- * have changed. */
+TkpComputeScrollbarGeometry(
+ register TkScrollbar *scrollPtr)
+ /* Scrollbar whose geometry may have
+ * changed. */
{
int fieldLength, minThumbSize;
/*
- * Windows doesn't use focus rings on scrollbars, but we still
- * perform basic sanity checks to appease backwards compatibility.
+ * Windows doesn't use focus rings on scrollbars, but we still perform
+ * basic sanity checks to appease backwards compatibility.
*/
if (scrollPtr->highlightWidth < 0) {
@@ -445,9 +418,9 @@ TkpComputeScrollbarGeometry(scrollPtr)
* scrollPtr->lastFraction);
/*
- * Adjust the slider so that some piece of it is always
- * displayed in the scrollbar and so that it has at least
- * a minimal width (so it can be grabbed with the mouse).
+ * Adjust the slider so that some piece of it is always displayed in the
+ * scrollbar and so that it has at least a minimal width (so it can be
+ * grabbed with the mouse).
*/
if (scrollPtr->sliderFirst > fieldLength) {
@@ -467,10 +440,9 @@ TkpComputeScrollbarGeometry(scrollPtr)
scrollPtr->sliderLast += scrollPtr->arrowLength;
/*
- * Register the desired geometry for the window (leave enough space
- * for the two arrows plus a minimum-size slider, plus border around
- * the whole window, if any). Then arrange for the window to be
- * redisplayed.
+ * Register the desired geometry for the window (leave enough space for
+ * the two arrows plus a minimum-size slider, plus border around the whole
+ * window, if any). Then arrange for the window to be redisplayed.
*/
if (scrollPtr->vertical) {
@@ -488,8 +460,8 @@ TkpComputeScrollbarGeometry(scrollPtr)
*
* ScrollbarProc --
*
- * This function is call by Windows whenever an event occurs on
- * a scrollbar control created by Tk.
+ * This function is call by Windows whenever an event occurs on a
+ * scrollbar control created by Tk.
*
* Results:
* Standard Windows return value.
@@ -501,11 +473,11 @@ TkpComputeScrollbarGeometry(scrollPtr)
*/
static LRESULT CALLBACK
-ScrollbarProc(hwnd, message, wParam, lParam)
- HWND hwnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
+ScrollbarProc(
+ HWND hwnd,
+ UINT message,
+ WPARAM wParam,
+ LPARAM lParam)
{
LRESULT result;
POINT point;
@@ -513,90 +485,89 @@ ScrollbarProc(hwnd, message, wParam, lParam)
Tk_Window tkwin = Tk_HWNDToWindow(hwnd);
if (tkwin == NULL) {
- panic("ScrollbarProc called on an invalid HWND");
+ Tcl_Panic("ScrollbarProc called on an invalid HWND");
}
scrollPtr = (WinScrollbar *)((TkWindow*)tkwin)->instanceData;
switch(message) {
- case WM_HSCROLL:
- case WM_VSCROLL: {
- Tcl_Interp *interp;
- Tcl_DString cmdString;
- int command = LOWORD(wParam);
- int code;
-
- GetCursorPos(&point);
- Tk_TranslateWinEvent(NULL, WM_MOUSEMOVE, 0,
- MAKELPARAM(point.x, point.y), &result);
-
- if (command == SB_ENDSCROLL) {
- return 0;
- }
-
- /*
- * Bail out immediately if there isn't a command to invoke.
- */
-
- if (scrollPtr->info.commandSize == 0) {
- Tcl_ServiceAll();
- return 0;
- }
-
- Tcl_DStringInit(&cmdString);
- Tcl_DStringAppend(&cmdString, scrollPtr->info.command,
- scrollPtr->info.commandSize);
-
- if (command == SB_LINELEFT || command == SB_LINERIGHT) {
- Tcl_DStringAppendElement(&cmdString, "scroll");
- Tcl_DStringAppendElement(&cmdString,
- (command == SB_LINELEFT ) ? "-1" : "1");
- Tcl_DStringAppendElement(&cmdString, "units");
- } else if (command == SB_PAGELEFT || command == SB_PAGERIGHT) {
- Tcl_DStringAppendElement(&cmdString, "scroll");
- Tcl_DStringAppendElement(&cmdString,
- (command == SB_PAGELEFT ) ? "-1" : "1");
- Tcl_DStringAppendElement(&cmdString, "pages");
- } else {
- char valueString[TCL_DOUBLE_SPACE];
- double pos = 0.0;
- switch (command) {
- case SB_THUMBPOSITION:
- pos = ((double)HIWORD(wParam)) / MAX_SCROLL;
- break;
-
- case SB_THUMBTRACK:
- pos = ((double)HIWORD(wParam)) / MAX_SCROLL;
- break;
-
- case SB_TOP:
- pos = 0.0;
- break;
-
- case SB_BOTTOM:
- pos = 1.0;
- break;
- }
- sprintf(valueString, "%g", pos);
- Tcl_DStringAppendElement(&cmdString, "moveto");
- Tcl_DStringAppendElement(&cmdString, valueString);
- }
+ case WM_HSCROLL:
+ case WM_VSCROLL: {
+ Tcl_Interp *interp;
+ Tcl_DString cmdString;
+ int command = LOWORD(wParam);
+ int code;
+
+ GetCursorPos(&point);
+ Tk_TranslateWinEvent(NULL, WM_MOUSEMOVE, 0,
+ MAKELPARAM(point.x, point.y), &result);
+
+ if (command == SB_ENDSCROLL) {
+ return 0;
+ }
- interp = scrollPtr->info.interp;
- code = Tcl_EvalEx(interp, cmdString.string, -1, TCL_EVAL_GLOBAL);
- if (code != TCL_OK && code != TCL_CONTINUE && code != TCL_BREAK) {
- Tcl_AddErrorInfo(interp, "\n (scrollbar command)");
- Tcl_BackgroundError(interp);
- }
- Tcl_DStringFree(&cmdString);
+ /*
+ * Bail out immediately if there isn't a command to invoke.
+ */
+ if (scrollPtr->info.commandSize == 0) {
Tcl_ServiceAll();
return 0;
}
- default:
- if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
- return result;
+ Tcl_DStringInit(&cmdString);
+ Tcl_DStringAppend(&cmdString, scrollPtr->info.command,
+ scrollPtr->info.commandSize);
+
+ if (command == SB_LINELEFT || command == SB_LINERIGHT) {
+ Tcl_DStringAppendElement(&cmdString, "scroll");
+ Tcl_DStringAppendElement(&cmdString,
+ (command == SB_LINELEFT ) ? "-1" : "1");
+ Tcl_DStringAppendElement(&cmdString, "units");
+ } else if (command == SB_PAGELEFT || command == SB_PAGERIGHT) {
+ Tcl_DStringAppendElement(&cmdString, "scroll");
+ Tcl_DStringAppendElement(&cmdString,
+ (command == SB_PAGELEFT ) ? "-1" : "1");
+ Tcl_DStringAppendElement(&cmdString, "pages");
+ } else {
+ char valueString[TCL_DOUBLE_SPACE];
+ double pos = 0.0;
+
+ switch (command) {
+ case SB_THUMBPOSITION:
+ pos = ((double)HIWORD(wParam)) / MAX_SCROLL;
+ break;
+ case SB_THUMBTRACK:
+ pos = ((double)HIWORD(wParam)) / MAX_SCROLL;
+ break;
+ case SB_TOP:
+ pos = 0.0;
+ break;
+ case SB_BOTTOM:
+ pos = 1.0;
+ break;
}
+
+ Tcl_PrintDouble(NULL, pos, valueString);
+ Tcl_DStringAppendElement(&cmdString, "moveto");
+ Tcl_DStringAppendElement(&cmdString, valueString);
+ }
+
+ interp = scrollPtr->info.interp;
+ code = Tcl_EvalEx(interp, cmdString.string, -1, TCL_EVAL_GLOBAL);
+ if (code != TCL_OK && code != TCL_CONTINUE && code != TCL_BREAK) {
+ Tcl_AddErrorInfo(interp, "\n (scrollbar command)");
+ Tcl_BackgroundError(interp);
+ }
+ Tcl_DStringFree(&cmdString);
+
+ Tcl_ServiceAll();
+ return 0;
+ }
+
+ default:
+ if (Tk_TranslateWinEvent(hwnd, message, wParam, lParam, &result)) {
+ return result;
+ }
}
return CallWindowProc(scrollPtr->oldProc, hwnd, message, wParam, lParam);
}
@@ -607,8 +578,8 @@ ScrollbarProc(hwnd, message, wParam, lParam)
* TkpConfigureScrollbar --
*
* This procedure is called after the generic code has finished
- * processing configuration options, in order to configure
- * platform specific options.
+ * processing configuration options, in order to configure platform
+ * specific options.
*
* Results:
* None.
@@ -620,10 +591,10 @@ ScrollbarProc(hwnd, message, wParam, lParam)
*/
void
-TkpConfigureScrollbar(scrollPtr)
- register TkScrollbar *scrollPtr; /* Information about widget; may or
- * may not already have values for
- * some fields. */
+TkpConfigureScrollbar(
+ register TkScrollbar *scrollPtr)
+ /* Information about widget; may or may not
+ * already have values for some fields. */
{
}
@@ -632,8 +603,8 @@ TkpConfigureScrollbar(scrollPtr)
*
* ScrollbarBindProc --
*
- * This procedure is invoked when the default <ButtonPress>
- * binding on the Scrollbar bind tag fires.
+ * This procedure is invoked when the default <ButtonPress> binding on
+ * the Scrollbar bind tag fires.
*
* Results:
* None.
@@ -645,14 +616,15 @@ TkpConfigureScrollbar(scrollPtr)
*/
static int
-ScrollbarBindProc(clientData, interp, eventPtr, tkwin, keySym)
- ClientData clientData;
- Tcl_Interp *interp;
- XEvent *eventPtr;
- Tk_Window tkwin;
- KeySym keySym;
+ScrollbarBindProc(
+ ClientData clientData,
+ Tcl_Interp *interp,
+ XEvent *eventPtr,
+ Tk_Window tkwin,
+ KeySym keySym)
{
- TkWindow *winPtr = (TkWindow*)tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
+
if (eventPtr->type == ButtonPress) {
winPtr->flags |= TK_DEFER_MODAL;
}
@@ -664,9 +636,8 @@ ScrollbarBindProc(clientData, interp, eventPtr, tkwin, keySym)
*
* ModalLoopProc --
*
- * This function is invoked at the end of the event processing
- * whenever the ScrollbarBindProc has been invoked for a ButtonPress
- * event.
+ * This function is invoked at the end of the event processing whenever
+ * the ScrollbarBindProc has been invoked for a ButtonPress event.
*
* Results:
* None.
@@ -678,16 +649,16 @@ ScrollbarBindProc(clientData, interp, eventPtr, tkwin, keySym)
*/
static void
-ModalLoopProc(tkwin, eventPtr)
- Tk_Window tkwin;
- XEvent *eventPtr;
+ModalLoopProc(
+ Tk_Window tkwin,
+ XEvent *eventPtr)
{
- TkWindow *winPtr = (TkWindow*)tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
WinScrollbar *scrollPtr = (WinScrollbar *) winPtr->instanceData;
int oldMode;
if (scrollPtr->hwnd) {
- Tcl_Preserve((ClientData)scrollPtr);
+ Tcl_Preserve(scrollPtr);
scrollPtr->winFlags |= IN_MODAL_LOOP;
oldMode = Tcl_SetServiceMode(TCL_SERVICE_ALL);
TkWinResendEvent(scrollPtr->oldProc, scrollPtr->hwnd, eventPtr);
@@ -696,7 +667,7 @@ ModalLoopProc(tkwin, eventPtr)
if (scrollPtr->hwnd && scrollPtr->winFlags & ALREADY_DEAD) {
DestroyWindow(scrollPtr->hwnd);
}
- Tcl_Release((ClientData)scrollPtr);
+ Tcl_Release(scrollPtr);
}
}
@@ -705,14 +676,12 @@ ModalLoopProc(tkwin, eventPtr)
*
* TkpScrollbarPosition --
*
- * Determine the scrollbar element corresponding to a
- * given position.
+ * Determine the scrollbar element corresponding to a given position.
*
* Results:
- * One of TOP_ARROW, TOP_GAP, etc., indicating which element
- * of the scrollbar covers the position given by (x, y). If
- * (x,y) is outside the scrollbar entirely, then OUTSIDE is
- * returned.
+ * One of TOP_ARROW, TOP_GAP, etc., indicating which element of the
+ * scrollbar covers the position given by (x, y). If (x,y) is outside the
+ * scrollbar entirely, then OUTSIDE is returned.
*
* Side effects:
* None.
@@ -721,10 +690,10 @@ ModalLoopProc(tkwin, eventPtr)
*/
int
-TkpScrollbarPosition(scrollPtr, x, y)
- register TkScrollbar *scrollPtr; /* Scrollbar widget record. */
- int x, y; /* Coordinates within scrollPtr's
- * window. */
+TkpScrollbarPosition(
+ register TkScrollbar *scrollPtr,
+ /* Scrollbar widget record. */
+ int x, int y) /* Coordinates within scrollPtr's window. */
{
int length, width, tmp;
@@ -746,7 +715,7 @@ TkpScrollbarPosition(scrollPtr, x, y)
/*
* All of the calculations in this procedure mirror those in
- * TkpDisplayScrollbar. Be sure to keep the two consistent.
+ * TkpDisplayScrollbar. Be sure to keep the two consistent.
*/
if (y < (scrollPtr->inset + scrollPtr->arrowLength)) {
@@ -763,3 +732,11 @@ TkpScrollbarPosition(scrollPtr, x, y)
}
return BOTTOM_GAP;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */