Sensible defaults
[wmaker-crm.git] / WPrefs.app / Font.c
blob36b31a37533ae3df375245533d573eedbca64efa
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.
23 #include "WPrefs.h"
24 #include <X11/Xlocale.h>
25 #include <ctype.h>
27 typedef struct _Panel {
28 WMBox *box;
29 char *sectionName;
31 char *description;
33 CallbackRec callbacks;
35 WMWidget *parent;
37 WMLabel *prevL;
39 WMFontPanel *fontPanel;
41 WMPopUpButton *fontSel;
42 WMFrame *multiF;
43 WMButton *togMulti;
44 WMFrame *langF;
45 WMPopUpButton *langP;
46 WMFrame *aaF;
47 WMButton *togAA;
49 /* single byte */
50 WMTextField *fontT;
51 WMButton *changeB;
53 /* multibyte */
54 WMLabel *fsetL;
55 WMList *fsetLs;
57 WMButton *addB;
58 WMButton *editB;
59 WMButton *remB;
61 WMButton *upB;
62 WMButton *downB;
64 WMColor *white;
65 WMColor *black;
66 WMColor *light;
67 WMColor *dark;
69 WMColor *back;
70 WMColor *colors[9];
72 Pixmap preview;
73 WMPixmap *previewPix;
74 WMPixmap *hand;
75 WMPixmap *up_arrow;
76 WMPixmap *down_arrow;
77 WMPixmap *alt_up_arrow;
78 WMPixmap *alt_down_arrow;
80 int oldsection;
81 char menuStyle;
82 char titleAlignment;
83 Bool MultiByteText;
85 Bool AntialiasedText;
86 } _Panel;
88 #define ICON_FILE "fonts"
90 static WMRect previewPositions[] = {
91 #define WINTITLE 0
92 {{30, 10}, {190, 20}},
93 #define DISTITLE 1
94 {{30, 35}, {90, 64}},
95 #define PMTITLE 2
96 {{30, 105}, {90, 20}},
97 #define PMITEM 3
98 {{30, 125}, {90, 20 * 4}},
99 #define PCLIP 4
100 {{156, 35}, {64, 64}},
101 #define PICON 5
102 {{156, 105}, {64, 64}}
105 #define EVERYTHING 0xff
107 static char *colorOptions[] = {
108 #define FTITLE (1<<0)
109 "FTitleColor", "white",
110 #define DISCOL (1<<1) /* Display uses white always */
111 #define MTITLE (1<<2)
112 "MenuTitleColor", "white",
113 #define MITEM (1<<3)
114 "MenuTextColor", "black",
115 #define CLIP (1<<4)
116 "ClipTitleColor", "black",
117 #define CCLIP (1<<4)
118 "ClipTitleColor", "#454045",
119 #define ICONT (1<<5)
120 "IconTitleColor", "white",
121 #define ICONB (1<<5)
122 "IconTitleBack", "black"
125 #define MSTYLE_NORMAL 0
126 #define MSTYLE_SINGLE 1
127 #define MSTYLE_FLAT 2
129 #define RESIZEBAR_BEVEL -1
130 #define MENU_BEVEL -2
131 #define CLIP_BUTTON_SIZE 23
132 #define ICON_SIZE 64
134 static char *textureOptions[] = {
135 "FTitleBack",
136 NULL,
137 "MenuTitleBack",
138 "MenuTextBack",
139 "IconBack",
140 "IconBack"
143 /* XPM */
144 static char *hand_xpm[] = {
145 "22 21 19 1",
146 " c None",
147 ". c #030305",
148 "+ c #7F7F7E",
149 "@ c #B5B5B6",
150 "# c #C5C5C6",
151 "$ c #969697",
152 "% c #FDFDFB",
153 "& c #F2F2F4",
154 "* c #E5E5E4",
155 "= c #ECECEC",
156 "- c #DCDCDC",
157 "; c #D2D2D0",
158 "> c #101010",
159 ", c #767674",
160 "' c #676767",
161 ") c #535355",
162 "! c #323234",
163 "~ c #3E3C56",
164 "{ c #333147",
165 " ",
166 " ..... ",
167 " ..+@##$. ",
168 " .%%%&@.......... ",
169 " .%*%%&#%%%%%%%%%$. ",
170 " .*#%%%%%%%%%&&&&==. ",
171 " .-%%%%%%%%%=*-;;;#$. ",
172 " .-%%%%%%%%&..>..... ",
173 " >-%%%%%%%%%*#+. ",
174 " >-%%%%%%%%%*@,. ",
175 " >#%%%%%%%%%*@'. ",
176 " >$&&%%%%%%=... ",
177 " .+@@;=&%%&;$,> ",
178 " .',$@####$+). ",
179 " .!',+$++,'. ",
180 " ..>>>>>. ",
181 " ",
182 " ~~{{{~~ ",
183 " {{{{{{{{{{{ ",
184 " ~~{{{~~ ",
188 static char *up_arrow_xpm[] = {
189 "9 9 3 1",
190 ". c #acaaac",
191 "% c #525552",
192 "# c #000000",
193 "....%....",
194 "....#....",
195 "...%#%...",
196 "...###...",
197 "..%###%..",
198 "..#####..",
199 ".%#####%.",
200 ".#######.",
201 "%#######%"
204 static char *down_arrow_xpm[] = {
205 "9 9 3 1",
206 ". c #acaaac",
207 "% c #525552",
208 "# c #000000",
209 "%#######%",
210 ".#######.",
211 ".%#####%.",
212 "..#####..",
213 "..%###%..",
214 "...###...",
215 "...%#%...",
216 "....#....",
217 "....%...."
220 static char *alt_up_arrow_xpm[] = {
221 "9 9 2 1",
222 ". c #ffffff",
223 "% c #525552",
224 "....%....",
225 "....%....",
226 "...%%%...",
227 "...%%%...",
228 "..%%%%%..",
229 "..%%%%%..",
230 ".%%%%%%%.",
231 ".%%%%%%%.",
232 "%%%%%%%%%"
235 static char *alt_down_arrow_xpm[] = {
236 "9 9 2 1",
237 ". c #ffffff",
238 "% c #525552",
239 "%%%%%%%%%",
240 ".%%%%%%%.",
241 ".%%%%%%%.",
242 "..%%%%%..",
243 "..%%%%%..",
244 "...%%%...",
245 "...%%%...",
246 "....%....",
247 "....%...."
250 /* XPM */
252 static WMPropList *CurrentFontArray = NULL;
253 //static WMPropList *CurrentMenuTitleFont = NULL;
254 //static WMPropList *CurrentMenuTextFont = NULL;
255 //static WMPropList *CurrentIconTitleFont = NULL;
256 //static WMPropList *CurrentClipTitleFont = NULL;
257 //static WMPropList *CurrentLargeDisplayFont = NULL;
259 static WMPropList *DefaultWindowTitleFont = NULL;
260 static WMPropList *DefaultMenuTitleFont = NULL;
261 static WMPropList *DefaultMenuTextFont = NULL;
262 static WMPropList *DefaultIconTitleFont = NULL;
263 static WMPropList *DefaultClipTitleFont = NULL;
264 static WMPropList *DefaultLargeDisplayFont = NULL;
266 static void changePage(WMWidget * w, void *data);
267 static void setLanguageType(void *data, Bool multiByte);
268 static void refillFontSetList(void *data);
269 static void readFontEncodings(void *data);
270 static void changeLanguageAction(WMWidget * w, void *data);
271 static void checkListForArrows(void *data);
273 static char *getFontEncoding(void *data);
274 static char *getFontSampleString(void *data);
276 /* note single element */
277 static WMFont *getFontForPreview(void *data, int element);
278 static WMFont *getDefaultSystemFont(void *data, int element);
280 static WMPropList *getDefaultFontProp(void *data, char *encoding, int section);
281 static WMPropList *getCurrentFontProp(void *data, int section);
283 static Bool isEncodingMultiByte(void *data);
285 static void str2rcolor(RContext * rc, char *name, RColor * color)
287 XColor xcolor;
289 XParseColor(rc->dpy, rc->cmap, name, &xcolor);
291 color->alpha = 255;
292 color->red = xcolor.red >> 8;
293 color->green = xcolor.green >> 8;
294 color->blue = xcolor.blue >> 8;
297 static void drawMenuBevel(RImage * img)
299 RColor light, dark, mid;
300 int i;
301 int iheight = img->height / 4;
303 light.alpha = 0;
304 light.red = light.green = light.blue = 80;
306 dark.alpha = 255;
307 dark.red = dark.green = dark.blue = 0;
309 mid.alpha = 0;
310 mid.red = mid.green = mid.blue = 40;
312 for (i = 1; i < 4; i++) {
313 ROperateLine(img, RSubtractOperation, 0, i * iheight - 2, img->width - 1, i * iheight - 2, &mid);
315 RDrawLine(img, 0, i * iheight - 1, img->width - 1, i * iheight - 1, &dark);
317 ROperateLine(img, RAddOperation, 1, i * iheight, img->width - 2, i * iheight, &light);
321 static void
322 paintTitle(WMScreen * scr, Drawable d, WMColor * color, WMFont * font, int part, WMAlignment align, char *text)
324 int l = strlen(text);
325 int x = previewPositions[part].pos.x;
326 int y = previewPositions[part].pos.y;
327 int w = previewPositions[part].size.width;
328 int h = previewPositions[part].size.height;
330 switch (align) {
331 case WALeft:
332 x += 5;
333 break;
334 case WARight:
335 x += w - 5 - WMWidthOfString(font, text, l);
336 break;
337 default:
338 case WACenter:
339 x += (w - WMWidthOfString(font, text, l)) / 2;
340 break;
342 WMDrawString(scr, d, color, font, x, y + (h - WMFontHeight(font)) / 2, text, l);
345 static void paintItems(WMScreen * scr, Drawable d, WMColor * color, WMFont * font, int part, char *text)
347 int l = strlen(text);
348 int x = previewPositions[part].pos.x;
349 int y = previewPositions[part].pos.y;
350 //int w = previewPositions[part].size.width;
351 int h = previewPositions[part].size.height / 4;
352 int i;
353 for (i = 0; i < 4; i++) {
354 WMDrawString(scr, d, color, font, x + 5, y + (20 * i) + (h - WMFontHeight(font)) / 2, text, l);
358 static void
359 paintIcon(WMScreen * scr, Drawable d, WMColor * color, WMColor * Iback, WMFont * font, int part, char *text)
361 Display *dpy = WMScreenDisplay(scr);
362 int l = strlen(text);
363 int x = previewPositions[part].pos.x + 1;
364 int y = previewPositions[part].pos.y + 1;
365 int w = previewPositions[part].size.width - 2;
366 int h = WMFontHeight(font) + 2;
368 XFillRectangle(dpy, d, WMColorGC(Iback), x, y, w, h);
369 x += (w - WMWidthOfString(font, text, l)) / 2;
370 WMDrawString(scr, d, color, font, x, y + (h - WMFontHeight(font)) / 2, text, l);
374 static void drawFonts(_Panel * panel, int elements)
376 WMScreen *scr = WMWidgetScreen(panel->box);
377 WMPixmap *pixmap;
378 Pixmap d;
380 pixmap = WMGetLabelImage(panel->prevL);
381 d = WMGetPixmapXID(pixmap);
383 if (elements & FTITLE) {
384 paintTitle(scr, d, panel->colors[0], getFontForPreview(panel, WINTITLE),
385 WINTITLE, panel->titleAlignment, _("Window Title Font"));
387 if (elements & DISCOL) {
388 paintTitle(scr, d, panel->white, getFontForPreview(panel, DISTITLE),
389 DISTITLE, WACenter, _("Display"));
391 if (elements & MTITLE) {
392 paintTitle(scr, d, panel->colors[1], getFontForPreview(panel, PMTITLE),
393 PMTITLE, WALeft, _("Menu Title"));
395 if (elements & MITEM) {
396 paintItems(scr, d, panel->colors[2], getFontForPreview(panel, PMITEM), PMITEM, _("Menu Item"));
398 if (elements & CLIP) {
399 WMDrawString(scr, d, panel->colors[4], getFontForPreview(panel, PCLIP), 169, 37, "1", 1);
400 WMDrawString(scr, d, panel->colors[3],
401 getFontForPreview(panel, PCLIP), 179, 84, _("Clip title"), 10);
403 if (elements & ICONT) {
404 paintIcon(scr, d, panel->colors[5], panel->colors[6],
405 getFontForPreview(panel, PICON), PICON, _("Icon Title"));
409 static void dumpRImage(char *path, RImage * image)
411 FILE *f;
412 int channels = (image->format == RRGBAFormat ? 4 : 3);
414 f = fopen(path, "w");
415 if (!f) {
416 wsyserror(path);
417 return;
419 fprintf(f, "%02x%02x%1x", image->width, image->height, channels);
421 fwrite(image->data, 1, image->width * image->height * channels, f);
423 if (fclose(f) < 0) {
424 wsyserror(path);
428 /*static int
429 isPixmap(WMPropList *prop)
431 WMPropList *p;
432 char *s;
434 p = WMGetFromPLArray(prop, 0);
435 s = WMGetFromPLString(p);
436 if (strcasecmp(&s[1], "pixmap")==0)
437 return 1;
438 else
439 return 0;
442 static Pixmap renderTexture(WMScreen * scr, WMPropList * texture, int width, int height, char *path, int border)
444 char *type;
445 RImage *image = NULL;
446 Pixmap pixmap;
447 RContext *rc = WMScreenRContext(scr);
448 char *str;
449 RColor rcolor;
451 type = WMGetFromPLString(WMGetFromPLArray(texture, 0));
453 if (strcasecmp(type, "solid") == 0) {
455 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
457 str2rcolor(rc, str, &rcolor);
459 image = RCreateImage(width, height, False);
460 RClearImage(image, &rcolor);
461 } else if (strcasecmp(type, "igradient") == 0) {
462 int t1, t2;
463 RColor c1[2], c2[2];
465 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
466 str2rcolor(rc, str, &c1[0]);
467 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
468 str2rcolor(rc, str, &c1[1]);
469 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
470 t1 = atoi(str);
472 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
473 str2rcolor(rc, str, &c2[0]);
474 str = WMGetFromPLString(WMGetFromPLArray(texture, 5));
475 str2rcolor(rc, str, &c2[1]);
476 str = WMGetFromPLString(WMGetFromPLArray(texture, 6));
477 t2 = atoi(str);
479 image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2);
480 } else if (strcasecmp(&type[1], "gradient") == 0) {
481 int style;
482 RColor rcolor2;
484 switch (toupper(type[0])) {
485 case 'V':
486 style = RVerticalGradient;
487 break;
488 case 'H':
489 style = RHorizontalGradient;
490 break;
491 default:
492 case 'D':
493 style = RDiagonalGradient;
494 break;
497 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
498 str2rcolor(rc, str, &rcolor);
499 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
500 str2rcolor(rc, str, &rcolor2);
502 image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
503 } else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'T') {
504 int style;
505 RColor rcolor2;
506 int i;
507 RImage *grad, *timage;
508 char *path;
510 switch (toupper(type[1])) {
511 case 'V':
512 style = RVerticalGradient;
513 break;
514 case 'H':
515 style = RHorizontalGradient;
516 break;
517 default:
518 case 'D':
519 style = RDiagonalGradient;
520 break;
523 str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
524 str2rcolor(rc, str, &rcolor);
525 str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
526 str2rcolor(rc, str, &rcolor2);
528 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
530 if ((path = wfindfileinarray(GetObjectForKey("PixmapPath"), str)) != NULL)
531 timage = RLoadImage(rc, path, 0);
533 if (!path || !timage) {
534 wwarning("could not load file '%s': %s", path, RMessageForError(RErrorCode));
535 } else {
536 grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
538 image = RMakeTiledImage(timage, width, height);
539 RReleaseImage(timage);
541 i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
543 RCombineImagesWithOpaqueness(image, grad, i);
544 RReleaseImage(grad);
546 } else if (strcasecmp(&type[2], "gradient") == 0 && toupper(type[0]) == 'M') {
547 int style;
548 RColor **colors;
549 int i, j;
551 switch (toupper(type[1])) {
552 case 'V':
553 style = RVerticalGradient;
554 break;
555 case 'H':
556 style = RHorizontalGradient;
557 break;
558 default:
559 case 'D':
560 style = RDiagonalGradient;
561 break;
564 j = WMGetPropListItemCount(texture);
566 if (j > 0) {
567 colors = wmalloc(j * sizeof(RColor *));
569 for (i = 2; i < j; i++) {
570 str = WMGetFromPLString(WMGetFromPLArray(texture, i));
571 colors[i - 2] = wmalloc(sizeof(RColor));
572 str2rcolor(rc, str, colors[i - 2]);
574 colors[i - 2] = NULL;
576 image = RRenderMultiGradient(width, height, colors, style);
578 for (i = 0; colors[i] != NULL; i++)
579 wfree(colors[i]);
580 wfree(colors);
582 } else if (strcasecmp(&type[1], "pixmap") == 0) {
583 RImage *timage = NULL;
584 char *path;
585 RColor color;
587 str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
589 if ((path = wfindfileinarray(GetObjectForKey("PixmapPath"), str)) != NULL)
590 timage = RLoadImage(rc, path, 0);
592 if (!path || !timage) {
593 wwarning("could not load file '%s': %s", path ? path : str, RMessageForError(RErrorCode));
594 } else {
595 str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
596 str2rcolor(rc, str, &color);
598 switch (toupper(type[0])) {
599 case 'T':
600 image = RMakeTiledImage(timage, width, height);
601 RReleaseImage(timage);
602 timage = image;
603 break;
604 case 'C':
605 image = RMakeCenteredImage(timage, width, height, &color);
606 RReleaseImage(timage);
607 timage = image;
608 break;
609 case 'S':
610 case 'M':
611 image = RScaleImage(timage, width, height);
612 RReleaseImage(timage);
613 timage = image;
614 break;
618 wfree(path);
621 if (!image)
622 return None;
624 if (path) {
625 dumpRImage(path, image);
628 if (border < 0) {
629 if (border == MENU_BEVEL) {
630 drawMenuBevel(image);
631 RBevelImage(image, RBEV_RAISED2);
633 } else if (border) {
634 RBevelImage(image, border);
637 RConvertImage(rc, image, &pixmap);
638 RReleaseImage(image);
640 return pixmap;
643 static Pixmap renderMenu(_Panel * panel, WMPropList * texture, int width, int iheight)
645 WMScreen *scr = WMWidgetScreen(panel->parent);
646 Display *dpy = WMScreenDisplay(scr);
647 Pixmap pix, tmp;
648 //RContext *rc = WMScreenRContext(scr);
649 GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
650 int i;
652 switch (panel->menuStyle) {
653 case MSTYLE_NORMAL:
654 tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
656 pix = XCreatePixmap(dpy, tmp, width, iheight * 4, WMScreenDepth(scr));
657 for (i = 0; i < 4; i++) {
658 XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight * i);
660 XFreePixmap(dpy, tmp);
661 break;
662 case MSTYLE_SINGLE:
663 pix = renderTexture(scr, texture, width, iheight * 4, NULL, MENU_BEVEL);
664 break;
665 case MSTYLE_FLAT:
666 pix = renderTexture(scr, texture, width, iheight * 4, NULL, RBEV_RAISED2);
667 break;
669 XFreeGC(dpy, gc);
671 return pix;
674 static void renderClip(_Panel * panel, GC gc, int part, int relief)
676 WMScreen *scr = WMWidgetScreen(panel->box);
677 Display *dpy = WMScreenDisplay(scr);
678 RContext *rc = WMScreenRContext(scr);
679 WMPropList *prop;
680 Pixmap pix;
681 XImage *original;
682 XPoint p[4];
683 RImage *tile;
684 RColor black;
685 RColor dark;
686 RColor light;
687 int pt, tp;
688 int as;
690 prop = GetObjectForKey(textureOptions[part]);
692 pix = renderTexture(scr, prop,
693 previewPositions[part].size.width, previewPositions[part].size.height, NULL, relief);
695 original = XGetImage(dpy, pix, 0, 0, 64, 64, AllPlanes, ZPixmap);
696 if (!original) {
697 wwarning(_("error capturing \"original\" tile image"), RMessageForError(RErrorCode));
699 tile = RCreateImageFromXImage(rc, original, NULL);
701 XDestroyImage(original);
702 XFreePixmap(WMScreenDisplay(scr), pix);
704 pt = CLIP_BUTTON_SIZE * ICON_SIZE / 64;
705 tp = ICON_SIZE - 1 - pt;
706 as = pt - 15;
708 black.alpha = 255;
709 black.red = black.green = black.blue = 0;
711 dark.alpha = 0;
712 dark.red = dark.green = dark.blue = 60;
714 light.alpha = 0;
715 light.red = light.green = light.blue = 80;
717 /* top right */
718 ROperateLine(tile, RSubtractOperation, tp, 0, ICON_SIZE - 2, pt - 1, &dark);
719 RDrawLine(tile, tp - 1, 0, ICON_SIZE - 1, pt + 1, &black);
720 ROperateLine(tile, RAddOperation, tp, 2, ICON_SIZE - 3, pt, &light);
722 /* arrow bevel */
723 ROperateLine(tile, RSubtractOperation, ICON_SIZE - 7 - as, 4, ICON_SIZE - 5, 4, &dark);
724 ROperateLine(tile, RSubtractOperation, ICON_SIZE - 6 - as, 5, ICON_SIZE - 5, 6 + as, &dark);
725 ROperateLine(tile, RAddOperation, ICON_SIZE - 5, 4, ICON_SIZE - 5, 6 + as, &light);
727 /* bottom left */
728 ROperateLine(tile, RAddOperation, 2, tp + 2, pt - 2, ICON_SIZE - 3, &dark);
729 RDrawLine(tile, 0, tp - 1, pt + 1, ICON_SIZE - 1, &black);
730 ROperateLine(tile, RSubtractOperation, 0, tp - 2, pt + 1, ICON_SIZE - 2, &light);
732 /* arrow bevel */
733 ROperateLine(tile, RSubtractOperation, 4, ICON_SIZE - 7 - as, 4, ICON_SIZE - 5, &dark);
734 ROperateLine(tile, RSubtractOperation, 5, ICON_SIZE - 6 - as, 6 + as, ICON_SIZE - 5, &dark);
735 ROperateLine(tile, RAddOperation, 4, ICON_SIZE - 5, 6 + as, ICON_SIZE - 5, &light);
737 RConvertImage(rc, tile, &pix);
739 /* top right arrow */
740 p[0].x = p[3].x = ICON_SIZE - 5 - as;
741 p[0].y = p[3].y = 5;
742 p[1].x = ICON_SIZE - 6;
743 p[1].y = 5;
744 p[2].x = ICON_SIZE - 6;
745 p[2].y = 4 + as;
746 XFillPolygon(dpy, pix, WMColorGC(panel->colors[4]), p, 3, Convex, CoordModeOrigin);
747 XDrawLines(dpy, pix, WMColorGC(panel->colors[4]), p, 4, CoordModeOrigin);
749 /* bottom left arrow */
750 p[0].x = p[3].x = 5;
751 p[0].y = p[3].y = ICON_SIZE - 5 - as;
752 p[1].x = 5;
753 p[1].y = ICON_SIZE - 6;
754 p[2].x = 4 + as;
755 p[2].y = ICON_SIZE - 6;
756 XFillPolygon(dpy, pix, WMColorGC(panel->colors[4]), p, 3, Convex, CoordModeOrigin);
757 XDrawLines(dpy, pix, WMColorGC(panel->colors[4]), p, 4, CoordModeOrigin);
759 XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
760 previewPositions[part].size.width,
761 previewPositions[part].size.height, previewPositions[part].pos.x, previewPositions[part].pos.y);
763 RReleaseImage(tile);
764 XFreePixmap(WMScreenDisplay(scr), pix);
767 static void renderPreview(_Panel * panel, GC gc, int part, int relief)
769 WMPropList *prop;
770 Pixmap pix;
771 WMScreen *scr = WMWidgetScreen(panel->box);
773 prop = GetObjectForKey(textureOptions[part]);
775 pix = renderTexture(scr, prop,
776 previewPositions[part].size.width, previewPositions[part].size.height, NULL, relief);
777 XCopyArea(WMScreenDisplay(scr), pix,
778 panel->preview, gc, 0, 0,
779 previewPositions[part].size.width,
780 previewPositions[part].size.height, previewPositions[part].pos.x, previewPositions[part].pos.y);
782 XFreePixmap(WMScreenDisplay(scr), pix);
785 static void paintPreviewBox(Panel * panel, int elements)
787 WMScreen *scr = WMWidgetScreen(panel->parent);
788 Display *dpy = WMScreenDisplay(scr);
789 //int refresh = 0;
790 GC gc;
791 WMColor *black = WMBlackColor(scr);
792 Pixmap mitem;
794 gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
796 if (panel->preview == None) {
797 WMPixmap *pix;
799 panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
800 240 - 4, 190 - 4, WMScreenDepth(scr));
802 pix = WMCreatePixmapFromXPixmaps(scr, panel->preview, None, 240 - 4, 190 - 4, WMScreenDepth(scr));
804 WMSetLabelImage(panel->prevL, pix);
805 WMReleasePixmap(pix);
807 XFillRectangle(dpy, panel->preview, WMColorGC(panel->back), 0, 0, 240 - 4, 190 - 4);
809 if (elements & (1 << WINTITLE)) {
810 renderPreview(panel, gc, WINTITLE, RBEV_RAISED2);
811 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
812 previewPositions[WINTITLE].pos.x - 1,
813 previewPositions[WINTITLE].pos.y - 1,
814 previewPositions[WINTITLE].size.width, previewPositions[WINTITLE].size.height);
816 if (elements & (1 << DISTITLE)) {
817 XDrawRectangle(dpy, panel->preview, WMColorGC(panel->back),
818 previewPositions[DISTITLE].pos.x - 1,
819 previewPositions[DISTITLE].pos.y - 1,
820 previewPositions[DISTITLE].size.width, previewPositions[DISTITLE].size.height);
822 if (elements & (1 << PMTITLE)) {
823 renderPreview(panel, gc, PMTITLE, RBEV_RAISED2);
824 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
825 previewPositions[PMTITLE].pos.x - 1,
826 previewPositions[PMTITLE].pos.y - 1,
827 previewPositions[PMTITLE].size.width, previewPositions[PMTITLE].size.height);
829 if (elements & (1 << PMITEM)) {
830 WMPropList *prop;
832 prop = GetObjectForKey(textureOptions[PMITEM]);
833 mitem = renderMenu(panel, prop,
834 previewPositions[PMITEM].size.width, previewPositions[PMITEM].size.height / 4);
836 XCopyArea(dpy, mitem, panel->preview, gc, 0, 0,
837 previewPositions[PMITEM].size.width,
838 previewPositions[PMITEM].size.height,
839 previewPositions[PMITEM].pos.x, previewPositions[PMITEM].pos.y);
841 XFreePixmap(dpy, mitem);
843 if (elements & (1 << PMITEM | 1 << PMTITLE)) {
844 XDrawLine(dpy, panel->preview, gc, 29, 125, 29, 125 + 20 * 4 + 25);
845 XDrawLine(dpy, panel->preview, gc, 119, 125, 119, 125 + 20 * 4 + 25);
847 if (elements & (1 << PCLIP)) {
848 renderClip(panel, gc, PCLIP, RBEV_RAISED3);
849 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
850 previewPositions[PCLIP].pos.x - 1,
851 previewPositions[PCLIP].pos.y - 1,
852 previewPositions[PCLIP].size.width, previewPositions[PCLIP].size.height);
854 if (elements & (1 << PICON)) {
855 renderPreview(panel, gc, PICON, RBEV_RAISED3);
856 XDrawRectangle(dpy, panel->preview, WMColorGC(black),
857 previewPositions[PICON].pos.x - 1,
858 previewPositions[PICON].pos.y - 1,
859 previewPositions[PICON].size.width, previewPositions[PICON].size.height);
861 drawFonts(panel, elements);
862 WMRedisplayWidget(panel->prevL);
863 XFreeGC(dpy, gc);
864 WMReleaseColor(black);
867 static void paintTextField(void *data, int section)
869 _Panel *panel = (_Panel *) data;
870 //char *sample = NULL;
871 int encoding;
872 encoding = WMGetPopUpButtonSelectedItem(panel->langP);
873 WMSetTextFieldFont(panel->fontT, getFontForPreview(panel, section));
874 switch (encoding) {
875 case 0: /* Current Font in theme */
876 WMSetTextFieldText(panel->fontT,
877 "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
878 break;
879 case 1: /* default */
880 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
881 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
882 break;
883 case 2: /* latin1 iso8859-1 */
884 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
885 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
886 break;
887 case 3: /* latin2 iso8859-2 */
888 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
889 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
890 break;
891 case 4: /* Greek iso8859-7 */
892 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
893 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
894 break;
895 /* luckily all these happen to have the MultiByte chars in the same places */
896 case 5: /* Japanese jisx0208.1983 */
897 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
898 // "Window Maker ÀßÄê¥æ¡¼¥Æ¥£¥ê¥Æ¥£");
899 break;
900 case 6: /* Korean ksc5601.1987 */
901 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
902 // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤");
903 break;
904 case 7: /* korean2 daewoo */
905 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
906 // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤");
907 break;
908 case 8: /* Russian koi8-r */
909 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
910 // "ó×ÏÊÓÔ×Á Window Maker");
911 break;
912 case 9: /* Ukranian koi8-u */
913 WMSetTextFieldText(panel->fontT, getFontSampleString(panel));
914 // "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz0123456789\x00e0\x00e6\x00e7\x00eb\x00ee\x00f0\x00f1\x00f3\x00f9\x00fd\x00c0\x00c6\x00c7\x00cb\x00ce\x00d0\x00d1\x00d3\x00d9\x00dd");
915 break;
919 static void previewClick(XEvent * event, void *clientData)
921 _Panel *panel = (_Panel *) clientData;
922 int i;
924 for (i = 0; i < sizeof(previewPositions) / sizeof(WMRect); i++) {
925 if (event->xbutton.x >= previewPositions[i].pos.x
926 && event->xbutton.y >= previewPositions[i].pos.y
927 && event->xbutton.x < previewPositions[i].pos.x
928 + previewPositions[i].size.width
929 && event->xbutton.y < previewPositions[i].pos.y + previewPositions[i].size.height) {
931 WMSetPopUpButtonSelectedItem(panel->fontSel, i);
932 changePage(panel->fontSel, panel);
933 return;
938 static void changePage(WMWidget * w, void *data)
940 _Panel *panel = (_Panel *) data;
941 int section;
942 WMScreen *scr = WMWidgetScreen(panel->box);
943 RContext *rc = WMScreenRContext(scr);
944 static WMPoint positions[] = {
945 {5, 15},
946 {5, 62},
947 {5, 110},
948 {5, 140},
949 {130, 62},
950 {130, 132}
953 if (w) {
954 section = WMGetPopUpButtonSelectedItem(panel->fontSel);
957 WMColor *color;
959 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
960 XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
961 positions[panel->oldsection].x, positions[panel->oldsection].y, 22, 22);
962 WMReleaseColor(color);
964 if (w) {
965 panel->oldsection = section;
966 WMDrawPixmap(panel->hand, panel->preview, positions[section].x, positions[section].y);
968 WMRedisplayWidget(panel->prevL);
969 paintTextField(panel, section);
970 refillFontSetList(panel);
973 static void setLanguageType(void *data, Bool multiByte)
975 _Panel *p = (_Panel *) data;
977 if (multiByte) {
978 WMMapWidget(p->fsetL);
979 WMMapWidget(p->fsetLs);
980 WMMapWidget(p->addB);
981 WMMapWidget(p->editB);
982 WMMapWidget(p->remB);
983 WMMapWidget(p->upB);
984 WMMapWidget(p->downB);
986 WMUnmapWidget(p->fontT);
987 WMUnmapWidget(p->changeB);
988 } else {
989 WMUnmapWidget(p->fsetL);
990 WMUnmapWidget(p->fsetLs);
991 WMUnmapWidget(p->addB);
992 WMUnmapWidget(p->editB);
993 WMUnmapWidget(p->remB);
994 WMUnmapWidget(p->upB);
995 WMUnmapWidget(p->downB);
997 WMMapWidget(p->fontT);
998 WMMapWidget(p->changeB);
1002 static void refillFontSetList(void *data)
1004 _Panel *panel = (_Panel *) data;
1005 WMPropList *array;
1006 char *encoding = getFontEncoding(panel);
1007 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1008 int i;
1009 //int pos;
1010 WMClearList(panel->fsetLs);
1011 if (!encoding) {
1012 array = getCurrentFontProp(panel, section);
1013 } else {
1014 array = getDefaultFontProp(panel, encoding, section);
1016 if (!array) {
1017 wwarning("error not Font prop given");
1018 } else {
1019 for (i = 0; i < WMGetPropListItemCount(array); i++) {
1020 WMGetFromPLArray(array, i);
1021 WMAddListItem(panel->fsetLs, WMGetFromPLString(WMGetFromPLArray(array, i)));
1023 WMReleasePropList(array);
1024 WMSelectListItem(panel->fsetLs, 0);
1027 checkListForArrows(panel);
1030 static void insertCurrentFont(char *data, char *type)
1032 WMPropList *key;
1033 WMPropList *array;
1034 char *tmp, *str;
1036 key = WMCreatePLString(type);
1037 array = WMCreatePLArray(NULL);
1039 str = wstrdup(data);
1040 tmp = strtok(str, ",");
1041 while (tmp) {
1042 WMAddToPLArray(array, WMCreatePLString(tmp));
1043 tmp = strtok(NULL, ",");
1045 wfree(str);
1047 WMPutInPLDictionary(CurrentFontArray, key, array);
1050 static void readFontEncodings(void *data)
1052 _Panel *panel = (_Panel *) data;
1053 WMPropList *pl = NULL;
1054 char *path;
1055 char *msg;
1057 path = WMPathForResourceOfType("font.data", NULL);
1058 if (!path) {
1059 msg = _("Could not locate font information file WPrefs.app/font.data");
1060 goto error;
1063 pl = WMReadPropListFromFile(path);
1064 if (!pl) {
1065 msg = _("Could not read font information file WPrefs.app/font.data");
1066 goto error;
1067 } else {
1068 int i;
1069 WMPropList *key = WMCreatePLString("Encodings");
1070 WMPropList *array;
1071 WMMenuItem *mi;
1073 array = WMGetFromPLDictionary(pl, key);
1074 WMReleasePropList(key);
1075 if (!array || !WMIsPLArray(array)) {
1076 msg = _("Invalid data in font information file WPrefs.app/font.data.\n"
1077 "Encodings data not found.");
1078 goto error;
1081 WMAddPopUpButtonItem(panel->langP, _("Current"));
1083 for (i = 0; i < WMGetPropListItemCount(array); i++) {
1084 WMPropList *item, *str;
1086 item = WMGetFromPLArray(array, i);
1087 str = WMGetFromPLArray(item, 0);
1088 mi = WMAddPopUpButtonItem(panel->langP, WMGetFromPLString(str));
1089 WMSetMenuItemRepresentedObject(mi, WMRetainPropList(item));
1091 WMSetPopUpButtonSelectedItem(panel->langP, 0);
1093 key = WMCreatePLString("WindowTitleFont");
1094 DefaultWindowTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1095 WMReleasePropList(key);
1097 key = WMCreatePLString("MenuTitleFont");
1098 DefaultMenuTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1099 WMReleasePropList(key);
1101 key = WMCreatePLString("MenuTextFont");
1102 DefaultMenuTextFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1103 WMReleasePropList(key);
1105 key = WMCreatePLString("IconTitleFont");
1106 DefaultIconTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1107 WMReleasePropList(key);
1109 key = WMCreatePLString("ClipTitleFont");
1110 DefaultClipTitleFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1111 WMReleasePropList(key);
1113 key = WMCreatePLString("LargeDisplayFont");
1114 DefaultLargeDisplayFont = WMRetainPropList(WMGetFromPLDictionary(pl, key));
1115 WMReleasePropList(key);
1118 WMReleasePropList(pl);
1119 return;
1120 error:
1121 if (pl)
1122 WMReleasePropList(pl);
1124 WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Error"), msg, _("OK"), NULL, NULL);
1127 static void checkListForArrows(void *data)
1129 _Panel *panel = (_Panel *) data;
1130 int list;
1131 list = WMGetListNumberOfRows(panel->fsetLs);
1133 if (list > 1) {
1134 if (WMGetListSelectedItemRow(panel->fsetLs) == 0) {
1135 WMSetButtonEnabled(panel->upB, False);
1136 WMSetButtonEnabled(panel->downB, True);
1137 } else if (WMGetListSelectedItemRow(panel->fsetLs) == list - 1) {
1138 WMSetButtonEnabled(panel->downB, False);
1139 WMSetButtonEnabled(panel->upB, True);
1140 } else {
1141 WMSetButtonEnabled(panel->upB, True);
1142 WMSetButtonEnabled(panel->downB, True);
1145 } else {
1146 WMSetButtonEnabled(panel->upB, False);
1147 WMSetButtonEnabled(panel->downB, False);
1149 /* added to control the Remove button */
1150 if (list > 1)
1151 WMSetButtonEnabled(panel->remB, True);
1152 else
1153 WMSetButtonEnabled(panel->remB, False);
1156 static char *fontOfLang(void *data, char *encoding, int section)
1158 _Panel *panel = (_Panel *) data;
1159 WMPropList *array;
1160 char *buf = NULL;
1161 int i;
1163 if (!encoding)
1164 array = getCurrentFontProp(panel, section);
1165 else
1166 array = getDefaultFontProp(panel, encoding, section);
1168 if (!array) {
1169 wwarning("error no font prop given");
1170 return NULL;
1171 } else {
1172 for (i = 0; i < WMGetPropListItemCount(array); i++) {
1173 if (buf)
1174 buf = wstrconcat(buf, ",");
1175 buf = wstrconcat(buf, WMGetFromPLString(WMGetFromPLArray(array, i)));
1177 WMReleasePropList(array);
1178 return wstrdup(buf);
1182 static void changeLanguageAction(WMWidget * w, void *data)
1184 Panel *panel = (Panel *) data;
1185 //WMScreen *scr = WMWidgetScreen(panel->box);
1186 int section;
1188 section = WMGetPopUpButtonSelectedItem(w);
1190 if (isEncodingMultiByte(panel)) {
1191 setLanguageType(panel, True);
1192 } else {
1193 if (panel->MultiByteText)
1194 setLanguageType(panel, True);
1195 else
1196 setLanguageType(panel, False);
1199 paintPreviewBox(panel, EVERYTHING);
1200 changePage(panel->fontSel, panel);
1203 static WMFont *getFontForPreview(void *data, int element)
1205 _Panel *panel = (_Panel *) data;
1206 WMFont *font;
1207 char *fname;
1208 WMScreen *scr = WMWidgetScreen(panel->box);
1209 char *encoding = getFontEncoding(panel);
1210 fname = fontOfLang(panel, encoding, element);
1211 //if (WMHasAntialiasingSupport(scr)) {
1212 if (panel->AntialiasedText) {
1213 // fix this -Dan font = WMCreateFontWithFlags(scr, fname, WFAntialiased);
1214 font = WMCreateFont(scr, fname);
1215 } else {
1216 font = WMCreateFont(scr, fname);
1218 //} else {
1219 // font = WMCreateFont(scr, fname);
1221 if (!font) {
1222 char *msg;
1223 int length;
1224 length = strlen("\"") +
1225 strlen(fname) +
1226 strlen
1227 ("\" was not loaded correctly. Make sure the font is available for that encoding.\nLoadind default system font.");
1228 msg = wmalloc(length + 1);
1229 snprintf(msg, length + 1,
1230 "\"%s\" was not loaded correctly. Make sure the font is available for that encoding.\nLoading default system font.",
1231 fname);
1232 WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent,
1233 _("Warning"), msg, _("OK"), NULL, NULL);
1234 font = getDefaultSystemFont(panel, element);
1236 return font;
1239 static char *getFontSampleString(void *data)
1241 _Panel *panel = (_Panel *) data;
1242 //WMScreen *scr = WMWidgetScreen(panel->box);
1243 WMMenuItem *mi;
1244 WMPropList *pl;
1245 int section;
1247 section = WMGetPopUpButtonSelectedItem(panel->langP);
1248 mi = WMGetPopUpButtonMenuItem(panel->langP, section);
1249 pl = WMGetMenuItemRepresentedObject(mi);
1251 if (!pl) {
1252 return NULL;
1253 } else {
1254 char *sample;
1255 sample = WMGetFromPLString(WMGetFromPLArray(pl, 3));
1256 return sample;
1260 static char *getFontEncoding(void *data)
1262 _Panel *panel = (_Panel *) data;
1263 //WMScreen *scr = WMWidgetScreen(panel->box);
1264 WMMenuItem *mi;
1265 WMPropList *pl;
1266 int section;
1268 section = WMGetPopUpButtonSelectedItem(panel->langP);
1269 mi = WMGetPopUpButtonMenuItem(panel->langP, section);
1270 pl = WMGetMenuItemRepresentedObject(mi);
1272 if (!pl) {
1273 return NULL;
1274 } else {
1275 char *encoding;
1276 encoding = WMGetFromPLString(WMGetFromPLArray(pl, 2));
1277 return encoding;
1281 static Bool isEncodingMultiByte(void *data)
1283 _Panel *panel = (_Panel *) data;
1284 //WMScreen *scr = WMWidgetScreen(panel->box);
1285 WMMenuItem *mi;
1286 WMPropList *pl;
1287 int section;
1289 section = WMGetPopUpButtonSelectedItem(panel->langP);
1290 mi = WMGetPopUpButtonMenuItem(panel->langP, section);
1291 pl = WMGetMenuItemRepresentedObject(mi);
1293 if (!pl) {
1294 return False;
1295 } else {
1296 char *multiByte;
1297 int res;
1298 multiByte = WMGetFromPLString(WMGetFromPLArray(pl, 1));
1299 res = atoi(multiByte);
1300 if (res)
1301 return True;
1302 else
1303 return False;
1307 static WMPropList *getCurrentFontProp(void *data, int section)
1309 WMPropList *array;
1310 switch (section) {
1311 case 0:
1312 array = WMRetainPropList(WMGetFromPLDictionary(CurrentFontArray,
1313 WMCreatePLString("WindowTitleFont")));
1314 break;
1315 case 1:
1316 array = WMRetainPropList(WMGetFromPLDictionary(CurrentFontArray,
1317 WMCreatePLString("LargeDisplayFont")));
1318 break;
1319 case 2:
1320 array = WMRetainPropList(WMGetFromPLDictionary(CurrentFontArray,
1321 WMCreatePLString("MenuTitleFont")));
1322 break;
1323 case 3:
1324 array = WMRetainPropList(WMGetFromPLDictionary(CurrentFontArray,
1325 WMCreatePLString("MenuTextFont")));
1326 break;
1327 case 4:
1328 array = WMRetainPropList(WMGetFromPLDictionary(CurrentFontArray,
1329 WMCreatePLString("ClipTitleFont")));
1330 break;
1331 case 5:
1332 array = WMRetainPropList(WMGetFromPLDictionary(CurrentFontArray,
1333 WMCreatePLString("IconTitleFont")));
1334 break;
1336 if (!WMIsPLArray(array)) {
1337 return NULL;
1338 } else {
1339 return array;
1343 static WMPropList *getDefaultFontProp(void *data, char *encoding, int section)
1345 WMPropList *array;
1346 WMPropList *key = WMCreatePLString(encoding);
1347 switch (section) {
1348 case 0:
1349 array = WMRetainPropList(WMGetFromPLDictionary(DefaultWindowTitleFont, key));
1350 WMReleasePropList(key);
1351 break;
1352 case 1:
1353 array = WMRetainPropList(WMGetFromPLDictionary(DefaultLargeDisplayFont, key));
1354 WMReleasePropList(key);
1355 break;
1356 case 2:
1357 array = WMRetainPropList(WMGetFromPLDictionary(DefaultMenuTitleFont, key));
1358 WMReleasePropList(key);
1359 break;
1360 case 3:
1361 array = WMRetainPropList(WMGetFromPLDictionary(DefaultMenuTextFont, key));
1362 WMReleasePropList(key);
1363 break;
1364 case 4:
1365 array = WMRetainPropList(WMGetFromPLDictionary(DefaultClipTitleFont, key));
1366 WMReleasePropList(key);
1367 break;
1368 case 5:
1369 array = WMRetainPropList(WMGetFromPLDictionary(DefaultIconTitleFont, key));
1370 WMReleasePropList(key);
1371 break;
1373 if (!WMIsPLArray(array)) {
1374 return NULL;
1375 } else {
1376 return array;
1380 static WMFont *getDefaultSystemFont(void *data, int element)
1382 _Panel *panel = (_Panel *) data;
1383 WMScreen *scr = WMWidgetScreen(panel->box);
1385 switch (element) {
1386 case 0:
1387 case 2:
1388 return WMBoldSystemFontOfSize(scr, 12);
1389 case 1:
1390 return WMBoldSystemFontOfSize(scr, 24);
1391 case 4:
1392 case 5:
1393 return WMSystemFontOfSize(scr, 8);
1394 case 3:
1395 default:
1396 return WMSystemFontOfSize(scr, 12);
1400 static void multiClick(WMWidget * w, void *data)
1402 _Panel *panel = (_Panel *) data;
1403 if (!panel->MultiByteText) {
1404 WMSetButtonText(panel->togMulti, _("Yes"));
1405 setLanguageType(panel, True);
1406 panel->MultiByteText = True;
1407 } else {
1408 WMSetButtonText(panel->togMulti, _("Auto"));
1409 if (isEncodingMultiByte(panel))
1410 setLanguageType(panel, True);
1411 else
1412 setLanguageType(panel, False);
1413 panel->MultiByteText = False;
1417 static void toggleAA(WMWidget * w, void *data)
1419 _Panel *panel = (_Panel *) data;
1420 //int section;
1421 if (panel->AntialiasedText)
1422 panel->AntialiasedText = False;
1423 else
1424 panel->AntialiasedText = True;
1425 /* hmm now i gotta redraw all the fonts in the preview section
1426 * and the text field
1428 paintPreviewBox(panel, EVERYTHING);
1429 changePage(panel->fontSel, panel);
1430 if (isEncodingMultiByte(panel))
1431 setLanguageType(panel, True);
1434 static void listClick(WMWidget * w, void *data)
1436 _Panel *panel = (_Panel *) data;
1438 checkListForArrows(panel);
1441 static void moveUpListItem(WMWidget * w, void *data)
1443 _Panel *panel = (_Panel *) data;
1444 WMListItem *tmp;
1445 int pos;
1446 char *listtext;
1447 WMPropList *array;
1448 WMPropList *string;
1449 char *encoding = getFontEncoding(panel);
1450 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1452 if (!encoding)
1453 array = getCurrentFontProp(panel, section);
1454 else
1455 array = getDefaultFontProp(panel, encoding, section);
1457 pos = WMGetListSelectedItemRow(panel->fsetLs);
1459 tmp = WMGetListItem(panel->fsetLs, pos);
1460 listtext = wstrdup(tmp->text);
1461 string = WMCreatePLString(listtext);
1463 WMRemoveListItem(panel->fsetLs, pos);
1464 WMDeleteFromPLArray(array, pos);
1465 WMInsertListItem(panel->fsetLs, pos - 1, listtext);
1466 WMInsertInPLArray(array, pos - 1, string);
1468 paintPreviewBox(panel, EVERYTHING);
1469 changePage(panel->fontSel, panel);
1471 WMSelectListItem(panel->fsetLs, pos - 1);
1472 checkListForArrows(panel);
1475 static void moveDownListItem(WMWidget * w, void *data)
1477 _Panel *panel = (_Panel *) data;
1478 WMListItem *tmp;
1479 int pos;
1480 char *listtext;
1481 WMPropList *array;
1482 WMPropList *string;
1483 char *encoding = getFontEncoding(panel);
1484 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1486 if (!encoding)
1487 array = getCurrentFontProp(panel, section);
1488 else
1489 array = getDefaultFontProp(panel, encoding, section);
1491 pos = WMGetListSelectedItemRow(panel->fsetLs);
1493 tmp = WMGetListItem(panel->fsetLs, pos);
1494 listtext = wstrdup(tmp->text);
1495 string = WMCreatePLString(listtext);
1496 WMRemoveListItem(panel->fsetLs, pos);
1497 WMDeleteFromPLArray(array, pos);
1498 WMInsertListItem(panel->fsetLs, pos + 1, listtext);
1499 WMInsertInPLArray(array, pos + 1, string);
1501 paintPreviewBox(panel, EVERYTHING);
1502 changePage(panel->fontSel, panel);
1504 WMSelectListItem(panel->fsetLs, pos + 1);
1505 checkListForArrows(panel);
1508 static void addButtonAction(WMWidget * w, void *data)
1510 _Panel *panel = (_Panel *) data;
1511 char *chosenFont;
1512 int pos;
1513 WMPropList *array;
1514 WMPropList *string;
1515 char *encoding = getFontEncoding(panel);
1516 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1518 if (!encoding)
1519 array = getCurrentFontProp(panel, section);
1520 else
1521 array = getDefaultFontProp(panel, encoding, section);
1523 WMHideFontPanel(panel->fontPanel);
1524 chosenFont = WMGetFontName(WMGetFontPanelFont(panel->fontPanel));
1525 string = WMCreatePLString(chosenFont);
1526 pos = WMGetListSelectedItemRow(panel->fsetLs);
1527 WMInsertListItem(panel->fsetLs, pos + 1, chosenFont);
1528 WMInsertInPLArray(array, pos + 1, string);
1529 WMSelectListItem(panel->fsetLs, pos + 1);
1531 paintPreviewBox(panel, EVERYTHING);
1532 changePage(panel->fontSel, panel);
1535 static void changeButtonAction(WMWidget * w, void *data)
1537 _Panel *panel = (_Panel *) data;
1538 char *chosenFont;
1539 int pos;
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 WMHideFontPanel(panel->fontPanel);
1552 chosenFont = WMGetFontName(WMGetFontPanelFont(panel->fontPanel));
1553 string = WMCreatePLString(chosenFont);
1555 pos = WMGetListSelectedItemRow(panel->fsetLs);
1556 WMRemoveListItem(panel->fsetLs, pos);
1557 WMDeleteFromPLArray(array, pos);
1558 WMInsertListItem(panel->fsetLs, pos, chosenFont);
1559 WMInsertInPLArray(array, pos, string);
1560 WMSelectListItem(panel->fsetLs, pos);
1562 paintPreviewBox(panel, EVERYTHING);
1563 changePage(panel->fontSel, panel);
1566 static void changeButtonClick(WMWidget * w, void *data)
1568 _Panel *panel = (_Panel *) data;
1570 WMSetFontPanelAction(panel->fontPanel, changeButtonAction, panel);
1571 WMShowFontPanel(panel->fontPanel);
1574 static void addButtonClick(WMWidget * w, void *data)
1576 _Panel *panel = (_Panel *) data;
1578 WMSetFontPanelAction(panel->fontPanel, addButtonAction, panel);
1579 WMShowFontPanel(panel->fontPanel);
1582 static void removeButtonClick(WMWidget * w, void *data)
1584 _Panel *panel = (_Panel *) data;
1585 int pos;
1586 int list;
1587 WMPropList *array;
1588 char *encoding = getFontEncoding(panel);
1589 int section = WMGetPopUpButtonSelectedItem(panel->fontSel);
1591 if (!encoding)
1592 array = getCurrentFontProp(panel, section);
1593 else
1594 array = getDefaultFontProp(panel, encoding, section);
1596 pos = WMGetListSelectedItemRow(panel->fsetLs);
1597 WMRemoveListItem(panel->fsetLs, pos);
1598 WMDeleteFromPLArray(array, pos);
1600 list = WMGetListNumberOfRows(panel->fsetLs);
1601 if (list != 0) {
1602 if (list > pos)
1603 WMSelectListItem(panel->fsetLs, pos);
1604 else if (list == pos)
1605 WMSelectListItem(panel->fsetLs, list - 1);
1606 else
1607 WMSelectListItem(panel->fsetLs, 0);
1609 checkListForArrows(panel);
1611 paintPreviewBox(panel, EVERYTHING);
1612 changePage(panel->fontSel, panel);
1615 static void showData(_Panel * panel)
1617 //WMScreen *scr = WMWidgetScreen(panel->parent);
1618 char *str;
1619 int i;
1621 CurrentFontArray = WMCreatePLDictionary(NULL, NULL);
1623 str = GetStringForKey("WindowTitleFont");
1624 insertCurrentFont(wstrdup(str), "WindowTitleFont");
1626 str = GetStringForKey("LargeDisplayFont");
1627 insertCurrentFont(wstrdup(str), "LargeDisplayFont");
1629 str = GetStringForKey("MenuTitleFont");
1630 insertCurrentFont(wstrdup(str), "MenuTitleFont");
1632 str = GetStringForKey("MenuTextFont");
1633 insertCurrentFont(wstrdup(str), "MenuTextFont");
1635 str = GetStringForKey("ClipTitleFont");
1636 insertCurrentFont(wstrdup(str), "ClipTitleFont");
1638 str = GetStringForKey("IconTitleFont");
1639 insertCurrentFont(wstrdup(str), "IconTitleFont");
1641 /* i put this here cause it needs to be known before we paint */
1642 readFontEncodings(panel);
1644 str = GetStringForKey("MenuStyle");
1645 if (str && strcasecmp(str, "flat") == 0) {
1646 panel->menuStyle = MSTYLE_FLAT;
1647 } else if (str && strcasecmp(str, "singletexture") == 0) {
1648 panel->menuStyle = MSTYLE_SINGLE;
1649 } else {
1650 panel->menuStyle = MSTYLE_NORMAL;
1653 str = GetStringForKey("TitleJustify");
1654 if (str && strcasecmp(str, "left") == 0) {
1655 panel->titleAlignment = WALeft;
1656 } else if (str && strcasecmp(str, "right") == 0) {
1657 panel->titleAlignment = WARight;
1658 } else {
1659 panel->titleAlignment = WACenter;
1661 for (i = 0; i < sizeof(colorOptions) / (2 * sizeof(char *)); i++) {
1662 WMColor *color;
1664 str = GetStringForKey(colorOptions[i * 2]);
1665 if (!str)
1666 str = colorOptions[i * 2 + 1];
1668 if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
1669 color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
1671 panel->colors[i] = color;
1674 str = GetStringForKey("MultiByteText");
1675 if (str) {
1676 if (strcasecmp(str, "YES") == 0) {
1677 setLanguageType(panel, True);
1678 WMSetButtonText(panel->togMulti, "Yes");
1679 printf("yes multi\n");
1680 panel->MultiByteText = True;
1681 } else if (strcasecmp(str, "AUTO") == 0) {
1682 char *locale;
1683 locale = setlocale(LC_CTYPE, NULL);
1684 if (locale != NULL
1685 && (strncmp(locale, "ja", 2) == 0
1686 || strncmp(locale, "zh", 2) == 0 || strncmp(locale, "ko", 2) == 0)) {
1687 setLanguageType(panel, True);
1688 WMSetButtonText(panel->togMulti, "Auto");
1689 printf("auto multi\n");
1690 panel->MultiByteText = True;
1691 } else {
1692 setLanguageType(panel, False);
1693 WMSetButtonText(panel->togMulti, "Auto");
1694 panel->MultiByteText = False;
1697 } else {
1698 char *locale;
1699 locale = setlocale(LC_CTYPE, NULL);
1700 if (locale != NULL
1701 && (strncmp(locale, "ja", 2) == 0
1702 || strncmp(locale, "zh", 2) == 0 || strncmp(locale, "ko", 2) == 0)) {
1703 setLanguageType(panel, True);
1704 WMSetButtonText(panel->togMulti, "Auto");
1705 printf("auto multi\n");
1706 panel->MultiByteText = True;
1707 } else {
1708 setLanguageType(panel, False);
1709 WMSetButtonText(panel->togMulti, "Auto");
1710 panel->MultiByteText = False;
1713 /* gotta check for Antialiasing AFTER MultiByte incase the use has both
1714 * to maintain behavior in Current Fonts set or i could add another if
1715 * statement to setLanguageType =) */
1716 //if (WMHasAntialiasingSupport(scr)) {
1717 WMMapWidget(panel->togAA);
1718 if (GetBoolForKey("AntialiasedText")) {
1719 WMSetButtonSelected(panel->togAA, True);
1720 panel->AntialiasedText = True;
1721 } else {
1722 WMSetButtonSelected(panel->togAA, False);
1723 panel->AntialiasedText = False;
1725 //} else {
1726 // WMUnmapWidget(panel->togAA);
1729 paintPreviewBox(panel, EVERYTHING);
1732 static void createPanel(Panel * p)
1734 _Panel *panel = (_Panel *) p;
1735 WMScreen *scr = WMWidgetScreen(panel->parent);
1737 panel->box = WMCreateBox(panel->parent);
1738 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
1740 panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
1741 panel->up_arrow = WMCreatePixmapFromXPMData(scr, up_arrow_xpm);
1742 panel->down_arrow = WMCreatePixmapFromXPMData(scr, down_arrow_xpm);
1743 panel->alt_up_arrow = WMCreatePixmapFromXPMData(scr, alt_up_arrow_xpm);
1744 panel->alt_down_arrow = WMCreatePixmapFromXPMData(scr, alt_down_arrow_xpm);
1746 panel->prevL = WMCreateLabel(panel->box);
1747 WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 45);
1748 WMMoveWidget(panel->prevL, 15, 35);
1749 WMSetLabelRelief(panel->prevL, WRSunken);
1750 WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
1752 WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask, previewClick, panel);
1754 /* Widget Selection */
1755 panel->fontSel = WMCreatePopUpButton(panel->box);
1756 WMResizeWidget(panel->fontSel, 135, 20);
1757 WMMoveWidget(panel->fontSel, 15, 10);
1758 WMAddPopUpButtonItem(panel->fontSel, _("Window Title Font"));
1759 WMAddPopUpButtonItem(panel->fontSel, _("Large Display Font"));
1760 WMAddPopUpButtonItem(panel->fontSel, _("Menu Title Font"));
1761 WMAddPopUpButtonItem(panel->fontSel, _("Menu Item Font"));
1762 WMAddPopUpButtonItem(panel->fontSel, _("Clip Title Font"));
1763 WMAddPopUpButtonItem(panel->fontSel, _("Icon Title Font"));
1765 WMSetPopUpButtonSelectedItem(panel->fontSel, 0);
1767 WMSetPopUpButtonAction(panel->fontSel, changePage, panel);
1769 /* MultiByteText toggle */
1770 panel->multiF = WMCreateFrame(panel->box);
1771 WMResizeWidget(panel->multiF, 70, 50);
1772 WMMoveWidget(panel->multiF, 440, 10);
1773 WMSetFrameTitle(panel->multiF, _("MultiByte"));
1775 panel->togMulti = WMCreateCommandButton(panel->multiF);
1776 WMResizeWidget(panel->togMulti, 40, 20);
1777 WMMoveWidget(panel->togMulti, 15, 20);
1778 WMSetButtonAction(panel->togMulti, multiClick, panel);
1780 WMMapSubwidgets(panel->multiF);
1782 /* language selection */
1783 panel->langF = WMCreateFrame(panel->box);
1784 WMResizeWidget(panel->langF, 165, 50);
1785 WMMoveWidget(panel->langF, 265, 10);
1786 WMSetFrameTitle(panel->langF, _("Default Font Encodings"));
1788 panel->langP = WMCreatePopUpButton(panel->langF);
1789 WMResizeWidget(panel->langP, 135, 20);
1790 WMMoveWidget(panel->langP, 15, 20);
1792 WMSetPopUpButtonAction(panel->langP, changeLanguageAction, panel);
1794 WMMapSubwidgets(panel->langF);
1796 /* Antialiasing */
1797 //if (WMHasAntialiasingSupport(scr)) {
1798 panel->togAA = WMCreateSwitchButton(panel->box);
1799 WMResizeWidget(panel->togAA, 110, 20);
1800 WMMoveWidget(panel->togAA, 155, 10);
1801 WMSetButtonText(panel->togAA, _("Smooth Fonts"));
1802 WMSetBalloonTextForView(_("Smooth Font edges for the eye candy\n"
1803 "requires a restart after saving"), WMWidgetView(panel->togAA));
1804 WMSetButtonAction(panel->togAA, toggleAA, panel);
1806 /* multibyte */
1807 panel->fsetL = WMCreateLabel(panel->box);
1808 WMResizeWidget(panel->fsetL, 245, 20);
1809 WMMoveWidget(panel->fsetL, 265, 70);
1810 WMSetLabelText(panel->fsetL, _("Font Set"));
1811 WMSetLabelRelief(panel->fsetL, WRSunken);
1812 WMSetLabelTextAlignment(panel->fsetL, WACenter);
1814 WMFont *font;
1815 WMColor *color;
1817 color = WMDarkGrayColor(scr);
1818 font = WMBoldSystemFontOfSize(scr, 12);
1820 WMSetWidgetBackgroundColor(panel->fsetL, color);
1821 WMSetLabelFont(panel->fsetL, font);
1823 WMReleaseFont(font);
1824 WMReleaseColor(color);
1826 color = WMWhiteColor(scr);
1827 WMSetLabelTextColor(panel->fsetL, color);
1828 WMReleaseColor(color);
1831 panel->fsetLs = WMCreateList(panel->box);
1832 WMResizeWidget(panel->fsetLs, 245, 86);
1833 WMMoveWidget(panel->fsetLs, 265, 92);
1834 WMSetListAction(panel->fsetLs, listClick, panel);
1835 WMSetListDoubleAction(panel->fsetLs, changeButtonClick, panel);
1837 panel->addB = WMCreateCommandButton(panel->box);
1838 WMResizeWidget(panel->addB, 78, 24);
1839 WMMoveWidget(panel->addB, 265, 201);
1840 WMSetButtonText(panel->addB, _("Add..."));
1841 WMSetButtonAction(panel->addB, addButtonClick, panel);
1843 panel->editB = WMCreateCommandButton(panel->box);
1844 WMResizeWidget(panel->editB, 78, 24);
1845 WMMoveWidget(panel->editB, 348, 201);
1846 WMSetButtonText(panel->editB, _("Change..."));
1847 WMSetButtonAction(panel->editB, changeButtonClick, panel);
1849 panel->remB = WMCreateCommandButton(panel->box);
1850 WMResizeWidget(panel->remB, 78, 24);
1851 WMMoveWidget(panel->remB, 431, 201);
1852 WMSetButtonText(panel->remB, _("Remove"));
1853 WMSetButtonAction(panel->remB, removeButtonClick, panel);
1855 /* happy Up/Down buttons */
1856 panel->upB = WMCreateCommandButton(panel->box);
1857 WMResizeWidget(panel->upB, 16, 16);
1858 WMMoveWidget(panel->upB, 265, 182);
1859 WMSetButtonImage(panel->upB, panel->up_arrow);
1860 WMSetButtonAltImage(panel->upB, panel->alt_up_arrow);
1861 WMSetButtonImagePosition(panel->upB, WIPImageOnly);
1862 WMSetButtonImageDimsWhenDisabled(panel->upB, True);
1863 WMSetButtonAction(panel->upB, moveUpListItem, panel);
1865 panel->downB = WMCreateCommandButton(panel->box);
1866 WMResizeWidget(panel->downB, 16, 16);
1867 WMMoveWidget(panel->downB, 286, 182);
1868 WMSetButtonImage(panel->downB, panel->down_arrow);
1869 WMSetButtonAltImage(panel->downB, panel->alt_down_arrow);
1870 WMSetButtonImagePosition(panel->downB, WIPImageOnly);
1871 WMSetButtonImageDimsWhenDisabled(panel->downB, True);
1872 WMSetButtonAction(panel->downB, moveDownListItem, panel);
1874 /* single byte */
1875 panel->fontT = WMCreateTextField(panel->box);
1876 WMResizeWidget(panel->fontT, 245, 30);
1877 WMMoveWidget(panel->fontT, 265, 120);
1879 panel->changeB = WMCreateCommandButton(panel->box);
1880 WMResizeWidget(panel->changeB, 104, 24);
1881 WMMoveWidget(panel->changeB, 335, 160);
1882 WMSetButtonText(panel->changeB, _("Change..."));
1883 WMSetButtonAction(panel->changeB, changeButtonClick, panel);
1885 panel->black = WMBlackColor(scr);
1886 panel->white = WMWhiteColor(scr);
1887 panel->light = WMGrayColor(scr);
1888 panel->dark = WMDarkGrayColor(scr);
1889 panel->back = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
1891 /* Font Panel !!!!! */
1892 panel->fontPanel = WMGetFontPanel(scr);
1894 #if 0
1895 for (i = 0; Languages[i].language != NULL; i++) {
1896 WMAddPopUpButtonItem(panel->langP, Languages[i].language);
1899 for (i = 0; Options[i].description != NULL; i++) {
1900 WMAddListItem(panel->settingLs, Options[i].description);
1902 #endif
1903 WMRealizeWidget(panel->box);
1904 WMMapSubwidgets(panel->box);
1906 showData(panel);
1907 changePage(panel->fontSel, panel);
1910 static void storeData(Panel * p)
1912 _Panel *panel = (_Panel *) p;
1913 int i;
1915 char *encoding = getFontEncoding(panel);
1917 for (i = 0; i < 6; i++) {
1918 switch (i) {
1919 case 0:
1920 SetStringForKey(fontOfLang(panel, encoding, i), "WindowTitleFont");
1921 break;
1922 case 1:
1923 SetStringForKey(fontOfLang(panel, encoding, i), "LargeDisplayFont");
1924 break;
1925 case 2:
1926 SetStringForKey(fontOfLang(panel, encoding, i), "MenuTitleFont");
1927 break;
1928 case 3:
1929 SetStringForKey(fontOfLang(panel, encoding, i), "MenuTextFont");
1930 break;
1931 case 4:
1932 SetStringForKey(fontOfLang(panel, encoding, i), "ClipTitleFont");
1933 break;
1934 case 5:
1935 SetStringForKey(fontOfLang(panel, encoding, i), "IconTitleFont");
1936 break;
1940 //if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
1941 SetBoolForKey(WMGetButtonSelected(panel->togAA), "AntialiasedText");
1943 if (panel->MultiByteText)
1944 SetStringForKey("YES", "MultiByteText");
1945 else {
1946 if (isEncodingMultiByte(panel))
1947 SetStringForKey("YES", "MultiByteText");
1948 else
1949 SetStringForKey("AUTO", "MultiByteText");
1953 static void prepClosure(Panel * p)
1955 _Panel *panel = (_Panel *) p;
1956 WMFreeFontPanel(panel->fontPanel);
1957 WMReleasePropList(CurrentFontArray);
1958 /* and what ever else i've forgotten or overlooked
1959 * maybe someone will add them */
1962 Panel *InitFont(WMScreen * scr, WMWidget * parent)
1964 _Panel *panel;
1966 panel = wmalloc(sizeof(_Panel));
1967 memset(panel, 0, sizeof(_Panel));
1969 panel->sectionName = _("Font Preferences");
1970 panel->description = _("Font Configurations for Windows, Menus etc");
1972 panel->parent = parent;
1974 panel->callbacks.createWidgets = createPanel;
1975 panel->callbacks.updateDomain = storeData;
1976 panel->callbacks.prepareForClose = prepClosure;
1978 AddSection(panel, ICON_FILE);
1980 return panel;