diff -rcN --exclude=Makefile --exclude=X11 ../XARClock/ARClock.c ./ARClock.c *** ../XARClock/ARClock.c Sun Jul 30 04:56:52 1995 --- ./ARClock.c Fri Jan 29 19:06:32 1999 *************** *** 82,87 **** --- 82,91 ---- offset(analog), XtRImmediate, (caddr_t) TRUE}, {XtNroman, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(roman), XtRImmediate, (caddr_t) TRUE}, + #ifdef I18N + {XtNkanji, XtCBoolean, XtRBoolean, sizeof(Boolean), + offset(kanji), XtRImmediate, (caddr_t) False}, + #endif {XtNnorth, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(north), XtRImmediate, (caddr_t) FALSE}, {XtNchime, XtCBoolean, XtRBoolean, sizeof(Boolean), *************** *** 90,97 **** --- 94,112 ---- offset(padding), XtRImmediate, (caddr_t) 8}, {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), offset(font), XtRString, "fixed"}, + #ifdef I18N + {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet), + offset(fs), XtRString, XtDefaultFontSet}, + {XtNfontList, XtCString, XtRString, sizeof(String), + offset(font_list), XtRImmediate, (XtPointer) NULL}, + #endif {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int), offset (backing_store), XtRString, "default"}, + #ifdef NO_STRFTIME + #else + {XtNformat, XtCString, XtRString, sizeof(String), + offset(format), XtRImmediate, (XtPointer) NULL}, + #endif }; #undef offset *************** *** 175,190 **** --- 190,265 ---- long time_value; (void) time(&time_value); tm = *localtime(&time_value); + #ifdef NO_STRFTIME str = asctime(&tm); + #else + { + #define format (w->clock.format?w->clock.format:"%c") + static int size = 8; + str = (char*)malloc(sizeof(char)*size); + while (strftime(str, size, format, &tm) == 0 + && strlen(format) != 0) { + size += 8; + str = (char*)realloc(str, sizeof(char)*size); + } + size = strlen(str) + 1; + } + #endif + w->clock.prev_time_string = (char*)malloc(sizeof(char)*(strlen(str)+10)); + #ifdef I18N + { + #include + XFontSet fs; + char **miss, *def; + int n_miss; + + if (w->clock.font_list) { + fs = XCreateFontSet(XtDisplay(w), w->clock.font_list, + &miss, &n_miss, &def); + if (fs) + w->clock.fs = fs; + } + } + #else if (w->clock.font == NULL) w->clock.font = XQueryFont( XtDisplay(w), XGContextFromGC( DefaultGCOfScreen(XtScreen(w))) ); + #endif + #ifdef I18N + { + XRectangle ink, log; + + XmbTextExtents(w->clock.fs, str, strlen(str), &ink, &log); + min_width = log.width + 2 * w->clock.padding; + min_height = log.height + 2 * w->clock.padding; + } + #else min_width = XTextWidth(w->clock.font, str, strlen(str)) + 2 * w->clock.padding; min_height = w->clock.font->ascent + w->clock.font->descent + 2 * w->clock.padding; + #endif + #ifdef NO_STRFTIME + #else + free(str); + #endif + } else { + #ifdef I18N + { + XFontSet fs; + char **miss, *def; + int n_miss; + + if (w->clock.font_list) { + fs = XCreateFontSet(XtDisplay(w), w->clock.font_list, + &miss, &n_miss, &def); + if (fs) + w->clock.fs = fs; + } + } + #endif } if (w->core.width == 0) w->core.width = min_width; *************** *** 308,320 **** double cos(); double sin(); ! static String arabic_roman_numbers[]= { "9", "10", "11", "12", "1", "2", "3", "4", "5", "6", "7", "8", "3", "2", "1", "12", "11", "10", "9", "8", "7", "6", "5", "4", "IX", "X", "XI", "XII", "I", "II", "III", "IIII", "V", "VI","VII", "VIII", "III", "II", "I", "XII", "XI", "X", "IX", "VIII", "VII", "VI","V", "IIII", }; if (id || !w->clock.interval_id) --- 383,399 ---- double cos(); double sin(); ! static String arabic_roman_kanji_numbers[]= { "9", "10", "11", "12", "1", "2", "3", "4", "5", "6", "7", "8", "3", "2", "1", "12", "11", "10", "9", "8", "7", "6", "5", "4", "IX", "X", "XI", "XII", "I", "II", "III", "IIII", "V", "VI","VII", "VIII", "III", "II", "I", "XII", "XI", "X", "IX", "VIII", "VII", "VI","V", "IIII", + "¶å", "½¦", "½¦°í", "½¦Æõ", "°í", "Æõ", "»²", "»Í", "¸à", + "Ï»", "¼·", "Ȭ", + "»²", "Æõ", "°í", "½¦Æõ", "½¦°í", "½¦", "¶å", "Ȭ", "¼·", + "Ï»", "¸à", "»Í", }; if (id || !w->clock.interval_id) *************** *** 342,348 **** --- 421,440 ---- int clear_from; int i, len, prev_len; + #ifdef NO_STRFTIME time_ptr = asctime(&tm); + #else + { + static int size = 8; + time_ptr = (char*)malloc(sizeof(char)*size); + while (strftime(time_ptr, size, format, &tm) == 0 + && strlen(format) != 0) { + size += 8; + time_ptr = (char*)realloc(time_ptr, sizeof(char)*size); + } + size = strlen(time_ptr) + 1; + } + #endif len = strlen (time_ptr); if (time_ptr[len - 1] == '\n') time_ptr[--len] = '\0'; prev_len = strlen (w->clock.prev_time_string); *************** *** 350,370 **** --- 442,487 ---- (w->clock.prev_time_string[i] == time_ptr[i])); i++); strcpy (w->clock.prev_time_string+i, time_ptr+i); + #ifdef I18N + { + XRectangle ink, log; + + XmbTextExtents(w->clock.fs, time_ptr, i, &ink, &log); + XmbDrawImageString(dpy, win, w->clock.fs, w->clock.myGC, + w->clock.padding + log.width, + w->core.height - w->clock.padding - 2, + time_ptr + i, len - i); + } + #else XDrawImageString (dpy, win, w->clock.myGC, (2+w->clock.padding + XTextWidth (w->clock.font, time_ptr, i)), 2+w->clock.font->ascent+w->clock.padding, time_ptr + i, len - i); + #endif /* * Clear any left over bits */ + #ifdef I18N + { + XRectangle ink, log; + + XmbTextExtents(w->clock.fs, time_ptr, len, &ink, &log); + clear_from = log.width + 2 + w->clock.padding; + } + #else clear_from = XTextWidth (w->clock.font, time_ptr, len) + 2 + w->clock.padding; + #endif if (clear_from < w->core.width) XFillRectangle (dpy, win, w->clock.EraseGC, clear_from, 0, w->core.width - clear_from, w->core.height); + #ifdef NO_STRFTIME + #else + free(time_ptr); + #endif } else { /* * The second (or minute) hand is sec (or min) *************** *** 403,414 **** x = (int) w->clock.centerX + x; y = (int) w->clock.centerY - y; ! if (w->clock.roman == FALSE) j = j; else j = j + 24; /* Center string */ x = x - XTextWidth(w->clock.font, ! arabic_roman_numbers[j], ! strlen(arabic_roman_numbers[j]))/2; y = y + (w->clock.font->ascent + w->clock.font->descent)/2; --- 520,553 ---- x = (int) w->clock.centerX + x; y = (int) w->clock.centerY - y; ! if (w->clock.kanji == TRUE) j = j + 48; ! else if (w->clock.roman == FALSE) j = j; else j = j + 24; /* Center string */ + #ifdef I18N + { + XRectangle ink, log; + + XmbTextExtents(w->clock.fs, arabic_roman_kanji_numbers[j], + strlen(arabic_roman_kanji_numbers[j]), &ink, &log); + + x = x - log.width/2; + + y = y + log.height/2; + + XmbDrawString(XtDisplay(w), + XtWindow(w), + w->clock.fs, + w->clock.myGC, + x, + y, + arabic_roman_kanji_numbers[j], + strlen(arabic_roman_kanji_numbers[j])); + } + #else x = x - XTextWidth(w->clock.font, ! arabic_roman_kanji_numbers[j], ! strlen(arabic_roman_kanji_numbers[j]))/2; y = y + (w->clock.font->ascent + w->clock.font->descent)/2; *************** *** 417,424 **** w->clock.myGC, x, y, ! arabic_roman_numbers[j], ! strlen(arabic_roman_numbers[j])); } /* --- 556,564 ---- w->clock.myGC, x, y, ! arabic_roman_kanji_numbers[j], ! strlen(arabic_roman_kanji_numbers[j])); ! #endif } /* *************** *** 822,827 **** --- 962,971 ---- if (new->clock.font != current->clock.font) redisplay = TRUE; + #ifdef I18N + if (new->clock.fs != current->clock.fs) + redisplay = TRUE; + #endif if ((new->clock.fgpixel != current->clock.fgpixel) || (new->core.background_pixel != current->core.background_pixel)) { diff -rcN --exclude=Makefile --exclude=X11 ../XARClock/Clock.h ./Clock.h *** ../XARClock/Clock.h Mon Jul 10 14:07:11 1995 --- ./Clock.h Mon Apr 20 21:14:01 1998 *************** *** 101,106 **** --- 101,111 ---- /* Boolean: arabic if FALSE */ #define XtNroman "roman" + #ifdef I18N + /* Boolean: kanji if FALSE */ + #define XtNkanji "kanji" + #endif + /* Boolean: clockwise if FALSE */ #define XtNnorth "north" *************** *** 109,114 **** --- 114,130 ---- /* Int: amount of space around outside of clock */ #define XtNpadding "padding" + + #ifdef I18N + /* String: font list for font set ifdef I18N */ + #define XtNfontList "fontList" + #endif + + #ifdef NO_STRFTIME + #else + /* String: strftime format if digital */ + #define XtNformat "format" + #endif typedef struct _ClockRec *ClockWidget; /* completely defined in ClockPrivate.h */ typedef struct _ClockClassRec *ClockWidgetClass; /* completely defined in ClockPrivate.h */ diff -rcN --exclude=Makefile --exclude=X11 ../XARClock/ClockP.h ./ClockP.h *** ../XARClock/ClockP.h Sun Jul 30 04:10:23 1995 --- ./ClockP.h Fri Jan 29 19:01:07 1999 *************** *** 60,66 **** #include #define SEG_BUFF_SIZE 128 - #define ASCII_TIME_BUFLEN 32 /* big enough for 26 plus slop */ /* New fields for the clock widget instance record */ typedef struct { --- 60,65 ---- *************** *** 68,73 **** --- 67,76 ---- Pixel Hipixel; /* color index for Highlighting */ Pixel Hdpixel; /* color index for hands */ XFontStruct *font; /* font for text */ + #ifdef I18N + XFontSet fs; /* font set for text */ + String font_list; /* font list for font set */ + #endif GC myGC; /* pointer to GraphicsContext */ GC EraseGC; /* eraser GC */ GC HandGC; /* Hand GC */ *************** *** 80,85 **** --- 83,91 ---- Boolean beeped; Boolean analog; Boolean roman; + #ifdef I18N + Boolean kanji; + #endif Boolean north; Boolean show_second_hand; Dimension second_hand_length; *************** *** 97,103 **** XPoint *hour, *sec; struct tm otm ; XtIntervalId interval_id; ! char prev_time_string[ASCII_TIME_BUFLEN]; } ClockPart; /* Full instance record declaration */ --- 103,113 ---- XPoint *hour, *sec; struct tm otm ; XtIntervalId interval_id; ! char *prev_time_string; ! #ifdef NO_STRFTIME ! #else ! String format; ! #endif } ClockPart; /* Full instance record declaration */ diff -rcN --exclude=Makefile --exclude=X11 ../XARClock/Imakefile ./Imakefile *** ../XARClock/Imakefile Mon Jul 10 14:07:11 1995 --- ./Imakefile Mon Apr 20 20:40:01 1998 *************** *** 1,4 **** ! DEFINES = -I. -I/usr/include CCOPTIONS = SYS_LIBRARIES = -lXmu -lXt -lm -lXaw LOCAL_LIBRARIES = $(XLIB) --- 1,5 ---- ! #DEFINES = -I. -I/usr/include -DNO_STRFTIME ! DEFINES = -I. -I/usr/include -DI18N CCOPTIONS = SYS_LIBRARIES = -lXmu -lXt -lm -lXaw LOCAL_LIBRARIES = $(XLIB) diff -rcN --exclude=Makefile --exclude=X11 ../XARClock/xarclock.c ./xarclock.c *** ../XARClock/xarclock.c Sun Jul 30 04:05:53 1995 --- ./xarclock.c Thu Oct 15 17:06:36 1998 *************** *** 49,54 **** --- 49,57 ---- pass over the remaining options after XtParseCommand is let loose. */ static XrmOptionDescRec options[] = { + #ifdef I18N + {"-fn", "*clock.fontList", XrmoptionSepArg, NULL}, + #endif {"-chime", "*clock.chime", XrmoptionNoArg, "TRUE"}, {"-hd", "*clock.hands", XrmoptionSepArg, NULL}, {"-hands", "*clock.hands", XrmoptionSepArg, NULL}, *************** *** 61,68 **** --- 64,78 ---- {"-analog", "*clock.analog", XrmoptionNoArg, "TRUE"}, {"-arabic", "*clock.roman", XrmoptionNoArg, "FALSE"}, {"-roman", "*clock.roman", XrmoptionNoArg, "TRUE"}, + #ifdef I18N + {"-kanji", "*clock.kanji", XrmoptionNoArg, "TRUE"}, + #endif {"-south", "*clock.north", XrmoptionNoArg, "FALSE"}, {"-north", "*clock.north", XrmoptionNoArg, "TRUE"}, + #ifdef NO_STRFTIME + #else + {"-format", "*clock.format", XrmoptionSepArg, NULL}, + #endif }; *************** *** 79,90 **** --- 89,112 ---- char *call; { (void) printf ("Usage: %s \n", call); + #ifdef I18N + (void) printf ("[-roman] [-arabic] [-kanji] [-south] [-north] \n"); + #else (void) printf ("[-roman] [-arabic] [-south] [-north] \n"); + #endif (void) printf ("[-analog] [-digital] [-bw ] \n"); (void) printf ("[-fg ] [-bg ] [-hd ] \n"); (void) printf ("[-hl ] [-bd ] \n"); + #ifdef I18N + (void) printf ("[-fn ] [-help] [-padding ] \n"); + #else (void) printf ("[-fn ] [-help] [-padding ] \n"); + #endif (void) printf ("[-rv] [-update ] [-display displayname] \n"); + #ifdef NO_STRFTIME + #else + (void) printf ("[-format ] \n"); + #endif (void) printf ("[-geometry geom] \n\n"); exit(1); } *************** *** 98,103 **** --- 120,128 ---- Pixmap icon_pixmap = None; XtAppContext app_con; + #ifdef I18N + XtSetLanguageProc(NULL, NULL, NULL); + #endif toplevel = XtAppInitialize (&app_con, "XClock", options, XtNumber(options), &argc, argv, NULL, NULL, ZERO); if (argc != 1) Syntax(argv[0]);