CssBox

TheArtOfDev.HtmlRenderer.Core.Dom

Represents a CSS Box of text or replaced elements.

Inherits: CssBoxProperties

Implements: IDisposable

Constructors

CssBox(CssBox, HtmlTag)

Init.

parentBox
optional: the parent of this css box in html
tag
optional: the html tag associated with this css box

Properties

Boxes : List<CssBox>

Gets the children boxes of this box

ContainingBlock : CssBox

Gets the containing block-box of this box. (The nearest parent box with display=block)

FirstHostingLineBox : CssLineBox

Gets or sets the first linebox where content of this box appear

FirstWord : CssRect

Gets the first word of the box

HtmlContainer : HtmlContainerInt

Gets the HtmlContainer of the Box. WARNING: May be null.

HtmlTag : HtmlTag

Gets the HTMLTag that hosts this box

IsBlock : bool

is the box "Display" is "Block", is this is an block box and not inline.

IsBrElement : bool

Is the box is of "br" element.

IsClickable : bool

Is the css box clickable (by default only "a" element is clickable)

IsFixed : bool

Gets a value indicating whether this instance or one of its parents has Position = fixed.

IsImage : bool

Gets if this box represents an image

IsInline : bool

is the box "Display" is "Inline", is this is an inline box and not block.

IsSpaceOrEmpty : bool

Tells if the box is empty or contains just blank spaces

LastHostingLineBox : CssLineBox

Gets or sets the last linebox where content of this box appear

LineBoxes : List<CssLineBox>

Gets the line-boxes of this box (if block box)

ParentBox : CssBox

Gets or sets the parent box of this box

ParentLineBoxes : List<CssLineBox>

Gets the linebox(es) that contains words of this box (if inline)

Rectangles : Dictionary<CssLineBox, RRect>

Gets the rectangles where this box should be painted

Text : SubString

Gets or sets the inner text of the box

Words : List<CssRect>

Gets the BoxWords of text in the box

Methods

CalculateActualRight() : double

Calculate the actual right of the box by the actual right of the child boxes if this box actual right is not set.

Returns: the calculated actual right value

CreateBlock(CssBox, HtmlTag, CssBox) : CssBox

Create new css block box for the given parent with the given optional html tag and insert it either at the end or before the given optional box. If no html tag is given the box will be anonymous. If no before box is given the new box will be added at the end of parent boxes collection. If before box doesn't exists in parent box exception is thrown.

parent
the box to add the new block box to it as child
tag
optional: the html tag to define the box
before
optional: to insert as specific location in parent box

Returns: the new block box

CreateBlock() : CssBox

Create new css block box.

Returns: the new block box

CreateBox(CssBox, HtmlTag, CssBox) : CssBox

Create new css box for the given parent with the given optional html tag and insert it either at the end or before the given optional box. If no html tag is given the box will be anonymous. If no before box is given the new box will be added at the end of parent boxes collection. If before box doesn't exists in parent box exception is thrown.

parent
the box to add the new box to it as child
tag
optional: the html tag to define the box
before
optional: to insert as specific location in parent box

Returns: the new box

CreateBox(HtmlTag, CssBox) : CssBox

Create new css box for the given parent with the given html tag.

tag
the html tag to define the box
parent
the box to add the new box to it as child

Returns: the new box

CreateListItemBox(RGraphics)

Creates the _listItemBox

g
Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

FirstWordOccourence(CssBox, CssLineBox) : CssRect

Searches for the first word occurrence inside the box, on the specified linebox

b
line
GetAttribute(string, string) : string

Gets the value of the specified attribute of the source HTML tag.

attribute
Attribute to retrieve
defaultValue
Value to return if attribute is not specified

Returns: Attribute value or defaultValue if no attribute specified

GetAttribute(string) : string

Gets the specified Attribute, returns string.Empty if no attribute specified

attribute
Attribute to retrieve

Returns: Attribute value or string.Empty if no attribute specified

GetIndexForList() : int

Gets the index of the box to be used on a (ordered) list

GetMaximumBottom(CssBox, double) : double

Gets the maximum bottom of the boxes inside the startBox

startBox
currentMaxBottom
GetMinimumWidth() : double

