JNIEXPORT jstring JNICALL Java_org_limewire_cef_CefV8Value_1N_N_1GetStringValue (JNIEnv *env, jobject obj) { CefRefPtr<CefV8Value> value( (CefV8Value*)GetCefBaseFromJNIObject(env, obj)); if(!value.get()) return NULL; CefString str = value->GetStringValue(); return env->NewString((const jchar*)str.c_str(), str.length()); }
void TransparentWnd::ShowTip(CefString& text){ return; TransparentWnd* pWin; if(!pTipWin){ if(text.length()){ pWin=new TransparentWnd(); pTipWin=(void *)pWin; std::stringstream ss; POINT pt; GetCursorPos(&pt); ss<<"{\"text\":\""<<text.ToString()<<"\",\"x\":"<<pt.x<<",\"y\":"<<pt.y<<"}"; pWin->RunAppIn("tip/index.app",ss.str()); } } else{ pWin=(TransparentWnd *)pTipWin; if(text.length()){ std::wstringstream ss; POINT pt; GetCursorPos(&pt); wstring t=text.ToWString(); replace_allW(t,L"'",L"\'"); ss<<"var e = new CustomEvent('AlloyDesktopShowTip', {" "detail: {" " 'text':'"<<t<<"',"<< " 'x':"<<pt.x<<"," " 'y':"<<pt.y<< "}" "});" "dispatchEvent(e);"; pWin->ExecJS(ss.str()); ExecJS(ss.str()); if(pWin->isHide){ pWin->Restore(); } } else{ pWin->Hide(); } } }
void TransparentWnd::RunApp(CefString appName, CefString param, CefString baseUrl){ wstring appNameW=appName.ToWString(); wstring path; if(!baseUrl.length()){ path=modulePath; } else{ path=baseUrl.ToWString(); replace_allW(path, L"\\", L"/"); path=path.substr(0,path.find_last_of('/')+1); } if(appNameW.find(L":")==-1){ appNameW=path.append(appNameW); } CreateBrowser(appNameW,param); }
Local<String> CefStringToV8(const CefString& str) { return String::New(reinterpret_cast<uint16_t*>(const_cast<CefString::char_type*>(str.c_str())), str.length()); }
void TransparentWnd::RunAppIn(CefString appName, CefString param, CefString baseUrl){ wstring appNameW=appName.ToWString(); if(appNameW.find(L":")==-1){ wstring path; if(!baseUrl.length()){ path=modulePath;//szPath; } else{ path=baseUrl.ToWString(); replace_allW(path, L"\\", L"/"); path=path.substr(0,path.find_last_of('/')+1); } appNameW=path.append(appNameW); } replace_allW(appNameW, L"\\", L"/"); int w,h,_x,_y; int enableDrag=0,disableTransparent=0,exStyle=0,hasBorder=false,_max=false,_enableResize=false,disableRefresh=0,disableDevelop=0; TCHAR url[1000],name[100],iconPath[1000]; wstring _folder=appNameW.substr(0,appNameW.find_last_of('/')+1); folder=_folder; GetPrivateProfileString(L"BASE",L"url",NULL,url,1000,appNameW.data()); GetPrivateProfileString(L"BASE",L"name",NULL,name,100,appNameW.data()); GetPrivateProfileString(L"BASE",L"icon",NULL,iconPath,1000,appNameW.data()); w=GetPrivateProfileInt(L"BASE",L"width",0,appNameW.data()); h=GetPrivateProfileInt(L"BASE",L"height",0,appNameW.data()); _x=GetPrivateProfileInt(L"BASE",L"x",0,appNameW.data()); _y=GetPrivateProfileInt(L"BASE",L"y",0,appNameW.data()); enableDrag=GetPrivateProfileInt(L"BASE",L"enableDrag",0,appNameW.data()); disableRefresh=GetPrivateProfileInt(L"BASE",L"disableRefresh",0,appNameW.data()); disableDevelop=GetPrivateProfileInt(L"BASE",L"disableDevelop",0,appNameW.data()); _enableResize=GetPrivateProfileInt(L"BASE",L"enableResize",0,appNameW.data()); disableTransparent=GetPrivateProfileInt(L"BASE",L"disableTransparent",0,appNameW.data()); hasBorder=GetPrivateProfileInt(L"BASE",L"hasBorder",0,appNameW.data()); _max=GetPrivateProfileInt(L"BASE",L"max",0,appNameW.data()); exStyle=GetPrivateProfileInt(L"BASE",L"exStyle",0,appNameW.data()); int l=wcslen(iconPath); if(l>0){ hIcon=GetIcon(iconPath); } if(_enableResize>0){ enableResize=true; } enableRefresh=disableRefresh==0; enableDevelop=disableDevelop==0; CefString cefFile(url); wstring file=cefFile.ToWString(); if(file.find(L":")==-1){ file=_folder.append(file); } bool isTransparent=disableTransparent==0; if(hasBorder){ char t[10]; _itoa(isTransparent,t,10); CefString ct(t); wstring _name(name); file=modulePath.append(L"window\\index.html?name=").append(_name).append(L"&url=").append(file).append(L"&transparent=").append(ct.ToWString().data()).append(L"&x="); _itoa(_x,t,10); ct=t; file.append(ct.ToWString().data()); file.append(L"&y="); _itoa(_y,t,10); ct=t; file.append(ct.ToWString().data()); file.append(L"&width="); _itoa(w,t,10); ct=t; file.append(ct.ToWString().data()); file.append(L"&height="); _itoa(h,t,10); ct=t; file.append(ct.ToWString().data()); file.append(L"&max="); _itoa(_max,t,10); ct=t; file.append(ct.ToWString().data()); isTransparent=true; if(param.length()){ file.append(L"¶m="+param.ToWString()); } } else { if(param.length()){ file.append(L"?param="+param.ToWString()); } } CreateBrowserWindow(file, exStyle, isTransparent); if(_max){ this->Max(); } else{ SetSize(w,h); Move(_x,_y); } this->SetTitle(name); if(enableDrag>0){ EnableDrag(); } }