virtual BOOL on_mouse(HELEMENT he, HELEMENT target, UINT event_type, POINT pt, UINT mouseButtons, UINT keyboardStates ) { dom::element table = he; if(event_type == MOUSE_WHEEL) { table.post_event(WY_GRID_VERTICAL_SCROLL, SCROLL_STEP_PLUS); } if( event_type != (MOUSE_DOWN | SINKING) && event_type != MOUSE_DCLICK ) return false; //if(mouseButtons != MAIN_MOUSE_BUTTON) // return false; // el must be table; dom::element row = target_row(table, dom::element(target)); if(row.is_valid()) // click on the row { if( (int)row.index() < (int)fixed_rows(table) ) { // click on the header cell dom::element header_cell = target_header(row,target); if( header_cell.is_valid() ) on_column_click(table, header_cell); return mouseButtons == MAIN_MOUSE_BUTTON; } set_current_row(table, row, keyboardStates, event_type == MOUSE_DCLICK); HTMLayoutUpdateWindow(table.get_element_hwnd(false)); } return FALSE;//mouseButtons == MAIN_MOUSE_BUTTON; // as it is always ours then stop event bubbling }
virtual BOOL on_mouse(HELEMENT he, HELEMENT target, UINT event_type, POINT pt, UINT mouseButtons, UINT keyboardStates ) { if( event_type != MOUSE_DOWN && event_type != MOUSE_DCLICK ) return false; if(mouseButtons != MAIN_MOUSE_BUTTON) return false; // el must be table; dom::element table = he; dom::element row = target_row(table, dom::element(target)); if(row.is_valid()) // click on the row { if( (int)row.index() < (int)fixed_rows(table) ) { // click on the header cell dom::element header_cell = target_header(row,target); if( header_cell.is_valid() ) on_column_click(table, header_cell); return true; } set_current_row(table, row, keyboardStates, event_type == MOUSE_DCLICK); } return true; // as it is always ours then stop event bubbling }
void sort_rows( dom::element& table, int column_no ) { row_sorter rs( column_no ); int fr = fixed_rows( table ); table.sort(rs,fr); }
int num_data_rows( HELEMENT he ) { dom::element tbl = get_table(he); int n = fixed_rows(tbl); int total = tbl.children_count(); return total - n; }
virtual BOOL on_mouse(HELEMENT he, HELEMENT target, UINT event_type, POINT pt, UINT mouseButtons, UINT keyboardStates ) { if( event_type == MOUSE_WHEEL ) { int dir = (int)mouseButtons; return on_scroll( he, target, dir < 0? SCROLL_STEP_PLUS : SCROLL_STEP_MINUS, 0, TRUE ); } if( event_type != MOUSE_DOWN && event_type != MOUSE_DCLICK ) return false; if(mouseButtons != MAIN_MOUSE_BUTTON) return false; dom::element table = get_table(he); dom::element row = target_row(table, dom::element(target)); if(row.is_valid()) // click on the row { if( (int)row.index() < (int)fixed_rows(table) ) { // click on the header cell dom::element header_cell = target_header(row,target); if( header_cell.is_valid() ) on_column_click(table, header_cell); return true; } set_current_row(table, row, keyboardStates, event_type == MOUSE_DCLICK); } return true; // as it is always ours then stop event bubbling }
virtual void get_rows_data( HELEMENT he ) { dom::element tbl = get_table(he); DATA_ROWS_PARAMS drp; drp.firstRecord = first_row_idx; drp.totalRecords = num_rows; drp.firstRowIdx = fixed_rows(tbl); drp.lastRowIdx = tbl.children_count() - 1; dom::element self = he; self.send_event(ROWS_DATA_REQUEST, (UINT_PTR)&drp,tbl); first_row_idx = drp.firstRecord; num_rows = drp.totalRecords; }
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); } } }
virtual BOOL on_key(HELEMENT he, HELEMENT target, UINT event_type, UINT code, UINT keyboardStates ) { if( event_type == KEY_DOWN ) { dom::element table = he; switch( code ) { case VK_DOWN: { dom::element c = get_current_row( table ); int idx = c.is_valid()? (c.index() + 1):fixed_rows(table); while( idx < (int)table.children_count() ) { dom::element row = table.child(idx); if( wcseq(row.get_style_attribute("display"),L"none" )) { ++idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case VK_UP: { dom::element c = get_current_row( table ); int idx = c.is_valid()? (c.index() - 1):(table.children_count() - 1); while( idx >= fixed_rows(table) ) { dom::element row = table.child(idx); if( wcseq(row.get_style_attribute("display"),L"none" )) { --idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case VK_PRIOR: { RECT trc = table.get_location(ROOT_RELATIVE | SCROLLABLE_AREA); int y = trc.top - (trc.bottom - trc.top); int first = fixed_rows(table); dom::element r; for( int i = table.children_count() - 1; i >= first; --i ) { dom::element nr = table.child(i); if( wcseq(nr.get_style_attribute("display"),L"none" )) continue; dom::element pr = r; r = nr; if( r.get_location(ROOT_RELATIVE | BORDER_BOX).top < y ) { // row found if(pr.is_valid()) r = pr; // to last fully visible break; } } set_current_row(table, r, keyboardStates); } return TRUE; case VK_NEXT: { RECT trc = table.get_location(ROOT_RELATIVE | SCROLLABLE_AREA); int y = trc.bottom + (trc.bottom - trc.top); int last = table.children_count() - 1; dom::element r; for( int i = fixed_rows(table); i <= last; ++i ) { dom::element nr = table.child(i); if( wcseq(nr.get_style_attribute("display"),L"none" )) continue; dom::element pr = r; r = nr; if( r.get_location(ROOT_RELATIVE | BORDER_BOX).bottom > y ) { // row found if(pr.is_valid()) r = pr; // to last fully visible break; } } set_current_row(table, r, keyboardStates); } return TRUE; case VK_HOME: { int idx = fixed_rows(table); while( (int)idx < (int)table.children_count() ) { dom::element row = table.child(idx); if( wcseq(row.get_style_attribute("display"),L"none" )) { ++idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case VK_END: { int idx = table.children_count() - 1; while( idx >= fixed_rows(table) ) { dom::element row = table.child(idx); if( wcseq(row.get_style_attribute("display"),L"none" )) { --idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case 'A': if( is_multiple(table) && (keyboardStates & CONTROL_KEY_PRESSED) != 0 ) { checkall(table, true); return TRUE; } return FALSE; } } return FALSE; }
virtual BOOL on_key(HELEMENT he, HELEMENT target, UINT event_type, UINT code, UINT keyboardStates ) { if( event_type != KEY_DOWN ) return false; dom::element table = get_table(he); switch( code ) { case VK_DOWN: { dom::element c = get_current_row( table ); int idx = c.is_valid()? (c.index() + 1):fixed_rows(table); while( idx < (int)table.children_count() ) { dom::element row = table.child(idx); if( aux::wcseq(row.get_style_attribute("display"),L"none" )) { ++idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case VK_UP: { dom::element c = get_current_row( table ); int idx = c.is_valid()? (c.index() - 1):(table.children_count() - 1); while( idx >= fixed_rows(table) ) { dom::element row = table.child(idx); if( aux::wcseq(row.get_style_attribute("display"),L"none" )) { --idx; continue; } set_current_row(table, row, keyboardStates); break; } } return TRUE; case VK_PRIOR: { } return TRUE; case VK_NEXT: { } return TRUE; case VK_HOME: { } return TRUE; case VK_END: { } return TRUE; } return FALSE; }