CODTextComponent Class

class CODTextComponent: public CODPointComponent

The text component supports single and multiple lines of text, horizontal and vertical alignment, rotation, and editing. The following properties can be used to configure its behavior.

OD_PROP_FONT - Determines the font to use for the text.

OD_PROP_MULTILINE - Boolean property that toggles between single and muliple line text.

OD_PROP_WORDBREAK - Boolean property that enables and disables automatic word wrap.

OD_PROP_VERT_ALIGNMENT - Integer property that can have the following values (DT_TOP, DT_VCENTER, DT_BOTTOM).

OD_PROP_HORZ_ALIGNMENT - Integer property that can have the following values (DT_LEFT, DT_CENTER, DT_RIGHT).

Like most other components, the text component also supports edit, line, and fill properties (OD_PROP_EDIT, OD_PROP_LINE, OD_PROP_FILL).

The  GetFormat method examines the properties and returns a flag value compatible with the Windows GDI function DrawText. The  DrawText method is similar in behavior to the Windows GDI DrawText function.

When  BeginEdit is called to the edit the text, an edit control is created and the component is rotated back to zero degrees for the duration of the edit action. The m_nSaveAngle member variable saves the rotation value so that when editing is complete, the component can be rotated back to the original angle.

The  CalcLineBreaks method is used to determine where line breaks occur in the text buffer. It populates a  CODLineBreakSet object that describes the position and size of each line. The text buffer may contain hard line breaks (carriage returns). If the OD_PROP_WORDBREAK property is TRUE, then CalcLineBreaks will determine where lines wrap as well.

The following properties are added to the component by this class:

OD_PROP_LINE, OD_PROP_FILL, OD_PROP_FONT, OD_PROP_WORDBREAK, OD_PROP_MULTILINE, OD_PROP_HORZ_ALIGNMENT, OD_PROP_VERT_ALIGNMENT, OD_PROP_AUTOSIZE

Defined in: OdTextComp.h

See Also

Component Property Identifiers

Component Property Identifiers

Class Members

 CODTextComponent()

Constructor.

 CODTextComponent(const CODTextComponent& src)

Copy constructor.

virtual  ~CODTextComponent()

Destructor.

BOOL  Create(CRect& rcBox, CDC* pDC)

Creates the text component given a bounding box.

BOOL  Create(CPoint ptLog, CDC* pDC)

Creates the text component given a center point.

CODTextComponent&  operator=(const CODTextComponent& src)

Assignment operator.

virtual CODComponent*  Dup() const

Create a duplicate copy of this object.

CString m_strText

The text to draw.

CODTextCompEdit* m_pEdit

Edit control for modifying text.

CFont* m_pEditFont

Edit font used for modifying the text.

int m_nSaveAngle

Saves the angle of rotation while text component is in edit mode.

State for enabling or disabling font scaling. False by default.

const CString&  GetText() const

Gets the text that is drawn.

virtual void  SetText(const LPCTSTR lpszText)

Sets the text to be drawn.

UINT  GetFormat() const

Returns the format properties as a bit field.

Returns a boolean for whether or not font scaling is enabled.

Enable or disable font scaling.

virtual CSize  CalcTextSize(CDC* pDC)

Calculate the size occupied by the text in logical units.

virtual CRect  CalcTextMargins(CDC* pDC)

Calculate the margins in logical units.

virtual CSize  CalcTextBorder(CDC* pDC)

Calculate the size of the text border in logical units.

virtual void  SizeToText(const OD_CONTROL_POINT ctlPt = OD_CENTER, CDC* pDC = 0)

Calculate the bounding points so that they match the dimensions of the text.

virtual void  GrowToText(const OD_CONTROL_POINT ctlPt = OD_CENTER, CDC* pDC = 0)

Calculate the bounding points so that the width/height are greater than or equal to the size of the text.

CRect  GetTextBox() const

Gets the dimensions of the text box.

void  SetTextBox(CRect rcBox)

Sets the dimensions of the text box.

int  GetAngle() const

Returns the current angle of rotation for the text.

virtual void  GetHandles(CODPointArray* pHandleArray, BOOL bVertexHandles = FALSE)

Return handle points (none for edit mode).

virtual void Scale(float fScaleX, float fScaleY, float fOriginX, float fOriginY)

Scales the component in reference to a point.

virtual int CalcFontPointSizeByRect(const CRect& rcTextBox, const CString& strText)

Calculates the size of font on a single line that will fit in the given rect.

virtual int CalcAnnotationFontPointSize(const CRect& rcTextBox, const CString& strText)

Calculates the size of font that will fit, with multiple or single lines, for the given rect.

int  CalcLineBreaks(CDC* pDC, CODLineBreakSet& setBreaks)

Calculates the line breaks for the text buffer.

BOOL  IsEditing() const

Indicates whether text component in edit mode or not.

virtual BOOL  BeginEdit(sfl::MvcViewport* pContainer)

Puts the text component into edit mode.

CString  GetEditText() const

Returns the text in the edit control.

virtual void  SetEditText(const LPCTSTR lpszText)

Sets the text in the edit control.

virtual void  SaveEdit()

Transfers the text from the edit control to the text component.

virtual void  CancelEdit()

Closes the edit control and ends edit mode.

virtual void  UpdateEdit(const sfl::MvcViewport* pContainer)

Updates the edit control to reflect change in text component properties.

CEdit*  GetEditControl()

Gets a pointer to the edit control.

virtual HBRUSH  GetCtlBrush(CDC* pDC)

Return a brush that can be used to paint the edit control.

virtual OD_MOVEVERTEX_RC  CalculateMovedVertices(int nIndex, int nOffsetX, int nOffsetY)

Adjust other vertices to stay synchronized with the move of the given vertex.

virtual void  OnDraw(CDC* pDC)

Draws the text.

virtual void  Serialize(CArchive& ar)

Serializes the text component.

void  DrawText(CDC* pDC)

Draws the text.

void  DrawEdit(CDC* pDC)

Positions the edit control and makes it visible.

void  SetDrawEllipsis(BOOL bEllipsis = TRUE);

Enables to draw ellipsis in a long text and sets left alignment.