/// <returns>Returns true if this operation succeeded.</returns>
virtual
bool
SetBackgroundColor
(
vint
start
,
vint
length
,
Color
value
)=
0
;
/// <summary>Bind an <see cref="IGuiGraphicsElement"/> to a range of text.</summary>
/// <param name="start">The position of the first character of the specified range.</param>
/// <param name="length">The length of the specified range by character.</param>
/// <param name="properties">The properties for the inline object.</param>
/// <returns>Returns true if this operation succeeded.</returns>
virtual
bool
SetInlineObject
(
vint
start
,
vint
length
,
const
InlineObjectProperties
&
properties
)=
0
;
/// <summary>Unbind all inline objects to a range of text.</summary>
/// <param name="start">The position of the first character of the specified range.</param>
/// <param name="length">The length of the specified range by character.</param>
/// <returns>Returns true if this operation succeeded.</returns>
virtual
bool
ResetInlineObject
(
vint
start
,
vint
length
)=
0
;
/// <summary>Get the layouted height of the text. The result depends on rich styled text and the two important properties that can be set using <see cref="SetWrapLine"/> and <see cref="SetMaxWidth"/>.</summary>
/// <returns>The layouted height.</returns>
virtual
vint
GetHeight
()=
0
;
/// <summary>Make the caret visible so that it will be rendered in the paragraph.</summary>
/// <returns>Returns true if this operation succeeded.</returns>
/// <param name="caret">The caret.</param>
/// <param name="color">The color of the caret.</param>
/// <param name="frontSide">Set to true to display the caret for the character before it.</param>
virtual
bool
OpenCaret
(
vint
caret
,
Color
color
,
bool
frontSide
)=
0
;
/// <summary>Make the caret invisible.</summary>
/// <returns>Returns true if this operation succeeded.</returns>
virtual
bool
CloseCaret
()=
0
;
/// <summary>Render the graphics element using a specified bounds.</summary>
/// <param name="bounds">Bounds to decide the size and position of the binded graphics element.</param>
virtual
void
Render
(
Rect
bounds
)=
0
;
/// <summary>Get a new caret from the old caret with a relative position.</summary>
/// <returns>The new caret. Returns -1 if failed.</returns>
/// <param name="comparingCaret">The caret to compare. If the position is CaretFirst or CaretLast, this argument is ignored.</param>
/// <param name="preferFrontSide">Only for CaretMoveUp and CaretMoveDown. Set to true to make the caret prefer to get closer to the character before it. After this function is called, this argument stored the suggested side for displaying the new caret.</param>
virtual
vint
GetCaret
(
vint
comparingCaret
,
CaretRelativePosition
position
,
bool
&
preferFrontSide
)=
0
;
/// <summary>Get the bounds of the caret.</summary>
/// <returns>The bounds whose width is 0. Returns an empty Rect value if failed.</returns>
/// <param name="caret">The caret.</param>
/// <param name="frontSide">Set to true to get the bounds of the front side, otherwise the back side. If only one side is valid, this argument is ignored.</param>
virtual
Rect
GetCaretBounds
(
vint
caret
,
bool
frontSide
)=
0
;
/// <summary>Get the caret from a specified position.</summary>
/// <returns>The caret. Returns -1 if failed.</returns>
/// <param name="point">The point.</param>
virtual
vint
GetCaretFromPoint
(
Point
point
)=
0
;
/// <summary>Get the inline object from a specified position.</summary>
/// <returns>The inline object. Returns null if failed.</returns>
/// <param name="point">The point.</param>
/// <param name="start">Get the start position of this element.</param>
/// <param name="length">Get the length of this element.</param>
virtual
Nullable
<
InlineObjectProperties
>
GetInlineObjectFromPoint
(
Point
point
,
vint
&
start
,
vint
&
length
)=
0
;
/// <summary>Get the nearest caret from a text position.</summary>
/// <returns>The caret. Returns -1 if failed. If the text position is a caret, then the result will be the text position itself without considering the frontSide argument.</returns>
/// <param name="textPos">The caret to compare. If the position is CaretFirst or CaretLast, this argument is ignored.</param>
/// <param name="frontSide">Set to true to search in front of the text position, otherwise the opposite position.</param>
virtual
vint
GetNearestCaretFromTextPos
(
vint
textPos
,
bool
frontSide
)=
0
;
/// <summary>Test is the caret valid.</summary>
/// <returns>Returns true if the caret is valid.</returns>
/// <param name="caret">The caret to test.</param>
virtual
bool
IsValidCaret
(
vint
caret
)=
0
;
/// <summary>Test is the text position valid.</summary>
/// <returns>Returns true if the text position is valid.</returns>
/// <param name="textPos">The text position to test.</param>
virtual
bool
IsValidTextPos
(
vint
textPos
)=
0
;
};
/// <summary>Paragraph callback</summary>
class
IGuiGraphicsParagraphCallback
:
public
IDescriptable
,
public
Description
<
IGuiGraphicsParagraphCallback
>
{
public
:
/// <summary>Called when an inline object with a valid callback id is being rendered.</summary>
/// <returns>Returns the new size of the rendered inline object.</returns>
/// <param name="callbackId">The callback id of the inline object</param>
/// <param name="location">The location of the inline object, relative to the left-top corner of this paragraph.</param>
virtual
Size
OnRenderInlineObject
(
vint
callbackId
,
Rect
location
) =
0
;
};
/// <summary>Renderer awared rich text document layout engine provider interface.</summary>
class
IGuiGraphicsLayoutProvider
:
public
IDescriptable
,
public
Description
<
IGuiGraphicsLayoutProvider
>
{
public
:
/// <summary>Create a paragraph with internal renderer device dependent objects initialized.</summary>
/// <param name="text">The text used to fill the paragraph.</param>
/// <param name="renderTarget">The render target that the created paragraph will render to.</param>
/// <param name="callback">A callback to receive necessary information when the paragraph is being rendered.</param>
/// <returns>The created paragraph object.</returns>