htmlayout::dom::element Class Reference

DOM element. More...

#include <htmlayout_dom.hpp>


Public Member Functions

 element ()
 Construct undefined element .
 element (HELEMENT h)
 Construct element from existing element handle.
 element (const element &e)
 Copy constructor;.
 ~element ()
 Destructor.
elementoperator= (HELEMENT h)
 Assign element an HELEMENT.
elementoperator= (const element &e)
 Assign element another element.
bool operator== (const element &rs) const
 Test equality of this and another element's.
bool operator!= (const element &rs) const
 Test equality of this and another element's.
bool is_valid () const
 Test whether element is valid.
unsigned int children_count () const
 Get number of child elements.
HELEMENT child (unsigned int index) const
 Get Nth child element.
HELEMENT parent () const
 Get parent element.
unsigned int index () const
 Get index of this element in its parent collection.
unsigned int get_attribute_count () const
 Get number of the attributes.
const wchar_t * get_attribute (unsigned int n) const
 Get attribute value by its index.
const char * get_attribute_name (unsigned int n) const
 Get attribute name by its index.
const wchar_t * get_attribute (const char *name) const
 Get attribute value by name.
void set_attribute (const char *name, const wchar_t *value)
 Add or replace attribute.
int get_attribute_int (const char *name, int def_val=0) const
 Get attribute integer value by name.
void remove_attribute (const char *name)
 Remove attribute.
const wchar_t * get_style_attribute (const char *name) const
 Get style attribute of the element by its name.
void set_style_attribute (const char *name, const wchar_t *value) const
 Set style attribute.
void set_capture ()
 Set mouse capture.
void select (callback *pcall, const char *tag_name=0, const char *attr_name=0, const wchar_t *attr_value=0, int depth=0) const
 Enumerate all descendant elements.
HELEMENT get_element_by_id (const char *id) const
 Get element by id.
void update (bool render_now=false) const
 Apply changes and refresh element area in its window.
void update (int mode) const
 Apply changes and refresh element area in its window.
HELEMENT next_sibling () const
 Get next sibling element.
HELEMENT prev_sibling () const
 Get previous sibling element.
HELEMENT first_sibling () const
 Get first sibling element.
HELEMENT last_sibling () const
 Get last sibling element.
HELEMENT root () const
 Get root of the element.
RECT get_location (unsigned int area=ROOT_RELATIVE|CONTENT_BOX) const
 Get bounding rectangle of the element.
bool is_inside (POINT client_pt) const
 Test if point is inside shape rectangle of the element.
void scroll_to_view (bool toTopOfView=false)
 Scroll this element to view.
const char * get_element_type () const
 Get element's type.
HWND get_element_hwnd (bool root_window)
 Get HWND of containing window.
UINT get_element_uid ()
 Get element UID - identifier suitable for storage.
void combine_url (LPWSTR inOutURL, UINT bufferSize)
 Combine given URL with URL of the document element belongs to.
void set_html (const unsigned char *html, size_t html_length, int where=SIH_REPLACE_CONTENT)
 Set inner or outer html of the element.
void destroy ()
 Delete element.
unsigned int get_state () const
 Get UI state bits of the element as set of ELEMENT_STATE_BITS.
bool get_state (unsigned int bits) const
 Checks if particular UI state bits are set in the element.
void set_state (unsigned int bitsToSet, unsigned int bitsToClear=0, bool update=true)
 Set UI state of the element with optional view update.
bool enabled ()
 "deeply enabled"
bool visible ()
 "deeply visible"
element clone ()
 create brand new copy of this element.
void insert (const element &e, unsigned int index)
 Insert element e at index position of this element.
void append (const element &e)
 Append element e as last child of this element.
void detach ()
 detach - remove this element from its parent
bool send_event (unsigned int event_code, UINT_PTR reason=0, HELEMENT heSource=0)
 traverse event - send it by sinking/bubbling on the parent/child chain of this element
void post_event (unsigned int event_code, unsigned int reason=0, HELEMENT heSource=0)
 post event - post it in the queue for later sinking/bubbling on the parent/child chain of this element.
void attach (event_handler *pevth)
 attach event handler to the element
