void Menu::setInputKey(const unsigned int charCode){ char *charString = getKeyString(charCode); if (charString != NULL){ *(unsigned int *) items[currentItem]->data = charCode; items[currentItem]->setInputString(charString); } else { items[currentItem]->setInputString(getKeyString(*(unsigned int *) items[currentItem]->data)); } }
MenuItem::MenuItem(const char *capt, void *dataPointer, InputType inpType, int minVal, int maxVal, char **strList){ subMenu = NULL; data = dataPointer; type = inpType; checked = false; stringList = strList; min = minVal; max = maxVal; unsigned int len = strlen(capt); caption = new char[len + 1]; strcpy(caption, capt); if (dataPointer != NULL){ if (inpType == INPUT_KEY){ char *charString = getKeyString(*(unsigned int *) dataPointer); if (charString != NULL) setInputString(charString); } else if (inpType == INPUT_BOOL){ setInputString(*(bool *) dataPointer? "True" : "False"); } else if (inpType == INPUT_INTEGER){ char str[16]; if (stringList){ setInputString(stringList[*(int *) dataPointer]); } else { sprintf(str, "%d", *(int *) dataPointer); setInputString(str); } } } }
void mapMap(Map map, proc fn, void *data) { Iterator it; BSTNode node; it = newNodeIterator(map->bst, INORDER); while (stepIterator(it, &node)) { fn(getKeyString(node), getNodeValue(node), data); } }
bool Blocks::blockCheck(bool block[]) { bool toreturn = false; string key = getKeyString(block); map<string, int>::iterator it = blocks.find(key); if (it == blocks.end()) { toreturn = false; } else { toreturn = true; } return toreturn; }
ResultsItem* ResultsItemModel::findResult(const std::string& sigName, SpectralLibraryMatch::MatchAlgorithm algType) { if (sigName.empty() || algType.isValid() == false) { return NULL; } std::map<std::string, ResultsItem*>::const_iterator it = mItemMap.find(getKeyString(sigName, algType)); if (it != mItemMap.end()) { return it->second; } return NULL; }
void Blocks::addToList(bool block[]) { string key = getKeyString(block); blocks.insert(pair<string, int>(key, 0)); print(key); }
bool GHOST_EventPrinter::processEvent(GHOST_IEvent* event) { bool handled = true; GHOST_ASSERT(event, "event==0"); if (event->getType() == GHOST_kEventWindowUpdate) return false; std::cout << "\nGHOST_EventPrinter::processEvent, time: " << (GHOST_TInt32)event->getTime() << ", type: "; switch (event->getType()) { case GHOST_kEventUnknown: std::cout << "GHOST_kEventUnknown"; handled = false; break; case GHOST_kEventButtonUp: { GHOST_TEventButtonData* buttonData = (GHOST_TEventButtonData*)((GHOST_IEvent*)event)->getData(); std::cout << "GHOST_kEventCursorButtonUp, button: " << buttonData->button; } break; case GHOST_kEventButtonDown: { GHOST_TEventButtonData* buttonData = (GHOST_TEventButtonData*)((GHOST_IEvent*)event)->getData(); std::cout << "GHOST_kEventButtonDown, button: " << buttonData->button; } break; case GHOST_kEventWheel: { GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*)((GHOST_IEvent*)event)->getData(); std::cout << "GHOST_kEventWheel, z: " << wheelData->z; } break; case GHOST_kEventCursorMove: { GHOST_TEventCursorData* cursorData = (GHOST_TEventCursorData*)((GHOST_IEvent*)event)->getData(); std::cout << "GHOST_kEventCursorMove, (x,y): (" << cursorData->x << "," << cursorData->y << ")"; } break; case GHOST_kEventKeyUp: { GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*)((GHOST_IEvent*)event)->getData(); STR_String str; getKeyString(keyData->key, str); std::cout << "GHOST_kEventKeyUp, key: " << str.Ptr(); } break; case GHOST_kEventKeyDown: { GHOST_TEventKeyData* keyData = (GHOST_TEventKeyData*)((GHOST_IEvent*)event)->getData(); STR_String str; getKeyString(keyData->key, str); std::cout << "GHOST_kEventKeyDown, key: " << str.Ptr(); } break; case GHOST_kEventDraggingEntered: { GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); std::cout << "GHOST_kEventDraggingEntered, dragged object type : " << dragnDropData->dataType; std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y; } break; case GHOST_kEventDraggingUpdated: { GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); std::cout << "GHOST_kEventDraggingUpdated, dragged object type : " << dragnDropData->dataType; std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y; } break; case GHOST_kEventDraggingExited: { GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); std::cout << "GHOST_kEventDraggingExited, dragged object type : " << dragnDropData->dataType; } break; case GHOST_kEventDraggingDropDone: { GHOST_TEventDragnDropData* dragnDropData = (GHOST_TEventDragnDropData*)((GHOST_IEvent*)event)->getData(); std::cout << "GHOST_kEventDraggingDropDone,"; std::cout << " mouse at x=" << dragnDropData->x << " y=" << dragnDropData->y; switch (dragnDropData->dataType) { case GHOST_kDragnDropTypeString: std::cout << " type : GHOST_kDragnDropTypeString,"; std::cout << "\n String received = " << (char*)dragnDropData->data; break; case GHOST_kDragnDropTypeFilenames: { GHOST_TStringArray *strArray = (GHOST_TStringArray*)dragnDropData->data; int i; std::cout << " type : GHOST_kDragnDropTypeFilenames,"; std::cout << "\n Received " << strArray->count << " filename" << (strArray->count > 1 ? "s:" : ":"); for (i=0;i<strArray->count;i++) std::cout << "\n File[" << i << "] : " << strArray->strings[i]; } break; default: break; } } break; case GHOST_kEventOpenMainFile: { GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData(); if (eventData) std::cout << "GHOST_kEventOpenMainFile for path : " << (char*)eventData; else std::cout << "GHOST_kEventOpenMainFile with no path specified!!"; } break; case GHOST_kEventQuit: std::cout << "GHOST_kEventQuit"; break; case GHOST_kEventWindowClose: std::cout << "GHOST_kEventWindowClose"; break; case GHOST_kEventWindowActivate: std::cout << "GHOST_kEventWindowActivate"; break; case GHOST_kEventWindowDeactivate: std::cout << "GHOST_kEventWindowDeactivate"; break; case GHOST_kEventWindowUpdate: std::cout << "GHOST_kEventWindowUpdate"; break; case GHOST_kEventWindowSize: std::cout << "GHOST_kEventWindowSize"; break; default: std::cout << "not found"; handled = false; break; } return handled; }
void ResultsItemModel::addResults(const std::vector<SpectralLibraryMatch::MatchResults>& theResults, const std::map<Signature*, ColorType>& colorMap, Progress* pProgress, bool* pAbort) { if (theResults.empty()) { return; } bool findPrevious = (rowCount() > 0); // don't look for previous results if model is empty. if (pProgress != NULL) { pProgress->updateProgress("Adding Match Results to Results Window...", 0, NORMAL); } unsigned int resultCount(0); unsigned int numResults = theResults.size(); mResults.reserve(mResults.size() + numResults); for (std::vector<SpectralLibraryMatch::MatchResults>::const_iterator it = theResults.begin(); it != theResults.end(); ++it) { if (pAbort != NULL && *pAbort) { if (pProgress != NULL) { pProgress->updateProgress("Adding Match Results to Results Window canceled by user", 0, ABORT); } return; } // Get the results item if it already exists ResultsItem* pItem(NULL); bool newItem(false); if (findPrevious) { pItem = findResult(it->mTargetName, it->mAlgorithmUsed); } // Add the top-level item for the results if (pItem == NULL) { int resultsRow = static_cast<int>(mResults.size()); beginInsertRows(QModelIndex(), resultsRow, resultsRow); // Set the target name and algorithm name in the item constructor so that they will be available when // the sort model automatically sorts the top-level results items when endInsertRows() is called QString targetName = QString::fromStdString(it->mTargetName); QString algorithmName = QString::fromStdString( StringUtilities::toDisplayString<SpectralLibraryMatch::MatchAlgorithm>(it->mAlgorithmUsed)); pItem = new ResultsItem(targetName, algorithmName); newItem = true; mItemMap[getKeyString(it->mTargetName, it->mAlgorithmUsed)] = pItem; mResults.push_back(pItem); endInsertRows(); } // Get the index for the top-level results item int resultsRow = getRow(pItem); QModelIndex resultsIndex = index(resultsRow, 0); // If the results item already exists, remove any existing signature match rows if (newItem == false) { int signatureRows = pItem->rows(); if (signatureRows <= 0) { // Set the number of rows to 1 to account for the row indicating no matches are found signatureRows = 1; } beginRemoveRows(resultsIndex, 0, signatureRows - 1); pItem->clear(); endRemoveRows(); } // Add the updated signature match rows int signatureRows = it->mResults.size(); if (signatureRows <= 0) { // Set the number of rows to 1 to account for the row indicating no matches are found signatureRows = 1; } mAddingResults = true; beginInsertRows(resultsIndex, 0, signatureRows - 1); pItem->setData(*it, colorMap); endInsertRows(); mAddingResults = false; // Update the progress if (pProgress != NULL) { ++resultCount; pProgress->updateProgress("Adding Match Results to Results Window...", resultCount * 100 / numResults, NORMAL); } } if (pProgress != NULL) { pProgress->updateProgress("Finished adding Match Results to Results Window.", 100, NORMAL); } }
const char *HGameConfig::getStrValue(int type) { const char *defaultvalue = getKeyDefault(type); string value = CCUserDefault::sharedUserDefault()->getStringForKey(getKeyString(type), defaultvalue); return HString::create(value)->getCString(); }
void HGameConfig::setConfig(int type, const char *value) { CCUserDefault::sharedUserDefault()->setStringForKey(getKeyString(type), value); CCUserDefault::sharedUserDefault()->flush(); }