本文整理汇总了C++中dom::element类的典型用法代码示例。如果您正苦于以下问题:C++ element类的具体用法?C++ element怎么用?C++ element使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_value
/** Get value of the DOM element. Returns value for elements recognized by get_ctl_type() function.
* \param[in] el \b const dom::element&, The element.
* \return \b value_t, value of the element.
**/
inline value_t get_value(dom::element& el )
{
switch(get_ctl_type(el))
{
case CTL_EDIT:
case CTL_DECIMAL:
case CTL_CURRENCY:
case CTL_PASSWORD:
case CTL_NUMERIC:
case CTL_PROGRESS:
case CTL_SLIDER:
case CTL_SELECT_SINGLE:
case CTL_SELECT_MULTIPLE:
case CTL_DD_SELECT:
case CTL_TEXTAREA:
case CTL_DATE:
case CTL_CALENDAR:
default:
return el.get_value();
// special cases:
case CTL_UNKNOWN:
if( !aux::wcseq(el.get_attribute("type"),L"hidden"))
break;
//else fall below if it is hidden
case CTL_BUTTON: return value_t(el.get_attribute("value"));
case CTL_CHECKBOX: return get_checkbox_bits(el);
case CTL_RADIO: return get_radio_index(el);
case CTL_HTMLAREA: return value_t(el.get_html(false/*inner*/));
}
return value_t();
}
示例2: setup_node
void setup_node( dom::element node )
{
dom::element on = node.find_first("option[check='on'],options[check='on']");
dom::element off = node.find_first("option[check='off'],options[check='off']");
dom::element mixed = node.find_first("options[check='mixed']");
const wchar_t* _prev = node.get_attribute(CHECK_ATTR);
std::wstring prev = _prev?_prev:L"";
if( mixed.is_valid() || (on.is_valid() && off.is_valid()))
{
node.set_attribute(CHECK_ATTR,L"mixed");
if(prev != L"mixed") node.update();
}
else if( on.is_valid() )
{
node.set_attribute(CHECK_ATTR,L"on");
if(prev != L"on") node.update();
}
else
{
node.set_attribute(CHECK_ATTR,L"off");
if(prev != L"off") node.update();
}
}
示例3: init_options
NODE_STATE init_options(dom::element n)
{
//NODE_STATE n_state = NODE_MIXED;
int n_off = 0;
int n_on = 0;
int n_total = 0;
for(int i = 0; i < int(n.children_count()); ++i)
{
dom::element t = n.child(i);
NODE_STATE t_state;
if( streq(t.get_element_type(),"options") )
t_state = init_options(t);
else if( streq(t.get_element_type(),"option") )
t_state = get_state(t);
else
continue;
set_state(t, t_state);
switch( t_state )
{
case NODE_OFF: ++n_off; break;
case NODE_ON: ++n_on; break;
}
++n_total;
}
if( n_off == n_total ) return NODE_OFF;
if( n_on == n_total ) return NODE_ON;
return NODE_MIXED;
}
示例4: checkall
void checkall (dom::element& table, bool onOff )
{
if( !is_multiple(table) ) return;
struct unchecker_cb: dom::callback
{
bool on_element(HELEMENT he)
{
htmlayout::dom::element el = he; if( el.get_state(STATE_CHECKED)) el.set_state(0,STATE_CHECKED,false ); return false; /*continue enumeration*/
}
};
struct checker_cb: dom::callback
{
bool on_element(HELEMENT he)
{
htmlayout::dom::element el = he; if( !el.get_state(STATE_CHECKED)) el.set_state(STATE_CHECKED,0,false ); return false; /*continue enumeration*/
}
};
if(onOff)
{
checker_cb checker;
table.find_all(&checker,"tr");
}
else
{
unchecker_cb unchecker;
table.find_all(&unchecker,"tr:checked");
}
}
示例5: set_anchor
void set_anchor (dom::element& table,const int idx)
{
dom::element row = table.find_first("tr:anchor");
if( row.is_valid() ) row.set_state( 0,STATE_ANCHOR,false);
row = table.child(idx);
if( row.is_valid() )
row.set_state( STATE_ANCHOR | STATE_CHECKED,0,false);
}
示例6: belongs_to
bool belongs_to( dom::element parent, dom::element child )
{
if( !child.is_valid())
return false;
if( parent == child )
return true;
return belongs_to( parent, child.parent() );
}
示例7: sort_rows
void sort_rows( dom::element& table, int column_no )
{
row_sorter rs( column_no );
int fr = fixed_rows( table );
table.sort(rs,fr);
table.update(true);
}
示例8: get_state
NODE_STATE get_state(dom::element item)
{
if(wcseq(item.get_attribute("check"),L"on"))
return NODE_ON;
else if(wcseq(item.get_attribute("check"),L"mixed"))
return NODE_MIXED;
else
return NODE_OFF;
}
示例9: set_state
void set_state(dom::element item, NODE_STATE st)
{
switch( st )
{
case NODE_ON: item.set_attribute("check",L"on"); break;
case NODE_MIXED: item.set_attribute("check",L"mixed"); break;
case NODE_OFF: item.set_attribute("check",L"off"); break;
}
}
示例10: select_all_options
// selects all options in multiselect.
inline void select_all_options(dom::element& select_el )
{
selected_cb all_options;
select_el.find_all(&all_options, "option"); // select all currently selected <option>s
for( int n = int(all_options.elements.size()) - 1; n >= 0 ; --n )
all_options.elements[n].set_state(STATE_CHECKED,0, false); // set state
select_el.update();
}
示例11: get_checkbox_bits
// returns bit mask - checkboxes set
inline value_t get_checkbox_bits(dom::element& el )
{
selected_cb selected;
dom::element r = el.parent(); // ATTN: I assume here that all checkboxes in the group belong to the same parent!
r.find_all(&selected, "[type='checkbox'][name='%S']", el.get_attribute("name"));
int m = 1, v = 0;
for( unsigned int n = 0; n < selected.elements.size(); ++n, m <<= 1 )
if ( selected.elements[n].get_state(STATE_CHECKED) ) v |= m;
return selected.elements.size()==1?value_t(v==1):value_t(v); // for alone checkbox we return true/false
}
示例12: get_radio_index
inline value_t get_radio_index( dom::element& el )
{
selected_cb selected;
dom::element r = el.parent(); // ATTN: I assume here that all radios in the group belong to the same parent!
r.find_all(&selected, "[type='radio'][name='%S']", el.get_attribute("name"));
for( unsigned int n = 0; n < selected.elements.size(); ++n )
if ( selected.elements[n].get_state(STATE_CHECKED) )
return value_t(int(n));
return value_t();
}
示例13: clear_all_options
// clear checked states in multiselect <select>.
// this simply resets :checked state for all checked <option>'s
inline void clear_all_options(dom::element& select_el )
{
selected_cb selected;
select_el.find_all(&selected, "option:checked,[role='option']:checked"); // select all currently selected <option>s
for( int n = int(selected.elements.size()) - 1; n >= 0 ; --n )
selected.elements[n].set_state(0, STATE_CHECKED, false); // reset state
select_el.update();
}
示例14: is_fullpath
bool is_fullpath(dom::element &el)
{
BOOL bFullPath = (el.get_attribute("fullpath") != NULL);
if ( !bFullPath )
{
dom::element ep = el.parent();
bFullPath = (ep.is_valid())?(ep.get_attribute("fullpath") != NULL):FALSE;
}
return bFullPath;
}
示例15: get_current_row
/** returns current row (if any) **/
dom::element get_current_row( dom::element& table )
{
for( int i = table.children_count() - 1; i >= 0 ; --i)
{
dom::element t = table.child((unsigned int)i);
if( t.get_state(STATE_CURRENT))
return t;
}
return dom::element(); // empty
}