Module: wine Branch: master Commit: 289043f4de77e4769a732c49d6a4c2074509392b URL: http://source.winehq.org/git/wine.git/?a=commit;h=289043f4de77e4769a732c49d6...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Jul 30 19:59:07 2014 +0400
dwrite: Store maximum width/height for text layout.
---
dlls/dwrite/dwrite_private.h | 2 +- dlls/dwrite/layout.c | 24 +++++++++++++++--------- dlls/dwrite/main.c | 4 ++-- dlls/dwrite/tests/layout.c | 9 ++++++++- 4 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 99fcca3..8db35a3 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -81,7 +81,7 @@ extern HRESULT create_font_from_logfont(const LOGFONTW*, IDWriteFont**) DECLSPEC extern HRESULT convert_fontface_to_logfont(IDWriteFontFace*, LOGFONTW*) DECLSPEC_HIDDEN; extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH, FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN; -extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,IDWriteTextLayout**) DECLSPEC_HIDDEN; +extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,IDWriteTextLayout**) DECLSPEC_HIDDEN; extern HRESULT create_trimmingsign(IDWriteInlineObject**) DECLSPEC_HIDDEN; extern HRESULT get_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN; extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c index 2ed328b..57538f5 100644 --- a/dlls/dwrite/layout.c +++ b/dlls/dwrite/layout.c @@ -64,6 +64,8 @@ struct dwrite_textlayout { WCHAR *str; UINT32 len; struct dwrite_textformat_data format; + FLOAT maxwidth; + FLOAT maxheight; };
struct dwrite_textformat { @@ -338,15 +340,17 @@ static HRESULT WINAPI dwritetextlayout_GetLocaleName(IDWriteTextLayout *iface, W static HRESULT WINAPI dwritetextlayout_SetMaxWidth(IDWriteTextLayout *iface, FLOAT maxWidth) { struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface); - FIXME("(%p)->(%f): stub\n", This, maxWidth); - return E_NOTIMPL; + TRACE("(%p)->(%.1f)\n", This, maxWidth); + This->maxwidth = maxWidth; + return S_OK; }
static HRESULT WINAPI dwritetextlayout_SetMaxHeight(IDWriteTextLayout *iface, FLOAT maxHeight) { struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface); - FIXME("(%p)->(%f): stub\n", This, maxHeight); - return E_NOTIMPL; + TRACE("(%p)->(%.1f)\n", This, maxHeight); + This->maxheight = maxHeight; + return S_OK; }
static HRESULT WINAPI dwritetextlayout_SetFontCollection(IDWriteTextLayout *iface, IDWriteFontCollection* collection, DWRITE_TEXT_RANGE range) @@ -436,15 +440,15 @@ static HRESULT WINAPI dwritetextlayout_SetLocaleName(IDWriteTextLayout *iface, W static FLOAT WINAPI dwritetextlayout_GetMaxWidth(IDWriteTextLayout *iface) { struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface); - FIXME("(%p): stub\n", This); - return 0.0; + TRACE("(%p)\n", This); + return This->maxwidth; }
static FLOAT WINAPI dwritetextlayout_GetMaxHeight(IDWriteTextLayout *iface) { struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface); - FIXME("(%p): stub\n", This); - return 0.0; + TRACE("(%p)\n", This); + return This->maxheight; }
static HRESULT WINAPI dwritetextlayout_layout_GetFontCollection(IDWriteTextLayout *iface, UINT32 pos, @@ -750,7 +754,7 @@ static void layout_format_from_textformat(struct dwrite_textlayout *layout, IDWr IDWriteTextFormat_GetFontCollection(format, &layout->format.collection); }
-HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, IDWriteTextLayout **layout) +HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, FLOAT maxwidth, FLOAT maxheight, IDWriteTextLayout **layout) { struct dwrite_textlayout *This;
@@ -763,6 +767,8 @@ HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *forma This->ref = 1; This->str = heap_strdupnW(str, len); This->len = len; + This->maxwidth = maxwidth; + This->maxheight = maxheight; layout_format_from_textformat(This, format);
*layout = &This->IDWriteTextLayout_iface; diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index cf3b530..357b41f 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -510,7 +510,7 @@ static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory *iface, WCHA TRACE("(%s %u %p %f %f %p)\n", debugstr_w(string), len, format, max_width, max_height, layout);
if (!format) return E_INVALIDARG; - return create_textlayout(string, len, format, layout); + return create_textlayout(string, len, format, max_width, max_height, layout); }
static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory *iface, WCHAR const* string, @@ -521,7 +521,7 @@ static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory pixels_per_dip, transform, use_gdi_natural, layout);
if (!format) return E_INVALIDARG; - return create_textlayout(string, len, format, layout); + return create_textlayout(string, len, format, layout_width, layout_height, layout); }
static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *iface, IDWriteTextFormat *format, diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 07e5e20..8305c77 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -65,6 +65,7 @@ static void test_CreateGdiCompatibleTextLayout(void) static const WCHAR strW[] = {'s','t','r','i','n','g',0}; IDWriteTextLayout *layout; IDWriteTextFormat *format; + FLOAT dimension; HRESULT hr;
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, FALSE, &layout); @@ -102,8 +103,14 @@ static void test_CreateGdiCompatibleTextLayout(void) /* zero length string is okay */ hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, strW, 0, format, 100.0, 100.0, 1.0, NULL, FALSE, &layout); ok(hr == S_OK, "got 0x%08x\n", hr); - IDWriteTextLayout_Release(layout);
+ dimension = IDWriteTextLayout_GetMaxWidth(layout); + ok(dimension == 100.0, "got %f\n", dimension); + + dimension = IDWriteTextLayout_GetMaxHeight(layout); + ok(dimension == 100.0, "got %f\n", dimension); + + IDWriteTextLayout_Release(layout); IDWriteTextFormat_Release(format); }