/** * Populate the list of Haar features from a list of feature names */ void createFeatures(const StringArray& features) { for (StringArray::const_iterator it = features.begin(); it != features.end(); ++it) { HaarFeature2D<T>* h = HaarFeature2DFactory<T>::fromString( it->c_str()); assert(h); m_border = std::max(m_border, h->requiredBorder()); m_features.push_back(h); } }
::CDB::doubleSeq * DAOImpl::get_double_seq ( const char * propertyName ) { Field fld; if( !get_field(propertyName, fld) ) { throw CDBFieldDoesNotExistExImpl ( __FILE__, __LINE__, "DAOImpl::get_long").getCDBFieldDoesNotExistEx(); } // I don't know why but it returns always an array of string if(fld.GetType() != Field::tyStringArray) { throw WrongCDBDataTypeExImpl ( __FILE__, __LINE__, "DAOImpl::get_long").getWrongCDBDataTypeEx(); } // create return value CDB::doubleSeq_var retSeq; try { retSeq = new CDB::doubleSeq(); } catch(...) { throw CORBA::NO_MEMORY (); }//try-catch StringArray * ary = fld.GetStringArray(); retSeq->length( ary->size() ); CORBA::ULong n=0; for(StringArray::const_iterator aiter = ary->begin(); aiter != ary->end(); ++aiter) { //retSeq[n++] = *aiter; //CORBA::long_dup( *aiter); //->c_str() ); double dbl; int parsed=sscanf(aiter->c_str(),"%lf",&dbl); if (parsed==1) { retSeq[n++]=dbl; } else { // The string doesn't contain a long: throw an exception throw WrongCDBDataTypeExImpl ( __FILE__, __LINE__, "DAOImpl::get_long").getWrongCDBDataTypeEx(); } } return retSeq._retn(); }
CDB::stringSeq* DAOImpl::get_string_seq ( const char * propertyName ) { Field fld; if( !get_field(propertyName, fld) ) { throw CDBFieldDoesNotExistExImpl ( __FILE__, __LINE__, "DAOImpl::get_long").getCDBFieldDoesNotExistEx(); } if(fld.GetType() != Field::tyStringArray) { throw WrongCDBDataTypeExImpl ( __FILE__, __LINE__, "DAOImpl::get_long").getWrongCDBDataTypeEx(); } // create return value CDB::stringSeq_var retSeq; ACE_NEW_THROW_EX (retSeq, CDB::stringSeq, CORBA::NO_MEMORY ()); ACE_CHECK_RETURN (0); StringArray * ary = fld.GetStringArray(); retSeq->length( ary->size() ); CORBA::ULong n=0; for(StringArray::const_iterator aiter = ary->begin(); aiter != ary->end(); ++aiter) { retSeq[n++] = CORBA::string_dup( aiter->c_str() ); } return retSeq._retn(); }
bool ListWidget::handleKeyDown(Common::KeyState state) { bool handled = true; bool dirty = false; int oldSelectedItem = _selectedItem; if (!_editMode && state.keycode <= Common::KEYCODE_z && isprint((unsigned char)state.ascii)) { // Quick selection mode: Go to first list item starting with this key // (or a substring accumulated from the last couple key presses). // Only works in a useful fashion if the list entries are sorted. uint32 time = g_system->getMillis(); if (_quickSelectTime < time) { _quickSelectStr = (char)state.ascii; } else { _quickSelectStr += (char)state.ascii; } _quickSelectTime = time + 300; // TODO: Turn this into a proper constant (kQuickSelectDelay ?) if (_quickSelect) { // FIXME: This is bad slow code (it scans the list linearly each time a // key is pressed); it could be much faster. Only of importance if we have // quite big lists to deal with -- so for now we can live with this lazy // implementation :-) int newSelectedItem = 0; int bestMatch = 0; bool stop; for (StringArray::const_iterator i = _list.begin(); i != _list.end(); ++i) { const int match = matchingCharsIgnoringCase(i->c_str(), _quickSelectStr.c_str(), stop); if (match > bestMatch || stop) { _selectedItem = newSelectedItem; bestMatch = match; if (stop) break; } newSelectedItem++; } scrollToCurrent(); } else { sendCommand(_cmd, 0); } } else if (_editMode) { // Class EditableWidget handles all text editing related key presses for us handled = EditableWidget::handleKeyDown(state); } else { // not editmode switch (state.keycode) { case Common::KEYCODE_RETURN: case Common::KEYCODE_KP_ENTER: if (_selectedItem >= 0) { // override continuous enter keydown if (_editable && (_currentKeyDown != Common::KEYCODE_RETURN && _currentKeyDown != Common::KEYCODE_KP_ENTER)) { dirty = true; startEditMode(); } else sendCommand(kListItemActivatedCmd, _selectedItem); } break; // Keypad & special keys // - if num lock is set, we do not handle the keypress // - if num lock is not set, we either fall down to the special key case // or ignore the key press for 0, 4, 5 and 6 case Common::KEYCODE_KP_PERIOD: if (state.flags & Common::KBD_NUM) { handled = false; break; } case Common::KEYCODE_BACKSPACE: case Common::KEYCODE_DELETE: if (_selectedItem >= 0) { if (_editable) { // Ignore delete and backspace when the list item is editable } else { sendCommand(kListItemRemovalRequestCmd, _selectedItem); } } break; case Common::KEYCODE_KP1: if (state.flags & Common::KBD_NUM) { handled = false; break; } case Common::KEYCODE_END: _selectedItem = _list.size() - 1; break; case Common::KEYCODE_KP2: if (state.flags & Common::KBD_NUM) { handled = false; break; } case Common::KEYCODE_DOWN: if (_selectedItem < (int)_list.size() - 1) _selectedItem++; break; case Common::KEYCODE_KP3: if (state.flags & Common::KBD_NUM) { handled = false; break; } case Common::KEYCODE_PAGEDOWN: _selectedItem += _entriesPerPage - 1; if (_selectedItem >= (int)_list.size() ) _selectedItem = _list.size() - 1; break; case Common::KEYCODE_KP7: if (state.flags & Common::KBD_NUM) { handled = false; break; } case Common::KEYCODE_HOME: _selectedItem = 0; break; case Common::KEYCODE_KP8: if (state.flags & Common::KBD_NUM) { handled = false; break; } case Common::KEYCODE_UP: if (_selectedItem > 0) _selectedItem--; break; case Common::KEYCODE_KP9: if (state.flags & Common::KBD_NUM) { handled = false; break; } case Common::KEYCODE_PAGEUP: _selectedItem -= _entriesPerPage - 1; if (_selectedItem < 0) _selectedItem = 0; break; default: handled = false; } scrollToCurrent(); } if (dirty || _selectedItem != oldSelectedItem) draw(); if (_selectedItem != oldSelectedItem) { sendCommand(kListSelectionChangedCmd, _selectedItem); // also draw scrollbar _scrollBar->draw(); } return handled; }