Home | All Classes | Grouped Classes | Index | Search

CL_TextStyler::bounding_rect

Calculate the rectangle that would be occupied by a draw operation.

	CL_Rect bounding_rect(
		int x, int y, const std::string& str);

	CL_Rect bounding_rect(
		CL_Rect dest, const std::string& str);

	CL_Rect bounding_rect(
		int x, int y, std::string::const_iterator start, std::string::const_iterator end);

	CL_Rect bounding_rect(
		CL_Rect dest, std::string::const_iterator start, std::string::const_iterator end);

Parameters:

x, y
Anchor position of where to render text. Actual rendering position depends on the alignment mode.
dest
Rectangle to draw text in. The text will be word-wrapped against delimiters to fit inside the rectangle.
str
The source string to parse and render.
start
String position to begin rendering at, inclusive.
end
String position to end rendering at, exclusive.

Detailed description:

You can specify a dest rectangle with a width or height of zero or less to disable word wrapping or height truncating, respectively.

It's more efficient to draw text into a GlyphBuffer, then use that for drawing and bounding rect calculation. This method is just for convienence.

See also:

CL_Rect | CL_TextStyler



Questions or comments, write to the ClanLib mailing list.