1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-15 05:25:53 +01:00

fixed font bug in WINGs

font panel problems
po file problems
misc bugs
This commit is contained in:
kojima
1999-09-22 02:09:42 +00:00
parent 54e241d2fc
commit d5fbe62ddd
15 changed files with 177 additions and 85 deletions

View File

@@ -1,3 +1,9 @@
changes since wmaker 0.61.0:
............................
- added WMGetTextFieldFont()
changes since wmaker 0.60.0:
............................

View File

@@ -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

View File

@@ -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)

View File

@@ -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...

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
WMSelectTextFieldRange(panel->sizT, wmkrange(0, strlen(item->text));
preview(panel);
}
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;
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);
}
}

View File

@@ -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;
}

View File

@@ -604,6 +604,13 @@ WMSetTextFieldFont(WMTextField *tPtr, WMFont *font)
}
WMFont*
WMGetTextFieldFont(WMTextField *tPtr)
{
return tPtr->font;
}
static void
didResizeTextField(W_ViewDelegate *self, WMView *view)