X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=filebrowser%2Fdraw.c;h=4f8abaae17eeb5dd51afedbd474c1d281cea9d48;hb=434e83abf93ec88caffddb95ad15d03df27b984b;hp=46ed663118336f907a69e1d03c8ad6b01c4c11fd;hpb=5dca19a2828b0e6e0594b734792533e0c4f76146;p=xboard.git diff --git a/filebrowser/draw.c b/filebrowser/draw.c index 46ed663..4f8abaa 100644 --- a/filebrowser/draw.c +++ b/filebrowser/draw.c @@ -25,8 +25,9 @@ */ #include -#include "selfile.h" #include "xstat.h" +#include "selfile.h" +#include "config.h" #include #include #include @@ -38,11 +39,6 @@ #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) {