And readded uiFontButton on Windows. Woo! Now we have to deal with styles.
This commit is contained in:
parent
1a8f7ad405
commit
dca92d507e
|
@ -26,8 +26,8 @@ list(APPEND _LIBUI_SOURCES
|
|||
windows/editablecombo.cpp
|
||||
windows/entry.cpp
|
||||
windows/events.cpp
|
||||
# windows/fontbutton.cpp
|
||||
# windows/fontdialog.cpp
|
||||
windows/fontbutton.cpp
|
||||
windows/fontdialog.cpp
|
||||
windows/form.cpp
|
||||
windows/graphemes.cpp
|
||||
windows/grid.cpp
|
||||
|
|
|
@ -14,13 +14,9 @@ extern uiDrawContext *newContext(ID2D1RenderTarget *);
|
|||
extern void freeContext(uiDrawContext *);
|
||||
|
||||
// dwrite.cpp
|
||||
#ifdef __cplusplus
|
||||
extern IDWriteFactory *dwfactory;
|
||||
#endif
|
||||
extern HRESULT initDrawText(void);
|
||||
extern void uninitDrawText(void);
|
||||
#if 0 /* TODO */
|
||||
#ifdef __cplusplus
|
||||
struct fontCollection {
|
||||
IDWriteFontCollection *fonts;
|
||||
WCHAR userLocale[LOCALE_NAME_MAX_LENGTH];
|
||||
|
@ -30,29 +26,8 @@ extern fontCollection *loadFontCollection(void);
|
|||
extern WCHAR *fontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *family);
|
||||
extern void fontCollectionFree(fontCollection *fc);
|
||||
extern WCHAR *fontCollectionCorrectString(fontCollection *fc, IDWriteLocalizedStrings *names);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// drawtext.cpp
|
||||
#if 0 /* TODO */
|
||||
#ifdef __cplusplus
|
||||
extern uiDrawTextFont *mkTextFont(IDWriteFont *df, BOOL addRef, WCHAR *family, BOOL copyFamily, double size);
|
||||
struct dwriteAttr {
|
||||
uiDrawTextWeight weight;
|
||||
uiDrawTextItalic italic;
|
||||
uiDrawTextStretch stretch;
|
||||
DWRITE_FONT_WEIGHT dweight;
|
||||
DWRITE_FONT_STYLE ditalic;
|
||||
DWRITE_FONT_STRETCH dstretch;
|
||||
};
|
||||
extern void attrToDWriteAttr(struct dwriteAttr *attr);
|
||||
extern void dwriteAttrToAttr(struct dwriteAttr *attr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// fontdialog.cpp
|
||||
#if 0 /* TODO */
|
||||
#ifdef __cplusplus
|
||||
struct fontDialogParams {
|
||||
IDWriteFont *font;
|
||||
double size;
|
||||
|
@ -63,5 +38,3 @@ extern BOOL showFontDialog(HWND parent, struct fontDialogParams *params);
|
|||
extern void loadInitialFontDialogParams(struct fontDialogParams *params);
|
||||
extern void destroyFontDialogParams(struct fontDialogParams *params);
|
||||
extern WCHAR *fontDialogParamsToString(struct fontDialogParams *params);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -401,3 +401,22 @@ void caretDrawParams(uiDrawContext *c, double height, struct caretDrawParams *p)
|
|||
// and there doesn't seem to be this either... (TODO check what PadWrite does?)
|
||||
p->xoff = 0;
|
||||
}
|
||||
|
||||
// TODO split this and the above related font matching code into a separate file?
|
||||
void fontdescFromIDWriteFont(IDWriteFont *font, uiDrawFontDescriptor *uidesc)
|
||||
{
|
||||
DWRITE_FONT_STYLE dwitalic;
|
||||
DWRITE_FONT_STRETCH dwstretch;
|
||||
|
||||
dwitalic = font->GetStyle();
|
||||
// TODO reverse the above misalignment if it is corrected
|
||||
uidesc->Weight = (uiDrawTextWeight) (font->GetWeight());
|
||||
dwstretch = font->GetStretch();
|
||||
|
||||
for (uidesc->Italic = uiDrawTextItalicNormal; uidesc->Italic < uiDrawTextItalicItalic; uidesc->Italic++)
|
||||
if (dwriteItalics[uidesc->Italic] == dwitalic)
|
||||
break;
|
||||
for (uidesc->Stretch = uiDrawTextStretchUltraCondensed; uidesc->Stretch < uiDrawTextStretchUltraExpanded; uidesc->Stretch++)
|
||||
if (dwriteStretches[uidesc->Stretch] == dwstretch)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ void uninitDrawText(void)
|
|||
dwfactory->Release();
|
||||
}
|
||||
|
||||
#if 0 /* TODO */
|
||||
|
||||
fontCollection *loadFontCollection(void)
|
||||
{
|
||||
fontCollection *fc;
|
||||
|
@ -88,5 +86,3 @@ void fontCollectionFree(fontCollection *fc)
|
|||
fc->fonts->Release();
|
||||
uiFree(fc);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -86,11 +86,11 @@ static void defaultOnChanged(uiFontButton *b, void *data)
|
|||
// do nothing
|
||||
}
|
||||
|
||||
uiDrawTextFont *uiFontButtonFont(uiFontButton *b)
|
||||
void uiFontButtonFont(uiFontButton *b, uiDrawFontDescriptor *desc)
|
||||
{
|
||||
// we don't own b->params.font; we have to add a reference
|
||||
// we don't own b->params.familyName either; we have to copy it
|
||||
return mkTextFont(b->params.font, TRUE, b->params.familyName, TRUE, b->params.size);
|
||||
fontdescFromIDWriteFont(b->params.font, desc);
|
||||
desc->Family = toUTF8(b->params.familyName);
|
||||
desc->Size = b->params.size;
|
||||
}
|
||||
|
||||
void uiFontButtonOnChanged(uiFontButton *b, void (*f)(uiFontButton *, void *), void *data)
|
||||
|
|
|
@ -320,6 +320,7 @@ static void sizeEdited(struct fontDialog *f)
|
|||
wsize = windowText(f->sizeCombobox);
|
||||
// this is what the Choose Font dialog does; it swallows errors while the real ChooseFont() is not lenient (and only checks on OK)
|
||||
size = wcstod(wsize, NULL);
|
||||
// TODO free wsize? I forget already
|
||||
if (size <= 0) // don't change on invalid size
|
||||
return;
|
||||
f->curSize = size;
|
||||
|
|
|
@ -159,3 +159,6 @@ extern D2D1_SIZE_F realGetSize(ID2D1RenderTarget *rt);
|
|||
|
||||
// draw.cpp
|
||||
extern ID2D1DCRenderTarget *makeHDCRenderTarget(HDC dc, RECT *r);
|
||||
|
||||
// drawtext.cpp
|
||||
extern void fontdescFromIDWriteFont(IDWriteFont *font, uiDrawFontDescriptor *uidesc);
|
||||
|
|
Loading…
Reference in New Issue