void MethodResultJni::callJSBack(jint jTabIndex) { RAWTRACE(__FUNCTION__); jhstring jhStrCallbackID = getStrCallback(m_env); String strCallbackID = rho_cast<String>(m_env, jhStrCallbackID.get()); jhstring jhCallbackData = getStrCallbackData(m_env); String strCallbackData = rho_cast<String>(m_env, jhCallbackData.get()); String strRes(CMethodResultConvertor().toJSON(*this)); String strCallback("Rho.callbackHandler( \""); strCallback += strCallbackID; strCallback += "\", {"; strCallback += strRes; strCallback += "},\""; strCallback += strCallbackData; strCallback += "\")"; jclass cls = getJNIClass(RHODES_JAVA_CLASS_WEB_VIEW); if (!cls) return; static jmethodID mid = getJNIClassStaticMethod(m_env, cls, "executeJs", "(Ljava/lang/String;I)V"); if (!mid) return; jhstring jhCallback = rho_cast<jstring>(m_env, strCallback); m_env->CallStaticVoidMethod(cls, mid, jhCallback.get(), jTabIndex); }
// Search for available resolutions - TODO: Move to Common? static wxArrayString GetListOfResolutions() { wxArrayString retlist; retlist.Add(_("Auto")); #ifdef _WIN32 DWORD iModeNum = 0; DEVMODE dmi; ZeroMemory(&dmi, sizeof(dmi)); dmi.dmSize = sizeof(dmi); std::vector<std::string> resos; while (EnumDisplaySettings(nullptr, iModeNum++, &dmi) != 0) { char res[100]; sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight); std::string strRes(res); // Only add unique resolutions if (std::find(resos.begin(), resos.end(), strRes) == resos.end()) { resos.push_back(strRes); retlist.Add(StrToWxStr(res)); } ZeroMemory(&dmi, sizeof(dmi)); } #elif defined(HAVE_XRANDR) && HAVE_XRANDR std::vector<std::string> resos; main_frame->m_XRRConfig->AddResolutions(resos); for (auto res : resos) retlist.Add(StrToWxStr(res)); #elif defined(__APPLE__) CFArrayRef modes = CGDisplayCopyAllDisplayModes(CGMainDisplayID(), nullptr); for (CFIndex i = 0; i < CFArrayGetCount(modes); i++) { std::stringstream res; CGDisplayModeRef mode; CFStringRef encoding; size_t w, h; bool is32; mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i); w = CGDisplayModeGetWidth(mode); h = CGDisplayModeGetHeight(mode); encoding = CGDisplayModeCopyPixelEncoding(mode); is32 = CFEqual(encoding, CFSTR(IO32BitDirectPixels)); CFRelease(encoding); if (!is32) continue; if (CGDisplayModeGetIOFlags(mode) & kDisplayModeStretchedFlag) continue; res << w << "x" << h; retlist.Add(res.str()); } CFRelease(modes); #endif return retlist; }
// Search for avaliable resolutions - TODO: Move to Common? wxArrayString GetListOfResolutions() { wxArrayString retlist; #ifdef _WIN32 DWORD iModeNum = 0; DEVMODE dmi; ZeroMemory(&dmi, sizeof(dmi)); dmi.dmSize = sizeof(dmi); std::vector<std::string> resos; while (EnumDisplaySettings(NULL, iModeNum++, &dmi) != 0) { char res[100]; sprintf(res, "%dx%d", dmi.dmPelsWidth, dmi.dmPelsHeight); std::string strRes(res); // Only add unique resolutions if (std::find(resos.begin(), resos.end(), strRes) == resos.end()) { resos.push_back(strRes); retlist.Add(wxString::FromAscii(res)); } ZeroMemory(&dmi, sizeof(dmi)); } #elif defined(HAVE_XRANDR) && HAVE_XRANDR main_frame->m_XRRConfig->AddResolutions(retlist); #elif defined(__APPLE__) CFArrayRef modes = CGDisplayAvailableModes(CGMainDisplayID()); for (CFIndex i = 0; i < CFArrayGetCount(modes); i++) { std::stringstream res; CFDictionaryRef mode; CFNumberRef ref; int w, h, d; mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, i); ref = (CFNumberRef)CFDictionaryGetValue(mode, kCGDisplayWidth); CFNumberGetValue(ref, kCFNumberIntType, &w); ref = (CFNumberRef)CFDictionaryGetValue(mode, kCGDisplayHeight); CFNumberGetValue(ref, kCFNumberIntType, &h); ref = (CFNumberRef)CFDictionaryGetValue(mode, kCGDisplayBitsPerPixel); CFNumberGetValue(ref, kCFNumberIntType, &d); if (CFDictionaryContainsKey(mode, kCGDisplayModeIsStretched)) continue; if (d != 32) continue; res << w << "x" << h; retlist.Add(res.str()); } #endif return retlist; }
bool CString::Load(UINT nId) { #ifdef _MFC_VER CString strRes(MAKEINTRESOURCE(nId)); *this = strRes; return !empty(); #else // Get the resource name via MAKEINTRESOURCE. This line is pretty much lifted from CString PCTSTR szName = MAKEINTRESOURCE((nId>>4)+1); HINSTANCE hModule = CString::GetResourceHandle(); // No sense continuing if we can't find the string resource. if ( ::FindResource(hModule, szName, RT_STRING) == NULL ) return false; int nMaxLen = 0; int nRetLen = 0; int nTries = 0; PTSTR pBuf = NULL; // Keep looping until: // we have a buffer big enough to hold the string, // or we exceed the maximum number of tries, // or there is an error do { nMaxLen += LOAD_BUF_SIZE; pBuf = reinterpret_cast<PTSTR>(_alloca((nMaxLen) * sizeof(TCHAR))); nRetLen = ::LoadString(hModule, nId, pBuf, nMaxLen); if ( nRetLen == 0 ) TRACE(_T("Resource ID %d does not exist -- cannot load\n"), nId); else if ( nRetLen < 1 ) TRACE(_T("Error 0x%X attempting to load resource %d\n"), ::GetLastError(), nId); else if ( nRetLen+1 < nMaxLen ) *this = pBuf; } while ( nRetLen+1 == nMaxLen && nTries++ < MAX_LOAD_TRIES ); return true; #endif }
void CPPgShortcuts::Localize(void) { static const uint16 s_auResTbl[][2] = { { IDC_SHORTCUTS_STATIC, IDS_SHORTCUTS_STATIC } }; if (::IsWindow(m_hWnd)) { CString strRes(_T(" ")); strRes += GetResString(IDS_SHORTCUTS_ENABLE); // the spaces let a blank space to display the IDC_SHORTCUTS_ENABLE checkbox SetDlgItemText(IDC_SHORTCUTS_GROUPBOX, strRes); for (uint32 i = 0; i < ARRSIZE(s_auResTbl); i++) { ::GetResString(&strRes, static_cast<UINT>(s_auResTbl[i][1])); SetDlgItemText(s_auResTbl[i][0], strRes); } RefreshShortcutsTree(); RefreshKeyCombo(); } }
void Visitor::postOutput() { CM_TRACE_FUNC("Visitor::postOutput()"); //compile the shader MString shaderdir(getShaderDirectory()); MString outSLO(renderman::getShaderFilePath_SLO(shaderNodeName.c_str())); MString srcSL (renderman::getShaderFilePath_SRC(shaderNodeName.c_str())); MString result; //NOTE: // the include directory can't contain '.', so I move _3delight to %LIQUID_ROOT%\dependence //"shader.exe -o \"outSLO\" -I\"%LIQUID_ROOT%\dependence\_3delight" \"srcSL\"" IfMErrorWarn(MGlobal::executeCommand("system(\"shader -o \\\""+outSLO+"\\\" -I\\\"%LIQUID_ROOT%/dependence/_3delight\\\" \\\""+srcSL+"\\\"\")", result, true)); //show the error if there is. std::string strRes(result.toLowerCase().asChar()); if(strRes.find("error") != std::string::npos) { liqAssert(strRes.c_str()); } }
void CSetPageBase::InitPropList() { CBCGPTagManager tm; CString strRes(_T("IDR_SETCONFIG_XML_") + m_strConfigName.MakeUpper()); if (!tm.LoadFromResource(strRes, _T("XML"))) { return; } CString strStyle; if (!tm.ExcludeTag(_T("SETCONFIG"), strStyle)) { return; } tm.SetBuffer(strStyle); int nVersion; tm.ReadInt(_T("VERSION"), nVersion); if (nVersion != 1) { return; } CString strPropertys; if (tm.ExcludeTag(_T("PROPERTYS"), strPropertys)) { CBCGPTagManager tmPropertys(strPropertys); CMyBCGPProp* pPropGroup = NULL; CString strProperty; while (tmPropertys.ExcludeTag(_T("PROPERTY"), strProperty)) { CBCGPTagManager tmProperty(strProperty); CString strName = _T("NO NAME"); tmProperty.ReadString(_T("NAME"), strName); BOOL bGroup = FALSE; if (tmProperty.ReadBool(_T("GROUP"), bGroup) && bGroup) { if (pPropGroup) { m_wndPropList.AddProperty(pPropGroup, FALSE, FALSE); pPropGroup = NULL; } pPropGroup = new CMyBCGPProp(strName); } else if (pPropGroup) { CString strType = _T("Combo"); tmProperty.ReadString(_T("TYPE"), strType); if (strType.CompareNoCase(_T("Combo")) == 0) { CString strValue; tmProperty.ReadString(_T("VALUE"), strValue); CMyBCGPProp* pProp = new CMyBCGPProp(strName, (_variant_t)strValue); CString strItem; while (tmProperty.ExcludeTag(_T("ITEM"), strItem)) { CBCGPTagManager tmItem(strItem); tmItem.ReadString(_T("VALUE"), strValue); CString strShort, strPreview; tmItem.ReadString(_T("SHORT"), strShort); tmItem.ReadString(_T("PREVIEW"), strPreview); Entity_Backward(strPreview, s_EntityText); EntityToSymbol(strPreview); pProp->AddComboOption(strValue, strShort, strPreview); } pPropGroup->AddSubItem(pProp); } else if (strType.CompareNoCase(_T("Number")) == 0) { int nValue; tmProperty.ReadInt(_T("VALUE"), nValue); CMyBCGPProp* pProp = new CMyBCGPProp(strName, (_variant_t)nValue); CSize range; tmProperty.ReadSize(_T("RANGE"), range); BOOL bBuddy = FALSE; tmProperty.ReadBool(_T("BUDDY"), bBuddy); CMyBCGPProp* pPropBuddy = NULL; if (bBuddy) { pPropBuddy = DYNAMIC_DOWNCAST(CMyBCGPProp, pPropGroup->GetSubItem(pPropGroup->GetSubItemsCount() - 1)); } CString strShort, strPreview; tmProperty.ReadString(_T("SHORT"), strShort); tmProperty.ReadString(_T("PREVIEW"), strPreview); Entity_Backward(strPreview, s_EntityText); EntityToSymbol(strPreview); pProp->SetNumberSpin(range.cx, range.cy, strShort, strPreview, pPropBuddy); pPropGroup->AddSubItem(pProp); } else if (strType.CompareNoCase(_T("Text")) == 0) { CString strValue; tmProperty.ReadString(_T("VALUE"), strValue); CMyBCGPProp* pProp = new CMyBCGPProp(strName, (_variant_t)strValue); CString strShort, strPreview; tmProperty.ReadString(_T("SHORT"), strShort); tmProperty.ReadString(_T("PREVIEW"), strPreview); Entity_Backward(strPreview, s_EntityText); EntityToSymbol(strPreview); pProp->SetEditText(strShort, strPreview); pPropGroup->AddSubItem(pProp); } } } if (pPropGroup) { m_wndPropList.AddProperty(pPropGroup, FALSE, FALSE); pPropGroup = NULL; } } }