void detach (event_handler *pevth)
 remove event handler from the list of event handlers of the element.
bool call_behavior_method (METHOD_PARAMS *p)
 call method, invokes method in all event handlers attached to the element
void sort (comparator &cmp, int start=0, int end=-1)
 reorders children of the element using sorting order defined by cmp

Static Public Member Functions

static HELEMENT root_element (HWND hHTMLayoutWnd)
 Get root DOM element of the HTMLayout document.
static HELEMENT focus_element (HWND hHTMLayoutWnd)
 Get focus DOM element of the HTMLayout document.
static HELEMENT find_element (HWND hHTMLayoutWnd, POINT clientPt)
 Find DOM element of the HTMLayout document by coordinates.
static void release_capture ()
 Release mouse capture.
static HELEMENT element_by_uid (HWND hHTMLayoutWnd, UINT uid)
 Get element handle by its UID.
static element create (const char *tagname, const wchar_t *text=0)
 create brand new element with text (optional).


Detailed Description

DOM element.


Constructor & Destructor Documentation

htmlayout::dom::element::element ( HELEMENT  h  )  [inline]

Construct element from existing element handle.

Parameters:
h HELEMENT

htmlayout::dom::element::element ( const element e  )  [inline]

Copy constructor;.

Parameters:
e element

htmlayout::dom::element::~element (  )  [inline]

Destructor.


Member Function Documentation

element& htmlayout::dom::element::operator= ( HELEMENT  h  )  [inline]

Assign element an HELEMENT.

Parameters:
h HELEMENT
Returns:
element&

element& htmlayout::dom::element::operator= ( const element e  )  [inline]

Assign element another element.

Parameters:
e element
Returns:
element&

bool htmlayout::dom::element::operator== ( const element rs  )  const [inline]

Test equality of this and another element's.

Parameters:
rs const element
Returns:
bool, true if elements are equal, false otherwise

bool htmlayout::dom::element::operator!= ( const element rs  )  const [inline]

Test equality of this and another element's.

Parameters:
rs const element
Returns:
bool, true if elements are not equal, false otherwise

bool htmlayout::dom::element::is_valid (  )  const [inline]

Test whether element is valid.

Returns:
bool, true if element is valid, false otherwise

unsigned int htmlayout::dom::element::children_count (  )  const [inline]

Get number of child elements.

Returns:
int, number of child elements

HELEMENT htmlayout::dom::element::child ( unsigned int  index  )  const [inline]

Get Nth child element.

Parameters:
index unsigned int, number of the child element
Returns:
HELEMENT, child element handle

HELEMENT htmlayout::dom::element::parent (  )  const [inline]

Get parent element.

Returns:
HELEMENT, handle of the parent element

unsigned int htmlayout::dom::element::index (  )  const [inline]

Get index of this element in its parent collection.

Returns:
unsigned int, index of this element in its parent collection

unsigned int htmlayout::dom::element::get_attribute_count (  )  const [inline]

Get number of the attributes.

Returns:
unsigned int, number of the attributes

const wchar_t* htmlayout::dom::element::get_attribute ( unsigned int  n  )  const [inline]

Get attribute value by its index.

Parameters:
n unsigned int, number of the attribute
Returns:
const wchar_t*, value of the n-th attribute

const char* htmlayout::dom::element::get_attribute_name ( unsigned int  n  )  const [inline]

Get attribute name by its index.

Parameters:
n unsigned int, number of the attribute
Returns:
const char*, name of the n-th attribute

const wchar_t* htmlayout::dom::element::get_attribute ( const char *  name  )  const [inline]

Get attribute value by name.

Parameters:
name const char*, name of the attribute
Returns:
const wchar_t*, value of the n-th attribute

void htmlayout::dom::element::set_attribute ( const char *  name,
const wchar_t *  value 
) [inline]

Add or replace attribute.

Parameters:
name const char*, name of the attribute
value const wchar_t*, name of the attribute

int htmlayout::dom::element::get_attribute_int ( const char *  name,
int  def_val = 0 
) const [inline]

Get attribute integer value by name.

Parameters:
name const char*, name of the attribute
Returns:
int , value of the attribute

