void ListBoxElement::updateData() { // Update title h3dguiSetListBoxTitles(node->getNode(), element, toWString(title).c_str()); // Delete rows h3dguiClearListBox(node->getNode(), element); // Readd rows for (unsigned int i = 0; i < rows.size(); i++) h3dguiAddListBoxRow(node->getNode(), element, toWString(rows[i]).c_str()); // Set selection h3dguiSetElementParamI(node->getNode(), element, ListBoxParam::SelectionI, selection); }
void WebOsCalendarSyncSource::getMoreItems() { // if(!mEvents.empty()) // return; //this will need to call listItems on the calendar service and fill a structure with all event ids. //user mItemOffset to get a bunch of items every time and not all of them at once. std::stringstream parameter; parameter << mItemOffset; std::vector<WString>& result = BlockingServiceCall("listEvents",toWString(parameter.str().c_str())); if(result.size() >= 2) { for(int i = 0; i < result.size()-1; i+=2) { std::pair<WString,WString> event; event.second = result[i]; event.first = result[i+1]; LOG.debug("Got key %s from %s",event.first.c_str(),result[i+1].c_str()); mEvents.push_back(event); mItemOffset++; } } LOG.info("Received %d events. Now have %d events. Offset now is: %d.",result.size(),mEvents.size(),mItemOffset); }
bool getFileList(std::wstring & path, std::wstring & mask, bool case_sensitive, std::vector<std::wstring> & tabfiles, bool rec, bool addFiles, bool addDir) { std::vector<std::string> tab; bool r = getFileList(toString(path,enc_iso8859), toString(mask,enc_iso8859), case_sensitive, tab, rec, addFiles, addDir); for (auto it = tab.begin(); it != tab.end(); it++) { tabfiles.push_back(toWString(*it,enc_iso8859)); } return r; }
void GUIFloatField::setText(float value) { // Only update with new value if it actually changed, otherwise // problems can occur when user types in "0." and the field // updates back to "0" effectively making "." unusable float curValue = parseFloat(mInputBox->getText()); if (value != curValue) mInputBox->setText(toWString(value)); }
void Node::dump(std::wostream& dest, unsigned& indent) const { for (unsigned i = 0; i < indent; i++) dest << L" "; dest << toWString() << L"\n"; indent++; for (size_t i = 0; i < children.size(); i++) children[i]->dump(dest, indent); indent--; }
PDL_bool receiveResultLoop(PDL_JSParameters *params) { pthread_mutex_lock(&callbackMutex); int numParams = PDL_GetNumJSParams(params); if(numParams == 0) { Funambol::LOG.info("JSCallback Loop failed."); pthread_cond_signal(&callbackReady); } else if(numParams < 6) { Funambol::LOG.info("Empty Loop."); pthread_cond_signal(&callbackReady); } else { Funambol::WString chunk = toWString(PDL_GetJSParamString(params,0)); int chunkIndex = PDL_GetJSParamInt(params,1); int numChunks = PDL_GetJSParamInt(params,2); int entryIndex = PDL_GetJSParamInt(params,3); int numEntries = PDL_GetJSParamInt(params,4); bool lastEventID = PDL_GetJSParamInt(params,5) != 0; if(chunkIndex != numChunks) { partlyResult += chunk; } else //chunkIndex == numChunks => last chunk! { if(lastEventID) //last chunk == eventId { //add parts until now as first result //and event id as second result. globalResults.push_back(partlyResult); globalResults.push_back(chunk); } else { partlyResult += chunk; globalResults.push_back(partlyResult); } partlyResult = ""; //clear result string for next entry. //was this the last entry in the list? if(entryIndex == numEntries) { //wake up processing thread, loop finished! pthread_cond_signal(&callbackReady); } } } pthread_mutex_unlock(&callbackMutex); return PDL_TRUE; }
//----------------------------------------------------------------------- FileInfoListPtr UnicodeFileSystemArchive::findFileInfo(const String& _pattern, bool _recursive, bool _dirs) const { // Note that we have to tell the SharedPtr to use OGRE_DELETE_T not OGRE_DELETE by passing category FileInfoListPtr lst(OGRE_NEW_T(FileInfoList, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T); WString wpattern = toWString(_pattern); FileFinder fileFinder(const_cast<UnicodeFileSystemArchive*>(this), mWName, getIgnoreHidden()); fileFinder.run(wpattern, _recursive, _dirs, nullptr, lst.getPointer()); return lst; }
QImage* Resources::loadImage(const QString& value) { auto it = m_images.find(value); if (it == m_images.end()) { auto i = new QImage{ value }; if (i->isNull()) { std::wcout << L"Failed to load " << toWString(value) << std::endl; } m_images[value].reset(i); return i; } return it->second.get(); }
void GUIGameObjectField::setValue(const HGameObject& value, bool triggerEvent) { if (value) { if (mInstanceId == value.getInstanceId()) return; mInstanceId = value->getInstanceId(); mDropButton->setContent(GUIContent(HString(toWString(value->getName()) + L" (" + toWString(mType) + L")"))); } else { if (mInstanceId == 0) return; mInstanceId = 0; mDropButton->setContent(GUIContent(HString(L"None (" + toWString(mType) + L")"))); } if (triggerEvent) onValueChanged(value); }
void TupleVectorNode::dump(std::wostream& dest, unsigned& indent) const { for (unsigned i = 0; i < indent; i++) dest << L" "; dest << toWString() << L"\n"; indent++; for (size_t i = 0; i < children.size(); i++) { for (unsigned j = 0; j < indent; j++) dest << L" "; dest << WFormatableString(L"[%0]:\n").arg(i); indent++; children[i]->dump(dest, indent); indent--; } indent--; }
Path GUIResourceTreeView::findUniquePath(const Path& path) { if(FileSystem::exists(path)) { Path newPath = path; WString filename = path.getWFilename(false); UINT32 cnt = 1; do { newPath.setBasename(filename + toWString(cnt)); cnt++; } while (FileSystem::exists(newPath)); return newPath; } else return path; }
//----------------------------------------------------------------------- void UnicodeFileSystemArchive::load() { OGRE_LOCK_AUTO_MUTEX // test to see if this folder is writeable mWName = toWString(mName); WString wTestPath = getFullPath("__testwrite.ogre"); std::ofstream writeStream; writeStream.open(wTestPath.c_str()); if (writeStream.fail()) mReadOnly = true; else { mReadOnly = false; writeStream.close(); ::_wremove(wTestPath.c_str()); } }
PDL_bool receiveResult(PDL_JSParameters *params) { pthread_mutex_lock(&callbackMutex); int numParams = PDL_GetNumJSParams(params); if(numParams == 0) { Funambol::LOG.info("JSCallback failed."); } else { for(size_t i = 0; i < numParams; i++) { Funambol::WString result = toWString(PDL_GetJSParamString(params,i)); globalResults.push_back(result); //for events this will add event and eventId as two different entries into vector. } } pthread_cond_signal(&callbackReady); pthread_mutex_unlock(&callbackMutex); return PDL_TRUE; }
ScriptEditorWidget::ScriptEditorWidget(const String& ns, const String& type, UINT32 defaultWidth, UINT32 defaultHeight, EditorWidgetContainer& parentContainer) : EditorWidgetBase(HString(toWString(type)), ns + "." + type, defaultWidth, defaultHeight, parentContainer) , mNamespace(ns), mTypename(type), mOnInitializeThunk(nullptr), mOnDestroyThunk(nullptr), mUpdateThunk(nullptr) , mManagedInstance(nullptr), mGetDisplayName(nullptr), mScriptOwner(nullptr), mContentsPanel(nullptr) , mIsInitialized(false) { if(createManagedInstance()) { if (mGetDisplayName != nullptr) { MonoObject* displayNameMono = mGetDisplayName->invokeVirtual(mManagedInstance, nullptr); ScriptHString* scriptHString = ScriptHString::toNative(displayNameMono); if (scriptHString != nullptr) { mDisplayName = HString(scriptHString->getInternalValue()); parentContainer.refreshWidgetNames(); } } } }
FMODAudio::FMODAudio() :mFMOD(nullptr), mMasterChannelGroup(nullptr), mVolume(1.0f), mIsPaused(false) { FMOD::Memory_Initialize(nullptr, 0, &FMODAlloc, &FMODRealloc, &FMODFree); FMOD::System_Create(&mFMOD); FMOD_ADVANCEDSETTINGS advancedSettings; memset(&advancedSettings, 0, sizeof(advancedSettings)); advancedSettings.cbSize = sizeof(advancedSettings); advancedSettings.vol0virtualvol = 0.001f; mFMOD->setAdvancedSettings(&advancedSettings); mFMOD->init(512, FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_THREAD_UNSAFE | FMOD_INIT_VOL0_BECOMES_VIRTUAL, nullptr); mFMOD->setStreamBufferSize(65536, FMOD_TIMEUNIT_RAWBYTES); mFMOD->set3DRolloffCallback(&FMOD3DRolloff); mFMOD->getMasterChannelGroup(&mMasterChannelGroup); INT32 numDevices; mFMOD->getNumDrivers(&numDevices); mAllDevices.resize(numDevices); char nameBuffer[256]; for(INT32 i = 0; i < numDevices; i++) { mFMOD->getDriverInfo(i, nameBuffer, sizeof(nameBuffer), nullptr, nullptr, nullptr, nullptr); mAllDevices[i].name = toWString(nameBuffer); } INT32 defaultDevice = 0; mFMOD->getDriver(&defaultDevice); if(defaultDevice < numDevices) { mDefaultDevice.name = mAllDevices[defaultDevice].name; mActiveDevice.name = mAllDevices[defaultDevice].name; } }
/** QString to path*/ path toPath(const QString& q) { std::wstring w = toWString(q); return path(w); }
WString toWString(const char* source) { return toWString(String(source)); }
size_t copyFiles(std::string sourcepath, std::string destpath, std::string mask, bool case_sensitive, bool rec, bool overwrite) { return copyFiles(toWString(sourcepath, enc_iso8859), toWString(destpath, enc_iso8859), toWString(mask, enc_iso8859), case_sensitive, rec, overwrite); }
WString toWString(Degree val, unsigned short precision, unsigned short width, char fill, std::ios::fmtflags flags) { return toWString(val.valueDegrees(), precision, width, fill, flags); }
bool FuelType::operator == (const FuelType& rhs) const { return toWString() == rhs.toWString(); }
//--------------------------------------------------------------------- WString UnicodeFileSystemArchive::getFullPath(const String& _filename) const { return getFullPath(toWString(_filename)); }
void GUIStatusBar::logModified() { LogEntry entry; if(!gDebug().getLog().getLastEntry(entry)) { GUIContent messageContent(HString(L"")); mMessage->setContent(messageContent); return; } HSpriteTexture iconTexture; Color textColor = COLOR_INFO; UINT32 logChannel = entry.getChannel(); switch (logChannel) { case (UINT32)DebugChannel::Debug: iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Info, 16, false); break; case (UINT32)DebugChannel::Warning: case (UINT32)DebugChannel::CompilerWarning: iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Warning, 16, false); textColor = COLOR_WARNING; break; case (UINT32)DebugChannel::Error: case (UINT32)DebugChannel::CompilerError: iconTexture = BuiltinEditorResources::instance().getLogMessageIcon(LogMessageIcon::Error, 16, false); textColor = COLOR_ERROR; break; } WString message = toWString(entry.getMessage()); size_t lfPos = message.find_first_of('\n'); size_t crPos = message.find_first_of('\r'); size_t newlinePos; if (lfPos != WString::npos) { if (crPos != WString::npos) newlinePos = std::min(lfPos, crPos); else newlinePos = lfPos; } else if (crPos != WString::npos) newlinePos = crPos; else newlinePos = -1; if (newlinePos == -1) { GUIContent messageContent(HString(message), iconTexture); mMessage->setContent(messageContent); mMessage->setTint(textColor); } else { WString firstLine = message.substr(0, newlinePos); GUIContent messageContent(HString(firstLine), iconTexture); mMessage->setContent(messageContent); mMessage->setTint(textColor); } }
void Ui::setChangelog(const char* text) { BSTR unicodestr = toWString(text); SetWindowText(m_edit_box, unicodestr); ::SysFreeString(unicodestr); }
void Ui::setText(const char* text) { BSTR unicodestr = toWString(text); SetWindowText(m_label, unicodestr); ::SysFreeString(unicodestr); }
/** * SaveFileDialog を呼び出します. * * Windows の SaveFileDialog によってファイルの保存先を決定します. * * @param filters フィルタ(区切り文字は'|') * @return 選択したファイルパス.確定せずに終了したときは空文字. * *************************************************************************************************/ inline std::string saveFileDialog(const std::string &filter) { return toString(saveFileDialog(toWString(filter))); }
/** * OpenFileDialog を呼び出します. * * Windows の OpenFileDialog によってファイルを1つ選択します. * ファイルを選択する際の選択フィルタを入力すると簡易的な OpenFileDialog が呼び出されます. * * * @param filters フィルタ(区切り文字は'|') * @return 選択したファイルパス.選択せずに終了したときは空文字. * * * 使用例 * @code * // 動画ファイルと画像ファイルを選択できる OpenFileDialog を呼び出します * std::string selectedPath = openFileDialog("動画ファイル(*.avi)|*.avi|" * "画像ファイル(*.png)|*.png|" * "すべてのファイル|*.*"); * * std::cout << "選択ファイル: " << selectedPath << std::endl; * @endcode * *************************************************************************************************/ inline std::string openFileDialog(const std::string &filter) { return toString(openFileDialog(toWString(filter))); }