updated german translation
[wmaker-crm.git] / WPrefs.app / Font.c
blob41a0f6770fce6b7fc3330913ebeeb7e3dacf80da
1 /* Font.c- text/font settings
2 *
3 * WPrefs - Window Maker Preferences Program
4 *
5 * Copyright (c) 1999-2003 Alfredo K. Kojima
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
24 #include "WPrefs.h"
25 #include <X11/Xlocale.h>
28 typedef struct _Panel {
29 WMBox *box;
30 char *sectionName;
32 char *description;
34 CallbackRec callbacks;
36 WMWidget *parent;
39 WMLabel *prevL;
41 WMFontPanel *fontPanel;
43 WMPopUpButton *fontSel;
44 WMFrame *multiF;
45 WMButton *togMulti;
46 WMFrame *langF;
47 WMPopUpButton *langP;
48 WMFrame *aaF;
49 WMButton *togAA;
51 /* single byte */
52 WMTextField *fontT;
53 WMButton *changeB;
55 /* multibyte */
56 WMLabel *fsetL;
57 WMList *fsetLs;
59 WMButton *addB;
60 WMButton *editB;
61 WMButton *remB;
63 WMButton *upB;
64 WMButton *downB;
66 WMColor *white;
67 WMColor *black;
68 WMColor *light;
69 WMColor *dark;
71 WMColor *back;
72 WMColor *colors[9];
74 Pixmap preview;
75 WMPixmap *previewPix;
76 WMPixmap *hand;
77 WMPixmap *up_arrow;
78 WMPixmap *down_arrow;
79 WMPixmap *alt_up_arrow;
80 WMPixmap *alt_down_arrow;
82 int oldsection;
83 char menuStyle;
84 char titleAlignment;
85 Bool MultiByteText;
87 Bool AntialiasedText;
88 } _Panel;
92 #define ICON_FILE "fonts"
94 static WMRect previewPositions[] = {
95 #define WINTITLE 0
96 {{30, 10},{190, 20}},
97 #define DISTITLE 1
98 {{30, 35},{90, 64}},
99 #define PMTITLE 2
100 {{30, 105},{90, 20}},
101 #define PMITEM 3
102 {{30, 125},{90, 20*4}},
103 #define PCLIP 4
104 {{156, 35},{64, 64}},
105 #define PICON 5
106 {{156, 105},{64, 64}}
108 #define EVERYTHING 0xff
110 static char *colorOptions[] = {
111 #define FTITLE (1<<0)
112 "FTitleColor", "white",
113 #define DISCOL (1<<1) /* Display uses white always */
114 #define MTITLE (1<<2)
115 "MenuTitleColor", "white",
116 #define MITEM (1<<3)
117 "MenuTextColor", "black",
118 #define CLIP (1<<4)
119 "ClipTitleColor", "black",
120 #define CCLIP (1<<4)
121 "ClipTitleColor", "#454045",
122 #define ICONT (1<<5)
123 "IconTitleColor", "white",
124 #define ICONB (1<<5)
125 "IconTitleBack", "black"
128 #define MSTYLE_NORMAL 0
129 #define MSTYLE_SINGLE 1
130 #define MSTYLE_FLAT 2
133 #define RESIZEBAR_BEVEL -1
134 #define MENU_BEVEL -2
135 #define CLIP_BUTTON_SIZE 23
136 #define ICON_SIZE 64
139 static char *textureOptions[] = {
140 "FTitleBack",
141 NULL,
142 "MenuTitleBack",
143 "MenuTextBack",
144 "IconBack",
145 "IconBack"
148 /* XPM */
149 static char * hand_xpm[] = {
150 "22 21 19 1",
151 " c None",
152 ". c #030305",
153 "+ c #7F7F7E",
154 "@ c #B5B5B6",
155 "# c #C5C5C6",
156 "$ c #969697",
157 "% c #FDFDFB",
158 "& c #F2F2F4",
159 "* c #E5E5E4",
160 "= c #ECECEC",
161 "- c #DCDCDC",
162 "; c #D2D2D0",
163 "> c #101010",
164 ", c #767674",
165 "' c #676767",
166 ") c #535355",
167 "! c #323234",
168 "~ c #3E3C56",
169 "{ c #333147",
170 " ",
171 " ..... ",
172 " ..+@##$. ",
173 " .%%%&@.......... ",
174 " .%*%%&#%%%%%%%%%$. ",
175 " .*#%%%%%%%%%&&&&==. ",
176 " .-%%%%%%%%%=*-;;;#$. ",
177 " .-%%%%%%%%&..>..... ",
178 " >-%%%%%%%%%*#+. ",
179 " >-%%%%%%%%%*@,. ",
180 " >#%%%%%%%%%*@'. ",
181 " >$&&%%%%%%=... ",
182 " .+@@;=&%%&;$,> ",
183 " .',$@####$+). ",
184 " .!',+$++,'. ",
185 " ..>>>>>. ",
186 " ",
187 " ~~{{{~~ ",
188 " {{{{{{{{{{{ ",
189 " ~~{{{~~ ",
190 " "};
192 static char *up_arrow_xpm[] = {
193 "9 9 3 1",
194 ". c #acaaac",
195 "% c #525552",
196 "# c #000000",
197 "....%....",
198 "....#....",
199 "...%#%...",
200 "...###...",
201 "..%###%..",
202 "..#####..",
203 ".%#####%.",
204 ".#######.",
205 "%#######%"
208 static char *down_arrow_xpm[] = {
209 "9 9 3 1",
210 ". c #acaaac",
211 "% c #525552",
212 "# c #000000",
213 "%#######%",
214 ".#######.",
215 ".%#####%.",
216 "..#####..",
217 "..%###%..",
218 "...###...",
219 "...%#%...",
220 "....#....",
221 "....%...."
224 static char *alt_up_arrow_xpm[] = {
225 "9 9 2 1",
226 ". c #ffffff",
227 "% c #525552",
228 "....%....",
229 "....%....",
230 "...%%%...",
231 "...%%%...",
232 "..%%%%%..",
233 "..%%%%%..",
234 ".%%%%%%%.",
235 ".%%%%%%%.",
236 "%%%%%%%%%"
239 static char *alt_down_arrow_xpm[] = {
240 "9 9 2 1",
241 ". c #ffffff",
242 "% c #525552",
243 "%%%%%%%%%",
244 ".%%%%%%%.",
245 ".%%%%%%%.",
246 "..%%%%%..",
247 "..%%%%%..",
248 "...%%%...",
249 "...%%%...",
250 "....%....",
251 "....%...."
253 /* XPM */
255 static WMPropList *CurrentFontArray = NULL;
256 //static WMPropList *CurrentMenuTitleFont = NULL;
257 //static WMPropList *CurrentMenuTextFont = NULL;
258 //static WMPropList *CurrentIconTitleFont = NULL;
259 //static WMPropList *CurrentClipTitleFont = NULL;
260 //static WMPropList *CurrentLargeDisplayFont = NULL;
262 static WMPropList *DefaultWindowTitleFont = NULL;
263 static WMPropList *DefaultMenuTitleFont = NULL;
264 static WMPropList *DefaultMenuTextFont = NULL;
265 static WMPropList *DefaultIconTitleFont = NULL;
266 static WMPropList *DefaultClipTitleFont = NULL;
267 static WMPropList *DefaultLargeDisplayFont = NULL;
269 static void changePage(WMWidget *w, void *data);
270 static void setLanguageType(void *data, Bool multiByte);
271 static void refillFontSetList(void *data);
272 static void readFontEncodings(void *data);
273 static void changeLanguageAction(WMWidget *w, void *data);
274 static void checkListForArrows(void *data);
276 static char* getFontEncoding(void *data);
277 static char* getFontSampleString(void *data);
279 /* note single element */
280 static WMFont* getFontForPreview(void *data, int element);
281 static WMFont* getDefaultSystemFont(void *data, int element);
283 static WMPropList* getDefaultFontProp(void *data, char *encoding, int section);
284 static WMPropList* getCurrentFontProp(void *data, int section);
286 static Bool isEncodingMultiByte(void *data);
288 static void
289 str2rcolor(RContext *rc, char *name, RColor *color)
291 XColor xcolor;
293 XParseColor(rc->dpy, rc->cmap, name, &xcolor);
295 color->alpha = 255;
296 color->red = xcolor.red >> 8;
297 color->green = xcolor.green >> 8;
298 color->blue = xcolor.blue >> 8;
301 static void
302 drawMenuBevel(RImage *img)
304 RColor light, dark, mid;
305 int i;
306 int iheight = img->height / 4;
308 light.alpha = 0;
309 light.red = light.green = light.blue = 80;
311 dark.alpha = 255;
312 dark.red = dark.green = dark.blue = 0;
314 mid.alpha = 0;
315 mid.red = mid.green = mid.blue = 40;
317 for (i = 1; i < 4; i++) {
318 ROperateLine(img, RSubtractOperation, 0, i*iheight-2,
319 img->width-1, i*iheight-2, &mid);
321 RDrawLine(img, 0, i*iheight-1, img->width-1, i*iheight-1, &dark);
323 ROperateLine(img, RAddOperation, 1, i*iheight,
324 img->width-2, i*iheight, &light);
328 static void
329 paintTitle(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
330 int part, WMAlignment align, char *text)
332 int l = strlen(text);
333 int x = previewPositions[part].pos.x;
334 int y = previewPositions[part].pos.y;
335 int w = previewPositions[part].size.width;
336 int h = previewPositions[part].size.height;
338 switch (align) {
339 case WALeft:
340 x += 5;
341 break;
342 case WARight:
343 x += w - 5 - WMWidthOfString(font, text, l);
344 break;
345 default:
346 case WACenter:
347 x += (w - WMWidthOfString(font, text, l))/2;
348 break;
350 WMDrawString(scr, d, color, font, x,
351 y + (h - WMFontHeight(font))/2, text, l);
354 static void
355 paintItems(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
356 int part, char *text)
358 int l = strlen(text);
359 int x = previewPositions[part].pos.x;
360 int y = previewPositions[part].pos.y;
361 int w = previewPositions[part].size.width;
362 int h = previewPositions[part].size.height/4;
363 int i;
364 for( i = 0; i < 4 ; i++) {
365 WMDrawString(scr, d, color, font, x+5,
366 y+(20*i)+(h - WMFontHeight(font))/2, text, l);
370 static void
371 paintIcon(WMScreen *scr,Drawable d, WMColor *color, WMColor *Iback,
372 WMFont *font, int part, char *text)
374 Display *dpy = WMScreenDisplay(scr);
375 int l = strlen(text);
376 int x = previewPositions[part].pos.x+1;
377 int y = previewPositions[part].pos.y+1;
378 int w = previewPositions[part].size.width-2;
379 int h = WMFontHeight(font)+2;
381 XFillRectangle(dpy, d, WMColorGC(Iback), x, y, w, h);
382 x += (w - WMWidthOfString(font, text, l))/2;
383 WMDrawString(scr, d, color, font, x,
384 y + (h - WMFontHeight(font))/2, text, l);
388 static void
389 drawFonts(_Panel *panel, int elements)
391 WMScreen *scr = WMWidgetScreen(panel->box);
392 WMPixmap *pixmap;
393 Pixmap d;
395 pixmap = WMGetLabelImage(panel->prevL);
396 d = WMGetPixmapXID(pixmap);
398 if(elements & FTITLE) {
399 paintTitle(scr, d, panel->colors[0], getFontForPreview(panel, WINTITLE),
400 WINTITLE, panel->titleAlignment, _("Window Title Font"));
402 if(elements & DISCOL) {
403 paintTitle(scr, d, panel->white, getFontForPreview(panel, DISTITLE),
404 DISTITLE, WACenter, _("Display"));
406 if(elements & MTITLE) {
407 paintTitle(scr, d, panel->colors[1], getFontForPreview(panel, PMTITLE),
408 PMTITLE, WALeft, _("Menu Title"));
410 if(elements & MITEM) {
411 paintItems(scr, d, panel->colors[2], getFontForPreview(panel, PMITEM),
412 PMITEM, _("Menu Item"));
414 if(elements & CLIP) {
415 WMDrawString(scr, d, panel->colors[4],
416 getFontForPreview(panel, PCLIP), 169,37, "1",1);
417 WMDrawString(scr, d, panel->colors[3],
418 getFontForPreview(panel, PCLIP),179, 84, _("Clip title"), 10);
420 if(elements & ICONT) {
421 paintIcon(scr, d, panel->colors[5], panel->colors[6],
422 getFontForPreview(panel, PICON), PICON, _("Icon Title"));
426 static void
427 dumpRImage(char *path, RImage *image)
429 FILE *f;
430 int channels = (image->format == RRGBAFormat ? 4 : 3);
432 f = fopen(path, "w");
433 if (!f) {
434 wsyserror(path);
435 return;
437 fprintf(f, "%02x%02x%1x", image->width, image->height, channels);
439 fwrite(image->data, 1, image->width * image->height * channels, f);
441 if (fclose(f) < 0) {
442 wsyserror(path);
446 static int
447 isPixmap(WMPropList *prop)
449 WMPropList *p;
450 char *s;
452 p = WMGetFromPLArray(prop, 0);
453 s = WMGetFromPLString(p);
454 if (strcasecmp(&s[1], "pixmap")==0)
455 return 1;
456 else
457 return 0;
460 static Pixmap
461 renderTexture(WMScreen *scr, WMPropList *texture, int width, int height,
462 char *path, int border)
464 char *type;
465 RImage *image = NULL;
466 Pixmap pixmap;
467 RContext *rc = WMScreenRContext(scr);
468 char *str;
469 RColor rcolor;
472 type = WMGetFromPLString(WMGetFromPLArray(texture, 0));
474 if (strcasecmp(type, "solid")==0) {
476 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
478 str2rcolor(rc, str, &rcolor);
480 image = RCreateImage(width, height, False);
481 RClearImage(image, &rcolor);
482 } else if (strcasecmp(type, "igradient")==0) {
483 int t1, t2;
484 RColor c1[2], c2[2];
486 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
487 str2rcolor(rc, str, &c1[0]);
488 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
489 str2rcolor(rc, str, &c1[1]);
490 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
491 t1 = atoi(str);
493 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
494 str2rcolor(rc, str, &c2[0]);
495 str = WMGetFromPLString(WMGetFromPLArray(texture, 5));
496 str2rcolor(rc, str, &c2[1]);
497 str = WMGetFromPLString(WMGetFromPLArray(texture, 6));
498 t2 = atoi(str);
500 image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2);
501 } else if (strcasecmp(&type[1], "gradient")==0) {
502 int style;
503 RColor rcolor2;
505 switch (toupper(type[0])) {
506 case 'V':
507 style = RVerticalGradient;
508 break;
509 case 'H':
510 style = RHorizontalGradient;
511 break;
512 default:
513 case 'D':
514 style = RDiagonalGradient;
515 break;
518 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
519 str2rcolor(rc, str, &rcolor);
520 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
521 str2rcolor(rc, str, &rcolor2);
523 image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
524 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='T') {
525 int style;
526 RColor rcolor2;
527 int i;
528 RImage *grad, *timage;
529 char *path;
531 switch (toupper(type[1])) {
532 case 'V':
533 style = RVerticalGradient;
534 break;
535 case 'H':
536 style = RHorizontalGradient;
537 break;
538 default:
539 case 'D':
540 style = RDiagonalGradient;
541 break;
544 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
545 str2rcolor(rc, str, &rcolor);
546 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
547 str2rcolor(rc, str, &rcolor2);
549 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
551 if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL)
552 timage = RLoadImage(rc, path, 0);
554 if (!path || !timage) {
555 wwarning("could not load file '%s': %s", path,
556 RMessageForError(RErrorCode));
557 } else {
558 grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
560 image = RMakeTiledImage(timage, width, height);
561 RReleaseImage(timage);
563 i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
565 RCombineImagesWithOpaqueness(image, grad, i);
566 RReleaseImage(grad);
568 } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='M') {
569 int style;
570 RColor **colors;
571 int i, j;
573 switch (toupper(type[1])) {
574 case 'V':
575 style = RVerticalGradient;
576 break;
577 case 'H':
578 style = RHorizontalGradient;
579 break;
580 default:
581 case 'D':
582 style = RDiagonalGradient;
583 break;
586 j = WMGetPropListItemCount(texture);
588 if (j > 0) {
589 colors = wmalloc(j * sizeof(RColor*));
591 for (i = 2; i < j; i++) {
592 str = WMGetFromPLString(WMGetFromPLArray(texture, i));
593 colors[i-2] = wmalloc(sizeof(RColor));
594 str2rcolor(rc, str, colors[i-2]);
596 colors[i-2] = NULL;
598 image = RRenderMultiGradient(width, height, colors, style);
600 for (i = 0; colors[i]!=NULL; i++)
601 wfree(colors[i]);
602 wfree(colors);
604 } else if (strcasecmp(&type[1], "pixmap")==0) {
605 RImage *timage = NULL;
606 char *path;
607 RColor color;
609 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
611 if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL)
612 timage = RLoadImage(rc, path, 0);
614 if (!path || !timage) {
615 wwarning("could not load file '%s': %s", path ? path : str,
616 RMessageForError(RErrorCode));
617 } else {
618 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
619 str2rcolor(rc, str, &color);
621 switch (toupper(type[0])) {
622 case 'T':
623 image = RMakeTiledImage(timage, width, height);
624 RReleaseImage(timage);
625 timage = image;
626 break;
627 case 'C':
628 image = RMakeCenteredImage(timage, width, height, &color);
629 RReleaseImage(timage);
630 timage = image;
631 break;
632 case 'S':
633 case 'M':
634 image = RScaleImage(timage, width, height);
635 RReleaseImage(timage);
636 timage = image;
637 break;
641 wfree(path);
644 if (!image)
645 return None;
647 if (path) {
648 dumpRImage(path, image);
651 if (border < 0) {
652 if (border == MENU_BEVEL) {
653 drawMenuBevel(image);
654 RBevelImage(image, RBEV_RAISED2);
656 } else if (border) {
657 RBevelImage(image, border);
660 RConvertImage(rc, image, &pixmap);
661 RReleaseImage(image);
663 return pixmap;
666 static Pixmap
667 renderMenu(_Panel *panel, WMPropList *texture, int width, int iheight)
669 WMScreen *scr = WMWidgetScreen(panel->parent);
670 Display *dpy = WMScreenDisplay(scr);
671 Pixmap pix, tmp;
672 RContext *rc = WMScreenRContext(scr);
673 GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
674 int i;
676 switch (panel->menuStyle) {
677 case MSTYLE_NORMAL:
678 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
680 pix = XCreatePixmap(dpy, tmp, width, iheight*4, WMScreenDepth(scr));
681 for (i = 0; i < 4; i++) {
682 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight*i);
684 XFreePixmap(dpy, tmp);
685 break;
686 case MSTYLE_SINGLE:
687 pix = renderTexture(scr, texture, width, iheight*4, NULL, MENU_BEVEL);
688 break;
689 case MSTYLE_FLAT:
690 pix = renderTexture(scr, texture, width, iheight*4, NULL, RBEV_RAISED2);
691 break;
693 XFreeGC(dpy, gc);
695 return pix;
698 static void
699 renderClip(_Panel *panel, GC gc, int part, int relief)
701 WMScreen *scr = WMWidgetScreen(panel->box);
702 Display *dpy = WMScreenDisplay(scr);
703 RContext *rc = WMScreenRContext(scr);
704 WMPropList *prop;
705 Pixmap pix;
706 XImage *original;
707 XPoint p[4];
708 RImage *tile;
709 RColor black;
710 RColor dark;
711 RColor light;
712 int pt, tp;
713 int as;
715 prop = GetObjectForKey(textureOptions[part]);
717 pix = renderTexture(scr, prop,
718 previewPositions[part].size.width,
719 previewPositions[part].size.height,
720 NULL, relief);
723 original = XGetImage(dpy, pix, 0, 0, 64, 64,
724 AllPlanes, ZPixmap);
725 if (!original){
726 wwarning(_("error capturing \"original\" tile image"),
727 RMessageForError(RErrorCode));
729 tile = RCreateImageFromXImage(rc, original, NULL);
731 XDestroyImage(original);
732 XFreePixmap(WMScreenDisplay(scr), pix);
734 pt = CLIP_BUTTON_SIZE*ICON_SIZE/64;
735 tp = ICON_SIZE-1 - pt;
736 as = pt - 15;
738 black.alpha = 255;
739 black.red = black.green = black.blue = 0;
741 dark.alpha = 0;
742 dark.red = dark.green = dark.blue = 60;
744 light.alpha = 0;
745 light.red = light.green = light.blue = 80;
748 /* top right */
749 ROperateLine(tile, RSubtractOperation, tp, 0, ICON_SIZE-2,
750 pt-1, &dark);
751 RDrawLine(tile, tp-1, 0, ICON_SIZE-1, pt+1, &black);
752 ROperateLine(tile, RAddOperation, tp, 2, ICON_SIZE-3,
753 pt, &light);
755 /* arrow bevel */
756 ROperateLine(tile, RSubtractOperation, ICON_SIZE - 7 - as, 4,
757 ICON_SIZE - 5, 4, &dark);
758 ROperateLine(tile, RSubtractOperation, ICON_SIZE - 6 - as, 5,
759 ICON_SIZE - 5, 6 + as, &dark);
760 ROperateLine(tile, RAddOperation, ICON_SIZE - 5, 4, ICON_SIZE - 5, 6 + as,
761 &light);
763 /* bottom left */
764 ROperateLine(tile, RAddOperation, 2, tp+2, pt-2,
765 ICON_SIZE-3, &dark);
766 RDrawLine(tile, 0, tp-1, pt+1, ICON_SIZE-1, &black);
767 ROperateLine(tile, RSubtractOperation, 0, tp-2, pt+1,
768 ICON_SIZE-2, &light);
770 /* arrow bevel */
771 ROperateLine(tile, RSubtractOperation, 4, ICON_SIZE - 7 - as, 4,
772 ICON_SIZE - 5, &dark);
773 ROperateLine(tile, RSubtractOperation, 5, ICON_SIZE - 6 - as,
774 6 + as, ICON_SIZE - 5, &dark);
775 ROperateLine(tile, RAddOperation, 4, ICON_SIZE - 5, 6 + as, ICON_SIZE - 5,
776 &light);
778 RConvertImage(rc, tile, &pix);
780 /* top right arrow */
781 p[0].x = p[3].x = ICON_SIZE-5-as;
782 p[0].y = p[3].y = 5;
783 p[1].x = ICON_SIZE-6;
784 p[1].y = 5;
785 p[2].x = ICON_SIZE-6;
786 p[2].y = 4+as;
787 XFillPolygon(dpy, pix, WMColorGC(panel->colors[4]), p, 3, Convex, CoordModeOrigin);
788 XDrawLines(dpy, pix, WMColorGC(panel->colors[4]), p, 4, CoordModeOrigin);
790 /* bottom left arrow */
791 p[0].x = p[3].x = 5;
792 p[0].y = p[3].y = ICON_SIZE-5-as;
793 p[1].x = 5;
794 p[1].y = ICON_SIZE-6;
795 p[2].x = 4+as;
796 p[2].y = ICON_SIZE-6;
797 XFillPolygon(dpy, pix, WMColorGC(panel->colors[4]), p, 3, Convex, CoordModeOrigin);
798 XDrawLines(dpy, pix, WMColorGC(panel->colors[4]), p, 4, CoordModeOrigin);
800 XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
801 previewPositions[part].size.width,
802 previewPositions[part].size.height,
803 previewPositions[part].pos.x,
804 previewPositions[part].pos.y);
806 RReleaseImage(tile);
807 XFreePixmap(WMScreenDisplay(scr), pix);
810 static void
811 renderPreview(_Panel *panel, GC gc, int part, int relief)
813 WMPropList *prop;
814 Pixmap pix;
815 WMScreen *scr = WMWidgetScreen(panel->box);
817 prop = GetObjectForKey(textureOptions[part]);
819 pix = renderTexture(scr, prop,
820 previewPositions[part].size.width,
821 previewPositions[part].size.height,
822 NULL, relief);
823 XCopyArea(WMScreenDisplay(scr), pix,
824 panel->preview, gc, 0, 0,
825 previewPositions[part].size.width,
826 previewPositions[part].size.height,
827 previewPositions[part].pos.x,
828 previewPositions[part].pos.y);
830 XFreePixmap(WMScreenDisplay(scr), pix);
833 static void
834 paintPreviewBox(Panel *panel, int elements)
836 WMScreen *scr = WMWidgetScreen(panel->parent);
837 Display *dpy = WMScreenDisplay(scr);
838 int refresh = 0;
839 GC gc;
840 WMColor *black = WMBlackColor(scr);
841 Pixmap mitem;
843 gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
845 if (panel->preview == None) {
846 WMPixmap *pix;
848 panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
849 240-4, 190-4, WMScreenDepth(scr));
851 pix = WMCreatePixmapFromXPixmaps(scr, panel->preview, None,
852 240-4, 190-4, WMScreenDepth(scr));
854 WMSetLabelImage(panel->prevL, pix);
855 WMReleasePixmap(pix);
857 XFillRectangle(dpy, panel->preview, WMColorGC(panel->back),
858 0, 0, 240-4, 190-4);
860 if (elements & (1<<WINTITLE)) {
861 renderPreview(panel, gc, WINTITLE, RBEV_RAISED2);
862 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
863 previewPositions[WINTITLE].pos.x-1,
864 previewPositions[WINTITLE].pos.y-1,
865 previewPositions[WINTITLE].size.width,
866 previewPositions[WINTITLE].size.height);
868 if (elements & (1<<DISTITLE)) {
869 XDrawRectangle(dpy, panel->preview, WMColorGC(panel->back),
870 previewPositions[DISTITLE].pos.x-1,
871 previewPositions[DISTITLE].pos.y-1,
872 previewPositions[DISTITLE].size.width,
873 previewPositions[DISTITLE].size.height);
875 if (elements & (1<<PMTITLE)) {
876 renderPreview(panel, gc, PMTITLE, RBEV_RAISED2);
877 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
878 previewPositions[PMTITLE].pos.x-1,
879 previewPositions[PMTITLE].pos.y-1,
880 previewPositions[PMTITLE].size.width,
881 previewPositions[PMTITLE].size.height);
883 if (elements & (1<<PMITEM)) {
884 WMPropList *prop;
886 prop = GetObjectForKey(textureOptions[PMITEM]);
887 mitem = renderMenu(panel, prop,
888 previewPositions[PMITEM].size.width,
889 previewPositions[PMITEM].size.height/4);
891 XCopyArea(dpy, mitem, panel->preview, gc, 0, 0,
892 previewPositions[PMITEM].size.width,
893 previewPositions[PMITEM].size.height,
894 previewPositions[PMITEM].pos.x,
895 previewPositions[PMITEM].pos.y);
897 XFreePixmap(dpy, mitem);
899 if (elements & (1<<PMITEM|1<<PMTITLE)) {
900 XDrawLine(dpy, panel->preview, gc, 29, 125, 29, 125+20*4+25);
901 XDrawLine(dpy, panel->preview, gc, 119, 125, 119, 125+20*4+25);
903 if (elements & (1<<PCLIP)) {
904 renderClip(panel, gc, PCLIP, RBEV_RAISED3);
905 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
906 previewPositions[PCLIP].pos.x-1,
907 previewPositions[PCLIP].pos.y-1,
908 previewPositions[PCLIP].size.width,
909 previewPositions[PCLIP].size.height);
911 if (elements & (1<<PICON)) {
912 renderPreview(panel, gc, PICON, RBEV_RAISED3);
913 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
914 previewPositions[PICON].pos.x-1,
915 previewPositions[PICON].pos.y-1,
916 previewPositions[PICON].size.width,
917 previewPositions[PICON].size.height);
919 drawFonts(panel, elements);
920 WMRedisplayWidget(panel->prevL);
921 XFreeGC(dpy, gc);
922 WMReleaseColor(black);
925 static void
926 paintTextField(void *data, int section)
928 _Panel *panel = (_Panel*)data;
929 char *sample = NULL;
930 int encoding;
931 encoding = WMGetPopUpButtonSelectedItem(panel->langP);
932 WMSetTextFieldFont(panel->fontT, getFontForPreview(panel, section));
933 switch(encoding) {
934 case 0: /* Current Font in theme */
935 WMSetTextFieldText(panel->fontT,
936 "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
937 break;
938 case 1: /* default */
939 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
940 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
941 break;
942 case 2: /* latin1 iso8859-1 */
943 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
944 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
945 break;
946 case 3: /* latin2 iso8859-2 */
947 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
948 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
949 break;
950 case 4: /* Greek iso8859-7 */
951 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
952 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
953 break;
954 /* luckily all these happen to have the MultiByte chars in the same places */
955 case 5: /* Japanese jisx0208.1983 */
956 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
957 // "Window Maker ÀßÄê¥æ¡¼¥Æ¥£¥ê¥Æ¥£");
958 break;
959 case 6: /* Korean ksc5601.1987 */
960 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
961 // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤");
962 break;
963 case 7: /* korean2 daewoo */
964 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
965 // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤");
966 break;
967 case 8: /* Russian koi8-r */
968 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
969 // "ó×ÏÊÓÔ×Á Window Maker");
970 break;
971 case 9: /* Ukranian koi8-u */
972 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
973 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
974 break;
978 static void
979 previewClick(XEvent *event, void *clientData)
981 _Panel *panel = (_Panel*)clientData;
982 int i;
984 for (i = 0; i < sizeof(previewPositions)/sizeof(WMRect); i++) {
985 if (event->xbutton.x >= previewPositions[i].pos.x
986 && event->xbutton.y >= previewPositions[i].pos.y
987 && event->xbutton.x < previewPositions[i].pos.x
988 + previewPositions[i].size.width
989 && event->xbutton.y < previewPositions[i].pos.y
990 + previewPositions[i].size.height) {
992 WMSetPopUpButtonSelectedItem(panel->fontSel, i);
993 changePage(panel->fontSel, panel);
994 return;
999 static void
1000 changePage(WMWidget *w, void *data)
1002 _Panel *panel = (_Panel*)data;
1003 int section;
1004 WMScreen *scr = WMWidgetScreen(panel->box);
1005 RContext *rc = WMScreenRContext(scr);
1006 static WMPoint positions[] = {
1007 {5, 15},
1008 {5, 62},
1009 {5, 110},
1010 {5, 140},
1011 {130, 62},
1012 {130, 132}
1015 if (w) {
1016 section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1019 WMColor *color;
1021 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1022 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
1023 positions[panel->oldsection].x,
1024 positions[panel->oldsection].y, 22, 22);
1025 WMReleaseColor(color);
1027 if (w) {
1028 panel->oldsection = section;
1029 WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
1030 positions[section].y);
1032 WMRedisplayWidget(panel->prevL);
1033 paintTextField(panel, section);
1034 refillFontSetList(panel);
1037 static void
1038 setLanguageType(void *data, Bool multiByte)
1040 _Panel *p = (_Panel*)data;
1042 if (multiByte) {
1043 WMMapWidget(p->fsetL);
1044 WMMapWidget(p->fsetLs);
1045 WMMapWidget(p->addB);
1046 WMMapWidget(p->editB);
1047 WMMapWidget(p->remB);
1048 WMMapWidget(p->upB);
1049 WMMapWidget(p->downB);
1051 WMUnmapWidget(p->fontT);
1052 WMUnmapWidget(p->changeB);
1053 } else {
1054 WMUnmapWidget(p->fsetL);
1055 WMUnmapWidget(p->fsetLs);
1056 WMUnmapWidget(p->addB);
1057 WMUnmapWidget(p->editB);
1058 WMUnmapWidget(p->remB);
1059 WMUnmapWidget(p->upB);
1060 WMUnmapWidget(p->downB);
1062 WMMapWidget(p->fontT);
1063 WMMapWidget(p->changeB);
1067 static void
1068 refillFontSetList(void *data)
1070 _Panel *panel = (_Panel*)data;
1071 WMPropList *array;
1072 char *encoding = getFontEncoding(panel);
1073 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1074 int i;
1075 int pos;
1076 WMClearList(panel->fsetLs);
1077 if(!encoding) {
1078 array = getCurrentFontProp(panel, section);
1079 } else {
1080 array = getDefaultFontProp(panel, encoding, section);
1082 if(!array){
1083 wwarning("error not Font prop given");
1084 } else {
1085 for (i = 0; i < WMGetPropListItemCount(array); i++) {
1086 WMGetFromPLArray(array, i);
1087 WMAddListItem( panel->fsetLs,
1088 WMGetFromPLString(
1089 WMGetFromPLArray(array, i)));
1091 WMReleasePropList(array);
1092 WMSelectListItem(panel->fsetLs, 0);
1095 checkListForArrows(panel);
1098 static void
1099 insertCurrentFont(char *data, char *type)
1101 WMPropList *key;
1102 WMPropList *array;
1103 char *tmp, *str;
1105 key = WMCreatePLString(type);
1106 array = WMCreatePLArray(NULL);
1108 str = wstrdup(data);
1109 tmp = strtok(str, ",");
1110 while(tmp) {
1111 WMAddToPLArray(array, WMCreatePLString(tmp));
1112 tmp = strtok(NULL, ",");
1114 wfree(str);
1117 WMPutInPLDictionary(CurrentFontArray, key, array);
1120 static void
1121 readFontEncodings(void *data)
1123 _Panel *panel = (_Panel*)data;
1124 WMPropList *pl = NULL;
1125 char *path;
1126 char *msg;
1128 path = WMPathForResourceOfType("font.data", NULL);
1129 if (!path) {
1130 msg = _("Could not locate font information file WPrefs.app/font.data");
1131 goto error;
1134 pl = WMReadPropListFromFile(path);
1135 if (!pl) {
1136 msg = _("Could not read font information file WPrefs.app/font.data");
1137 goto error;
1138 } else {
1139 int i;
1140 WMPropList *key = WMCreatePLString("Encodings");
1141 WMPropList *array;
1142 WMMenuItem *mi;
1144 array = WMGetFromPLDictionary(pl, key);
1145 WMReleasePropList(key);
1146 if (!array || !WMIsPLArray(array)) {
1147 msg = _("Invalid data in font information file WPrefs.app/font.data.\n"
1148 "Encodings data not found.");
1149 goto error;
1152 WMAddPopUpButtonItem(panel->langP, _("Current"));
1154 for (i = 0; i < WMGetPropListItemCount(array); i++) {
1155 WMPropList *item, *str;
1157 item = WMGetFromPLArray(array, i);
1158 str = WMGetFromPLArray(item, 0);
1159 mi = WMAddPopUpButtonItem(panel->langP, WMGetFromPLString(str));
1160 WMSetMenuItemRepresentedObject(mi, WMRetainPropList(item));
1162 WMSetPopUpButtonSelectedItem(panel->langP, 0);
1165 key = WMCreatePLString("WindowTitleFont");
1166 DefaultWindowTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1167 WMReleasePropList(key);
1169 key = WMCreatePLString("MenuTitleFont");
1170 DefaultMenuTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1171 WMReleasePropList(key);
1173 key = WMCreatePLString("MenuTextFont");
1174 DefaultMenuTextFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1175 WMReleasePropList(key);
1177 key = WMCreatePLString("IconTitleFont");
1178 DefaultIconTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1179 WMReleasePropList(key);
1181 key = WMCreatePLString("ClipTitleFont");
1182 DefaultClipTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1183 WMReleasePropList(key);
1185 key = WMCreatePLString("LargeDisplayFont");
1186 DefaultLargeDisplayFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1187 WMReleasePropList(key);
1190 WMReleasePropList(pl);
1191 return;
1192 error:
1193 if (pl)
1194 WMReleasePropList(pl);
1196 WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent,
1197 _("Error"), msg, _("OK"), NULL, NULL);
1200 static void
1201 checkListForArrows(void *data)
1203 _Panel *panel = (_Panel*)data;
1204 int list;
1205 list = WMGetListNumberOfRows(panel->fsetLs);
1207 if(list > 1)
1209 if(WMGetListSelectedItemRow(panel->fsetLs) == 0) {
1210 WMSetButtonEnabled(panel->upB, False);
1211 WMSetButtonEnabled(panel->downB, True);
1212 } else if(WMGetListSelectedItemRow(panel->fsetLs) == list-1) {
1213 WMSetButtonEnabled(panel->downB, False);
1214 WMSetButtonEnabled(panel->upB, True);
1215 } else {
1216 WMSetButtonEnabled(panel->upB, True);
1217 WMSetButtonEnabled(panel->downB, True);
1220 } else {
1221 WMSetButtonEnabled(panel->upB, False);
1222 WMSetButtonEnabled(panel->downB, False);
1224 /* added to control the Remove button */
1225 if(list > 1)
1226 WMSetButtonEnabled(panel->remB, True);
1227 else
1228 WMSetButtonEnabled(panel->remB, False);
1231 static char*
1232 fontOfLang(void *data, char *encoding, int section)
1234 _Panel *panel = (_Panel*)data;
1235 WMPropList *array;
1236 char *buf = NULL;
1237 int i;
1239 if(!encoding)
1240 array = getCurrentFontProp(panel, section);
1241 else
1242 array = getDefaultFontProp(panel, encoding, section);
1244 if(!array) {
1245 wwarning("error no font prop given");
1246 return NULL;
1247 } else {
1248 for(i=0; i<WMGetPropListItemCount(array); i++)
1250 if(buf) buf = wstrconcat(buf, ",");
1251 buf = wstrconcat(buf, WMGetFromPLString(WMGetFromPLArray(array, i)));
1253 WMReleasePropList(array);
1254 return wstrdup(buf);
1258 static void
1259 changeLanguageAction(WMWidget *w, void *data)
1261 Panel *panel = (Panel*)data;
1262 WMScreen *scr = WMWidgetScreen(panel->box);
1263 int section;
1265 section = WMGetPopUpButtonSelectedItem(w);
1267 if(isEncodingMultiByte(panel)) {
1268 setLanguageType(panel, True);
1269 } else {
1270 if(panel->MultiByteText) setLanguageType(panel, True);
1271 else setLanguageType(panel, False);
1274 paintPreviewBox(panel, EVERYTHING);
1275 changePage(panel->fontSel, panel);
1278 static WMFont*
1279 getFontForPreview(void *data, int element)
1281 _Panel *panel = (_Panel*)data;
1282 WMFont *font;
1283 char *fname;
1284 WMScreen *scr = WMWidgetScreen(panel->box);
1285 char *encoding = getFontEncoding(panel);
1286 fname = fontOfLang(panel, encoding, element);
1287 if (WMHasAntialiasingSupport(scr))
1289 if(panel->AntialiasedText) {
1290 font = WMCreateFontWithFlags(scr, fname, WFAntialiased);
1291 } else {
1292 font = WMCreateFont(scr, fname);
1294 } else {
1295 font = WMCreateFont(scr, fname);
1297 if(!font) {
1298 char *msg;
1299 int length;
1300 length = strlen("\"")+
1301 strlen(fname)+strlen("\" was not loaded correctly. Make sure the font is available for that encoding.\nLoadind default system font.");
1302 msg = wmalloc(length +1);
1303 snprintf(msg, length + 1,
1304 "\"%s\" was not loaded correctly. Make sure the font is available for that encoding.\nLoading default system font.",
1305 fname);
1306 WMRunAlertPanel(WMWidgetScreen(panel->parent),panel->parent,
1307 _("Warning"), msg, _("OK"), NULL, NULL);
1308 font = getDefaultSystemFont(panel, element);
1310 return font;
1313 static char*
1314 getFontSampleString(void *data)
1316 _Panel *panel = (_Panel*)data;
1317 WMScreen *scr = WMWidgetScreen(panel->box);
1318 WMMenuItem *mi;
1319 WMPropList *pl;
1320 int section;
1322 section = WMGetPopUpButtonSelectedItem(panel->langP);
1323 mi = WMGetPopUpButtonMenuItem(panel->langP, section);
1324 pl = WMGetMenuItemRepresentedObject(mi);
1326 if (!pl) {
1327 return NULL;
1328 } else {
1329 char *sample;
1330 sample = WMGetFromPLString(WMGetFromPLArray(pl,3));
1331 return sample;
1335 static char*
1336 getFontEncoding(void *data)
1338 _Panel *panel = (_Panel*)data;
1339 WMScreen *scr = WMWidgetScreen(panel->box);
1340 WMMenuItem *mi;
1341 WMPropList *pl;
1342 int section;
1344 section = WMGetPopUpButtonSelectedItem(panel->langP);
1345 mi = WMGetPopUpButtonMenuItem(panel->langP, section);
1346 pl = WMGetMenuItemRepresentedObject(mi);
1348 if (!pl) {
1349 return NULL;
1350 } else {
1351 char *encoding;
1352 encoding = WMGetFromPLString(WMGetFromPLArray(pl,2));
1353 return encoding;
1357 static Bool
1358 isEncodingMultiByte(void *data)
1360 _Panel *panel = (_Panel*)data;
1361 WMScreen *scr = WMWidgetScreen(panel->box);
1362 WMMenuItem *mi;
1363 WMPropList *pl;
1364 int section;
1366 section = WMGetPopUpButtonSelectedItem(panel->langP);
1367 mi = WMGetPopUpButtonMenuItem(panel->langP, section);
1368 pl = WMGetMenuItemRepresentedObject(mi);
1370 if (!pl) {
1371 return False;
1372 } else {
1373 char *multiByte;
1374 int res;
1375 multiByte = WMGetFromPLString(WMGetFromPLArray(pl,1));
1376 res = atoi(multiByte);
1377 if(res)
1378 return True;
1379 else
1380 return False;
1384 static WMPropList*
1385 getCurrentFontProp(void *data, int section)
1387 WMPropList *array;
1388 switch (section) {
1389 case 0:
1390 array = WMRetainPropList(
1391 WMGetFromPLDictionary(CurrentFontArray,
1392 WMCreatePLString("WindowTitleFont")));
1393 break;
1394 case 1:
1395 array = WMRetainPropList(
1396 WMGetFromPLDictionary(CurrentFontArray,
1397 WMCreatePLString("LargeDisplayFont")));
1398 break;
1399 case 2:
1400 array = WMRetainPropList(
1401 WMGetFromPLDictionary(CurrentFontArray,
1402 WMCreatePLString("MenuTitleFont")));
1403 break;
1404 case 3:
1405 array = WMRetainPropList(
1406 WMGetFromPLDictionary(CurrentFontArray,
1407 WMCreatePLString("MenuTextFont")));
1408 break;
1409 case 4:
1410 array = WMRetainPropList(
1411 WMGetFromPLDictionary(CurrentFontArray,
1412 WMCreatePLString("ClipTitleFont")));
1413 break;
1414 case 5:
1415 array = WMRetainPropList(
1416 WMGetFromPLDictionary(CurrentFontArray,
1417 WMCreatePLString("IconTitleFont")));
1418 break;
1420 if(!WMIsPLArray(array)) {
1421 return NULL;
1422 } else {
1423 return array;
1427 static WMPropList*
1428 getDefaultFontProp(void *data, char *encoding, int section)
1430 WMPropList *array;
1431 WMPropList *key = WMCreatePLString(encoding);
1432 switch (section) {
1433 case 0:
1434 array = WMRetainPropList(
1435 WMGetFromPLDictionary(DefaultWindowTitleFont, key));
1436 WMReleasePropList(key);
1437 break;
1438 case 1:
1439 array = WMRetainPropList(
1440 WMGetFromPLDictionary(DefaultLargeDisplayFont, key));
1441 WMReleasePropList(key);
1442 break;
1443 case 2:
1444 array = WMRetainPropList(
1445 WMGetFromPLDictionary(DefaultMenuTitleFont, key));
1446 WMReleasePropList(key);
1447 break;
1448 case 3:
1449 array = WMRetainPropList(
1450 WMGetFromPLDictionary(DefaultMenuTextFont, key));
1451 WMReleasePropList(key);
1452 break;
1453 case 4:
1454 array = WMRetainPropList(
1455 WMGetFromPLDictionary(DefaultClipTitleFont, key));
1456 WMReleasePropList(key);
1457 break;
1458 case 5:
1459 array = WMRetainPropList(
1460 WMGetFromPLDictionary(DefaultIconTitleFont, key));
1461 WMReleasePropList(key);
1462 break;
1464 if(!WMIsPLArray(array)) {
1465 return NULL;
1466 } else {
1467 return array;
1471 static WMFont*
1472 getDefaultSystemFont(void *data, int element)
1474 _Panel *panel = (_Panel*)data;
1475 WMScreen *scr = WMWidgetScreen(panel->box);
1476 switch(element) {
1477 case 0:
1478 return WMBoldSystemFontOfSize(scr, 12);
1479 break;
1480 case 1:
1481 return WMBoldSystemFontOfSize(scr, 24);
1482 break;
1483 case 2:
1484 return WMBoldSystemFontOfSize(scr, 12);
1485 break;
1486 case 3:
1487 return WMSystemFontOfSize(scr, 12);
1488 break;
1489 case 4:
1490 return WMSystemFontOfSize(scr, 8);
1491 break;
1492 case 5:
1493 return WMSystemFontOfSize(scr, 8);
1494 break;
1498 static void
1499 multiClick(WMWidget *w, void *data)
1501 _Panel *panel = (_Panel*)data;
1502 if(!panel->MultiByteText) {
1503 WMSetButtonText(panel->togMulti, _("Yes"));
1504 setLanguageType(panel, True);
1505 panel->MultiByteText = True;
1506 } else {
1507 WMSetButtonText(panel->togMulti, _("Auto"));
1508 if(isEncodingMultiByte(panel)) setLanguageType(panel, True);
1509 else setLanguageType(panel, False);
1510 panel->MultiByteText = False;
1514 static void
1515 toggleAA(WMWidget *w, void *data)
1517 _Panel *panel = (_Panel*)data;
1518 int section;
1519 if(panel->AntialiasedText)
1520 panel->AntialiasedText = False;
1521 else
1522 panel->AntialiasedText = True;
1523 /* hmm now i gotta redraw all the fonts in the preview section
1524 * and the text field
1526 paintPreviewBox(panel, EVERYTHING);
1527 changePage(panel->fontSel, panel);
1528 if(isEncodingMultiByte(panel)) setLanguageType(panel, True);
1531 static void
1532 listClick(WMWidget *w, void *data)
1534 _Panel *panel = (_Panel*)data;
1536 checkListForArrows(panel);
1539 static void
1540 moveUpListItem(WMWidget *w, void *data)
1542 _Panel *panel = (_Panel*)data;
1543 WMListItem *tmp;
1544 int pos;
1545 char *listtext;
1546 WMPropList *array;
1547 WMPropList *string;
1548 char *encoding = getFontEncoding(panel);
1549 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1551 if(!encoding)
1552 array = getCurrentFontProp(panel, section);
1553 else
1554 array = getDefaultFontProp(panel, encoding, section);
1556 pos = WMGetListSelectedItemRow(panel->fsetLs);
1558 tmp = WMGetListItem(panel->fsetLs, pos);
1559 listtext = wstrdup(tmp->text);
1560 string = WMCreatePLString(listtext);
1562 WMRemoveListItem(panel->fsetLs, pos);
1563 WMDeleteFromPLArray(array, pos);
1564 WMInsertListItem(panel->fsetLs, pos-1, listtext);
1565 WMInsertInPLArray(array, pos-1, string);
1567 paintPreviewBox(panel, EVERYTHING);
1568 changePage(panel->fontSel, panel);
1570 WMSelectListItem(panel->fsetLs, pos-1);
1571 checkListForArrows(panel);
1574 static void
1575 moveDownListItem(WMWidget *w, void *data)
1577 _Panel *panel = (_Panel*)data;
1578 WMListItem *tmp;
1579 int pos;
1580 char *listtext;
1581 WMPropList *array;
1582 WMPropList *string;
1583 char *encoding = getFontEncoding(panel);
1584 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1586 if(!encoding)
1587 array = getCurrentFontProp(panel, section);
1588 else
1589 array = getDefaultFontProp(panel, encoding, section);
1591 pos = WMGetListSelectedItemRow(panel->fsetLs);
1593 tmp = WMGetListItem(panel->fsetLs, pos);
1594 listtext = wstrdup(tmp->text);
1595 string = WMCreatePLString(listtext);
1596 WMRemoveListItem(panel->fsetLs, pos);
1597 WMDeleteFromPLArray(array, pos);
1598 WMInsertListItem(panel->fsetLs, pos+1, listtext);
1599 WMInsertInPLArray(array, pos+1, string);
1601 paintPreviewBox(panel, EVERYTHING);
1602 changePage(panel->fontSel, panel);
1604 WMSelectListItem(panel->fsetLs, pos+1);
1605 checkListForArrows(panel);
1608 static void
1609 addButtonAction(WMWidget *w, void *data)
1611 _Panel *panel = (_Panel*)data;
1612 char *chosenFont;
1613 int pos;
1614 WMPropList *array;
1615 WMPropList *string;
1616 char *encoding = getFontEncoding(panel);
1617 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1619 if(!encoding)
1620 array = getCurrentFontProp(panel, section);
1621 else
1622 array = getDefaultFontProp(panel, encoding, section);
1624 WMHideFontPanel(panel->fontPanel);
1625 chosenFont = WMGetFontPanelFontName(panel->fontPanel);
1626 string = WMCreatePLString(chosenFont);
1627 pos = WMGetListSelectedItemRow(panel->fsetLs);
1628 WMInsertListItem(panel->fsetLs, pos+1, chosenFont);
1629 WMInsertInPLArray(array, pos+1, string);
1630 WMSelectListItem(panel->fsetLs, pos+1);
1632 paintPreviewBox(panel, EVERYTHING);
1633 changePage(panel->fontSel, panel);
1636 static void
1637 changeButtonAction(WMWidget *w, void *data)
1639 _Panel *panel = (_Panel*)data;
1640 char *chosenFont;
1641 int pos;
1642 WMPropList *array;
1643 WMPropList *string;
1644 char *encoding = getFontEncoding(panel);
1645 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1647 if(!encoding)
1648 array = getCurrentFontProp(panel, section);
1649 else
1650 array = getDefaultFontProp(panel, encoding, section);
1652 WMHideFontPanel(panel->fontPanel);
1654 chosenFont = WMGetFontPanelFontName(panel->fontPanel);
1655 string = WMCreatePLString(chosenFont);
1657 pos = WMGetListSelectedItemRow(panel->fsetLs);
1658 WMRemoveListItem(panel->fsetLs, pos);
1659 WMDeleteFromPLArray(array, pos);
1660 WMInsertListItem(panel->fsetLs, pos, chosenFont);
1661 WMInsertInPLArray(array, pos, string);
1662 WMSelectListItem(panel->fsetLs, pos);
1664 paintPreviewBox(panel, EVERYTHING);
1665 changePage(panel->fontSel, panel);
1668 static void
1669 changeButtonClick(WMWidget *w, void *data)
1671 _Panel *panel = (_Panel*)data;
1673 WMSetFontPanelAction(panel->fontPanel, changeButtonAction, panel);
1674 WMShowFontPanel(panel->fontPanel);
1677 static void
1678 addButtonClick(WMWidget *w, void *data)
1680 _Panel *panel = (_Panel*)data;
1682 WMSetFontPanelAction(panel->fontPanel, addButtonAction, panel);
1683 WMShowFontPanel(panel->fontPanel);
1686 static void
1687 removeButtonClick(WMWidget *w, void *data)
1689 _Panel *panel = (_Panel*)data;
1690 int pos;
1691 int list;
1692 WMPropList *array;
1693 char *encoding = getFontEncoding(panel);
1694 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1696 if(!encoding)
1697 array = getCurrentFontProp(panel, section);
1698 else
1699 array = getDefaultFontProp(panel, encoding, section);
1701 pos = WMGetListSelectedItemRow(panel->fsetLs);
1702 WMRemoveListItem(panel->fsetLs, pos);
1703 WMDeleteFromPLArray(array, pos);
1705 list = WMGetListNumberOfRows(panel->fsetLs);
1706 if(list != 0) {
1707 if(list > pos)
1708 WMSelectListItem(panel->fsetLs, pos);
1709 else if(list == pos)
1710 WMSelectListItem(panel->fsetLs, list-1);
1711 else
1712 WMSelectListItem(panel->fsetLs, 0);
1714 checkListForArrows(panel);
1716 paintPreviewBox(panel, EVERYTHING);
1717 changePage(panel->fontSel, panel);
1720 static void
1721 showData(_Panel *panel)
1723 WMScreen *scr = WMWidgetScreen(panel->parent);
1724 char *str;
1725 int i;
1727 CurrentFontArray = WMCreatePLDictionary(NULL, NULL);
1729 str = GetStringForKey("WindowTitleFont");
1730 insertCurrentFont(wstrdup(str), "WindowTitleFont");
1732 str = GetStringForKey("LargeDisplayFont");
1733 insertCurrentFont(wstrdup(str), "LargeDisplayFont");
1735 str = GetStringForKey("MenuTitleFont");
1736 insertCurrentFont(wstrdup(str), "MenuTitleFont");
1738 str = GetStringForKey("MenuTextFont");
1739 insertCurrentFont(wstrdup(str), "MenuTextFont");
1741 str = GetStringForKey("ClipTitleFont");
1742 insertCurrentFont(wstrdup(str), "ClipTitleFont");
1744 str = GetStringForKey("IconTitleFont");
1745 insertCurrentFont(wstrdup(str), "IconTitleFont");
1747 /* i put this here cause it needs to be known before we paint */
1748 readFontEncodings(panel);
1750 str = GetStringForKey("MenuStyle");
1751 if (str && strcasecmp(str, "flat")==0) {
1752 panel->menuStyle = MSTYLE_FLAT;
1753 } else if (str && strcasecmp(str, "singletexture")==0) {
1754 panel->menuStyle = MSTYLE_SINGLE;
1755 } else {
1756 panel->menuStyle = MSTYLE_NORMAL;
1759 str = GetStringForKey("TitleJustify");
1760 if (str && strcasecmp(str, "left")==0) {
1761 panel->titleAlignment = WALeft;
1762 } else if (str && strcasecmp(str, "right")==0) {
1763 panel->titleAlignment = WARight;
1764 } else {
1765 panel->titleAlignment = WACenter;
1767 for (i = 0; i < sizeof(colorOptions)/(2*sizeof(char*)); i++) {
1768 WMColor *color;
1770 str = GetStringForKey(colorOptions[i*2]);
1771 if (!str)
1772 str = colorOptions[i*2+1];
1774 if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
1775 color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
1777 panel->colors[i] = color;
1780 str = GetStringForKey("MultiByteText");
1781 if (str)
1783 if (strcasecmp(str, "YES")==0) {
1784 setLanguageType(panel, True);
1785 WMSetButtonText(panel->togMulti, "Yes");
1786 printf("yes multi\n");
1787 panel->MultiByteText = True;
1788 } else if (strcasecmp(str, "AUTO") == 0) {
1789 char *locale;
1790 locale = setlocale(LC_CTYPE, NULL);
1791 if(locale != NULL
1792 && (strncmp(locale, "ja", 2) == 0
1793 || strncmp(locale, "zh", 2) == 0
1794 || strncmp(locale, "ko", 2) == 0)) {
1795 setLanguageType(panel, True);
1796 WMSetButtonText(panel->togMulti, "Auto");
1797 printf("auto multi\n");
1798 panel->MultiByteText = True;
1799 } else {
1800 setLanguageType(panel, False);
1801 WMSetButtonText(panel->togMulti, "Auto");
1802 panel->MultiByteText = False;
1805 } else {
1806 char *locale;
1807 locale = setlocale(LC_CTYPE, NULL);
1808 if(locale != NULL
1809 && (strncmp(locale, "ja", 2) == 0
1810 || strncmp(locale, "zh", 2) == 0
1811 || strncmp(locale, "ko", 2) == 0)) {
1812 setLanguageType(panel, True);
1813 WMSetButtonText(panel->togMulti, "Auto");
1814 printf("auto multi\n");
1815 panel->MultiByteText = True;
1816 } else {
1817 setLanguageType(panel, False);
1818 WMSetButtonText(panel->togMulti, "Auto");
1819 panel->MultiByteText = False;
1822 /* gotta check for Antialiasing AFTER MultiByte incase the use has both
1823 * to maintain behavior in Current Fonts set or i could add another if
1824 * statement to setLanguageType =) */
1825 if (WMHasAntialiasingSupport(scr))
1827 WMMapWidget(panel->togAA);
1828 if(GetBoolForKey("AntialiasedText")){
1829 WMSetButtonSelected(panel->togAA, True);
1830 panel->AntialiasedText = True;
1831 } else {
1832 WMSetButtonSelected(panel->togAA, False);
1833 panel->AntialiasedText = False;
1835 } else {
1836 WMUnmapWidget(panel->togAA);
1840 paintPreviewBox(panel, EVERYTHING);
1843 static void
1844 createPanel(Panel *p)
1846 _Panel *panel = (_Panel*)p;
1847 WMScreen *scr = WMWidgetScreen(panel->parent);
1850 panel->box = WMCreateBox(panel->parent);
1851 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
1853 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1854 panel->up_arrow = WMCreatePixmapFromXPMData(scr, up_arrow_xpm);
1855 panel->down_arrow = WMCreatePixmapFromXPMData(scr, down_arrow_xpm);
1856 panel->alt_up_arrow = WMCreatePixmapFromXPMData(scr, alt_up_arrow_xpm);
1857 panel->alt_down_arrow = WMCreatePixmapFromXPMData(scr, alt_down_arrow_xpm);
1859 panel->prevL = WMCreateLabel(panel->box);
1860 WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 45);
1861 WMMoveWidget(panel->prevL, 15, 35);
1862 WMSetLabelRelief(panel->prevL, WRSunken);
1863 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1865 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask,
1866 previewClick, panel);
1868 /* Widget Selection */
1869 panel->fontSel = WMCreatePopUpButton(panel->box);
1870 WMResizeWidget(panel->fontSel, 135, 20);
1871 WMMoveWidget(panel->fontSel, 15, 10);
1872 WMAddPopUpButtonItem(panel->fontSel, _("Window Title Font"));
1873 WMAddPopUpButtonItem(panel->fontSel, _("Large Display Font"));
1874 WMAddPopUpButtonItem(panel->fontSel, _("Menu Title Font"));
1875 WMAddPopUpButtonItem(panel->fontSel, _("Menu Item Font" ));
1876 WMAddPopUpButtonItem(panel->fontSel, _("Clip Title Font"));
1877 WMAddPopUpButtonItem(panel->fontSel, _("Icon Title Font"));
1879 WMSetPopUpButtonSelectedItem(panel->fontSel, 0);
1881 WMSetPopUpButtonAction(panel->fontSel, changePage, panel);
1883 /* MultiByteText toggle */
1884 panel->multiF = WMCreateFrame(panel->box);
1885 WMResizeWidget(panel->multiF, 70, 50);
1886 WMMoveWidget(panel->multiF, 440, 10);
1887 WMSetFrameTitle(panel->multiF, _("MultiByte"));
1890 panel->togMulti = WMCreateCommandButton(panel->multiF);
1891 WMResizeWidget(panel->togMulti, 40, 20);
1892 WMMoveWidget(panel->togMulti, 15, 20);
1893 WMSetButtonAction(panel->togMulti, multiClick, panel);
1895 WMMapSubwidgets(panel->multiF);
1897 /* language selection */
1898 panel->langF = WMCreateFrame(panel->box);
1899 WMResizeWidget(panel->langF, 165, 50);
1900 WMMoveWidget(panel->langF, 265, 10);
1901 WMSetFrameTitle(panel->langF, _("Default Font Encodings"));
1903 panel->langP = WMCreatePopUpButton(panel->langF);
1904 WMResizeWidget(panel->langP, 135, 20);
1905 WMMoveWidget(panel->langP, 15, 20);
1907 WMSetPopUpButtonAction(panel->langP, changeLanguageAction, panel);
1909 WMMapSubwidgets(panel->langF);
1911 /* Antialiasing */
1912 if (WMHasAntialiasingSupport(scr))
1914 panel->togAA = WMCreateSwitchButton(panel->box);
1915 WMResizeWidget(panel->togAA, 110, 20);
1916 WMMoveWidget(panel->togAA, 155, 10);
1917 WMSetButtonText(panel->togAA, _("Smooth Fonts"));
1918 WMSetBalloonTextForView(_("Smooth Font edges for the eye candy\n"
1919 "requires a restart after saving"),
1920 WMWidgetView(panel->togAA));
1921 WMSetButtonAction(panel->togAA, toggleAA, panel);
1923 /* multibyte */
1924 panel->fsetL = WMCreateLabel(panel->box);
1925 WMResizeWidget(panel->fsetL, 245, 20);
1926 WMMoveWidget(panel->fsetL, 265, 70);
1927 WMSetLabelText(panel->fsetL, _("Font Set"));
1928 WMSetLabelRelief(panel->fsetL, WRSunken);
1929 WMSetLabelTextAlignment(panel->fsetL, WACenter);
1931 WMFont *font;
1932 WMColor *color;
1934 color = WMDarkGrayColor(scr);
1935 font = WMBoldSystemFontOfSize(scr, 12);
1937 WMSetWidgetBackgroundColor(panel->fsetL, color);
1938 WMSetLabelFont(panel->fsetL, font);
1940 WMReleaseFont(font);
1941 WMReleaseColor(color);
1943 color = WMWhiteColor(scr);
1944 WMSetLabelTextColor(panel->fsetL, color);
1945 WMReleaseColor(color);
1948 panel->fsetLs = WMCreateList(panel->box);
1949 WMResizeWidget(panel->fsetLs, 245, 86);
1950 WMMoveWidget(panel->fsetLs, 265, 92);
1951 WMSetListAction(panel->fsetLs, listClick, panel);
1952 WMSetListDoubleAction(panel->fsetLs, changeButtonClick, panel);
1954 panel->addB = WMCreateCommandButton(panel->box);
1955 WMResizeWidget(panel->addB, 78, 24);
1956 WMMoveWidget(panel->addB, 265, 201);
1957 WMSetButtonText(panel->addB, _("Add..."));
1958 WMSetButtonAction(panel->addB, addButtonClick, panel);
1960 panel->editB = WMCreateCommandButton(panel->box);
1961 WMResizeWidget(panel->editB, 78, 24);
1962 WMMoveWidget(panel->editB, 348, 201);
1963 WMSetButtonText(panel->editB, _("Change..."));
1964 WMSetButtonAction(panel->editB, changeButtonClick, panel);
1966 panel->remB = WMCreateCommandButton(panel->box);
1967 WMResizeWidget(panel->remB, 78, 24);
1968 WMMoveWidget(panel->remB, 431, 201);
1969 WMSetButtonText(panel->remB, _("Remove"));
1970 WMSetButtonAction(panel->remB, removeButtonClick, panel);
1972 /* happy Up/Down buttons */
1973 panel->upB = WMCreateCommandButton(panel->box);
1974 WMResizeWidget(panel->upB, 16, 16);
1975 WMMoveWidget(panel->upB, 265, 182);
1976 WMSetButtonImage(panel->upB, panel->up_arrow);
1977 WMSetButtonAltImage(panel->upB, panel->alt_up_arrow);
1978 WMSetButtonImagePosition(panel->upB, WIPImageOnly);
1979 WMSetButtonImageDimsWhenDisabled(panel->upB, True);
1980 WMSetButtonAction(panel->upB, moveUpListItem, panel);
1982 panel->downB = WMCreateCommandButton(panel->box);
1983 WMResizeWidget(panel->downB, 16, 16);
1984 WMMoveWidget(panel->downB, 286, 182);
1985 WMSetButtonImage(panel->downB, panel->down_arrow);
1986 WMSetButtonAltImage(panel->downB, panel->alt_down_arrow);
1987 WMSetButtonImagePosition(panel->downB, WIPImageOnly);
1988 WMSetButtonImageDimsWhenDisabled(panel->downB, True);
1989 WMSetButtonAction(panel->downB, moveDownListItem, panel);
1991 /* single byte */
1992 panel->fontT = WMCreateTextField(panel->box);
1993 WMResizeWidget(panel->fontT, 245, 30);
1994 WMMoveWidget(panel->fontT, 265, 120);
1996 panel->changeB = WMCreateCommandButton(panel->box);
1997 WMResizeWidget(panel->changeB, 104, 24);
1998 WMMoveWidget(panel->changeB, 335, 160);
1999 WMSetButtonText(panel->changeB, _("Change..."));
2000 WMSetButtonAction(panel->changeB, changeButtonClick, panel);
2003 panel->black = WMBlackColor(scr);
2004 panel->white = WMWhiteColor(scr);
2005 panel->light = WMGrayColor(scr);
2006 panel->dark = WMDarkGrayColor(scr);
2007 panel->back = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
2009 /* Font Panel !!!!! */
2010 panel->fontPanel = WMGetFontPanel(scr);
2012 #if 0
2013 for (i = 0; Languages[i].language != NULL; i++) {
2014 WMAddPopUpButtonItem(panel->langP, Languages[i].language);
2017 for (i = 0; Options[i].description != NULL; i++) {
2018 WMAddListItem(panel->settingLs, Options[i].description);
2020 #endif
2021 WMRealizeWidget(panel->box);
2022 WMMapSubwidgets(panel->box);
2024 showData(panel);
2025 changePage(panel->fontSel, panel);
2028 static void
2029 storeData(Panel *p)
2031 _Panel *panel = (_Panel*)p;
2032 int i;
2034 char *encoding = getFontEncoding(panel);
2036 for(i=0;i < 6; i++)
2038 switch(i) {
2039 case 0:
2040 SetStringForKey(fontOfLang(panel, encoding, i),
2041 "WindowTitleFont");
2042 break;
2043 case 1:
2044 SetStringForKey(fontOfLang(panel, encoding, i),
2045 "LargeDisplayFont");
2046 break;
2047 case 2:
2048 SetStringForKey(fontOfLang(panel, encoding, i),
2049 "MenuTitleFont");
2050 break;
2051 case 3:
2052 SetStringForKey(fontOfLang(panel, encoding, i),
2053 "MenuTextFont");
2054 break;
2055 case 4:
2056 SetStringForKey(fontOfLang(panel, encoding, i),
2057 "ClipTitleFont");
2058 break;
2059 case 5:
2060 SetStringForKey(fontOfLang(panel, encoding, i),
2061 "IconTitleFont");
2062 break;
2066 if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
2067 SetBoolForKey(WMGetButtonSelected(panel->togAA), "AntialiasedText");
2069 if(panel->MultiByteText)
2070 SetStringForKey("YES", "MultiByteText");
2071 else {
2072 if(isEncodingMultiByte(panel)) SetStringForKey("YES", "MultiByteText");
2073 else SetStringForKey("AUTO", "MultiByteText");
2077 static void
2078 prepClosure(Panel *p)
2080 _Panel *panel = (_Panel*)p;
2081 WMFreeFontPanel(panel->fontPanel);
2082 WMReleasePropList(CurrentFontArray);
2083 /* and what ever else i've forgotten or overlooked
2084 * maybe someone will add them */
2087 Panel*
2088 InitFont(WMScreen *scr, WMWidget *parent)
2090 _Panel *panel;
2092 panel = wmalloc(sizeof(_Panel));
2093 memset(panel, 0, sizeof(_Panel));
2095 panel->sectionName = _("Font Preferences");
2096 panel->description = _("Font Configurations for Windows, Menus etc");
2098 panel->parent = parent;
2100 panel->callbacks.createWidgets = createPanel;
2101 panel->callbacks.updateDomain = storeData;
2102 panel->callbacks.prepareForClose = prepClosure;
2104 AddSection(panel, ICON_FILE);
2106 return panel;