Couple mouse wheel to v-scrolls in file browser
[xboard.git] / filebrowser / draw.c
index 47efa17..abab957 100644 (file)
 #endif
 #define ABS(x) (((x) < 0) ? (-(x)) : (x))
 
+/* added missing prototypes */
+extern char SFstatChar(struct stat*);
+extern int SFchdir(char *);
+void SFvSliderMovedCallback(Widget, int, int);
+
 typedef struct {
        char *fontname;
 } TextData, *textPtr;
@@ -59,6 +64,7 @@ static int SFcurrentListY;
 
 static XtIntervalId SFscrollTimerId;
 
+void
 SFinitFont()
 {
        TextData        *data;
@@ -84,8 +90,10 @@ SFinitFont()
        SFcharWidth = (SFfont->max_bounds.width + SFfont->min_bounds.width) / 2;
        SFcharAscent = SFfont->max_bounds.ascent;
        SFcharHeight = SFcharAscent + SFfont->max_bounds.descent;
+       return;
 }
 
+void
 SFcreateGC()
 {
        XGCValues       gcValues;
@@ -149,8 +157,10 @@ SFcreateGC()
                1,
                Unsorted
        );
+       return;
 }
 
+void
 SFclearList(n, doScroll)
        int     n;
        int     doScroll;
@@ -191,9 +201,10 @@ SFclearList(n, doScroll)
                                (float) 1.0);
                }
        }
+       return;
 }
 
-static
+static void
 SFdeleteEntry(dir, entry)
        SFDir   *dir;
        SFEntry *entry;
@@ -242,15 +253,17 @@ SFdeleteEntry(dir, entry)
                (float) (((double) ((dir->nEntries < SFlistSize) ?
                        dir->nEntries : SFlistSize)) / dir->nEntries)
        );
+       return;
 }
 
-static
+static void
 SFwriteStatChar(name, last, statBuf)
        char            *name;
        int             last;
        struct stat     *statBuf;
 {
        name[last] = SFstatChar(statBuf);
+       return;
 }
 
 static int
@@ -320,7 +333,7 @@ SFstatAndCheck(dir, entry)
        return 0;
 }
 
-static
+static void
 SFdrawStrings(w, dir, from, to)
        register Window w;
        register SFDir  *dir;
@@ -395,8 +408,10 @@ SFdrawStrings(w, dir, from, to)
                        );
                }
        }
+       return;
 }
 
+void
 SFdrawList(n, doScroll)
        int     n;
        int     doScroll;
@@ -420,8 +435,10 @@ SFdrawList(n, doScroll)
                );
                SFdrawStrings(w, dir, 0, SFlistSize - 1);
        }
+       return;
 }
 
+void
 SFdrawLists(doScroll)
        int     doScroll;
 {
@@ -430,9 +447,10 @@ SFdrawLists(doScroll)
        for (i = 0; i < NR; i++) {
                SFdrawList(i, doScroll);
        }
+       return;
 }
 
-static
+static void
 SFinvertEntry(n)
        register int    n;
 {
@@ -445,6 +463,7 @@ SFinvertEntry(n)
                SFentryWidth,
                SFentryHeight
        );
+       return;
 }
 
 static unsigned long
@@ -486,7 +505,7 @@ SFscrollTimer(p, id)
        int     save;
        int     n;
 
-        n = (int) p;
+        n = (int)(intptr_t) p;
 
        dir = &(SFdirs[SFdirPtr + n]);
        save = dir->vOrigin;
@@ -516,7 +535,7 @@ SFscrollTimer(p, id)
 
        if (SFbuttonPressed) {
                SFscrollTimerId = XtAppAddTimeOut(SFapp,
-                       SFscrollTimerInterval(), SFscrollTimer, (XtPointer) n);
+                       SFscrollTimerInterval(), SFscrollTimer, (XtPointer)(intptr_t) n);
        }
 }
 
@@ -557,7 +576,7 @@ SFnewInvertEntry(n, event)
                                SFscrollTimerAdded = 1;
                                SFscrollTimerId = XtAppAddTimeOut(SFapp,
                                        SFscrollTimerInterval(), SFscrollTimer,
-                                       (XtPointer) n);
+                                       (XtPointer)(intptr_t) n);
                        }
                }
 
@@ -620,20 +639,7 @@ SFmotionList(w, n, event)
                        SFinvertEntry(n);
                }
        }
-}
-
-/* ARGSUSED */
-void
-SFvFloatSliderMovedCallback(w, n, fnew)
-       Widget  w;
-       int     n;
-       float   *fnew;
-{
-       int     new;
-
-       new = (*fnew) * SFdirs[SFdirPtr + n].nEntries;
-
-       SFvSliderMovedCallback(w, n, new);
+       return;
 }
 
 /* ARGSUSED */
@@ -649,7 +655,10 @@ SFvSliderMovedCallback(w, n, new)
 
        dir = &(SFdirs[SFdirPtr + n]);
 
+
        old = dir->vOrigin;
+       if(new == -1) new = old + 1; else if(new == -2) new = old - 1; // [HGM] indicates scroll direction on mousewheel event
+       if(new < 0 || new > dir->nEntries - SFlistSize) return;
        dir->vOrigin = new;
 
        if (old == new) {
@@ -724,6 +733,21 @@ SFvSliderMovedCallback(w, n, new)
 
 /* ARGSUSED */
 void
+SFvFloatSliderMovedCallback(w, n, fnew)
+       Widget  w;
+       int     n;
+       float   *fnew;
+{
+       int     new;
+
+       new = (*fnew) * SFdirs[SFdirPtr + n].nEntries;
+
+       SFvSliderMovedCallback(w, n, new);
+}
+
+
+/* ARGSUSED */
+void
 SFvAreaSelectedCallback(w, n, pnew)
        Widget  w;
        int     n;