/** 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, 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);
    }
Exemplo n.º 3
0
 /** 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); 
 }
  virtual void on_column_click( dom::element& table, dom::element& header_cell )
  {
    super::on_column_click( table, header_cell );

    dom::element current = table.find_first("th:checked");
    if( current == header_cell )
      return; // already here, nothing to do.

    if( current.is_valid() )
      current.set_state(0, STATE_CHECKED);
    header_cell.set_state(STATE_CHECKED);

	dom::element ctr = get_current_row( table );
    sort_rows( table, header_cell.index() );
	if( ctr.is_valid() )
		ctr.scroll_to_view();

  }
    BOOL select_next_option( dom::element& option )
    {
       dom::element next = option.next_sibling();
       if( !next.is_valid() ) 
         goto ADD_NEW;
       if( !aux::streq(next.get_element_type(),"option") )
         goto ADD_NEW;
       next.set_state(STATE_FOCUS); 
       return TRUE;
ADD_NEW:
       std::wstring text = option.text();
       if(text.empty() || text == L" ")
       {
         ::MessageBeep(MB_ICONEXCLAMATION);
         return FALSE;
       }

       dom::element select = option.parent();
       next = dom::element::create("option", L" ");
       select.insert(next,option.index()+1);
       select.update();
       next.set_state(STATE_FOCUS); 
       return TRUE;
    }
 /** Click on column header (fixed row).
     Overrided in sortable-grid **/
 virtual void on_column_click( dom::element& table, dom::element& header_cell )
 {
   table.post_event( TABLE_HEADER_CLICK, header_cell.index(), header_cell); 
 }