Uredi

Deli z drugimi prek


CD2DTextLayout Class

A wrapper for IDWriteTextLayout.

Syntax

class CD2DTextLayout : public CD2DResource;

Members

Public Constructors

Name Description
CD2DTextLayout::CD2DTextLayout Constructs a CD2DTextLayout object.
CD2DTextLayout::~CD2DTextLayout The destructor. Called when a D2D text layout object is being destroyed.

Public Methods

Name Description
CD2DTextLayout::Create Creates a CD2DTextLayout. (Overrides CD2DResource::Create.)
CD2DTextLayout::Destroy Destroys a CD2DTextLayout object. (Overrides CD2DResource::Destroy.)
CD2DTextLayout::Get Returns IDWriteTextLayout interface
CD2DTextLayout::GetFontFamilyName Copies the font family name of the text at the specified position.
CD2DTextLayout::GetLocaleName Gets the locale name of the text at the specified position.
CD2DTextLayout::IsValid Checks resource validity (Overrides CD2DResource::IsValid.)
CD2DTextLayout::ReCreate Re-creates a CD2DTextLayout. (Overrides CD2DResource::ReCreate.)
CD2DTextLayout::SetFontFamilyName Sets null-terminated font family name for text within a specified text range
CD2DTextLayout::SetLocaleName Sets the locale name for text within a specified text range

Public Operators

Name Description
CD2DTextLayout::operator IDWriteTextLayout* Returns IDWriteTextLayout interface

Protected Data Members

Name Description
CD2DTextLayout::m_pTextLayout A pointer to an IDWriteTextLayout.

Inheritance Hierarchy

CObject

CD2DResource

CD2DTextLayout

Requirements

Header: afxrendertarget.h

CD2DTextLayout::~CD2DTextLayout

The destructor. Called when a D2D text layout object is being destroyed.

virtual ~CD2DTextLayout();

CD2DTextLayout::CD2DTextLayout

Constructs a CD2DTextLayout object.

CD2DTextLayout(
    CRenderTarget* pParentTarget,
    const CString& strText,
    CD2DTextFormat& textFormat,
    const CD2DSizeF& sizeMax,
    BOOL bAutoDestroy = TRUE);

Parameters

pParentTarget
A pointer to the render target.

strText
A CString object that contains the string to create a new CD2DTextLayout object from.

textFormat
A CString object that contains the format to apply to the string.

sizeMax
The size of the layout box.

bAutoDestroy
Indicates that the object will be destroyed by owner (pParentTarget).

CD2DTextLayout::Create

Creates a CD2DTextLayout.

virtual HRESULT Create(CRenderTarget* */);

Return Value

If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

CD2DTextLayout::Destroy

Destroys a CD2DTextLayout object.

virtual void Destroy();

CD2DTextLayout::Get

Returns IDWriteTextLayout interface

IDWriteTextLayout* Get();

Return Value

Pointer to an IDWriteTextLayout interface or NULL if object is not initialized yet.

CD2DTextLayout::GetFontFamilyName

Copies the font family name of the text at the specified position.

CString GetFontFamilyName(
    UINT32 currentPosition,
    DWRITE_TEXT_RANGE* textRange = NULL) const;

Parameters

currentPosition
The position of the text to examine.

textRange
The range of text that has the same formatting as the text at the position specified by currentPosition. This means the run has the exact formatting as the position specified, including but not limited to the font family name.

Return Value

CString object that contains the current font family name.

CD2DTextLayout::GetLocaleName

Gets the locale name of the text at the specified position.

CString GetLocaleName(
    UINT32 currentPosition,
    DWRITE_TEXT_RANGE* textRange = NULL) const;

Parameters

currentPosition
The position of the text to inspect.

textRange
The range of text that has the same formatting as the text at the position specified by currentPosition. This means the run has the exact formatting as the position specified, including but not limited to the locale name.

Return Value

CString object that contains the current locale name.

CD2DTextLayout::IsValid

Checks resource validity

virtual BOOL IsValid() const;

Return Value

TRUE if resource is valid; otherwise FALSE.

CD2DTextLayout::m_pTextLayout

A pointer to an IDWriteTextLayout.

IDWriteTextLayout* m_pTextLayout;

CD2DTextLayout::operator IDWriteTextLayout*

Returns IDWriteTextLayout interface

operator IDWriteTextLayout*();

Return Value

Pointer to an IDWriteTextLayout interface or NULL if object is not initialized yet.

CD2DTextLayout::ReCreate

Re-creates a CD2DTextLayout.

virtual HRESULT ReCreate(CRenderTarget* */);

Return Value

If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

CD2DTextLayout::SetFontFamilyName

Sets null-terminated font family name for text within a specified text range

BOOL SetFontFamilyName(
    LPCWSTR pwzFontFamilyName,
    DWRITE_TEXT_RANGE textRange);

Parameters

pwzFontFamilyName
The font family name that applies to the entire text string within the range specified by textRange

textRange
Text range to which this change applies

Return Value

If the method succeeds, it returns TRUE. Otherwise, it returns FALSE

CD2DTextLayout::SetLocaleName

Sets the locale name for text within a specified text range

BOOL SetLocaleName(
    LPCWSTR pwzLocaleName,
    DWRITE_TEXT_RANGE textRange);

Parameters

pwzLocaleName
A null-terminated locale name string

textRange
Text range to which this change applies

Return Value

If the method succeeds, it returns TRUE. Otherwise, it returns FALSE

See also

Classes