From f9851d88f182d6d4ebcb9fe11c210d71f6a97ca7 Mon Sep 17 00:00:00 2001 From: kojima Date: Fri, 14 Jan 2000 16:41:44 +0000 Subject: [PATCH] updated font configuration panel --- WPrefs.app/Appearance.c | 96 ++++--- WPrefs.app/Font.c | 489 ++++++++++++++++++++++++++++++++++++ WPrefs.app/Makefile.am | 2 +- WPrefs.app/Makefile.in | 12 +- WPrefs.app/Text.c | 338 ------------------------- WPrefs.app/WPrefs.c | 8 +- WPrefs.app/font.data | 67 +++++ WPrefs.app/po/Makefile.in | 13 +- WPrefs.app/tiff/Makefile.in | 13 +- WPrefs.app/xpm/Makefile.in | 13 +- 10 files changed, 653 insertions(+), 398 deletions(-) create mode 100644 WPrefs.app/Font.c delete mode 100644 WPrefs.app/Text.c create mode 100644 WPrefs.app/font.data diff --git a/WPrefs.app/Appearance.c b/WPrefs.app/Appearance.c index ca31fc6d..25985aa9 100644 --- a/WPrefs.app/Appearance.c +++ b/WPrefs.app/Appearance.c @@ -225,46 +225,49 @@ static char *blueled2_xpm[] = { "..####.." }; + /* XPM */ static char * hand_xpm[] = { -"22 21 17 1", -" c None", -". c #030305", -"+ c #101010", -"@ c #535355", -"# c #7F7F7E", -"$ c #969697", -"% c #B5B5B6", -"& c #C5C5C6", -"* c #D2D2D0", -"= c #DCDCDC", -"- c #E5E5E4", -"; c #ECECEC", -"> c #767674", -", c #F2F2F4", -"' c #676767", -") c #FDFDFB", -"! c #323234", +"22 21 19 1", +" c None", +". c #030305", +"+ c #7F7F7E", +"@ c #B5B5B6", +"# c #C5C5C6", +"$ c #969697", +"% c #FDFDFB", +"& c #F2F2F4", +"* c #E5E5E4", +"= c #ECECEC", +"- c #DCDCDC", +"; c #D2D2D0", +"> c #101010", +", c #767674", +"' c #676767", +") c #535355", +"! c #323234", +"~ c #3E3C56", +"{ c #333147", " ", " ..... ", -" ..#%&&$. ", -" .))),%.......... ", -" .)-)),&)))))))))$. ", -" .-&))))))))),,,,;;. ", -" .=)))))))));-=***&$. ", -" .=)))))))),..+..... ", -" +=)))))))))-&#. ", -" +=)))))))))-%>. ", -" +&)))))))))-%'. ", -" +$,,))))));... ", -" .#%%*;,)),*$>+ ", -" .'>$%&&&&$#@. ", -" .!'>#$##>'. ", -" ..+++++. ", +" ..+@##$. ", +" .%%%&@.......... ", +" .%*%%&#%%%%%%%%%$. ", +" .*#%%%%%%%%%&&&&==. ", +" .-%%%%%%%%%=*-;;;#$. ", +" .-%%%%%%%%&..>..... ", +" >-%%%%%%%%%*#+. ", +" >-%%%%%%%%%*@,. ", +" >#%%%%%%%%%*@'. ", +" >$&&%%%%%%=... ", +" .+@@;=&%%&;$,> ", +" .',$@####$+). ", +" .!',+$++,'. ", +" ..>>>>>. ", " ", -" ##@@@## ", -" @@@@@@@@@@@ ", -" >>@@@## ", +" ~~{{{~~ ", +" {{{{{{{{{{{ ", +" ~~{{{~~ ", " "}; @@ -768,6 +771,7 @@ updatePreviewBox(_Panel *panel, int elements) Pixmap pix; GC gc; int colorUpdate = 0; + WMColor *black = WMBlackColor(scr); gc = XCreateGC(dpy, WMWidgetXID(panel->win), 0, NULL); @@ -778,7 +782,7 @@ updatePreviewBox(_Panel *panel, int elements) panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->win), 240-4, 215-4, WMScreenDepth(scr)); - color = WMGrayColor(scr); + color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); XFillRectangle(dpy, panel->preview, WMColorGC(color), 0, 0, 240-4, 215-4); WMReleaseColor(color); @@ -789,14 +793,29 @@ updatePreviewBox(_Panel *panel, int elements) if (elements & (1<preview, WMColorGC(black), + previewPositions[PFOCUSED].pos.x-1, + previewPositions[PFOCUSED].pos.y-1, + previewPositions[PFOCUSED].size.width, + previewPositions[PFOCUSED].size.height); colorUpdate |= FTITLE_COL; } if (elements & (1<preview, WMColorGC(black), + previewPositions[PUNFOCUSED].pos.x-1, + previewPositions[PUNFOCUSED].pos.y-1, + previewPositions[PUNFOCUSED].size.width, + previewPositions[PUNFOCUSED].size.height); colorUpdate |= UTITLE_COL; } if (elements & (1<preview, WMColorGC(black), + previewPositions[POWNER].pos.x-1, + previewPositions[POWNER].pos.y-1, + previewPositions[POWNER].size.width, + previewPositions[POWNER].size.height); colorUpdate |= OTITLE_COL; } if (elements & (1<dpy, panel->preview, WMColorGC(color), positions[panel->oldsection].x, positions[panel->oldsection].y, 22, 22); @@ -1432,7 +1452,7 @@ changeColorPage(WMWidget *w, void *data) if (panel->preview) { WMColor *color; - color = WMGrayColor(scr); + color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); XFillRectangle(rc->dpy, panel->preview, WMColorGC(color), positions[panel->oldcsection].x, positions[panel->oldcsection].y, 22, 22); diff --git a/WPrefs.app/Font.c b/WPrefs.app/Font.c new file mode 100644 index 00000000..5bdb6a37 --- /dev/null +++ b/WPrefs.app/Font.c @@ -0,0 +1,489 @@ +/* Font.c- text/font settings + * + * WPrefs - Window Maker Preferences Program + * + * Copyright (c) 1999 Alfredo K. Kojima + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + + +#include "WPrefs.h" + +#include + +typedef struct _Panel { + WMFrame *frame; + char *sectionName; + + char *description; + + CallbackRec callbacks; + + WMWindow *win; + + + WMLabel *prevL; + + WMFrame *langF; + WMPopUpButton *langP; + + /* single byte */ + WMTextField *fontT; + WMButton *changeB; + + /* multibyte */ + WMLabel *fsetL; + WMList *fsetLs; + + WMButton *addB; + WMButton *editB; + WMButton *remB; + + + WMFont *windowTitleFont; + WMFont *menuTitleFont; + WMFont *menuItemFont; + + + WMColor *white; + WMColor *black; + WMColor *light; + WMColor *dark; + + WMColor *back; + + Pixmap preview; + WMPixmap *previewPix; +} _Panel; + + + +#define ICON_FILE "fonts" + + + +static proplist_t DefaultWindowTitleFont = NULL; +static proplist_t DefaultMenuTitleFont = NULL; +static proplist_t DefaultMenuTextFont = NULL; +static proplist_t DefaultIconTitleFont = NULL; +static proplist_t DefaultClipTitleFont = NULL; +static proplist_t DefaultDisplayFont = NULL; + + + +static void +drawMenuItem(WMScreen *scr, Display *dpy, Drawable d, + int x, int y, int w, int h, + GC light, GC dark, GC black, GC white, + WMFont *font, int fh, char *text) +{ + XFillRectangle(dpy, d, light, x, y, w, h); + + XDrawLine(dpy, d, black, x, y, x, y+h); + XDrawLine(dpy, d, black, x+w, y, x+w, y+h); + + XDrawLine(dpy, d, white, x+1, y, x+1, y+h-1); + XDrawLine(dpy, d, white, x+1, y, x+w-1, y); + + XDrawLine(dpy, d, dark, x+w-1, y+1, x+w-1, y+h-3); + XDrawLine(dpy, d, dark, x+1, y+h-2, x+w-1, y+h-2); + + XDrawLine(dpy, d, black, x, y+h-1, x+w, y+h-1); + + WMDrawString(scr, d, black, font, x + 5, y+(h-fh)/2, + text, strlen(text)); +} + + + +static void +paintPreviewBox(Panel *panel) +{ + WMScreen *scr = WMWidgetScreen(panel->win); + Display *dpy = WMScreenDisplay(scr); + GC black = WMColorGC(panel->black); + GC white = WMColorGC(panel->white); + GC dark = WMColorGC(panel->dark); + GC light = WMColorGC(panel->light); + + + if (panel->preview == None) { + WMPixmap *pix; + + panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->win), + 240-4, 215-4, WMScreenDepth(scr)); + + pix = WMCreatePixmapFromXPixmaps(scr, panel->preview, None, + 240-4, 215-4, WMScreenDepth(scr)); + + WMSetLabelImage(panel->prevL, pix); + WMReleasePixmap(pix); + } + + XFillRectangle(dpy, panel->preview, WMColorGC(panel->back), + 0, 0, 240-4, 215-4); + + /* window title */ + { + int h, fh; + + fh = WMFontHeight(panel->windowTitleFont); + h = fh+6; + + XFillRectangle(dpy, panel->preview, black, + 19, 19, 203, h+3); + + XDrawLine(dpy, panel->preview, light, + 20, 20, 220, 20); + XDrawLine(dpy, panel->preview, light, + 20, 20, 20, 20+h); + + XDrawLine(dpy, panel->preview, dark, + 20, 20+h, 220, 20+h); + XDrawLine(dpy, panel->preview, dark, + 220, 20, 220, 20+h); + + WMDrawString(scr, panel->preview, white, panel->windowTitleFont, + 20+(200-WMWidthOfString(panel->windowTitleFont, "Window Titlebar", 15))/2, + 20+(h-fh)/2, "Window Titlebar", 15); + } + + /* menu title */ + { + int h, h2, fh, fh2; + int i; + const mx = 20; + const my = 120; + const mw = 100; + + + fh = WMFontHeight(panel->menuTitleFont); + h = fh+6; + + XFillRectangle(dpy, panel->preview, black, + mx-1, my-1, mw+3, h+3); + + XDrawLine(dpy, panel->preview, light, + mx, my, mx+mw, my); + XDrawLine(dpy, panel->preview, light, + mx, my, mx, my+h); + + XDrawLine(dpy, panel->preview, dark, + mx, my+h, mx+mw, my+h); + XDrawLine(dpy, panel->preview, dark, + mx+mw, my, mx+mw, my+h); + + WMDrawString(scr, panel->preview, white, panel->menuTitleFont, + mx+5, my+(h-fh)/2, "Menu Title", 10); + + fh2 = WMFontHeight(panel->menuItemFont); + h2 = fh2+6; + + /* menu items */ + for (i = 0; i < 4; i++) { + drawMenuItem(scr, dpy, panel->preview, + mx-1, my+2+h+i*h2, mw+2, h2, + light, dark, black, white, + panel->menuItemFont, fh2, + "Menu Item"); + } + } + + + WMRedisplayWidget(panel->prevL); +} + + + +static void +showData(_Panel *panel) +{ + WMScreen *scr = WMWidgetScreen(panel->win); + char *str; + + str = GetStringForKey("WindowTitleFont"); + + panel->windowTitleFont = WMCreateFont(scr, str); + + + str = GetStringForKey("MenuTitleFont"); + + panel->menuTitleFont = WMCreateFont(scr, str); + + + str = GetStringForKey("MenuTextFont"); + + panel->menuItemFont = WMCreateFont(scr, str); + + + + + paintPreviewBox(panel); +} + + +static void +setLanguageType(Panel *p, Bool multiByte) +{ + if (multiByte) { + WMMapWidget(p->fsetL); + WMMapWidget(p->fsetLs); + WMMapWidget(p->addB); + WMMapWidget(p->editB); + WMMapWidget(p->remB); + + WMUnmapWidget(p->fontT); + WMUnmapWidget(p->changeB); + } else { + WMUnmapWidget(p->fsetL); + WMUnmapWidget(p->fsetLs); + WMUnmapWidget(p->addB); + WMUnmapWidget(p->editB); + WMUnmapWidget(p->remB); + + WMMapWidget(p->fontT); + WMMapWidget(p->changeB); + } +} + + + + + + +static void +readFontEncodings(Panel *panel) +{ + proplist_t pl = NULL; + char *path; + char *msg; + + path = WMPathForResourceOfType("font.data", NULL); + if (!path) { + msg = _("Could not locate font information file WPrefs.app/font.data"); + goto error; + } + + pl = PLGetProplistWithPath(path); + if (!pl) { + msg = _("Could not read font information file WPrefs.app/font.data"); + goto error; + } else { + int i; + proplist_t key = PLMakeString("Encodings"); + proplist_t array; + WMMenuItem *mi; + + array = PLGetDictionaryEntry(pl, key); + PLRelease(key); + if (!array || !PLIsArray(array)) { + msg = _("Invalid data in font information file WPrefs.app/font.data.\n" + "Encodings data not found."); + goto error; + } + + WMAddPopUpButtonItem(panel->langP, _("- Custom -")); + + for (i = 0; i < PLGetNumberOfElements(array); i++) { + proplist_t item, str; + + item = PLGetArrayElement(array, i); + str = PLGetArrayElement(item, 0); + mi = WMAddPopUpButtonItem(panel->langP, PLGetString(str)); + WMSetMenuItemRepresentedObject(mi, PLRetain(item)); + } + + key = PLMakeString("WindowTitleFont"); + DefaultWindowTitleFont = PLGetDictionaryEntry(pl, key); + PLRelease(key); + + key = PLMakeString("MenuTitleFont"); + DefaultMenuTitleFont = PLGetDictionaryEntry(pl, key); + PLRelease(key); + + key = PLMakeString("MenuTextFont"); + DefaultMenuTextFont = PLGetDictionaryEntry(pl, key); + PLRelease(key); + } + + PLRelease(pl); + return; +error: + if (pl) + PLRelease(pl); + + WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win, + _("Error"), msg, _("OK"), NULL, NULL); +} + + + +static void +changeLanguageAction(WMWidget *w, void *data) +{ + Panel *panel = (Panel*)data; + WMMenuItem *mi; + proplist_t pl, font; + char buffer[512]; + + mi = WMGetPopUpButtonMenuItem(w, WMGetPopUpButtonSelectedItem(w)); + pl = WMGetMenuItemRepresentedObject(mi); + + if (!pl) { + /* custom */ + } else { + + } +} + + +static void +createPanel(Panel *p) +{ + _Panel *panel = (_Panel*)p; + WMScreen *scr = WMWidgetScreen(panel->win); + + panel->frame = WMCreateFrame(panel->win); + WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT); + WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP); + + + panel->prevL = WMCreateLabel(panel->frame); + WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT-20); + WMMoveWidget(panel->prevL, 15, 10); + WMSetLabelRelief(panel->prevL, WRSunken); + WMSetLabelImagePosition(panel->prevL, WIPImageOnly); + + + /* language selection */ + + panel->langF = WMCreateFrame(panel->frame); + WMResizeWidget(panel->langF, 245, 50); + WMMoveWidget(panel->langF, 265, 10); + WMSetFrameTitle(panel->langF, _("Default Font Sets")); + + panel->langP = WMCreatePopUpButton(panel->langF); + WMResizeWidget(panel->langP, 215, 20); + WMMoveWidget(panel->langP, 15, 20); + + WMMapSubwidgets(panel->langF); + + + /* multibyte */ + panel->fsetL = WMCreateLabel(panel->frame); + WMResizeWidget(panel->fsetL, 205, 20); + WMMoveWidget(panel->fsetL, 215, 127); + WMSetLabelText(panel->fsetL, _("Font Set")); + WMSetLabelRelief(panel->fsetL, WRSunken); + WMSetLabelTextAlignment(panel->fsetL, WACenter); + { + WMFont *font; + WMColor *color; + + color = WMDarkGrayColor(scr); + font = WMBoldSystemFontOfSize(scr, 12); + + WMSetWidgetBackgroundColor(panel->fsetL, color); + WMSetLabelFont(panel->fsetL, font); + + WMReleaseFont(font); + WMReleaseColor(color); + + color = WMWhiteColor(scr); + WMSetLabelTextColor(panel->fsetL, color); + WMReleaseColor(color); + } + + panel->fsetLs = WMCreateList(panel->frame); + WMResizeWidget(panel->fsetLs, 205, 71); + WMMoveWidget(panel->fsetLs, 215, 149); + + + panel->addB = WMCreateCommandButton(panel->frame); + WMResizeWidget(panel->addB, 80, 24); + WMMoveWidget(panel->addB, 430, 127); + WMSetButtonText(panel->addB, _("Add...")); + + panel->editB = WMCreateCommandButton(panel->frame); + WMResizeWidget(panel->editB, 80, 24); + WMMoveWidget(panel->editB, 430, 161); + WMSetButtonText(panel->editB, _("Change...")); + + panel->remB = WMCreateCommandButton(panel->frame); + WMResizeWidget(panel->remB, 80, 24); + WMMoveWidget(panel->remB, 430, 195); + WMSetButtonText(panel->remB, _("Remove")); + + /* single byte */ + panel->fontT = WMCreateTextField(panel->frame); + WMResizeWidget(panel->fontT, 240, 20); + WMMoveWidget(panel->fontT, 265, 130); + + panel->changeB = WMCreateCommandButton(panel->frame); + WMResizeWidget(panel->changeB, 104, 24); + WMMoveWidget(panel->changeB, 335, 160); + WMSetButtonText(panel->changeB, _("Change...")); + + + panel->black = WMBlackColor(scr); + panel->white = WMWhiteColor(scr); + panel->light = WMGrayColor(scr); + panel->dark = WMDarkGrayColor(scr); + panel->back = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True); + +#if 0 + for (i = 0; Languages[i].language != NULL; i++) { + WMAddPopUpButtonItem(panel->langP, Languages[i].language); + } + + for (i = 0; Options[i].description != NULL; i++) { + WMAddListItem(panel->settingLs, Options[i].description); + } +#endif + WMRealizeWidget(panel->frame); + WMMapSubwidgets(panel->frame); + + setLanguageType(panel, False); + + showData(panel); + + readFontEncodings(panel); +} + + + + +Panel* +InitFont(WMScreen *scr, WMWindow *win) +{ + _Panel *panel; + + panel = wmalloc(sizeof(_Panel)); + memset(panel, 0, sizeof(_Panel)); + + panel->sectionName = _("Font Preferences"); + panel->description = _("Font Configurations for Windows, Menus etc"); + + panel->win = win; + + panel->callbacks.createWidgets = createPanel; + + AddSection(panel, ICON_FILE); + + return panel; +} + diff --git a/WPrefs.app/Makefile.am b/WPrefs.app/Makefile.am index ce61edf0..29b95aeb 100644 --- a/WPrefs.app/Makefile.am +++ b/WPrefs.app/Makefile.am @@ -20,6 +20,7 @@ WPrefs_SOURCES = \ Configurations.c \ Expert.c \ Focus.c \ + Font.c \ Icons.c \ KeyboardSettings.c \ KeyboardShortcuts.c \ @@ -29,7 +30,6 @@ WPrefs_SOURCES = \ NoMenuAlert.c \ Paths.c \ Preferences.c \ - Text.c \ TexturePanel.c \ TexturePanel.h \ Themes.c \ diff --git a/WPrefs.app/Makefile.in b/WPrefs.app/Makefile.in index 7b3603b1..afd9dd86 100644 --- a/WPrefs.app/Makefile.in +++ b/WPrefs.app/Makefile.in @@ -107,7 +107,7 @@ wpdata_DATA = WPrefs.tiff WPrefs.xpm EXTRA_DIST = $(wpdata_DATA) -WPrefs_SOURCES = main.c WPrefs.c WPrefs.h Appearance.c Configurations.c Expert.c Focus.c Icons.c KeyboardSettings.c KeyboardShortcuts.c Menu.c MenuPreferences.c MouseSettings.c NoMenuAlert.c Paths.c Preferences.c Text.c TexturePanel.c TexturePanel.h Themes.c WindowHandling.c Workspace.c double.c double.h editmenu.c editmenu.h MenuGuru.c xmodifier.c +WPrefs_SOURCES = main.c WPrefs.c WPrefs.h Appearance.c Configurations.c Expert.c Focus.c Font.c Icons.c KeyboardSettings.c KeyboardShortcuts.c Menu.c MenuPreferences.c MouseSettings.c NoMenuAlert.c Paths.c Preferences.c TexturePanel.c TexturePanel.h Themes.c WindowHandling.c Workspace.c double.c double.h editmenu.c editmenu.h MenuGuru.c xmodifier.c CPPFLAGS = @CPPFLAGS@ -DLOCALEDIR=\"$(NLSDIR)\" @@ -132,9 +132,9 @@ X_CFLAGS = @X_CFLAGS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ WPrefs_OBJECTS = main.o WPrefs.o Appearance.o Configurations.o Expert.o \ -Focus.o Icons.o KeyboardSettings.o KeyboardShortcuts.o Menu.o \ +Focus.o Font.o Icons.o KeyboardSettings.o KeyboardShortcuts.o Menu.o \ MenuPreferences.o MouseSettings.o NoMenuAlert.o Paths.o Preferences.o \ -Text.o TexturePanel.o Themes.o WindowHandling.o Workspace.o double.o \ +TexturePanel.o Themes.o WindowHandling.o Workspace.o double.o \ editmenu.o MenuGuru.o xmodifier.o WPrefs_LDFLAGS = CFLAGS = @CFLAGS@ @@ -149,7 +149,7 @@ DIST_COMMON = README Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best SOURCES = $(WPrefs_SOURCES) OBJECTS = $(WPrefs_OBJECTS) @@ -158,7 +158,7 @@ all: all-redirect .SUFFIXES: .SUFFIXES: .S .c .lo .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps WPrefs.app/Makefile + cd $(top_srcdir) && $(AUTOMAKE) --gnu WPrefs.app/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ @@ -348,7 +348,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/WPrefs.app/Text.c b/WPrefs.app/Text.c deleted file mode 100644 index 2e61669b..00000000 --- a/WPrefs.app/Text.c +++ /dev/null @@ -1,338 +0,0 @@ -/* Text.c- text/font settings - * - * WPrefs - Window Maker Preferences Program - * - * Copyright (c) 1998 Alfredo K. Kojima - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - - -#include "WPrefs.h" - -typedef struct _Panel { - WMFrame *frame; - char *sectionName; - - char *description; - - CallbackRec callbacks; - - WMWindow *win; - - WMPopUpButton *secP; - WMButton *setB; - - WMTextField *nameT; - - WMLabel *sampleL; - - WMFrame *alignF; - WMButton *leftB; - WMButton *centerB; - WMButton *rightB; - - - /**/ - WMFont *windowF; - char *windowFont; - WMFont *menuF; - char *menuFont; - WMFont *itemF; - char *itemFont; - WMFont *clipF; - char *clipFont; - WMFont *iconF; - char *iconFont; - WMFont *geoF; - char *geoFont; -} _Panel; - - - -#define ICON_FILE "fonts" - - - - -static void -changePage(WMWidget *w, void *data) -{ - _Panel *panel = (_Panel*)data; - int sect; - - sect = WMGetPopUpButtonSelectedItem(w); - - if (sect == 0) { - WMMapWidget(panel->alignF); - } else { - WMUnmapWidget(panel->alignF); - } - - switch (sect) { - case 0: - WMSetTextFieldText(panel->nameT, panel->windowFont); - WMSetLabelFont(panel->sampleL, panel->windowF); - break; - case 1: - WMSetTextFieldText(panel->nameT, panel->menuFont); - WMSetLabelFont(panel->sampleL, panel->menuF); - break; - case 2: - WMSetTextFieldText(panel->nameT, panel->itemFont); - WMSetLabelFont(panel->sampleL, panel->itemF); - break; - case 3: - WMSetTextFieldText(panel->nameT, panel->iconFont); - WMSetLabelFont(panel->sampleL, panel->iconF); - break; - case 4: - WMSetTextFieldText(panel->nameT, panel->clipFont); - WMSetLabelFont(panel->sampleL, panel->clipF); - break; - case 5: - WMSetTextFieldText(panel->nameT, panel->geoFont); - WMSetLabelFont(panel->sampleL, panel->geoF); - break; - } -} - - -static void -showData(_Panel *panel) -{ - WMScreen *scr = WMWidgetScreen(panel->win); - char *str; - - str = GetStringForKey("WindowTitleFont"); - if (!str) - str = "-*-helvetica-bold-r-normal-*-12-*"; - panel->windowF = WMCreateFont(scr, str); - panel->windowFont = wstrdup(str); - - str = GetStringForKey("MenuTitleFont"); - if (!str) - str = "-*-helvetica-bold-r-normal-*-12-*"; - panel->menuF = WMCreateFont(scr, str); - panel->menuFont = wstrdup(str); - - str = GetStringForKey("MenuTextFont"); - if (!str) - str = "-*-helvetica-medium-r-normal-*-12-*"; - panel->itemF = WMCreateFont(scr, str); - panel->itemFont = wstrdup(str); - - str = GetStringForKey("IconTitleFont"); - if (!str) - str = "-*-helvetica-medium-r-normal-*-8-*"; - panel->iconF = WMCreateFont(scr, str); - panel->iconFont = wstrdup(str); - - str = GetStringForKey("ClipTitleFont"); - if (!str) - str = "-*-helvetica-medium-r-normal-*-10-*"; - panel->clipF = WMCreateFont(scr, str); - panel->clipFont = wstrdup(str); - - str = GetStringForKey("DisplayFont"); - if (!str) - str = "-*-helvetica-medium-r-normal-*-12-*"; - panel->geoF = WMCreateFont(scr, str); - panel->geoFont = wstrdup(str); - - str = GetStringForKey("TitleJustify"); - if (strcasecmp(str,"left")==0) - WMPerformButtonClick(panel->leftB); - else if (strcasecmp(str,"center")==0) - WMPerformButtonClick(panel->centerB); - else if (strcasecmp(str,"right")==0) - WMPerformButtonClick(panel->rightB); - - changePage(panel->secP, panel); -} - - -static void -editedName(void *data, WMNotification *notification) -{ - _Panel *panel = (_Panel*)data; - - if ((int)WMGetNotificationClientData(notification)==WMReturnTextMovement) { - char *name; - WMFont *font; - char buffer[256]; - - name = WMGetTextFieldText(panel->nameT); - font = WMCreateFont(WMWidgetScreen(panel->win), name); - if (!font) { - sprintf(buffer, _("Invalid font %s."), name); - WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win, - _("Error"), buffer, _("OK"), NULL, NULL); - free(name); - } else { - int sect; - - sect = WMGetPopUpButtonSelectedItem(panel->secP); - - switch (sect) { - case 0: - if (panel->windowFont) - free(panel->windowFont); - panel->windowFont = name; - if (panel->windowF) - WMReleaseFont(panel->windowF); - panel->windowF = font; - break; - case 1: - if (panel->menuFont) - free(panel->menuFont); - panel->menuFont = name; - if (panel->menuF) - WMReleaseFont(panel->menuF); - panel->menuF = font; - break; - case 2: - if (panel->itemFont) - free(panel->itemFont); - panel->itemFont = name; - if (panel->itemF) - WMReleaseFont(panel->itemF); - panel->itemF = font; - break; - case 3: - if (panel->iconFont) - free(panel->iconFont); - panel->iconFont = name; - if (panel->iconF) - WMReleaseFont(panel->iconF); - panel->iconF = font; - break; - case 4: - if (panel->clipFont) - free(panel->clipFont); - panel->clipFont = name; - if (panel->clipF) - WMReleaseFont(panel->clipF); - panel->clipF = font; - break; - case 5: - if (panel->geoFont) - free(panel->geoFont); - panel->geoFont = name; - if (panel->geoF) - WMReleaseFont(panel->geoF); - panel->geoF = font; - break; - } - changePage(panel->secP, panel); - } - } -} - - -static void -createPanel(Panel *p) -{ - _Panel *panel = (_Panel*)p; - - panel->frame = WMCreateFrame(panel->win); - WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT); - WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP); - - panel->setB = WMCreateCommandButton(panel->frame); - WMResizeWidget(panel->setB, 145, 20); - WMMoveWidget(panel->setB, 50, 25); - WMSetButtonText(panel->setB, _("Set Font...")); - - panel->secP = WMCreatePopUpButton(panel->frame); - WMResizeWidget(panel->secP, 260, 20); - WMMoveWidget(panel->secP, 205, 25); - WMSetPopUpButtonAction(panel->secP, changePage, panel); - WMAddPopUpButtonItem(panel->secP, _("Window Title Font")); - WMAddPopUpButtonItem(panel->secP, _("Menu Title Font")); - WMAddPopUpButtonItem(panel->secP, _("Menu Item Font")); - WMAddPopUpButtonItem(panel->secP, _("Icon Title Font")); - WMAddPopUpButtonItem(panel->secP, _("Clip Title Font")); - WMAddPopUpButtonItem(panel->secP, _("Geometry Display Font")); - WMSetPopUpButtonSelectedItem(panel->secP, 0); - - panel->nameT = WMCreateTextField(panel->frame); - WMResizeWidget(panel->nameT, 285, 24); - WMMoveWidget(panel->nameT, 50, 80); - WMAddNotificationObserver(editedName, panel, - WMTextDidEndEditingNotification, panel->nameT); - - panel->sampleL = WMCreateLabel(panel->frame); - WMResizeWidget(panel->sampleL, 285, 85); - WMMoveWidget(panel->sampleL, 50, 135); - WMSetLabelRelief(panel->sampleL, WRSunken); - WMSetLabelText(panel->sampleL, _("Sample Text\nabcdefghijklmnopqrstuvxywz\nABCDEFGHIJKLMNOPQRSTUVXYWZ\n0123456789")); - - panel->alignF = WMCreateFrame(panel->frame); - WMResizeWidget(panel->alignF, 120, 160); - WMMoveWidget(panel->alignF, 345, 60); - WMSetFrameTitle(panel->alignF, _("Alignment")); - - panel->leftB = WMCreateButton(panel->alignF, WBTOnOff); - WMResizeWidget(panel->leftB, 100, 24); - WMMoveWidget(panel->leftB, 10, 25); - WMSetButtonText(panel->leftB, _("Left")); - WMSetButtonTextAlignment(panel->leftB, WALeft); - - panel->centerB = WMCreateButton(panel->alignF, WBTOnOff); - WMResizeWidget(panel->centerB, 100, 24); - WMMoveWidget(panel->centerB, 10, 70); - WMSetButtonText(panel->centerB, _("Center")); - WMSetButtonTextAlignment(panel->centerB, WACenter); - WMGroupButtons(panel->leftB, panel->centerB); - - panel->rightB = WMCreateButton(panel->alignF, WBTOnOff); - WMResizeWidget(panel->rightB, 100, 24); - WMMoveWidget(panel->rightB, 10, 115); - WMSetButtonText(panel->rightB, _("Right")); - WMSetButtonTextAlignment(panel->rightB, WARight); - WMGroupButtons(panel->leftB, panel->rightB); - - WMMapSubwidgets(panel->alignF); - - WMRealizeWidget(panel->frame); - WMMapSubwidgets(panel->frame); - - showData(panel); -} - - - -Panel* -InitText(WMScreen *scr, WMWindow *win) -{ - _Panel *panel; - - panel = wmalloc(sizeof(_Panel)); - memset(panel, 0, sizeof(_Panel)); - - panel->sectionName = _("Text Preferences"); -/* panel->description =*/ - - panel->win = win; - - panel->callbacks.createWidgets = createPanel; - - AddSection(panel, ICON_FILE); - - return panel; -} - diff --git a/WPrefs.app/WPrefs.c b/WPrefs.app/WPrefs.c index 76fd6c67..a9be39c9 100644 --- a/WPrefs.app/WPrefs.c +++ b/WPrefs.app/WPrefs.c @@ -39,7 +39,7 @@ extern Panel *InitFocus(WMScreen *scr, WMWindow *win); extern Panel *InitPreferences(WMScreen *scr, WMWindow *win); -extern Panel *InitText(WMScreen *scr, WMWindow *win); +extern Panel *InitFont(WMScreen *scr, WMWindow *win); extern Panel *InitConfigurations(WMScreen *scr, WMWindow *win); @@ -594,9 +594,11 @@ Initialize(WMScreen *scr) InitMouseSettings(scr, WPrefs.win); InitAppearance(scr, WPrefs.win); - + +#ifdef akk + InitFont(scr, WPrefs.win); +#endif #ifdef not_yet_fully_implemented - InitText(scr, WPrefs.win); InitThemes(scr, WPrefs.win); #endif InitExpert(scr, WPrefs.win); diff --git a/WPrefs.app/font.data b/WPrefs.app/font.data new file mode 100644 index 00000000..19561c7b --- /dev/null +++ b/WPrefs.app/font.data @@ -0,0 +1,67 @@ +{ + Encodings = (("default", 0, "iso8859-1", + "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz\n1234567890"), + ("latin1 iso8859-1", 0, "iso8859-1", + "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz\n1234567890"), + ("latin2 iso8859-2", 0, "iso8859-2", + "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz\n1234567890"), + ("Greek iso8859-7", 0, "iso8859-7", + "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz\n1234567890"), + ("Japanese jis", 1, "jis", + "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz\n1234567890"), + ("Korean ksc5601", 1, "ksc5601", + "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz\n1234567890"), + ("Russian koi8", 0, "koi8", + "ABCDEFGHIKLMNOPQRSTUVXYWZabcdefghiklmnopqrstuvxywz\n1234567890") + ); + + WindowTitleFont = { + "iso8859-1" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-iso8859-1"); + "iso8859-2" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-iso8859-2"); + "iso8859-7" = ("-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-7"); + "jis" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*", + "-*-*-medium-r-normal-*-14-*", + "-*-*-medium-r-normal-*-*-*"); + "ksc5601" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*", + "-*-kodig-medium-r-normal--12-*-*-*-*-*-*-*", + "-*-*-medium-r-normal--12-*-*-*-*-*-*-*", + "-*-*-medium-r-normal--*-*-*-*-*-*-*-*", + "-*-*-*-r-normal--*-*-*-*-*-*-*-*", + "-*-*-*-*-*--*-*-*-*-*-*-*-*","*"); + "koi8" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-koi8-r"); + }; + + MenuTitleFont = { + "iso8859-1" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-iso8859-1"); + "iso8859-2" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-iso8859-2"); + "iso8859-7" = ("-*-helvetica-bold-r-normal-*-14-*-*-*-*-*-iso8859-7"); + "jis" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*", + "-*-*-medium-r-normal-*-14-*", + "-*-*-medium-r-normal-*-*-*"); + "ksc5601" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*", + "-*-kodig-medium-r-normal--12-*-*-*-*-*-*-*", + "-*-*-medium-r-normal--12-*-*-*-*-*-*-*", + "-*-*-medium-r-normal--*-*-*-*-*-*-*-*", + "-*-*-*-r-normal--*-*-*-*-*-*-*-*", + "-*-*-*-*-*--*-*-*-*-*-*-*-*","*"); + "koi8" = ("-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-koi8-r"); + }; + + MenuTextFont = { + "iso8859-1" = ("-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-iso8859-1"); + "iso8859-2" = ("-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-iso8859-2"); + "iso8859-7" = ("-*-helvetica-medium-r-normal-*-14-*-*-*-*-*-iso8859-7"); + "jis" = ("-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*", + "-*-*-medium-r-medium-*-14-*", + "-*-*-medium-r-medium-*-*-*"); + "ksc5601" = ("-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*", + "-*-kodig-medium-r-normal--12-*-*-*-*-*-*-*", + "-*-*-medium-r-normal--12-*-*-*-*-*-*-*", + "-*-*-medium-r-normal--*-*-*-*-*-*-*-*", + "-*-*-*-r-normal--*-*-*-*-*-*-*-*", + "-*-*-*-*-*--*-*-*-*-*-*-*-*","*"); + "koi8" = ("-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-koi8-r"); + }; +} + + diff --git a/WPrefs.app/po/Makefile.in b/WPrefs.app/po/Makefile.in index 742112e6..a48b479f 100644 --- a/WPrefs.app/po/Makefile.in +++ b/WPrefs.app/po/Makefile.in @@ -119,15 +119,15 @@ DIST_COMMON = README Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: .SUFFIXES: .mo .po $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps WPrefs.app/po/Makefile + cd $(top_srcdir) && $(AUTOMAKE) --gnu WPrefs.app/po/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -140,10 +140,15 @@ distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = WPrefs.app/po distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu WPrefs.app/po/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/WPrefs.app/tiff/Makefile.in b/WPrefs.app/tiff/Makefile.in index dc456409..c4752d1e 100644 --- a/WPrefs.app/tiff/Makefile.in +++ b/WPrefs.app/tiff/Makefile.in @@ -109,14 +109,14 @@ DIST_COMMON = README Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps WPrefs.app/tiff/Makefile + cd $(top_srcdir) && $(AUTOMAKE) --gnu WPrefs.app/tiff/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -148,10 +148,15 @@ distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = WPrefs.app/tiff distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu WPrefs.app/tiff/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/WPrefs.app/xpm/Makefile.in b/WPrefs.app/xpm/Makefile.in index b71ed514..8379a2df 100644 --- a/WPrefs.app/xpm/Makefile.in +++ b/WPrefs.app/xpm/Makefile.in @@ -109,14 +109,14 @@ DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar +TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps WPrefs.app/xpm/Makefile + cd $(top_srcdir) && $(AUTOMAKE) --gnu WPrefs.app/xpm/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -148,10 +148,15 @@ distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = WPrefs.app/xpm distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu WPrefs.app/xpm/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pr $$/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \