/** set current row **/ void set_current_row( dom::element& table, dom::element& row, UINT keyboardStates, bool dblClick = false ) { if(is_multiple(table)) { if (keyboardStates & SHIFT_KEY_PRESSED) { checkall(table, false); check_range(table,row.index(),TRUE); // from current to new } else { if (keyboardStates & CONTROL_KEY_PRESSED) set_checked_row (table,row, true); // toggle else checkall(table, false); set_anchor(table,row.index ()); } } // get previously selected row: dom::element prev = get_current_row( table ); if( prev.is_valid() ) { if( prev != row ) prev.set_state(0,STATE_CURRENT, false); // drop state flags } row.set_state(STATE_CURRENT); // set state flags row.scroll_to_view(); ::UpdateWindow(row.get_element_hwnd(false)); table.post_event( dblClick? TABLE_ROW_DBL_CLICK:TABLE_ROW_CLICK, row.index(), row); }
/** set current row **/ void set_current_row( dom::element& table, dom::element& row, UINT keyboardStates, bool dblClick = false ) { // get previously selected row: dom::element prev = get_current_row( table ); if( prev.is_valid() ) { if( prev != row ) prev.set_state(0,STATE_CURRENT, false); // drop state flags } row.set_state(STATE_CURRENT); // set state flags row.scroll_to_view(); table.post_event( dblClick? TABLE_ROW_DBL_CLICK:TABLE_ROW_CLICK, row.index(), row); }
// set current item virtual void set_current_item( const dom::element& ctl, dom::element& item ) { // get previously expanded item: dom::element prev = ctl.find_first(":expanded"); dom::element prev_current = ctl.find_first(":current"); if(prev_current != item && prev_current.is_valid()) prev_current.set_state(0, STATE_CURRENT); if( prev == item ) { prev.set_state(STATE_CURRENT | STATE_COLLAPSED); } else { if( prev.is_valid() ) prev.set_state(STATE_COLLAPSED); // collapse old one item.set_state(STATE_CURRENT | STATE_EXPANDED); // set new expanded. } item.scroll_to_view(); }
/** set current row **/ void set_current_row( dom::element& table, dom::element& row, UINT keyboardStates, bool dblClick = false, bool smooth = false ) { // get previously selected row: dom::element prev = get_current_row( table ); uint new_row_checked = STATE_CHECKED; uint old_row_checked = STATE_CHECKED; if(is_multiple(table)) { if (keyboardStates & SHIFT_KEY_PRESSED) { checkall(table, false); check_range(table,row.index(),TRUE); // from current to new } else { if (keyboardStates & CONTROL_KEY_PRESSED) { set_checked_row (table,row, true); // toggle new_row_checked = 0; } else checkall(table, false); set_anchor(table,row.index ()); } old_row_checked = 0; } if( prev.is_valid() ) { if( prev != row ) prev.set_state(0,STATE_CURRENT | old_row_checked); // drop state flags } row.set_state(STATE_CURRENT | new_row_checked); // set state flags row.scroll_to_view(false,smooth); //::UpdateWindow(row.get_element_hwnd(false)); table.post_event( dblClick? TABLE_ROW_DBL_CLICK:TABLE_ROW_CLICK, row.index(), row); table.post_event(WY_GRID_VERTICAL_SCROLL, 0); }