void htmlayout::dom::element::remove_attribute ( const char *  name  )  [inline]

Remove attribute.

Parameters:
name const char*, name of the attribute

const wchar_t* htmlayout::dom::element::get_style_attribute ( const char *  name  )  const [inline]

Get style attribute of the element by its name.

Parameters:
name const char*, name of the style attribute, e.g. "background-color"
Returns:
const wchar_t*, value of the style attribute
Also all style attributes of the element are available in "style" attribute of the element.

void htmlayout::dom::element::set_style_attribute ( const char *  name,
const wchar_t *  value 
) const [inline]

Set style attribute.

Parameters:
name const char*, name of the style attribute
value const wchar_t*, value of the style attribute
Example:
 e.set_style_attribute("background-color", L"red"); 

static HELEMENT htmlayout::dom::element::root_element ( HWND  hHTMLayoutWnd  )  [inline, static]

Get root DOM element of the HTMLayout document.

Parameters:
hHTMLayoutWnd HWND, HTMLayout window
Returns:
HELEMENT, root element
See also:
also root

static HELEMENT htmlayout::dom::element::focus_element ( HWND  hHTMLayoutWnd  )  [inline, static]

Get focus DOM element of the HTMLayout document.

Parameters:
hHTMLayoutWnd HWND, HTMLayout window
Returns:
HELEMENT, focus element
COMMENT: to set focus use: set_state(STATE_FOCUS)

static HELEMENT htmlayout::dom::element::find_element ( HWND  hHTMLayoutWnd,
POINT  clientPt 
) [inline, static]

Find DOM element of the HTMLayout document by coordinates.

Parameters:
hHTMLayoutWnd HWND, HTMLayout window
clientPt POINT, coordinates.
Returns:
HELEMENT, found element handle or zero

void htmlayout::dom::element::set_capture (  )  [inline]

Set mouse capture.

After call to this function all mouse events will be targeted to this element. To remove mouse capture call htmlayout::dom::element::release_capture().

static void htmlayout::dom::element::release_capture (  )  [inline, static]

Release mouse capture.

Mouse capture can be set with element:set_capture()

void htmlayout::dom::element::select ( callback pcall,
const char *  tag_name = 0,
const char *  attr_name = 0,
const wchar_t *  attr_value = 0,
int  depth = 0 
) const [inline]

Enumerate all descendant elements.

Parameters:
pcall htmlayout::dom::callback*, callback structure. Its member function htmlayout::dom::callback::on_element() is called for every enumerated element.
tag_name const char*, comma separated list of tag names to search, e.g. "div", "p", "div,p" etc. Can be NULL.
attr_name const char*, name of attribute, can contain wildcard characters, see below. Can be NULL.
attr_value const char*, name of attribute, can contain wildcard characters, see below. Can be NULL.
depth int, depth - depth of search. 0 means all descendants, 1 - direct children only, 2 - children and their children and so on.
Wildcard characters in attr_name and attr_value:

Example:
  • [a-z] - all lowercase letters
  • [a-zA-Z] - all letters
  • [abd-z] - all lowercase letters except of 'c'
  • [-a-z] - all lowercase letters and '-'
Example:
 document.select(mycallback, "a", "href", "http:*.php"); 
will call mycallback.on_element() on each element in the document having 'href' attribute with value starting from "http:" and ending with ".php"
Example:
 document.select(mycallback); 
will enumerate ALL elements in the document.

HELEMENT htmlayout::dom::element::get_element_by_id ( const char *  id  )  const [inline]

Get element by id.

Parameters:
id char*, value of the "id" attribute.
Returns:
HELEMENT, handle of the first element with the "id" attribute equal to given.

void htmlayout::dom::element::update ( bool  render_now = false  )  const [inline]

Apply changes and refresh element area in its window.

Parameters:
[in] render_now bool, if true element will be redrawn immediately.

void htmlayout::dom::element::update ( int  mode  )  const [inline]

Apply changes and refresh element area in its window.

Parameters:
[in] render_now bool, if true element will be redrawn immediately.

HELEMENT htmlayout::dom::element::next_sibling (  )  const [inline]

Get next sibling element.

