dwrite: Implement SetWordWrapping() for layout.
This commit is contained in:
parent
cf5d9848d8
commit
2f79a876f9
|
@ -363,6 +363,16 @@ static inline HRESULT format_set_readingdirection(struct dwrite_textformat_data
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static inline HRESULT format_set_wordwrapping(struct dwrite_textformat_data *format,
|
||||
DWRITE_WORD_WRAPPING wrapping, BOOL *changed)
|
||||
{
|
||||
if ((UINT32)wrapping > DWRITE_WORD_WRAPPING_CHARACTER)
|
||||
return E_INVALIDARG;
|
||||
if (changed) *changed = format->wrapping != wrapping;
|
||||
format->wrapping = wrapping;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT get_fontfallback_from_format(const struct dwrite_textformat_data *format, IDWriteFontFallback **fallback)
|
||||
{
|
||||
*fallback = format->fallback;
|
||||
|
@ -2199,7 +2209,6 @@ static HRESULT WINAPI dwritetextlayout_SetParagraphAlignment(IDWriteTextLayout2
|
|||
static HRESULT WINAPI dwritetextlayout_SetWordWrapping(IDWriteTextLayout2 *iface, DWRITE_WORD_WRAPPING wrapping)
|
||||
{
|
||||
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
|
||||
TRACE("(%p)->(%d)\n", This, wrapping);
|
||||
return IDWriteTextFormat1_SetWordWrapping(&This->IDWriteTextFormat1_iface, wrapping);
|
||||
}
|
||||
|
||||
|
@ -3296,8 +3305,19 @@ static HRESULT WINAPI dwritetextformat1_layout_SetParagraphAlignment(IDWriteText
|
|||
static HRESULT WINAPI dwritetextformat1_layout_SetWordWrapping(IDWriteTextFormat1 *iface, DWRITE_WORD_WRAPPING wrapping)
|
||||
{
|
||||
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
|
||||
FIXME("(%p)->(%d): stub\n", This, wrapping);
|
||||
return E_NOTIMPL;
|
||||
BOOL changed;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)->(%d)\n", This, wrapping);
|
||||
|
||||
hr = format_set_wordwrapping(&This->format, wrapping, &changed);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (changed)
|
||||
This->recompute |= RECOMPUTE_EFFECTIVE_RUNS;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritetextformat1_layout_SetReadingDirection(IDWriteTextFormat1 *iface, DWRITE_READING_DIRECTION direction)
|
||||
|
@ -4181,14 +4201,8 @@ static HRESULT WINAPI dwritetextformat_SetParagraphAlignment(IDWriteTextFormat1
|
|||
static HRESULT WINAPI dwritetextformat_SetWordWrapping(IDWriteTextFormat1 *iface, DWRITE_WORD_WRAPPING wrapping)
|
||||
{
|
||||
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
|
||||
|
||||
TRACE("(%p)->(%d)\n", This, wrapping);
|
||||
|
||||
if ((UINT32)wrapping > DWRITE_WORD_WRAPPING_CHARACTER)
|
||||
return E_INVALIDARG;
|
||||
|
||||
This->format.wrapping = wrapping;
|
||||
return S_OK;
|
||||
return format_set_wordwrapping(&This->format, wrapping, NULL);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritetextformat_SetReadingDirection(IDWriteTextFormat1 *iface, DWRITE_READING_DIRECTION direction)
|
||||
|
|
|
@ -3396,6 +3396,44 @@ static void test_pixelsnapping(void)
|
|||
IDWriteFactory_Release(factory);
|
||||
}
|
||||
|
||||
static void test_SetWordWrapping(void)
|
||||
{
|
||||
static const WCHAR strW[] = {'a',0};
|
||||
IDWriteTextFormat *format;
|
||||
IDWriteTextLayout *layout;
|
||||
IDWriteFactory *factory;
|
||||
DWRITE_WORD_WRAPPING v;
|
||||
HRESULT hr;
|
||||
|
||||
factory = create_factory();
|
||||
|
||||
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL, 12.0, enusW, &format);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
v = IDWriteTextFormat_GetWordWrapping(format);
|
||||
ok(v == DWRITE_WORD_WRAPPING_WRAP, "got %d\n", v);
|
||||
|
||||
hr = IDWriteFactory_CreateTextLayout(factory, strW, 1, format, 500.0, 100.0, &layout);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
v = IDWriteTextLayout_GetWordWrapping(layout);
|
||||
ok(v == DWRITE_WORD_WRAPPING_WRAP, "got %d\n", v);
|
||||
|
||||
hr = IDWriteTextLayout_SetWordWrapping(layout, DWRITE_WORD_WRAPPING_NO_WRAP);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IDWriteTextLayout_SetWordWrapping(layout, DWRITE_WORD_WRAPPING_NO_WRAP);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
v = IDWriteTextFormat_GetWordWrapping(format);
|
||||
ok(v == DWRITE_WORD_WRAPPING_WRAP, "got %d\n", v);
|
||||
|
||||
IDWriteTextLayout_Release(layout);
|
||||
IDWriteTextFormat_Release(format);
|
||||
IDWriteFactory_Release(factory);
|
||||
}
|
||||
|
||||
START_TEST(layout)
|
||||
{
|
||||
static const WCHAR ctrlstrW[] = {0x202a,0};
|
||||
|
@ -3440,6 +3478,7 @@ START_TEST(layout)
|
|||
test_SetParagraphAlignment();
|
||||
test_SetReadingDirection();
|
||||
test_pixelsnapping();
|
||||
test_SetWordWrapping();
|
||||
|
||||
IDWriteFactory_Release(factory);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue