wxRuby Documentation Home

# Wx::HtmlCell

Internal data structure. It represents fragments of parsed HTML
page, the so-called cell – a word, picture, table, horizontal line and so on.
It is used by HtmlWindow and
HtmlWinParser to represent HTML page in memory.

You can divide cells into two groups : visible cells with non-zero width and
height and helper cells (usually with zero width and height) that
perform special actions such as color or font change.

## Derived from

Object

## See Also

Cells Overview,
HtmlContainerCell

## Methods

- HtmlCell.new
- HtmlCell#adjust_pagebreak
- HtmlCell#draw
- HtmlCell#draw_invisible
- HtmlCell#find
- HtmlCell#get_descent
- HtmlCell#get_first_child
- HtmlCell#get_height
- HtmlCell#get_id
- HtmlCell#get_link
- HtmlCell#get_next
- HtmlCell#get_parent
- HtmlCell#get_pos_x
- HtmlCell#get_pos_y
- HtmlCell#get_width
- HtmlCell#layout
- HtmlCell#on_mouse_click
- HtmlCell#set_id
- HtmlCell#set_link
- HtmlCell#set_next
- HtmlCell#set_parent
- HtmlCell#set_pos

### HtmlCell.new

### HtmlCell#adjust_pagebreak

Boolean adjust_pagebreak(%(arg-type)Integer% pagebreak)

This method is used to adjust pagebreak position. The parameter is
variable that contains y-coordinate of page break (= horizontal line that
should not be crossed by words, images etc.). If this cell cannot be divided
into two pieces (each one on another page) then it moves the pagebreak
few pixels up.

Returns true if pagebreak was modified, false otherwise

Usage:

while (container→AdjustPagebreak(&p)) {}

### HtmlCell#draw

draw(%(arg-type)DC% dc, Integer x, Integer y, Integer view_y1, Integer view_y2)

Renders the cell.

#### Parameters

- dc Device context to which the cell is to be drawn
- x,y Coordinates of parent’s upper left corner (origin). You must
  add this to m_PosX,m_PosY when passing coordinates to dc’s methods
  Example : `dc -> DrawText("hello", x + m_PosX, y + m_PosY)`
- view_y1 y-coord of the first line visible in window. This is
  used to optimize rendering speed
- view_y2 y-coord of the last line visible in window. This is
  used to optimize rendering speed

### HtmlCell#draw_invisible

draw_invisible(%(arg-type)DC% dc, Integer x, Integer y)

This method is called instead of Draw when the
cell is certainly out of the screen (and thus invisible). This is not
nonsense – some tags (like HtmlColourCell
or font setter) must be drawn even if they are invisible!

#### Parameters

- dc Device context to which the cell is to be drawn
- x,y Coordinates of parent’s upper left corner. You must
  add this to m_PosX,m_PosY when passing coordinates to dc’s methods
  Example : `dc -> DrawText("hello", x + m_PosX, y + m_PosY)`

### HtmlCell#find

HtmlCell find(%(arg-type)Integer% condition, (arg-type) param)

Returns pointer to itself if this cell matches condition (or if any of the cells
following in the list matches), NULL otherwise.
(In other words if you call top-level container’s Find it will
return pointer to the first cell that matches the condition)

It is recommended way how to obtain pointer to particular cell or
to cell of some type (e.g. HtmlAnchorCell reacts on
HTML_COND_ISANCHOR condition)

#### Parameters

- condition Unique integer identifier of condition
- param Optional parameters

#### Defined conditions

HTML_COND_ISANCHOR | Finds particular anchor. param is pointer to String with name of the anchor.
HTML_COND_USER | User-defined conditions startfrom this number.

### HtmlCell#get_descent

Integer get_descent()

Returns descent value of the cell (m_Descent member).
See explanation:

descent.bmp

### HtmlCell#get_first_child

HtmlCell get_first_child()

Returns pointer to the first cell in the list.
You can then use child’s get_next
method to obtain pointer to the next cell in list.

Note: This shouldn’t be used by the end user. If you need some way of
finding particular cell in the list, try Find method
instead.

### HtmlCell#get_height

Integer get_height()

Returns height of the cell (m_Height member).

### HtmlCell#get_id

String get_id()

Returns unique cell identifier if there is any, empty string otherwise.

### HtmlCell#get_link

HtmlLinkInfo get_link(%(arg-type)Integer% x = 0, Integer y = 0)

Returns hypertext link if associated with this cell or NULL otherwise.
See HtmlLinkInfo.
(Note: this makes sense only for visible tags).

#### Parameters

- x,y Coordinates of position where the user pressed mouse button.
  These coordinates are used e.g. by COLORMAP. Values are relative to the
  upper left corner of THIS cell (i.e. from 0 to m_Width or m_Height)

### HtmlCell#get_next

HtmlCell get_next()

Returns pointer to the next cell in list (see htmlcell.h if you’re
interested in details).

### HtmlCell#get_parent

HtmlContainerCell get_parent()

Returns pointer to parent container.

### HtmlCell#get_pos_x

Integer get_pos_x()

Returns X position within parent (the value is relative to parent’s
upper left corner). The returned value is meaningful only if
parent’s Layout was called before!

### HtmlCell#get_pos_y

Integer get_pos_y()

Returns Y position within parent (the value is relative to parent’s
upper left corner). The returned value is meaningful only if
parent’s Layout was called before!

### HtmlCell#get_width

Integer get_width()

Returns width of the cell (m_Width member).

### HtmlCell#layout

layout(%(arg-type)Integer% w)

This method performs two actions:

1. adjusts the cell’s width according to the fact that maximal possible width is w.
   (this has sense when working with horizontal lines, tables etc.)
2. prepares layout (=fill-in m_PosX, m_PosY (and sometimes m_Height) members)
   based on actual width w

It must be called before displaying cells structure because
m_PosX and m_PosY are undefined (or invalid)
before calling Layout.

### HtmlCell#on_mouse_click

on_mouse_click(%(arg-type)Window% parent, Integer x, Integer y, MouseEvent event)

This function is simple event handler. Each time the user clicks mouse button over a cell
within HtmlWindow this method of that cell is called. Default behavior is
that it calls HtmlWindow#load_page.

#### Note

If you need more “advanced” event handling
you should use HtmlBinderCell instead.

#### Parameters

- parent parent window (always HtmlWindow!)
- x, y coordinates of mouse click (this is relative to cell’s origin
- left, middle, right boolean flags for mouse buttons. true if the left/middle/right
  button is pressed, false otherwise

### HtmlCell#set_id

set_id(%(arg-type)String% id)

Sets unique cell identifier. Default value is no identifier, i.e. empty string.

### HtmlCell#set_link

set_link(%(arg-type)HtmlLinkInfo% link)

Sets the hypertext link associated with this cell. (Default value
is HtmlLinkInfo("", "") (no link))

### HtmlCell#set_next

set_next(%(arg-type)HtmlCell% cell)

Sets the next cell in the list. This shouldn’t be called by user – it is
to be used only by HtmlContainerCell#insert_cell.

### HtmlCell#set_parent

set_parent(%(arg-type)HtmlContainerCell% p)

Sets parent container of this cell. This is called from
HtmlContainerCell#insert_cell.

### HtmlCell#set_pos

set_pos(%(arg-type)Integer% x, Integer y)

Sets the cell’s position within parent container.

[This page automatically generated from the Textile source at 2023-06-09 00:45:31 +0000]