Use ListBox in stead of ComboBox in Match-Options dialog
[xboard.git] / filebrowser / draw.c
index 46ed663..4f8abaa 100644 (file)
@@ -25,8 +25,9 @@
  */
 
 #include <stdio.h>
-#include "selfile.h"
 #include "xstat.h"
+#include "selfile.h"
+#include "config.h"
 #include <X11/StringDefs.h>
 #include <X11/Xaw/Scrollbar.h>
 #include <X11/Xaw/Cardinals.h>
 #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;
@@ -58,7 +54,11 @@ static XtResource textResources[] = {
                XtOffset(textPtr, fontname), XtRString, SF_DEFAULT_FONT},
 };
 
+#if ENABLE_NLS
+extern XFontSet fontSet; //XXX should really be in a .h file
+#else
 static XFontStruct *SFfont;
+#endif
 
 static int SFcurrentListY;
 
@@ -67,6 +67,12 @@ static XtIntervalId SFscrollTimerId;
 void
 SFinitFont()
 {
+#if ENABLE_NLS
+       XFontSetExtents *fse = XExtentsOfFontSet(fontSet);
+       SFcharWidth = fse->max_logical_extent.width;
+       SFcharAscent = -fse->max_logical_extent.y;
+       SFcharHeight = fse->max_logical_extent.height;
+#else
        TextData        *data;
 
        data = XtNew(TextData);
@@ -90,6 +96,7 @@ SFinitFont()
        SFcharWidth = (SFfont->max_bounds.width + SFfont->min_bounds.width) / 2;
        SFcharAscent = SFfont->max_bounds.ascent;
        SFcharHeight = SFcharAscent + SFfont->max_bounds.descent;
+#endif
        return;
 }
 
@@ -130,7 +137,9 @@ SFcreateGC()
 
        gcValues.foreground = SFfore;
        gcValues.background = SFback;
+#if !ENABLE_NLS
        gcValues.font = SFfont->fid;
+#endif
 
        SFtextGC = XCreateGC(
                SFdisplay,
@@ -138,7 +147,9 @@ SFcreateGC()
                (unsigned long)
                        GCForeground            |
                        GCBackground            |
+#if !ENABLE_NLS
                        GCFont                  |
+#endif
                        0,
                &gcValues
        );
@@ -360,6 +371,18 @@ SFdrawStrings(w, dir, from, to)
                                continue;
                        }
                }
+#if ENABLE_NLS
+               XmbDrawImageString(
+                       SFdisplay,
+                       w,
+                       fontSet,
+                       SFtextGC,
+                       x,
+                       SFtextYoffset + i * SFentryHeight,
+                       entry->shown,
+                       strlen(entry->shown)
+               );
+#else
                XDrawImageString(
                        SFdisplay,
                        w,
@@ -369,6 +392,7 @@ SFdrawStrings(w, dir, from, to)
                        entry->shown,
                        strlen(entry->shown)
                );
+#endif
                if (dir->vOrigin + i == dir->beginSelection) {
                        XDrawLine(
                                SFdisplay,
@@ -424,6 +448,18 @@ SFdrawList(n, doScroll)
        if (SFdirPtr + (3-NR) + n < SFdirEnd) {
                dir = &(SFdirs[SFdirPtr + n + (3-NR)]);
                w = XtWindow(selFileLists[n]);
+#if ENABLE_NLS
+               XmbDrawImageString(
+                       SFdisplay,
+                       w,
+                       fontSet,
+                       SFtextGC,
+                       SFtextX - dir->hOrigin * SFcharWidth,
+                       SFlineToTextV + SFaboveAndBelowText + SFcharAscent,
+                       dir->dir,
+                       strlen(dir->dir)
+               );
+#else
                XDrawImageString(
                        SFdisplay,
                        w,
@@ -433,6 +469,7 @@ SFdrawList(n, doScroll)
                        dir->dir,
                        strlen(dir->dir)
                );
+#endif
                SFdrawStrings(w, dir, 0, SFlistSize - 1);
        }
        return;
@@ -655,7 +692,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) {