From d5fbe62dddf634a2b639a54b42043e3a11bf36bd Mon Sep 17 00:00:00 2001 From: kojima Date: Wed, 22 Sep 1999 02:09:42 +0000 Subject: [PATCH] fixed font bug in WINGs font panel problems po file problems misc bugs --- WINGs/ChangeLog | 6 ++ WINGs/Makefile.am | 2 +- WINGs/Makefile.in | 4 +- WINGs/README | 3 +- WINGs/WINGs.h | 12 +++ WINGs/wfont.c | 7 +- WINGs/wfontpanel.c | 150 ++++++++++++++++++++---------------- WINGs/wmisc.c | 40 ++++++++++ WINGs/wtextfield.c | 7 ++ WindowMaker/Defaults/WindowMaker.in | 2 +- po/de.po | 6 +- src/client.c | 2 +- src/misc.c | 12 +-- src/window.c | 1 + src/winmenu.c | 4 + 15 files changed, 175 insertions(+), 83 deletions(-) diff --git a/WINGs/ChangeLog b/WINGs/ChangeLog index 8b3b8bd8..e74d8bfb 100644 --- a/WINGs/ChangeLog +++ b/WINGs/ChangeLog @@ -1,3 +1,9 @@ +changes since wmaker 0.61.0: +............................ + +- added WMGetTextFieldFont() + + changes since wmaker 0.60.0: ............................ diff --git a/WINGs/Makefile.am b/WINGs/Makefile.am index 8ee5c3db..f06e525f 100644 --- a/WINGs/Makefile.am +++ b/WINGs/Makefile.am @@ -45,7 +45,7 @@ testcolorpanel_LDADD = libWINGs.a $(LIBLIST) testnot_SOURCES = testnot.c -testnot_LDADD = libWUtil.a @LIBRARY_SEARCH_PATH@ @LIBPL@ +testnot_LDADD = libWUtil.a $(LIBLIST) wmquery_SOURCES = wmquery.c diff --git a/WINGs/Makefile.in b/WINGs/Makefile.in index a803b0cd..4d8266d3 100644 --- a/WINGs/Makefile.in +++ b/WINGs/Makefile.in @@ -131,7 +131,7 @@ testcolorpanel_LDADD = libWINGs.a $(LIBLIST) testnot_SOURCES = testnot.c -testnot_LDADD = libWUtil.a @LIBRARY_SEARCH_PATH@ @LIBPL@ +testnot_LDADD = libWUtil.a $(LIBLIST) wmquery_SOURCES = wmquery.c @@ -197,7 +197,7 @@ testcolorpanel_DEPENDENCIES = libWINGs.a \ $(top_builddir)/wrlib/libwraster.la testcolorpanel_LDFLAGS = testnot_OBJECTS = testnot.o -testnot_DEPENDENCIES = libWUtil.a +testnot_DEPENDENCIES = libWUtil.a $(top_builddir)/wrlib/libwraster.la testnot_LDFLAGS = CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) diff --git a/WINGs/README b/WINGs/README index 5494108d..8cc0e698 100644 --- a/WINGs/README +++ b/WINGs/README @@ -64,6 +64,7 @@ Widgets provided by WINGs: - file panel - color panel - alert panel +- font panel Planned: -------- @@ -74,8 +75,6 @@ Planned: If you think you can code the following, please do. They are needed by WPrefs.app, but the number of other things I have to do is huge. -- font panel (the UI part is done. Might require a rewrite of the font list - retrievel code. Might also require a WMFontManager) - input method support (XIM). I have no idea of how to code it. People who use different characters than ASCII will have trouble editing menus without it... diff --git a/WINGs/WINGs.h b/WINGs/WINGs.h index 2a8a8414..f4573f4e 100644 --- a/WINGs/WINGs.h +++ b/WINGs/WINGs.h @@ -474,6 +474,16 @@ typedef struct WMTabViewDelegate { +/* ...................................................................... */ + + +WMRange wmkrange(int start, int count); + +WMPoint wmkpoint(int x, int y); + +WMSize wmksize(unsigned int width, unsigned int height); + + /* ....................................................................... */ @@ -884,6 +894,8 @@ void WMSetTextFieldAlignment(WMTextField *tPtr, WMAlignment alignment); void WMSetTextFieldFont(WMTextField *tPtr, WMFont *font); +WMFont *WMGetTextFieldFont(WMTextField *tPtr); + void WMSetTextFieldBordered(WMTextField *tPtr, Bool bordered); void WMSetTextFieldBeveled(WMTextField *tPtr, Bool flag); diff --git a/WINGs/wfont.c b/WINGs/wfont.c index 68b803c7..48d479fb 100644 --- a/WINGs/wfont.c +++ b/WINGs/wfont.c @@ -346,7 +346,12 @@ makeFontSetOfSize(char *fontset, int size) end = 0; tmp = wmalloc(end + strlen(f) + 8); - sprintf(tmp + end, f, size); + if (end != 0) { + sprintf(tmp, "%s,", newfs); + sprintf(tmp + end + 1, f, size); + } else { + sprintf(tmp + end, f, size); + } if (newfs) free(newfs); diff --git a/WINGs/wfontpanel.c b/WINGs/wfontpanel.c index b1b862bc..46117d4a 100644 --- a/WINGs/wfontpanel.c +++ b/WINGs/wfontpanel.c @@ -27,7 +27,6 @@ typedef struct W_FontPanel { WMList *sizLs; WMButton *revertB; - WMButton *previewB; WMButton *setB; proplist_t fdb; @@ -71,6 +70,7 @@ static int scalableFontSizes[] = { +static void getSelectedFont(FontPanel *panel, char buffer[]); static void arrangeLowerFrame(FontPanel *panel); @@ -80,9 +80,6 @@ static void typefaceClick(WMWidget *, void *); static void sizeClick(WMWidget *, void *); -static void previewClick(WMWidget *w, void *data); - - static void listFamilies(WMScreen *scr, WMFontPanel *panel); static void @@ -107,7 +104,7 @@ notificationObserver(void *self, WMNotification *notif) WMResizeWidget(panel->split, w, h-BUTTON_SPACE_HEIGHT); WMMoveWidget(panel->setB, w-80, h-(BUTTON_SPACE_HEIGHT-5)); - WMMoveWidget(panel->previewB, w-160, h-(BUTTON_SPACE_HEIGHT-5)); + WMMoveWidget(panel->revertB, w-240, h-(BUTTON_SPACE_HEIGHT-5)); } else if (object == WMWidgetView(panel->upperF)) { @@ -156,7 +153,7 @@ WMGetFontPanel(WMScreen *scr) memset(panel, 0, sizeof(FontPanel)); panel->win = WMCreateWindow(scr, "fontPanel"); -// WMSetWidgetBackgroundColor(panel->win, WMWhiteColor(scr)); +/* WMSetWidgetBackgroundColor(panel->win, WMWhiteColor(scr));*/ WMResizeWidget(panel->win, DEF_WIDTH, DEF_HEIGHT); WMSetWindowMinSize(panel->win, MIN_WIDTH, MIN_HEIGHT); WMSetViewNotifySizeChanges(WMWidgetView(panel->win), True); @@ -171,7 +168,7 @@ WMGetFontPanel(WMScreen *scr) WMSetFrameRelief(panel->upperF, WRFlat); WMSetViewNotifySizeChanges(WMWidgetView(panel->upperF), True); panel->lowerF = WMCreateFrame(panel->win); -// WMSetWidgetBackgroundColor(panel->lowerF, WMBlackColor(scr)); +/* WMSetWidgetBackgroundColor(panel->lowerF, WMBlackColor(scr));*/ WMSetFrameRelief(panel->lowerF, WRFlat); WMSetViewNotifySizeChanges(WMWidgetView(panel->lowerF), True); @@ -239,12 +236,6 @@ WMGetFontPanel(WMScreen *scr) WMMoveWidget(panel->setB, 240, DEF_HEIGHT - (BUTTON_SPACE_HEIGHT-5)); WMSetButtonText(panel->setB, "Set"); - panel->previewB = WMCreateCommandButton(panel->win); - WMResizeWidget(panel->previewB, 70, 24); - WMMoveWidget(panel->previewB, 160, DEF_HEIGHT - (BUTTON_SPACE_HEIGHT-5)); - WMSetButtonText(panel->previewB, "Preview"); - WMSetButtonAction(panel->previewB, previewClick, panel); - panel->revertB = WMCreateCommandButton(panel->win); WMResizeWidget(panel->revertB, 70, 24); WMMoveWidget(panel->revertB, 80, DEF_HEIGHT - (BUTTON_SPACE_HEIGHT-5)); @@ -313,22 +304,34 @@ WMHideFontPanel(WMFontPanel *panel) void WMSetFontPanelFont(WMFontPanel *panel, WMFont *font) { + +} + + +Bool +WMSetFontPanelFontName(WMFontPanel *panel, char *fontName) +{ + + return True; } WMFont* WMGetFontPanelFont(WMFontPanel *panel) { - return NULL; + return WMGetTextFieldFont(panel->sampleT); } char* WMGetFontPanelFontName(WMFontPanel *panel) { - return NULL; -} + char name[256]; + getSelectedFont(panel, name); + + return wstrdup(name); +} @@ -571,6 +574,7 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256]) Family *fam; WMBag *family; + family = WMHashGet(families, fontFields[FAMILY]); if (family) { @@ -583,7 +587,7 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256]) enc = (strcmp(fam->encoding, fontFields[ENCODING]) == 0); reg = (strcmp(fam->registry, fontFields[REGISTRY]) == 0); found = (strcmp(fam->foundry, fontFields[FOUNDRY]) == 0); - + if (enc && reg && found) { addTypefaceToFamily(fam, fontFields); return; @@ -600,7 +604,7 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256]) if (enc && reg) { /* has the same encoding, but the foundry is different */ - fam->showRegistry = 1; + fam->showFoundry = 1; fam = wmalloc(sizeof(Family)); memset(fam, 0, sizeof(Family)); @@ -609,12 +613,11 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256]) fam->foundry = wstrdup(fontFields[FOUNDRY]); fam->registry = wstrdup(fontFields[REGISTRY]); fam->encoding = wstrdup(fontFields[ENCODING]); - fam->showRegistry = 1; + fam->showFoundry = 1; addTypefaceToFamily(fam, fontFields); WMPutInBag(family, fam); - return; } } @@ -628,7 +631,7 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256]) if (found) { /* has the same foundry, but encoding is different */ - fam->showFoundry = 1; + fam->showRegistry = 1; fam = wmalloc(sizeof(Family)); memset(fam, 0, sizeof(Family)); @@ -637,12 +640,11 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256]) fam->foundry = wstrdup(fontFields[FOUNDRY]); fam->registry = wstrdup(fontFields[REGISTRY]); fam->encoding = wstrdup(fontFields[ENCODING]); - fam->showFoundry = 1; + fam->showRegistry = 1; addTypefaceToFamily(fam, fontFields); WMPutInBag(family, fam); - return; } } @@ -660,7 +662,6 @@ addFontToFamily(WMHashTable *families, char fontFields[NUM_FIELDS][256]) addTypefaceToFamily(fam, fontFields); WMPutInBag(family, fam); - return; } @@ -758,6 +759,56 @@ listFamilies(WMScreen *scr, WMFontPanel *panel) } +static void +getSelectedFont(FontPanel *panel, char buffer[]) +{ + WMListItem *item; + Family *family; + Typeface *face; + char *size; + + + item = WMGetListSelectedItem(panel->famLs); + if (!item) + return; + family = (Family*)item->clientData; + + item = WMGetListSelectedItem(panel->typLs); + if (!item) + return; + face = (Typeface*)item->clientData; + + size = WMGetTextFieldText(panel->sizT); + + sprintf(buffer, "-%s-%s-%s-%s-%s-%s-%s-*-*-*-*-*-%s-%s", + family->foundry, + family->name, + face->weight, + face->slant, + face->setWidth, + face->addStyle, + size, + family->registry, + family->encoding); +} + + + +static void +preview(FontPanel *panel) +{ + char buffer[256]; + WMFont *font; + + getSelectedFont(panel, buffer); + + font = WMCreateFont(WMWidgetScreen(panel->win), buffer); + if (font) { + WMSetTextFieldFont(panel->sampleT, font); + WMReleaseFont(font); + } +} + static void @@ -775,7 +826,7 @@ familyClick(WMWidget *w, void *data) int facei = -1; int sizei = -1; - /* must try to keep the same type face and size for the new family */ + /* must try to keep the same typeface and size for the new family */ item = WMGetListSelectedItem(panel->typLs); if (item) oface = wstrdup(item->text); @@ -853,6 +904,9 @@ familyClick(WMWidget *w, void *data) if (osize) free(osize); + + + preview(panel); } @@ -903,6 +957,8 @@ typefaceClick(WMWidget *w, void *data) if (osize) free(osize); + + preview(panel); } @@ -915,49 +971,9 @@ sizeClick(WMWidget *w, void *data) item = WMGetListSelectedItem(panel->sizLs); WMSetTextFieldText(panel->sizT, item->text); -} - - -static void -previewClick(WMWidget *w, void *data) -{ - FontPanel *panel = (FontPanel*)data; - char buffer[256]; - WMListItem *item; - Family *family; - Typeface *face; - char *size; - WMFont *font; - - item = WMGetListSelectedItem(panel->famLs); - if (!item) - return; - family = (Family*)item->clientData; + WMSelectTextFieldRange(panel->sizT, wmkrange(0, strlen(item->text)); - item = WMGetListSelectedItem(panel->typLs); - if (!item) - return; - face = (Typeface*)item->clientData; - - size = WMGetTextFieldText(panel->sizT); - - sprintf(buffer, "-%s-%s-%s-%s-%s-%s-%s-*-*-*-*-*-%s-%s", - family->foundry, - family->name, - face->weight, - face->slant, - face->setWidth, - face->addStyle, - size, - family->registry, - family->encoding); - - font = WMCreateFont(WMWidgetScreen(w), buffer); - if (font) { - WMSetTextFieldFont(panel->sampleT, font); - WMReleaseFont(font); - } + preview(panel); } - diff --git a/WINGs/wmisc.c b/WINGs/wmisc.c index 1647a951..d3a447d4 100644 --- a/WINGs/wmisc.c +++ b/WINGs/wmisc.c @@ -297,3 +297,43 @@ W_PaintTextAndImage(W_View *view, int wrap, GC textGC, W_Font *font, } + +WMRange +wmkrange(int start, int count) +{ + WMRange range; + + range.position = start; + range.count = count; + + return range; +} + + +WMPoint +wmkpoint(int x, int y) +{ + WMPoint point; + + point.x = x; + point.y = y; + + return point; +} + + +WMSize +wmksize(unsigned int width, unsigned int height) +{ + WMSize size; + + size.width = width; + size.height = height; + + return size; +} + + + + + diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index 2349f533..d68021b9 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -604,6 +604,13 @@ WMSetTextFieldFont(WMTextField *tPtr, WMFont *font) } +WMFont* +WMGetTextFieldFont(WMTextField *tPtr) +{ + return tPtr->font; +} + + static void didResizeTextField(W_ViewDelegate *self, WMView *view) diff --git a/WindowMaker/Defaults/WindowMaker.in b/WindowMaker/Defaults/WindowMaker.in index aab433ea..13058ed4 100644 --- a/WindowMaker/Defaults/WindowMaker.in +++ b/WindowMaker/Defaults/WindowMaker.in @@ -1,6 +1,6 @@ { MultiByteText = NO; - SmoothWorkspaceBack = YES; + SmoothWorkspaceBack = NO; WindozeCycling = NO; PopupSwitchMenu = NO; MenuStyle = normal; diff --git a/po/de.po b/po/de.po index 3619cd80..ff5c7338 100644 --- a/po/de.po +++ b/po/de.po @@ -958,7 +958,7 @@ msgstr "Signal %i (%s) erhalten - breche ab...\n" #: ../src/startup.c:277 msgid "got signal %i - exiting...\n" -msgstr "Signal %i erhalten - breche ab" +msgstr "Signal %i erhalten - breche ab\n" #: ../src/startup.c:290 msgid "got signal %i (%s)\n" @@ -1180,7 +1180,7 @@ msgid "" "To access the window commands menu of a window\n" "without it's titlebar, press Control+Esc (or the\n" "equivalent shortcut, if you changed the default\n" -"settings)." +"settings).\n" msgstr "" "Die Titelzeile dieses Fensters entfernen.\n" "Drücken Sie Strg+Esc (oder das entsprechende\n" @@ -1218,7 +1218,7 @@ msgstr "Immer Oben" #: ../src/winspector.c:1188 msgid "" "Keep the window over other windows, not allowing\n" -"them to covert it." +"them to covert it.\n" msgstr "" "Halte dieses Fenster über allen anderen. Erlaube keinem\n" "anderen Fenster, dieses zu überdecken.\n" diff --git a/src/client.c b/src/client.c index 4e0d0a05..b0fc7640 100644 --- a/src/client.c +++ b/src/client.c @@ -585,7 +585,7 @@ wClientCheckProperty(WWindow *wwin, XPropertyEvent *event) if (wwin->frame) wWindowUpdateButtonImages(wwin); - + } else if (event->atom==_XA_WM_COLORMAP_WINDOWS) { GetColormapWindows(wwin); diff --git a/src/misc.c b/src/misc.c index fa0a2c19..e4b2612a 100644 --- a/src/misc.c +++ b/src/misc.c @@ -153,11 +153,13 @@ MakeCPPArgs(char *path) /* put the dir where the menu is being read from to the * search path */ - tmp = wstrdup(path); - buf = strrchr(tmp, '/'); - if (buf) *buf = 0; /* trunc filename */ - putdef(line, " -I", tmp); - free(tmp); + if (path) { + tmp = wstrdup(path); + buf = strrchr(tmp, '/'); + if (buf) *buf = 0; /* trunc filename */ + putdef(line, " -I", tmp); + free(tmp); + } /* this should be done just once, but it works this way */ diff --git a/src/window.c b/src/window.c index f9c4f0aa..e59be5f6 100644 --- a/src/window.c +++ b/src/window.c @@ -2010,6 +2010,7 @@ int req_x, req_y; /* new position of the frame */ #endif } + void wWindowUpdateButtonImages(WWindow *wwin) { diff --git a/src/winmenu.c b/src/winmenu.c index 65ffd728..4dccb1ab 100644 --- a/src/winmenu.c +++ b/src/winmenu.c @@ -215,6 +215,10 @@ makeShortcutCommand(WMenu *menu, WMenuEntry *entry) WMPutInBag(scr->shortcutWindows[index], tmp); } + } else { + scr->shortcutWindows[index] = WMCreateBag(4); + + WMPutInBag(scr->shortcutWindows[index], wwin); } wSelectWindow(wwin, !wwin->flags.selected); -- 2.11.4.GIT