changed indentation to use spaces only
[wmaker-crm.git] / WPrefs.app / Font.c
blob329c3bf56dc486a1579a3e34d39f3bcdc6b204eb
1 /* Font.c- text/font settings
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1999-2003 Alfredo K. Kojima
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>
26 #include <ctype.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)) {
1288 if(panel->AntialiasedText) {
1289 // fix this -Dan font = WMCreateFontWithFlags(scr, fname, WFAntialiased);
1290 font = WMCreateFont(scr, fname);
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);
1477 switch(element) {
1478 case 0:
1479 case 2:
1480 return WMBoldSystemFontOfSize(scr, 12);
1481 case 1:
1482 return WMBoldSystemFontOfSize(scr, 24);
1483 case 4:
1484 case 5:
1485 return WMSystemFontOfSize(scr, 8);
1486 case 3:
1487 default:
1488 return WMSystemFontOfSize(scr, 12);
1492 static void
1493 multiClick(WMWidget *w, void *data)
1495 _Panel *panel = (_Panel*)data;
1496 if(!panel->MultiByteText) {
1497 WMSetButtonText(panel->togMulti, _("Yes"));
1498 setLanguageType(panel, True);
1499 panel->MultiByteText = True;
1500 } else {
1501 WMSetButtonText(panel->togMulti, _("Auto"));
1502 if(isEncodingMultiByte(panel)) setLanguageType(panel, True);
1503 else setLanguageType(panel, False);
1504 panel->MultiByteText = False;
1508 static void
1509 toggleAA(WMWidget *w, void *data)
1511 _Panel *panel = (_Panel*)data;
1512 //int section;
1513 if(panel->AntialiasedText)
1514 panel->AntialiasedText = False;
1515 else
1516 panel->AntialiasedText = True;
1517 /* hmm now i gotta redraw all the fonts in the preview section
1518 * and the text field
1520 paintPreviewBox(panel, EVERYTHING);
1521 changePage(panel->fontSel, panel);
1522 if(isEncodingMultiByte(panel)) setLanguageType(panel, True);
1525 static void
1526 listClick(WMWidget *w, void *data)
1528 _Panel *panel = (_Panel*)data;
1530 checkListForArrows(panel);
1533 static void
1534 moveUpListItem(WMWidget *w, void *data)
1536 _Panel *panel = (_Panel*)data;
1537 WMListItem *tmp;
1538 int pos;
1539 char *listtext;
1540 WMPropList *array;
1541 WMPropList *string;
1542 char *encoding = getFontEncoding(panel);
1543 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1545 if(!encoding)
1546 array = getCurrentFontProp(panel, section);
1547 else
1548 array = getDefaultFontProp(panel, encoding, section);
1550 pos = WMGetListSelectedItemRow(panel->fsetLs);
1552 tmp = WMGetListItem(panel->fsetLs, pos);
1553 listtext = wstrdup(tmp->text);
1554 string = WMCreatePLString(listtext);
1556 WMRemoveListItem(panel->fsetLs, pos);
1557 WMDeleteFromPLArray(array, pos);
1558 WMInsertListItem(panel->fsetLs, pos-1, listtext);
1559 WMInsertInPLArray(array, pos-1, string);
1561 paintPreviewBox(panel, EVERYTHING);
1562 changePage(panel->fontSel, panel);
1564 WMSelectListItem(panel->fsetLs, pos-1);
1565 checkListForArrows(panel);
1568 static void
1569 moveDownListItem(WMWidget *w, void *data)
1571 _Panel *panel = (_Panel*)data;
1572 WMListItem *tmp;
1573 int pos;
1574 char *listtext;
1575 WMPropList *array;
1576 WMPropList *string;
1577 char *encoding = getFontEncoding(panel);
1578 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1580 if(!encoding)
1581 array = getCurrentFontProp(panel, section);
1582 else
1583 array = getDefaultFontProp(panel, encoding, section);
1585 pos = WMGetListSelectedItemRow(panel->fsetLs);
1587 tmp = WMGetListItem(panel->fsetLs, pos);
1588 listtext = wstrdup(tmp->text);
1589 string = WMCreatePLString(listtext);
1590 WMRemoveListItem(panel->fsetLs, pos);
1591 WMDeleteFromPLArray(array, pos);
1592 WMInsertListItem(panel->fsetLs, pos+1, listtext);
1593 WMInsertInPLArray(array, pos+1, string);
1595 paintPreviewBox(panel, EVERYTHING);
1596 changePage(panel->fontSel, panel);
1598 WMSelectListItem(panel->fsetLs, pos+1);
1599 checkListForArrows(panel);
1602 static void
1603 addButtonAction(WMWidget *w, void *data)
1605 _Panel *panel = (_Panel*)data;
1606 char *chosenFont;
1607 int pos;
1608 WMPropList *array;
1609 WMPropList *string;
1610 char *encoding = getFontEncoding(panel);
1611 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1613 if(!encoding)
1614 array = getCurrentFontProp(panel, section);
1615 else
1616 array = getDefaultFontProp(panel, encoding, section);
1618 WMHideFontPanel(panel->fontPanel);
1619 chosenFont = WMGetFontName(WMGetFontPanelFont(panel->fontPanel));
1620 string = WMCreatePLString(chosenFont);
1621 pos = WMGetListSelectedItemRow(panel->fsetLs);
1622 WMInsertListItem(panel->fsetLs, pos+1, chosenFont);
1623 WMInsertInPLArray(array, pos+1, string);
1624 WMSelectListItem(panel->fsetLs, pos+1);
1626 paintPreviewBox(panel, EVERYTHING);
1627 changePage(panel->fontSel, panel);
1630 static void
1631 changeButtonAction(WMWidget *w, void *data)
1633 _Panel *panel = (_Panel*)data;
1634 char *chosenFont;
1635 int pos;
1636 WMPropList *array;
1637 WMPropList *string;
1638 char *encoding = getFontEncoding(panel);
1639 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1641 if(!encoding)
1642 array = getCurrentFontProp(panel, section);
1643 else
1644 array = getDefaultFontProp(panel, encoding, section);
1646 WMHideFontPanel(panel->fontPanel);
1648 chosenFont = WMGetFontName(WMGetFontPanelFont(panel->fontPanel));
1649 string = WMCreatePLString(chosenFont);
1651 pos = WMGetListSelectedItemRow(panel->fsetLs);
1652 WMRemoveListItem(panel->fsetLs, pos);
1653 WMDeleteFromPLArray(array, pos);
1654 WMInsertListItem(panel->fsetLs, pos, chosenFont);
1655 WMInsertInPLArray(array, pos, string);
1656 WMSelectListItem(panel->fsetLs, pos);
1658 paintPreviewBox(panel, EVERYTHING);
1659 changePage(panel->fontSel, panel);
1662 static void
1663 changeButtonClick(WMWidget *w, void *data)
1665 _Panel *panel = (_Panel*)data;
1667 WMSetFontPanelAction(panel->fontPanel, changeButtonAction, panel);
1668 WMShowFontPanel(panel->fontPanel);
1671 static void
1672 addButtonClick(WMWidget *w, void *data)
1674 _Panel *panel = (_Panel*)data;
1676 WMSetFontPanelAction(panel->fontPanel, addButtonAction, panel);
1677 WMShowFontPanel(panel->fontPanel);
1680 static void
1681 removeButtonClick(WMWidget *w, void *data)
1683 _Panel *panel = (_Panel*)data;
1684 int pos;
1685 int list;
1686 WMPropList *array;
1687 char *encoding = getFontEncoding(panel);
1688 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1690 if(!encoding)
1691 array = getCurrentFontProp(panel, section);
1692 else
1693 array = getDefaultFontProp(panel, encoding, section);
1695 pos = WMGetListSelectedItemRow(panel->fsetLs);
1696 WMRemoveListItem(panel->fsetLs, pos);
1697 WMDeleteFromPLArray(array, pos);
1699 list = WMGetListNumberOfRows(panel->fsetLs);
1700 if(list != 0) {
1701 if(list > pos)
1702 WMSelectListItem(panel->fsetLs, pos);
1703 else if(list == pos)
1704 WMSelectListItem(panel->fsetLs, list-1);
1705 else
1706 WMSelectListItem(panel->fsetLs, 0);
1708 checkListForArrows(panel);
1710 paintPreviewBox(panel, EVERYTHING);
1711 changePage(panel->fontSel, panel);
1714 static void
1715 showData(_Panel *panel)
1717 //WMScreen *scr = WMWidgetScreen(panel->parent);
1718 char *str;
1719 int i;
1721 CurrentFontArray = WMCreatePLDictionary(NULL, NULL);
1723 str = GetStringForKey("WindowTitleFont");
1724 insertCurrentFont(wstrdup(str), "WindowTitleFont");
1726 str = GetStringForKey("LargeDisplayFont");
1727 insertCurrentFont(wstrdup(str), "LargeDisplayFont");
1729 str = GetStringForKey("MenuTitleFont");
1730 insertCurrentFont(wstrdup(str), "MenuTitleFont");
1732 str = GetStringForKey("MenuTextFont");
1733 insertCurrentFont(wstrdup(str), "MenuTextFont");
1735 str = GetStringForKey("ClipTitleFont");
1736 insertCurrentFont(wstrdup(str), "ClipTitleFont");
1738 str = GetStringForKey("IconTitleFont");
1739 insertCurrentFont(wstrdup(str), "IconTitleFont");
1741 /* i put this here cause it needs to be known before we paint */
1742 readFontEncodings(panel);
1744 str = GetStringForKey("MenuStyle");
1745 if (str && strcasecmp(str, "flat")==0) {
1746 panel->menuStyle = MSTYLE_FLAT;
1747 } else if (str && strcasecmp(str, "singletexture")==0) {
1748 panel->menuStyle = MSTYLE_SINGLE;
1749 } else {
1750 panel->menuStyle = MSTYLE_NORMAL;
1753 str = GetStringForKey("TitleJustify");
1754 if (str && strcasecmp(str, "left")==0) {
1755 panel->titleAlignment = WALeft;
1756 } else if (str && strcasecmp(str, "right")==0) {
1757 panel->titleAlignment = WARight;
1758 } else {
1759 panel->titleAlignment = WACenter;
1761 for (i = 0; i < sizeof(colorOptions)/(2*sizeof(char*)); i++) {
1762 WMColor *color;
1764 str = GetStringForKey(colorOptions[i*2]);
1765 if (!str)
1766 str = colorOptions[i*2+1];
1768 if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
1769 color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
1771 panel->colors[i] = color;
1774 str = GetStringForKey("MultiByteText");
1775 if (str)
1777 if (strcasecmp(str, "YES")==0) {
1778 setLanguageType(panel, True);
1779 WMSetButtonText(panel->togMulti, "Yes");
1780 printf("yes multi\n");
1781 panel->MultiByteText = True;
1782 } else if (strcasecmp(str, "AUTO") == 0) {
1783 char *locale;
1784 locale = setlocale(LC_CTYPE, NULL);
1785 if(locale != NULL
1786 && (strncmp(locale, "ja", 2) == 0
1787 || strncmp(locale, "zh", 2) == 0
1788 || strncmp(locale, "ko", 2) == 0)) {
1789 setLanguageType(panel, True);
1790 WMSetButtonText(panel->togMulti, "Auto");
1791 printf("auto multi\n");
1792 panel->MultiByteText = True;
1793 } else {
1794 setLanguageType(panel, False);
1795 WMSetButtonText(panel->togMulti, "Auto");
1796 panel->MultiByteText = False;
1799 } else {
1800 char *locale;
1801 locale = setlocale(LC_CTYPE, NULL);
1802 if(locale != NULL
1803 && (strncmp(locale, "ja", 2) == 0
1804 || strncmp(locale, "zh", 2) == 0
1805 || strncmp(locale, "ko", 2) == 0)) {
1806 setLanguageType(panel, True);
1807 WMSetButtonText(panel->togMulti, "Auto");
1808 printf("auto multi\n");
1809 panel->MultiByteText = True;
1810 } else {
1811 setLanguageType(panel, False);
1812 WMSetButtonText(panel->togMulti, "Auto");
1813 panel->MultiByteText = False;
1816 /* gotta check for Antialiasing AFTER MultiByte incase the use has both
1817 * to maintain behavior in Current Fonts set or i could add another if
1818 * statement to setLanguageType =) */
1819 //if (WMHasAntialiasingSupport(scr)) {
1820 WMMapWidget(panel->togAA);
1821 if(GetBoolForKey("AntialiasedText")){
1822 WMSetButtonSelected(panel->togAA, True);
1823 panel->AntialiasedText = True;
1824 } else {
1825 WMSetButtonSelected(panel->togAA, False);
1826 panel->AntialiasedText = False;
1828 //} else {
1829 // WMUnmapWidget(panel->togAA);
1833 paintPreviewBox(panel, EVERYTHING);
1836 static void
1837 createPanel(Panel *p)
1839 _Panel *panel = (_Panel*)p;
1840 WMScreen *scr = WMWidgetScreen(panel->parent);
1843 panel->box = WMCreateBox(panel->parent);
1844 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
1846 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1847 panel->up_arrow = WMCreatePixmapFromXPMData(scr, up_arrow_xpm);
1848 panel->down_arrow = WMCreatePixmapFromXPMData(scr, down_arrow_xpm);
1849 panel->alt_up_arrow = WMCreatePixmapFromXPMData(scr, alt_up_arrow_xpm);
1850 panel->alt_down_arrow = WMCreatePixmapFromXPMData(scr, alt_down_arrow_xpm);
1852 panel->prevL = WMCreateLabel(panel->box);
1853 WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 45);
1854 WMMoveWidget(panel->prevL, 15, 35);
1855 WMSetLabelRelief(panel->prevL, WRSunken);
1856 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1858 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask,
1859 previewClick, panel);
1861 /* Widget Selection */
1862 panel->fontSel = WMCreatePopUpButton(panel->box);
1863 WMResizeWidget(panel->fontSel, 135, 20);
1864 WMMoveWidget(panel->fontSel, 15, 10);
1865 WMAddPopUpButtonItem(panel->fontSel, _("Window Title Font"));
1866 WMAddPopUpButtonItem(panel->fontSel, _("Large Display Font"));
1867 WMAddPopUpButtonItem(panel->fontSel, _("Menu Title Font"));
1868 WMAddPopUpButtonItem(panel->fontSel, _("Menu Item Font" ));
1869 WMAddPopUpButtonItem(panel->fontSel, _("Clip Title Font"));
1870 WMAddPopUpButtonItem(panel->fontSel, _("Icon Title Font"));
1872 WMSetPopUpButtonSelectedItem(panel->fontSel, 0);
1874 WMSetPopUpButtonAction(panel->fontSel, changePage, panel);
1876 /* MultiByteText toggle */
1877 panel->multiF = WMCreateFrame(panel->box);
1878 WMResizeWidget(panel->multiF, 70, 50);
1879 WMMoveWidget(panel->multiF, 440, 10);
1880 WMSetFrameTitle(panel->multiF, _("MultiByte"));
1883 panel->togMulti = WMCreateCommandButton(panel->multiF);
1884 WMResizeWidget(panel->togMulti, 40, 20);
1885 WMMoveWidget(panel->togMulti, 15, 20);
1886 WMSetButtonAction(panel->togMulti, multiClick, panel);
1888 WMMapSubwidgets(panel->multiF);
1890 /* language selection */
1891 panel->langF = WMCreateFrame(panel->box);
1892 WMResizeWidget(panel->langF, 165, 50);
1893 WMMoveWidget(panel->langF, 265, 10);
1894 WMSetFrameTitle(panel->langF, _("Default Font Encodings"));
1896 panel->langP = WMCreatePopUpButton(panel->langF);
1897 WMResizeWidget(panel->langP, 135, 20);
1898 WMMoveWidget(panel->langP, 15, 20);
1900 WMSetPopUpButtonAction(panel->langP, changeLanguageAction, panel);
1902 WMMapSubwidgets(panel->langF);
1904 /* Antialiasing */
1905 //if (WMHasAntialiasingSupport(scr)) {
1906 panel->togAA = WMCreateSwitchButton(panel->box);
1907 WMResizeWidget(panel->togAA, 110, 20);
1908 WMMoveWidget(panel->togAA, 155, 10);
1909 WMSetButtonText(panel->togAA, _("Smooth Fonts"));
1910 WMSetBalloonTextForView(_("Smooth Font edges for the eye candy\n"
1911 "requires a restart after saving"),
1912 WMWidgetView(panel->togAA));
1913 WMSetButtonAction(panel->togAA, toggleAA, panel);
1915 /* multibyte */
1916 panel->fsetL = WMCreateLabel(panel->box);
1917 WMResizeWidget(panel->fsetL, 245, 20);
1918 WMMoveWidget(panel->fsetL, 265, 70);
1919 WMSetLabelText(panel->fsetL, _("Font Set"));
1920 WMSetLabelRelief(panel->fsetL, WRSunken);
1921 WMSetLabelTextAlignment(panel->fsetL, WACenter);
1923 WMFont *font;
1924 WMColor *color;
1926 color = WMDarkGrayColor(scr);
1927 font = WMBoldSystemFontOfSize(scr, 12);
1929 WMSetWidgetBackgroundColor(panel->fsetL, color);
1930 WMSetLabelFont(panel->fsetL, font);
1932 WMReleaseFont(font);
1933 WMReleaseColor(color);
1935 color = WMWhiteColor(scr);
1936 WMSetLabelTextColor(panel->fsetL, color);
1937 WMReleaseColor(color);
1940 panel->fsetLs = WMCreateList(panel->box);
1941 WMResizeWidget(panel->fsetLs, 245, 86);
1942 WMMoveWidget(panel->fsetLs, 265, 92);
1943 WMSetListAction(panel->fsetLs, listClick, panel);
1944 WMSetListDoubleAction(panel->fsetLs, changeButtonClick, panel);
1946 panel->addB = WMCreateCommandButton(panel->box);
1947 WMResizeWidget(panel->addB, 78, 24);
1948 WMMoveWidget(panel->addB, 265, 201);
1949 WMSetButtonText(panel->addB, _("Add..."));
1950 WMSetButtonAction(panel->addB, addButtonClick, panel);
1952 panel->editB = WMCreateCommandButton(panel->box);
1953 WMResizeWidget(panel->editB, 78, 24);
1954 WMMoveWidget(panel->editB, 348, 201);
1955 WMSetButtonText(panel->editB, _("Change..."));
1956 WMSetButtonAction(panel->editB, changeButtonClick, panel);
1958 panel->remB = WMCreateCommandButton(panel->box);
1959 WMResizeWidget(panel->remB, 78, 24);
1960 WMMoveWidget(panel->remB, 431, 201);
1961 WMSetButtonText(panel->remB, _("Remove"));
1962 WMSetButtonAction(panel->remB, removeButtonClick, panel);
1964 /* happy Up/Down buttons */
1965 panel->upB = WMCreateCommandButton(panel->box);
1966 WMResizeWidget(panel->upB, 16, 16);
1967 WMMoveWidget(panel->upB, 265, 182);
1968 WMSetButtonImage(panel->upB, panel->up_arrow);
1969 WMSetButtonAltImage(panel->upB, panel->alt_up_arrow);
1970 WMSetButtonImagePosition(panel->upB, WIPImageOnly);
1971 WMSetButtonImageDimsWhenDisabled(panel->upB, True);
1972 WMSetButtonAction(panel->upB, moveUpListItem, panel);
1974 panel->downB = WMCreateCommandButton(panel->box);
1975 WMResizeWidget(panel->downB, 16, 16);
1976 WMMoveWidget(panel->downB, 286, 182);
1977 WMSetButtonImage(panel->downB, panel->down_arrow);
1978 WMSetButtonAltImage(panel->downB, panel->alt_down_arrow);
1979 WMSetButtonImagePosition(panel->downB, WIPImageOnly);
1980 WMSetButtonImageDimsWhenDisabled(panel->downB, True);
1981 WMSetButtonAction(panel->downB, moveDownListItem, panel);
1983 /* single byte */
1984 panel->fontT = WMCreateTextField(panel->box);
1985 WMResizeWidget(panel->fontT, 245, 30);
1986 WMMoveWidget(panel->fontT, 265, 120);
1988 panel->changeB = WMCreateCommandButton(panel->box);
1989 WMResizeWidget(panel->changeB, 104, 24);
1990 WMMoveWidget(panel->changeB, 335, 160);
1991 WMSetButtonText(panel->changeB, _("Change..."));
1992 WMSetButtonAction(panel->changeB, changeButtonClick, panel);
1995 panel->black = WMBlackColor(scr);
1996 panel->white = WMWhiteColor(scr);
1997 panel->light = WMGrayColor(scr);
1998 panel->dark = WMDarkGrayColor(scr);
1999 panel->back = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
2001 /* Font Panel !!!!! */
2002 panel->fontPanel = WMGetFontPanel(scr);
2004 #if 0
2005 for (i = 0; Languages[i].language != NULL; i++) {
2006 WMAddPopUpButtonItem(panel->langP, Languages[i].language);
2009 for (i = 0; Options[i].description != NULL; i++) {
2010 WMAddListItem(panel->settingLs, Options[i].description);
2012 #endif
2013 WMRealizeWidget(panel->box);
2014 WMMapSubwidgets(panel->box);
2016 showData(panel);
2017 changePage(panel->fontSel, panel);
2020 static void
2021 storeData(Panel *p)
2023 _Panel *panel = (_Panel*)p;
2024 int i;
2026 char *encoding = getFontEncoding(panel);
2028 for(i=0;i < 6; i++)
2030 switch(i) {
2031 case 0:
2032 SetStringForKey(fontOfLang(panel, encoding, i),
2033 "WindowTitleFont");
2034 break;
2035 case 1:
2036 SetStringForKey(fontOfLang(panel, encoding, i),
2037 "LargeDisplayFont");
2038 break;
2039 case 2:
2040 SetStringForKey(fontOfLang(panel, encoding, i),
2041 "MenuTitleFont");
2042 break;
2043 case 3:
2044 SetStringForKey(fontOfLang(panel, encoding, i),
2045 "MenuTextFont");
2046 break;
2047 case 4:
2048 SetStringForKey(fontOfLang(panel, encoding, i),
2049 "ClipTitleFont");
2050 break;
2051 case 5:
2052 SetStringForKey(fontOfLang(panel, encoding, i),
2053 "IconTitleFont");
2054 break;
2058 //if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
2059 SetBoolForKey(WMGetButtonSelected(panel->togAA), "AntialiasedText");
2061 if(panel->MultiByteText)
2062 SetStringForKey("YES", "MultiByteText");
2063 else {
2064 if(isEncodingMultiByte(panel)) SetStringForKey("YES", "MultiByteText");
2065 else SetStringForKey("AUTO", "MultiByteText");
2069 static void
2070 prepClosure(Panel *p)
2072 _Panel *panel = (_Panel*)p;
2073 WMFreeFontPanel(panel->fontPanel);
2074 WMReleasePropList(CurrentFontArray);
2075 /* and what ever else i've forgotten or overlooked
2076 * maybe someone will add them */
2079 Panel*
2080 InitFont(WMScreen *scr, WMWidget *parent)
2082 _Panel *panel;
2084 panel = wmalloc(sizeof(_Panel));
2085 memset(panel, 0, sizeof(_Panel));
2087 panel->sectionName = _("Font Preferences");
2088 panel->description = _("Font Configurations for Windows, Menus etc");
2090 panel->parent = parent;
2092 panel->callbacks.createWidgets = createPanel;
2093 panel->callbacks.updateDomain = storeData;
2094 panel->callbacks.prepareForClose = prepClosure;
2096 AddSection(panel, ICON_FILE);
2098 return panel;