Returns:
HELEMENT, handle of the next sibling element if it exists or 0 otherwise

HELEMENT htmlayout::dom::element::prev_sibling (  )  const [inline]

Get previous sibling element.

Returns:
HELEMENT, handle of previous sibling element if it exists or 0 otherwise

HELEMENT htmlayout::dom::element::first_sibling (  )  const [inline]

Get first sibling element.

Returns:
HELEMENT, handle of the first sibling element if it exists or 0 otherwise

HELEMENT htmlayout::dom::element::last_sibling (  )  const [inline]

Get last sibling element.

Returns:
HELEMENT, handle of last sibling element if it exists or 0 otherwise

HELEMENT htmlayout::dom::element::root (  )  const [inline]

Get root of the element.

Returns:
HELEMENT, handle of document root element (html)

RECT htmlayout::dom::element::get_location ( unsigned int  area = ROOT_RELATIVE | CONTENT_BOX  )  const [inline]

Get bounding rectangle of the element.

Parameters:
root_relative bool, if true function returns location of the element relative to HTMLayout window, otherwise the location is given relative to first scrollable container.
Returns:
RECT, bounding rectangle of the element.

bool htmlayout::dom::element::is_inside ( POINT  client_pt  )  const [inline]

Test if point is inside shape rectangle of the element.

client_pt - client rect relative point

const char* htmlayout::dom::element::get_element_type (  )  const [inline]

Get element's type.

Returns:
const char*, name of the elements type
Example:
For <div> tag function will return "div".

HWND htmlayout::dom::element::get_element_hwnd ( bool  root_window  )  [inline]

Get HWND of containing window.

Parameters:
root_window bool, handle of which window to get:
  • true - HTMLayout window
  • false - nearest parent element having overflow:auto or :scroll
Returns:
HWND

UINT htmlayout::dom::element::get_element_uid (  )  [inline]

Get element UID - identifier suitable for storage.

Returns:
UID

static HELEMENT htmlayout::dom::element::element_by_uid ( HWND  hHTMLayoutWnd,
UINT  uid 
) [inline, static]

Get element handle by its UID.

Parameters:
hHTMLayoutWnd HWND, HTMLayout window
uid UINT, uid of the element
Returns:
HELEMENT, handle of element with the given uid or 0 if not found

void htmlayout::dom::element::combine_url ( LPWSTR  inOutURL,
UINT  bufferSize 
) [inline]

Combine given URL with URL of the document element belongs to.

Parameters:
[in,out] inOutURL LPWSTR, at input this buffer contains zero-terminated URL to be combined, after function call it contains zero-terminated combined URL
bufferSize UINT, size of the buffer pointed by inOutURL

void htmlayout::dom::element::set_html ( const unsigned char *  html,
size_t  html_length,
int  where = SIH_REPLACE_CONTENT 
) [inline]

Set inner or outer html of the element.

Parameters:
html const unsigned char*, UTF-8 encoded string containing html text
html_length size_t, length in bytes of html
where int, possible values are:
  • SIH_REPLACE_CONTENT - replace content of the element
  • SIH_INSERT_AT_START - insert html before first child of the element
  • SIH_APPEND_AFTER_LAST - insert html after last child of the element

void htmlayout::dom::element::destroy (  )  [inline]

Delete element.

This function removes element from the DOM tree and then deletes it.

static element htmlayout::dom::element::create ( const char *  tagname,
const wchar_t *  text = 0 
) [inline, static]

create brand new element with text (optional).

Example: element div = element::create("div");

element htmlayout::dom::element::clone (  )  [inline]

create brand new copy of this element.

Element will be created disconected. You need to call insert to inject it in some container. Example: element select = ...; element option1 = ...; element option2 = option1.clone(); select.insert(option2, option1.index() + 1);

void htmlayout::dom::element::post_event ( unsigned int  event_code,
unsigned int  reason = 0,
HELEMENT  heSource = 0 
) [inline]

post event - post it in the queue for later sinking/bubbling on the parent/child chain of this element.

method returns immediately


The documentation for this class was generated from the following file:
Generated on Fri May 18 22:05:12 2007 for HTMLayout by  doxygen 1.5.1-p1