예제 #1
0
    // select next/prev/first/last tab
    bool select_tab( dom::element& tabs_el, dom::element& tab_el, int direction )
    {
      // find new tab 
      dom::element new_tab_el(0);
      switch( direction )
      {
        case -2: new_tab_el = tabs_el.first_sibling(); 
                 while( new_tab_el.is_valid() )
                 {
                   if( !new_tab_el.get_state(STATE_DISABLED) )
                     break;
                   new_tab_el = new_tab_el.next_sibling();
                 }
                 break;
        case -1: new_tab_el = tab_el.prev_sibling(); 
                 while( new_tab_el.is_valid() )
                 {
                   if( !new_tab_el.get_state(STATE_DISABLED) )
                     break;
                   new_tab_el = new_tab_el.prev_sibling();
                 }
                 break;
        case +1: new_tab_el = tab_el.next_sibling(); 
                 while( new_tab_el.is_valid() )
                 {
                   if( !new_tab_el.get_state(STATE_DISABLED) )
                     break;
                   new_tab_el = new_tab_el.next_sibling();
                 }
                 break;
        case +2: new_tab_el = tab_el.last_sibling(); 
                 while( new_tab_el.is_valid() )
                 {
                   if( !new_tab_el.get_state(STATE_DISABLED) )
                     break;
                   new_tab_el = new_tab_el.prev_sibling();
                 }
                 break;
        default: assert(false); return false;
      }

      if( !new_tab_el.is_valid() || new_tab_el.get_attribute("panel") == 0 )  //is not a tab element
        return FALSE;

      return select_tab( tabs_el, new_tab_el );
    }
    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;
    }