Gets the minimum width that the box can be. The box can be as thin as the longest word plus padding. The check is deep thru box tree.

Returns: the min width of the box

GetMinimumWidth_LongestWord(CssBox, double, CssRect)

Gets the longest word (in width) inside the box, deeply.

box
maxWidth
maxWidthWord
GetMinMaxSumWords(CssBox, double, double, double, double)

Get the and of the box words content and .

box
the box to calculate for
min
the width that allows for each word to fit (width of the longest word)
maxSum
the max width a single line of words can take without wrapping
paddingSum
the total amount of padding the content has
marginSum
GetMinMaxWidth(double, double)

Get the and width of the box content.

minWidth
The minimum width the content must be so it won't overflow (largest word + padding).
maxWidth
The total width the content can take without line wrapping (with padding).
GetParent() : CssBoxProperties

Get the parent of this css properties instance.

GetSelectionBackBrush(RGraphics, bool) : RBrush

Get brush for selection background depending if it has external and if alpha is required for images.

g
forceAlpha
used for images so they will have alpha effect
GetSelectionForeBrush() : RColor

Get brush for the text depending if there is selected text color set.

GetWidthMarginDeep(CssBox) : double

Get the total margin value (left and right) from the given box to the given end box.

box
the box to start calculation from.

Returns: the total margin

HasJustInlineSiblings() : bool

Gets if this box has only inline siblings (including itself)

InheritStyle(CssBox, bool)

Gets the rectangles where inline box will be drawn. See Remarks for more info.

Returns: Rectangles where content should be placed

MarginBottomCollapse() : double

Gets the result of collapsing the vertical margins of the two boxes

Returns: Resulting bottom margin

MarginTopCollapse(CssBoxProperties) : double

Gets the result of collapsing the vertical margins of the two boxes

prevSibling
the previous box under the same parent

Returns: Resulting top margin

MeasureWordsSize(RGraphics)

Assigns words its width and height

g
OffsetRectangle(CssLineBox, double)

Offsets the rectangle of the specified linebox by the specified gap, and goes deep for rectangles of children in that linebox.

lineBox
gap
OffsetTop(double)

Deeply offsets the top of the box and its contents

amount
OnImageLoadComplete(RImage, RRect, bool)

On image load process complete with image request refresh for it to be painted.

image
the image loaded or null if failed
rectangle
the source rectangle to draw in the image (empty - draw everything)
async
is the callback was called async to load image call
Paint(RGraphics)

Paints the fragment

g
Device context to use
PaintBackground(RGraphics, RRect, bool, bool)

Paints the background of the box

g
the device to draw into
rect
the bounding rectangle to draw in
isFirst
is it the first rectangle of the element
isLast
is it the last rectangle of the element
PaintDecoration(RGraphics, RRect, bool, bool)

Paints the text decoration (underline/strike-through/over-line)

g
the device to draw into
rectangle
isFirst
isLast
PaintImp(RGraphics)

Paints the fragment

g
the device to draw to
PaintWords(RGraphics, RPoint)

Paint all the words in the box.

g
the device to draw into
offset
the current scroll offset to offset the words
ParseToWords()

Splits the text into words and saves the result

PerformLayout(RGraphics)

Measures the bounds of box and children, recursively. Performs layout of the DOM structure creating lines by set bounds restrictions.

g
Device context to use
PerformLayoutImp(RGraphics)

Measures the bounds of box and children, recursively. Performs layout of the DOM structure creating lines by set bounds restrictions.

g
Device context to use
RectanglesReset()

Resets the Rectangles array

SetAllBoxes(CssBox)

Move all child boxes from to this box.

fromBox
the box to move all its child boxes from
SetBeforeBox(CssBox)

Set this box in

before
ToString() : string

ToString override.

Fields

_htmlContainer : HtmlContainerInt

the root container for the hierarchy

_htmltag : HtmlTag

the html tag that is associated with this css box, null if anonymous box

_imageLoadHandler : ImageLoadHandler

handler for loading background image

_parentBox : CssBox

the parent css box of this css box in the hierarchy

_tableFixed : bool

Do not use or alter this flag

_text : SubString

the inner text of the box