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,
25 #include <X11/Xlocale.h>
28 typedef struct _Panel
{
34 CallbackRec callbacks
;
41 WMFontPanel
*fontPanel
;
43 WMPopUpButton
*fontSel
;
79 WMPixmap
*alt_up_arrow
;
80 WMPixmap
*alt_down_arrow
;
92 #define ICON_FILE "fonts"
94 static WMRect previewPositions
[] = {
100 {{30, 105},{90, 20}},
102 {{30, 125},{90, 20*4}},
104 {{156, 35},{64, 64}},
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",
117 "MenuTextColor", "black",
119 "ClipTitleColor", "black",
121 "ClipTitleColor", "#454045",
123 "IconTitleColor", "white",
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
139 static char *textureOptions
[] = {
149 static char * hand_xpm
[] = {
173 " .%%%&@.......... ",
174 " .%*%%&#%%%%%%%%%$. ",
175 " .*#%%%%%%%%%&&&&==. ",
176 " .-%%%%%%%%%=*-;;;#$. ",
177 " .-%%%%%%%%&..>..... ",
192 static char *up_arrow_xpm
[] = {
208 static char *down_arrow_xpm
[] = {
224 static char *alt_up_arrow_xpm
[] = {
239 static char *alt_down_arrow_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
);
289 str2rcolor(RContext
*rc
, char *name
, RColor
*color
)
293 XParseColor(rc
->dpy
, rc
->cmap
, name
, &xcolor
);
296 color
->red
= xcolor
.red
>> 8;
297 color
->green
= xcolor
.green
>> 8;
298 color
->blue
= xcolor
.blue
>> 8;
302 drawMenuBevel(RImage
*img
)
304 RColor light
, dark
, mid
;
306 int iheight
= img
->height
/ 4;
309 light
.red
= light
.green
= light
.blue
= 80;
312 dark
.red
= dark
.green
= dark
.blue
= 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
);
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
;
343 x
+= w
- 5 - WMWidthOfString(font
, text
, l
);
347 x
+= (w
- WMWidthOfString(font
, text
, l
))/2;
350 WMDrawString(scr
, d
, color
, font
, x
,
351 y
+ (h
- WMFontHeight(font
))/2, text
, l
);
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;
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
);
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
);
389 drawFonts(_Panel
*panel
, int elements
)
391 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
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"));
427 dumpRImage(char *path
, RImage
*image
)
430 int channels
= (image
->format
== RRGBAFormat
? 4 : 3);
432 f
= fopen(path
, "w");
437 fprintf(f
, "%02x%02x%1x", image
->width
, image
->height
, channels
);
439 fwrite(image
->data
, 1, image
->width
* image
->height
* channels
, f
);
447 isPixmap(WMPropList *prop)
452 p = WMGetFromPLArray(prop, 0);
453 s = WMGetFromPLString(p);
454 if (strcasecmp(&s[1], "pixmap")==0)
461 renderTexture(WMScreen
*scr
, WMPropList
*texture
, int width
, int height
,
462 char *path
, int border
)
465 RImage
*image
= NULL
;
467 RContext
*rc
= WMScreenRContext(scr
);
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) {
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));
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));
500 image
= RRenderInterwovenGradient(width
, height
, c1
, t1
, c2
, t2
);
501 } else if (strcasecmp(&type
[1], "gradient")==0) {
505 switch (toupper(type
[0])) {
507 style
= RVerticalGradient
;
510 style
= RHorizontalGradient
;
514 style
= RDiagonalGradient
;
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') {
528 RImage
*grad
, *timage
;
531 switch (toupper(type
[1])) {
533 style
= RVerticalGradient
;
536 style
= RHorizontalGradient
;
540 style
= RDiagonalGradient
;
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
));
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
);
568 } else if (strcasecmp(&type
[2], "gradient")==0 && toupper(type
[0])=='M') {
573 switch (toupper(type
[1])) {
575 style
= RVerticalGradient
;
578 style
= RHorizontalGradient
;
582 style
= RDiagonalGradient
;
586 j
= WMGetPropListItemCount(texture
);
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]);
598 image
= RRenderMultiGradient(width
, height
, colors
, style
);
600 for (i
= 0; colors
[i
]!=NULL
; i
++)
604 } else if (strcasecmp(&type
[1], "pixmap")==0) {
605 RImage
*timage
= NULL
;
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
));
618 str
= WMGetFromPLString(WMGetFromPLArray(texture
, 2));
619 str2rcolor(rc
, str
, &color
);
621 switch (toupper(type
[0])) {
623 image
= RMakeTiledImage(timage
, width
, height
);
624 RReleaseImage(timage
);
628 image
= RMakeCenteredImage(timage
, width
, height
, &color
);
629 RReleaseImage(timage
);
634 image
= RScaleImage(timage
, width
, height
);
635 RReleaseImage(timage
);
648 dumpRImage(path
, image
);
652 if (border
== MENU_BEVEL
) {
653 drawMenuBevel(image
);
654 RBevelImage(image
, RBEV_RAISED2
);
657 RBevelImage(image
, border
);
660 RConvertImage(rc
, image
, &pixmap
);
661 RReleaseImage(image
);
667 renderMenu(_Panel
*panel
, WMPropList
*texture
, int width
, int iheight
)
669 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
670 Display
*dpy
= WMScreenDisplay(scr
);
672 //RContext *rc = WMScreenRContext(scr);
673 GC gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
676 switch (panel
->menuStyle
) {
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
);
687 pix
= renderTexture(scr
, texture
, width
, iheight
*4, NULL
, MENU_BEVEL
);
690 pix
= renderTexture(scr
, texture
, width
, iheight
*4, NULL
, RBEV_RAISED2
);
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
);
715 prop
= GetObjectForKey(textureOptions
[part
]);
717 pix
= renderTexture(scr
, prop
,
718 previewPositions
[part
].size
.width
,
719 previewPositions
[part
].size
.height
,
723 original
= XGetImage(dpy
, pix
, 0, 0, 64, 64,
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
;
739 black
.red
= black
.green
= black
.blue
= 0;
742 dark
.red
= dark
.green
= dark
.blue
= 60;
745 light
.red
= light
.green
= light
.blue
= 80;
749 ROperateLine(tile
, RSubtractOperation
, tp
, 0, ICON_SIZE
-2,
751 RDrawLine(tile
, tp
-1, 0, ICON_SIZE
-1, pt
+1, &black
);
752 ROperateLine(tile
, RAddOperation
, tp
, 2, ICON_SIZE
-3,
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
,
764 ROperateLine(tile
, RAddOperation
, 2, tp
+2, pt
-2,
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
);
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,
778 RConvertImage(rc
, tile
, &pix
);
780 /* top right arrow */
781 p
[0].x
= p
[3].x
= ICON_SIZE
-5-as
;
783 p
[1].x
= ICON_SIZE
-6;
785 p
[2].x
= ICON_SIZE
-6;
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 */
792 p
[0].y
= p
[3].y
= ICON_SIZE
-5-as
;
794 p
[1].y
= ICON_SIZE
-6;
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
);
807 XFreePixmap(WMScreenDisplay(scr
), pix
);
811 renderPreview(_Panel
*panel
, GC gc
, int part
, int relief
)
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
,
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
);
834 paintPreviewBox(Panel
*panel
, int elements
)
836 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
837 Display
*dpy
= WMScreenDisplay(scr
);
840 WMColor
*black
= WMBlackColor(scr
);
843 gc
= XCreateGC(dpy
, WMWidgetXID(panel
->parent
), 0, NULL
);
845 if (panel
->preview
== None
) {
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
),
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
)) {
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
);
922 WMReleaseColor(black
);
926 paintTextField(void *data
, int section
)
928 _Panel
*panel
= (_Panel
*)data
;
929 //char *sample = NULL;
931 encoding
= WMGetPopUpButtonSelectedItem(panel
->langP
);
932 WMSetTextFieldFont(panel
->fontT
, getFontForPreview(panel
, section
));
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");
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");
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");
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");
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");
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 ÀßÄê¥æ¡¼¥Æ¥£¥ê¥Æ¥£");
959 case 6: /* Korean ksc5601.1987 */
960 WMSetTextFieldText(panel
->fontT
, getFontSampleString(panel
));
961 // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤");
963 case 7: /* korean2 daewoo */
964 WMSetTextFieldText(panel
->fontT
, getFontSampleString(panel
));
965 // "À©µµ¿ì ¸ÞÀÌÄ¿ ¼³Á¤");
967 case 8: /* Russian koi8-r */
968 WMSetTextFieldText(panel
->fontT
, getFontSampleString(panel
));
969 // "ó×ÏÊÓÔ×Á Window Maker");
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");
979 previewClick(XEvent
*event
, void *clientData
)
981 _Panel
*panel
= (_Panel
*)clientData
;
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
);
1000 changePage(WMWidget
*w
, void *data
)
1002 _Panel
*panel
= (_Panel
*)data
;
1004 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1005 RContext
*rc
= WMScreenRContext(scr
);
1006 static WMPoint positions
[] = {
1016 section
= WMGetPopUpButtonSelectedItem(panel
->fontSel
);
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
);
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
);
1038 setLanguageType(void *data
, Bool multiByte
)
1040 _Panel
*p
= (_Panel
*)data
;
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
);
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
);
1068 refillFontSetList(void *data
)
1070 _Panel
*panel
= (_Panel
*)data
;
1072 char *encoding
= getFontEncoding(panel
);
1073 int section
= WMGetPopUpButtonSelectedItem(panel
->fontSel
);
1076 WMClearList(panel
->fsetLs
);
1078 array
= getCurrentFontProp(panel
, section
);
1080 array
= getDefaultFontProp(panel
, encoding
, section
);
1083 wwarning("error not Font prop given");
1085 for (i
= 0; i
< WMGetPropListItemCount(array
); i
++) {
1086 WMGetFromPLArray(array
, i
);
1087 WMAddListItem( panel
->fsetLs
,
1089 WMGetFromPLArray(array
, i
)));
1091 WMReleasePropList(array
);
1092 WMSelectListItem(panel
->fsetLs
, 0);
1095 checkListForArrows(panel
);
1099 insertCurrentFont(char *data
, char *type
)
1105 key
= WMCreatePLString(type
);
1106 array
= WMCreatePLArray(NULL
);
1108 str
= wstrdup(data
);
1109 tmp
= strtok(str
, ",");
1111 WMAddToPLArray(array
, WMCreatePLString(tmp
));
1112 tmp
= strtok(NULL
, ",");
1117 WMPutInPLDictionary(CurrentFontArray
, key
, array
);
1121 readFontEncodings(void *data
)
1123 _Panel
*panel
= (_Panel
*)data
;
1124 WMPropList
*pl
= NULL
;
1128 path
= WMPathForResourceOfType("font.data", NULL
);
1130 msg
= _("Could not locate font information file WPrefs.app/font.data");
1134 pl
= WMReadPropListFromFile(path
);
1136 msg
= _("Could not read font information file WPrefs.app/font.data");
1140 WMPropList
*key
= WMCreatePLString("Encodings");
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.");
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
);
1194 WMReleasePropList(pl
);
1196 WMRunAlertPanel(WMWidgetScreen(panel
->parent
), panel
->parent
,
1197 _("Error"), msg
, _("OK"), NULL
, NULL
);
1201 checkListForArrows(void *data
)
1203 _Panel
*panel
= (_Panel
*)data
;
1205 list
= WMGetListNumberOfRows(panel
->fsetLs
);
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
);
1216 WMSetButtonEnabled(panel
->upB
, True
);
1217 WMSetButtonEnabled(panel
->downB
, True
);
1221 WMSetButtonEnabled(panel
->upB
, False
);
1222 WMSetButtonEnabled(panel
->downB
, False
);
1224 /* added to control the Remove button */
1226 WMSetButtonEnabled(panel
->remB
, True
);
1228 WMSetButtonEnabled(panel
->remB
, False
);
1232 fontOfLang(void *data
, char *encoding
, int section
)
1234 _Panel
*panel
= (_Panel
*)data
;
1240 array
= getCurrentFontProp(panel
, section
);
1242 array
= getDefaultFontProp(panel
, encoding
, section
);
1245 wwarning("error no font prop given");
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
);
1259 changeLanguageAction(WMWidget
*w
, void *data
)
1261 Panel
*panel
= (Panel
*)data
;
1262 //WMScreen *scr = WMWidgetScreen(panel->box);
1265 section
= WMGetPopUpButtonSelectedItem(w
);
1267 if(isEncodingMultiByte(panel
)) {
1268 setLanguageType(panel
, True
);
1270 if(panel
->MultiByteText
) setLanguageType(panel
, True
);
1271 else setLanguageType(panel
, False
);
1274 paintPreviewBox(panel
, EVERYTHING
);
1275 changePage(panel
->fontSel
, panel
);
1279 getFontForPreview(void *data
, int element
)
1281 _Panel
*panel
= (_Panel
*)data
;
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
);
1292 font
= WMCreateFont(scr
, fname
);
1295 // font = WMCreateFont(scr, fname);
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.",
1306 WMRunAlertPanel(WMWidgetScreen(panel
->parent
),panel
->parent
,
1307 _("Warning"), msg
, _("OK"), NULL
, NULL
);
1308 font
= getDefaultSystemFont(panel
, element
);
1314 getFontSampleString(void *data
)
1316 _Panel
*panel
= (_Panel
*)data
;
1317 //WMScreen *scr = WMWidgetScreen(panel->box);
1322 section
= WMGetPopUpButtonSelectedItem(panel
->langP
);
1323 mi
= WMGetPopUpButtonMenuItem(panel
->langP
, section
);
1324 pl
= WMGetMenuItemRepresentedObject(mi
);
1330 sample
= WMGetFromPLString(WMGetFromPLArray(pl
,3));
1336 getFontEncoding(void *data
)
1338 _Panel
*panel
= (_Panel
*)data
;
1339 //WMScreen *scr = WMWidgetScreen(panel->box);
1344 section
= WMGetPopUpButtonSelectedItem(panel
->langP
);
1345 mi
= WMGetPopUpButtonMenuItem(panel
->langP
, section
);
1346 pl
= WMGetMenuItemRepresentedObject(mi
);
1352 encoding
= WMGetFromPLString(WMGetFromPLArray(pl
,2));
1358 isEncodingMultiByte(void *data
)
1360 _Panel
*panel
= (_Panel
*)data
;
1361 //WMScreen *scr = WMWidgetScreen(panel->box);
1366 section
= WMGetPopUpButtonSelectedItem(panel
->langP
);
1367 mi
= WMGetPopUpButtonMenuItem(panel
->langP
, section
);
1368 pl
= WMGetMenuItemRepresentedObject(mi
);
1375 multiByte
= WMGetFromPLString(WMGetFromPLArray(pl
,1));
1376 res
= atoi(multiByte
);
1385 getCurrentFontProp(void *data
, int section
)
1390 array
= WMRetainPropList(
1391 WMGetFromPLDictionary(CurrentFontArray
,
1392 WMCreatePLString("WindowTitleFont")));
1395 array
= WMRetainPropList(
1396 WMGetFromPLDictionary(CurrentFontArray
,
1397 WMCreatePLString("LargeDisplayFont")));
1400 array
= WMRetainPropList(
1401 WMGetFromPLDictionary(CurrentFontArray
,
1402 WMCreatePLString("MenuTitleFont")));
1405 array
= WMRetainPropList(
1406 WMGetFromPLDictionary(CurrentFontArray
,
1407 WMCreatePLString("MenuTextFont")));
1410 array
= WMRetainPropList(
1411 WMGetFromPLDictionary(CurrentFontArray
,
1412 WMCreatePLString("ClipTitleFont")));
1415 array
= WMRetainPropList(
1416 WMGetFromPLDictionary(CurrentFontArray
,
1417 WMCreatePLString("IconTitleFont")));
1420 if(!WMIsPLArray(array
)) {
1428 getDefaultFontProp(void *data
, char *encoding
, int section
)
1431 WMPropList
*key
= WMCreatePLString(encoding
);
1434 array
= WMRetainPropList(
1435 WMGetFromPLDictionary(DefaultWindowTitleFont
, key
));
1436 WMReleasePropList(key
);
1439 array
= WMRetainPropList(
1440 WMGetFromPLDictionary(DefaultLargeDisplayFont
, key
));
1441 WMReleasePropList(key
);
1444 array
= WMRetainPropList(
1445 WMGetFromPLDictionary(DefaultMenuTitleFont
, key
));
1446 WMReleasePropList(key
);
1449 array
= WMRetainPropList(
1450 WMGetFromPLDictionary(DefaultMenuTextFont
, key
));
1451 WMReleasePropList(key
);
1454 array
= WMRetainPropList(
1455 WMGetFromPLDictionary(DefaultClipTitleFont
, key
));
1456 WMReleasePropList(key
);
1459 array
= WMRetainPropList(
1460 WMGetFromPLDictionary(DefaultIconTitleFont
, key
));
1461 WMReleasePropList(key
);
1464 if(!WMIsPLArray(array
)) {
1472 getDefaultSystemFont(void *data
, int element
)
1474 _Panel
*panel
= (_Panel
*)data
;
1475 WMScreen
*scr
= WMWidgetScreen(panel
->box
);
1480 return WMBoldSystemFontOfSize(scr
, 12);
1482 return WMBoldSystemFontOfSize(scr
, 24);
1485 return WMSystemFontOfSize(scr
, 8);
1488 return WMSystemFontOfSize(scr
, 12);
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
;
1501 WMSetButtonText(panel
->togMulti
, _("Auto"));
1502 if(isEncodingMultiByte(panel
)) setLanguageType(panel
, True
);
1503 else setLanguageType(panel
, False
);
1504 panel
->MultiByteText
= False
;
1509 toggleAA(WMWidget
*w
, void *data
)
1511 _Panel
*panel
= (_Panel
*)data
;
1513 if(panel
->AntialiasedText
)
1514 panel
->AntialiasedText
= False
;
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
);
1526 listClick(WMWidget
*w
, void *data
)
1528 _Panel
*panel
= (_Panel
*)data
;
1530 checkListForArrows(panel
);
1534 moveUpListItem(WMWidget
*w
, void *data
)
1536 _Panel
*panel
= (_Panel
*)data
;
1542 char *encoding
= getFontEncoding(panel
);
1543 int section
= WMGetPopUpButtonSelectedItem(panel
->fontSel
);
1546 array
= getCurrentFontProp(panel
, section
);
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
);
1569 moveDownListItem(WMWidget
*w
, void *data
)
1571 _Panel
*panel
= (_Panel
*)data
;
1577 char *encoding
= getFontEncoding(panel
);
1578 int section
= WMGetPopUpButtonSelectedItem(panel
->fontSel
);
1581 array
= getCurrentFontProp(panel
, section
);
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
);
1603 addButtonAction(WMWidget
*w
, void *data
)
1605 _Panel
*panel
= (_Panel
*)data
;
1610 char *encoding
= getFontEncoding(panel
);
1611 int section
= WMGetPopUpButtonSelectedItem(panel
->fontSel
);
1614 array
= getCurrentFontProp(panel
, section
);
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
);
1631 changeButtonAction(WMWidget
*w
, void *data
)
1633 _Panel
*panel
= (_Panel
*)data
;
1638 char *encoding
= getFontEncoding(panel
);
1639 int section
= WMGetPopUpButtonSelectedItem(panel
->fontSel
);
1642 array
= getCurrentFontProp(panel
, section
);
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
);
1663 changeButtonClick(WMWidget
*w
, void *data
)
1665 _Panel
*panel
= (_Panel
*)data
;
1667 WMSetFontPanelAction(panel
->fontPanel
, changeButtonAction
, panel
);
1668 WMShowFontPanel(panel
->fontPanel
);
1672 addButtonClick(WMWidget
*w
, void *data
)
1674 _Panel
*panel
= (_Panel
*)data
;
1676 WMSetFontPanelAction(panel
->fontPanel
, addButtonAction
, panel
);
1677 WMShowFontPanel(panel
->fontPanel
);
1681 removeButtonClick(WMWidget
*w
, void *data
)
1683 _Panel
*panel
= (_Panel
*)data
;
1687 char *encoding
= getFontEncoding(panel
);
1688 int section
= WMGetPopUpButtonSelectedItem(panel
->fontSel
);
1691 array
= getCurrentFontProp(panel
, section
);
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
);
1702 WMSelectListItem(panel
->fsetLs
, pos
);
1703 else if(list
== pos
)
1704 WMSelectListItem(panel
->fsetLs
, list
-1);
1706 WMSelectListItem(panel
->fsetLs
, 0);
1708 checkListForArrows(panel
);
1710 paintPreviewBox(panel
, EVERYTHING
);
1711 changePage(panel
->fontSel
, panel
);
1715 showData(_Panel
*panel
)
1717 //WMScreen *scr = WMWidgetScreen(panel->parent);
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
;
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
;
1759 panel
->titleAlignment
= WACenter
;
1761 for (i
= 0; i
< sizeof(colorOptions
)/(2*sizeof(char*)); i
++) {
1764 str
= GetStringForKey(colorOptions
[i
*2]);
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");
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) {
1784 locale
= setlocale(LC_CTYPE
, 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
;
1794 setLanguageType(panel
, False
);
1795 WMSetButtonText(panel
->togMulti
, "Auto");
1796 panel
->MultiByteText
= False
;
1801 locale
= setlocale(LC_CTYPE
, 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
;
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
;
1825 WMSetButtonSelected(panel
->togAA
, False
);
1826 panel
->AntialiasedText
= False
;
1829 // WMUnmapWidget(panel->togAA);
1833 paintPreviewBox(panel
, EVERYTHING
);
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
);
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
);
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
);
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
);
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
);
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
);
2013 WMRealizeWidget(panel
->box
);
2014 WMMapSubwidgets(panel
->box
);
2017 changePage(panel
->fontSel
, panel
);
2023 _Panel
*panel
= (_Panel
*)p
;
2026 char *encoding
= getFontEncoding(panel
);
2032 SetStringForKey(fontOfLang(panel
, encoding
, i
),
2036 SetStringForKey(fontOfLang(panel
, encoding
, i
),
2037 "LargeDisplayFont");
2040 SetStringForKey(fontOfLang(panel
, encoding
, i
),
2044 SetStringForKey(fontOfLang(panel
, encoding
, i
),
2048 SetStringForKey(fontOfLang(panel
, encoding
, i
),
2052 SetStringForKey(fontOfLang(panel
, encoding
, i
),
2058 //if (WMHasAntialiasingSupport(WMWidgetScreen(panel->box)))
2059 SetBoolForKey(WMGetButtonSelected(panel
->togAA
), "AntialiasedText");
2061 if(panel
->MultiByteText
)
2062 SetStringForKey("YES", "MultiByteText");
2064 if(isEncodingMultiByte(panel
)) SetStringForKey("YES", "MultiByteText");
2065 else SetStringForKey("AUTO", "MultiByteText");
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 */
2080 InitFont(WMScreen
*scr
, WMWidget
*parent
)
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
);