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; }
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); }
/** 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 }
void check_range (const dom::element& table, int idx, bool check) { if (!is_multiple(table)) return; int start_idx = get_anchor(table); int start = min(start_idx,idx ); int end = max(start_idx,idx ); int f_rows = fixed_rows(table); if(start < f_rows) start = f_rows; for( ;end >= start; --end ) { dom::element row = table.child(end); if(!wcseq(row.get_style_attribute("display"),L"none" )) { if (check) row.set_state(STATE_CHECKED,0,false); else row.set_state(0,STATE_CHECKED,false); } } }
void check_range (const dom::element& table, int idx, bool check) { if (!is_multiple(table)) return; int start_idx = get_anchor(table); int start = min(start_idx,idx ); int end = max(start_idx,idx ); int f_rows = fixed_rows(table); if(start < f_rows) start = f_rows; for( ;end >= start; --end ) { dom::element row = table.child(end); if(!!row.visible()) { if (check) row.set_state(STATE_CHECKED,0); else row.set_state(0,STATE_CHECKED); } } }