void set_checked_row( dom::element& table, dom::element& row, bool toggle = false )
    {
      if(toggle)
      {
        if( row.get_state( STATE_CHECKED) )
          row.set_state( 0,STATE_CHECKED,false);
        else
          row.set_state( STATE_CHECKED,0,false);
      }
      else
		    row.set_state( STATE_CHECKED,0,false);
	  }
    /** 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); 
    }
예제 #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); 
 }
예제 #4
0
    // select 
    bool select_tab( dom::element& tabs_el, dom::element& tab_el )
    {
      if(tab_el.get_state(STATE_CURRENT))
        // already selected, nothing to do...
        return true; // but we've handled it.
     
      //find currently selected element (tab and panel) and remove "selected" from them
      dom::element prev_panel_el = tabs_el.find_first(":root>[name]:expanded");
      dom::element prev_tab_el = tabs_el.find_first(":root>.strip>[panel]:current");

      // find new tab and panel       
      const wchar_t* pname = tab_el.get_attribute("panel");
      dom::element panel_el = tabs_el.find_first(":root>[name=\"%S\"]", pname);
      
      if( !panel_el.is_valid() || !tab_el.is_valid() )
      {
        assert(false); // panel="somename" without matching name="somename"
        return true;
      }

      if( prev_panel_el.is_valid() )
      {
        prev_panel_el.set_attribute("selected", 0); // remove selected attribute - just in case somone is using attribute selectors    
        prev_panel_el.set_state(STATE_COLLAPSED,0); // set collapsed in case of someone use it for styling
      }
      if( prev_tab_el.is_valid() )
      {
        prev_tab_el.set_attribute("selected", 0); // remove selected attribute
        prev_tab_el.set_state(0,STATE_CURRENT); // reset also state flag, :current
      }
      
      panel_el.set_attribute("selected", L""); // set selected attribute (empty)
      panel_el.set_state(STATE_EXPANDED,0); // expand it
      
      tab_el.set_attribute("selected", L""); // set selected attribute (empty)
      tab_el.set_state(STATE_CURRENT,0); // set also state flag, :current
                  
      // notify all parties involved
	  if (prev_tab_el.is_valid())
	  {
		  prev_tab_el.post_event(ELEMENT_COLLAPSED,0, prev_tab_el); // source here is old collapsed tab itself
	  }
      tab_el.post_event(ELEMENT_EXPANDED,0, tab_el);  // source here is new expanded tab itself
      // NOTE #1: these event will bubble from panel elements up to the root so panel itself, tabs ctl, its parent, etc.
      // will receive these notifications. Handle them if you need to change UI dependent from current tab. 
      // NOTE #2: while handling this event in:
      //        virtual BOOL on_event (HELEMENT he, HELEMENT target, BEHAVIOR_EVENTS type, UINT reason ),
      // HELEMENT target is the panel element being collapsed/expanded
      
      return true;
    }
예제 #5
0
    // set current item
    virtual void set_current_item( const dom::element& ctl, dom::element& item )
    {
      // get previously selected item:
      dom::element prev_current = ctl.find_first(":current");
      dom::element prev = ctl.find_first(":expanded");
	  
      if(prev_current != item && prev_current.is_valid())
        prev_current.set_state(0, STATE_CURRENT);

      if( prev.is_valid() )
      {
        if( prev == item ) return; // already here, nothing to do.
        prev.set_state(0,STATE_CURRENT | STATE_EXPANDED); // drop state flags
      }
      item.set_state(STATE_CURRENT | STATE_EXPANDED); // set state flags
    }
  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();

  }
예제 #7
0
   // 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);
    }