Fixed build errors. Now to test.

This commit is contained in:
Pietro Gagliardi 2018-03-17 15:49:00 -04:00
parent 2f02836181
commit a5bbc83359
8 changed files with 37 additions and 31 deletions

View File

@ -5,7 +5,11 @@
#define uiprivAlloc(x, y) uiAlloc(x, y)
#define uiprivRealloc(x, y, z) uiRealloc(x, y, z)
#define uiprivFree(x) uiFree(x)
#ifndef _WIN32
#define uiprivStricmp(x, y) strcasecmp(x, y)
#else
#define uiprivStricmp(x, y) stricmp(x, y)
#endif
// attribute.c
extern uiAttribute *uiprivAttributeRetain(uiAttribute *a);

View File

@ -210,6 +210,7 @@ public:
};
// also needed by applyEffectsAttributes() below
// TODO provide all the fields of std::hash and std::equal_to?
class applyEffectsHash {
public:
typedef combinedEffectsAttr *ceaptr;

View File

@ -59,7 +59,7 @@ uiDrawTextLayout *uiDrawNewTextLayout(uiDrawTextLayoutParams *p)
logHRESULT(L"error applying text layout alignment", hr);
hr = dwfactory->CreateTextLayout(
(const WCHAR *) attrstrUTF16(p->String), attrstrUTF16Len(p->String),
(const WCHAR *) uiprivAttributedStringUTF16String(p->String), uiprivAttributedStringUTF16Len(p->String),
tl->format,
// FLOAT is float, not double, so this should work... TODO
FLT_MAX, FLT_MAX,
@ -84,11 +84,11 @@ uiDrawTextLayout *uiDrawNewTextLayout(uiDrawTextLayoutParams *p)
if (hr != S_OK)
logHRESULT(L"error setting IDWriteTextLayout max layout width", hr);
attrstrToIDWriteTextLayoutAttrs(p, tl->layout, &(tl->backgroundParams));
uiprivAttributedStringApplyAttributesToDWriteTextLayout(p, tl->layout, &(tl->backgroundParams));
// and finally copy the UTF-8/UTF-16 index conversion tables
tl->u8tou16 = attrstrCopyUTF8ToUTF16(p->String, &(tl->nUTF8));
tl->u16tou8 = attrstrCopyUTF16ToUTF8(p->String, &(tl->nUTF16));
tl->u8tou16 = uiprivAttributedStringCopyUTF8ToUTF16Table(p->String, &(tl->nUTF8));
tl->u16tou8 = uiprivAttributedStringCopyUTF16ToUTF8Table(p->String, &(tl->nUTF16));
return tl;
}
@ -97,7 +97,7 @@ void uiDrawFreeTextLayout(uiDrawTextLayout *tl)
{
uiFree(tl->u16tou8);
uiFree(tl->u8tou16);
for (auto p in *(tl->backgroundParams))
for (auto p : *(tl->backgroundParams))
uiprivFree(p);
delete tl->backgroundParams;
tl->layout->Release();
@ -147,7 +147,7 @@ drawingEffectsAttr::drawingEffectsAttr(void)
this->hasUnderlineColor = false;
}
virtual HRESULT STDMETHODCALLTYPE drawingEffectsAttr::QueryInterface(REFIID riid, void **ppvObject)
HRESULT STDMETHODCALLTYPE drawingEffectsAttr::QueryInterface(REFIID riid, void **ppvObject)
{
if (ppvObject == NULL)
return E_POINTER;
@ -160,13 +160,13 @@ virtual HRESULT STDMETHODCALLTYPE drawingEffectsAttr::QueryInterface(REFIID riid
return E_NOINTERFACE;
}
virtual ULONG STDMETHODCALLTYPE drawingEffectsAttr::AddRef(void)
ULONG STDMETHODCALLTYPE drawingEffectsAttr::AddRef(void)
{
this->refcount++;
return this->refcount;
}
virtual ULONG STDMETHODCALLTYPE drawingEffectsAttr::Release(void)
ULONG STDMETHODCALLTYPE drawingEffectsAttr::Release(void)
{
this->refcount--;
if (this->refcount == 0) {
@ -315,7 +315,7 @@ public:
virtual HRESULT STDMETHODCALLTYPE DrawGlyphRun(void *clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, const DWRITE_GLYPH_RUN *glyphRun, const DWRITE_GLYPH_RUN_DESCRIPTION *glyphRunDescription, IUnknown *clientDrawingEffect)
{
D2D1_POINT_2F baseline;
drawingEffecsAttr *dea = (drawingEffectAttrs *) clientDrawingEffect;
drawingEffectsAttr *dea = (drawingEffectsAttr *) clientDrawingEffect;
ID2D1SolidColorBrush *brush;
baseline.x = baselineOriginX;
@ -330,7 +330,7 @@ public:
}
if (brush == NULL) {
brush = this->black;
brush->Retain();
brush->AddRef();
}
this->rt->DrawGlyphRun(
baseline,
@ -387,17 +387,17 @@ public:
}
if (brush == NULL) {
brush = this->black;
brush->Retain();
brush->AddRef();
}
rect.left = baselineOriginX;
rect.top = baselineOriginY + underline->offset;
rect.right = rect.left + underline->width;
rect.bottom = rect.top + underline->thickness;
switch (utype) {
case uiDrawUnderlineStyleSingle:
case uiUnderlineSingle:
this->rt->FillRectangle(&rect, brush);
break;
case uiDrawUnderlineStyleDouble:
case uiUnderlineDouble:
// TODO do any of the matrix methods return errors?
// TODO standardize double-underline shape across platforms? wavy underline shape?
this->rt->GetTransform(&pixeltf);
@ -420,7 +420,7 @@ public:
rect.bottom = rect.top + underline->thickness;
this->rt->FillRectangle(&rect, brush);
break;
case uiDrawUnderlineStyleSuggestion:
case uiUnderlineSuggestion:
{ // TODO get rid of the extra block
// TODO properly clean resources on failure
// TODO use fully qualified C overloads for all methods

View File

@ -47,7 +47,7 @@ WCHAR *uiprivFontCollectionFamilyName(fontCollection *fc, IDWriteFontFamily *fam
hr = family->GetFamilyNames(&names);
if (hr != S_OK)
logHRESULT(L"error getting names of font out", hr);
str = fontCollectionCorrectString(fc, names);
str = uiprivFontCollectionCorrectString(fc, names);
names->Release();
return str;
}

View File

@ -87,7 +87,7 @@ static void defaultOnChanged(uiFontButton *b, void *data)
// do nothing
}
void uiFontButtonFont(uiFontButton *b, uiDrawFontDescriptor *desc)
void uiFontButtonFont(uiFontButton *b, uiFontDescriptor *desc)
{
uiprivFontDescriptorFromIDWriteFont(b->params.font, desc);
desc->Family = toUTF8(b->params.familyName);

View File

@ -18,7 +18,7 @@ struct fontDialog {
struct fontDialogParams *params;
fontCollection *fc;
struct fontCollection *fc;
RECT sampleRect;
HWND sampleBox;
@ -169,7 +169,7 @@ static WCHAR *fontStyleName(struct fontCollection *fc, IDWriteFont *font)
hr = font->GetFaceNames(&str);
if (hr != S_OK)
logHRESULT(L"error getting font style name for font dialog", hr);
wstr = fontCollectionCorrectString(fc, str);
wstr = uiprivFontCollectionCorrectString(fc, str);
str->Release();
return wstr;
}
@ -365,7 +365,7 @@ static void fontDialogDrawSampleText(struct fontDialog *f, ID2D1RenderTarget *rt
if (hr != S_OK)
exists = FALSE;
if (exists) {
sample = fontCollectionCorrectString(f->fc, sampleStrings);
sample = uiprivFontCollectionCorrectString(f->fc, sampleStrings);
sampleStrings->Release();
} else
sample = L"The quick brown fox jumps over the lazy dog.";
@ -474,13 +474,13 @@ static struct fontDialog *beginFontDialog(HWND hwnd, LPARAM lParam)
f->styleCombobox = getDlgItem(f->hwnd, rcFontStyleCombobox);
f->sizeCombobox = getDlgItem(f->hwnd, rcFontSizeCombobox);
f->fc = loadFontCollection();
f->fc = uiprivLoadFontCollection();
nFamilies = f->fc->fonts->GetFontFamilyCount();
for (i = 0; i < nFamilies; i++) {
hr = f->fc->fonts->GetFontFamily(i, &family);
if (hr != S_OK)
logHRESULT(L"error getting font family", hr);
wname = fontCollectionFamilyName(f->fc, family);
wname = uiprivFontCollectionFamilyName(f->fc, family);
pos = cbAddString(f->familyCombobox, wname);
uiFree(wname);
cbSetItemData(f->familyCombobox, (WPARAM) pos, (LPARAM) family);
@ -503,7 +503,7 @@ static void endFontDialog(struct fontDialog *f, INT_PTR code)
{
wipeStylesBox(f);
cbWipeAndReleaseData(f->familyCombobox);
fontCollectionFree(f->fc);
uiprivFontCollectionFree(f->fc);
if (EndDialog(f->hwnd, code) == 0)
logLastError(L"error ending font dialog");
uiFree(f);
@ -520,13 +520,13 @@ static INT_PTR tryFinishDialog(struct fontDialog *f, WPARAM wParam)
}
// OK
destroyFontDialogParams(f->params);
uiprivDestroyFontDialogParams(f->params);
f->params->font = (IDWriteFont *) cbGetItemData(f->styleCombobox, f->curStyle);
// we need to save font from being destroyed with the combobox
f->params->font->AddRef();
f->params->size = f->curSize;
family = (IDWriteFontFamily *) cbGetItemData(f->familyCombobox, f->curFamily);
f->params->familyName = fontCollectionFamilyName(f->fc, family);
f->params->familyName = uiprivFontCollectionFamilyName(f->fc, family);
f->params->styleName = fontStyleName(f->fc, f->params->font);
endFontDialog(f, 2);
return TRUE;
@ -636,7 +636,7 @@ void uiprivLoadInitialFontDialogParams(struct fontDialogParams *params)
// If Arial isn't found, we'll use Helvetica and then MS Sans Serif as fallbacks, and if not, we'll just grab the first font family in the collection.
// We need the correct localized name for Regular (and possibly Arial too? let's say yes to be safe), so let's grab the strings from DirectWrite instead of hardcoding them.
fc = loadFontCollection();
fc = uiprivLoadFontCollection();
family = tryFindFamily(fc->fonts, L"Arial");
if (family == NULL) {
family = tryFindFamily(fc->fonts, L"Helvetica");
@ -661,12 +661,12 @@ void uiprivLoadInitialFontDialogParams(struct fontDialogParams *params)
params->font = font;
params->size = 10;
params->familyName = fontCollectionFamilyName(fc, family);
params->familyName = uiprivFontCollectionFamilyName(fc, family);
params->styleName = fontStyleName(fc, font);
// don't release font; we still need it
family->Release();
fontCollectionFree(fc);
uiprivFontCollectionFree(fc);
}
void uiprivDestroyFontDialogParams(struct fontDialogParams *params)

View File

@ -49,13 +49,13 @@ void uiprivFontDescriptorFromIDWriteFont(IDWriteFont *font, uiFontDescriptor *ui
dwitalic = font->GetStyle();
// TODO reverse the above misalignment if it is corrected
uidesc->Weight = (uiDrawTextWeight) (font->GetWeight());
uidesc->Weight = (uiTextWeight) (font->GetWeight());
dwstretch = font->GetStretch();
for (uidesc->Italic = uiDrawTextItalicNormal; uidesc->Italic < uiDrawTextItalicItalic; uidesc->Italic++)
for (uidesc->Italic = uiTextItalicNormal; uidesc->Italic < uiTextItalicItalic; uidesc->Italic++)
if (dwriteItalics[uidesc->Italic] == dwitalic)
break;
for (uidesc->Stretch = uiDrawTextStretchUltraCondensed; uidesc->Stretch < uiDrawTextStretchUltraExpanded; uidesc->Stretch++)
for (uidesc->Stretch = uiTextStretchUltraCondensed; uidesc->Stretch < uiTextStretchUltraExpanded; uidesc->Stretch++)
if (dwriteStretches[uidesc->Stretch] == dwstretch)
break;
}

View File

@ -11,7 +11,8 @@ static uiForEach addToTypography(const uiOpenTypeFeatures *otf, char a, char b,
HRESULT hr;
ZeroMemory(&dff, sizeof (DWRITE_FONT_FEATURE));
dff.nameTag = /*(DWRITE_FONT_FEATURE_TAG)*/ DWRITE_MAKE_OPENTYPE_TAG(a, b, c, d);
// yes, the cast here is necessary (the compiler will complain otherwise)...
dff.nameTag = (DWRITE_FONT_FEATURE_TAG) DWRITE_MAKE_OPENTYPE_TAG(a, b, c, d);
dff.parameter = (UINT32) value;
hr = dt->AddFontFeature(dff);
if (hr != S_OK)