void rho_param_free(rho_param *p) { int i, lim; if (!p) return; switch (p->type) { case RHO_PARAM_STRING: free(p->v.string); break; case RHO_PARAM_ARRAY: for (i = 0, lim = p->v.array->size; i < lim; ++i) rho_param_free(p->v.array->value[i]); free(p->v.array->value); free(p->v.array); break; case RHO_PARAM_HASH: for (i = 0, lim = p->v.hash->size; i < lim; ++i) { free(p->v.hash->name[i]); rho_param_free(p->v.hash->value[i]); } free(p->v.hash->name); free(p->v.hash->value); free(p->v.hash); break; } free(p); }
AndroidMapDevice::~AndroidMapDevice() { RHO_MAP_TRACE("AndroidMapDevice: dtor start"); rho_param_free(m_params); JNIEnv *env = jnienv(); if (m_jdevice) env->DeleteGlobalRef(m_jdevice); RHO_MAP_TRACE("AndroidMapDevice: dtor finish"); }
AndroidMapDevice::~AndroidMapDevice() { RHO_MAP_TRACE("AndroidMapDevice: dtor start"); rho_param_free(m_params); JNIEnv *env = jnienv(); if (m_jdevice) { JNIEnv *env = jnienv(); jclass cls = getJNIClass(RHODES_JAVA_CLASS_MAPVIEW); if (!cls) return; jmethodID mid = getJNIClassMethod(env, cls, "destroyDevice", "()V"); if (!mid) return; env->CallVoidMethod(m_jdevice, mid); env->DeleteGlobalRef(m_jdevice); } RHO_MAP_TRACE("AndroidMapDevice: dtor finish"); }
extern "C" void rho_barcode_take_barcode(const char* callback, VALUE options) { JNIEnv *env = jnienv(); jclass cls = rho_find_class(env, "com/rhomobile/barcode/Barcode"); if (!cls) return; jmethodID mid = env->GetStaticMethodID( cls, "take", "(Ljava/lang/String;I)V"); if (!mid) return; int camera_index = 0; if (!rho_ruby_is_NIL(options)) { // parse options for camera index ( 0 - main, 1 - front) rho_param *param = rho_param_fromvalue(options); if (param->type == RHO_PARAM_HASH) { int i; for (i = 0; i < param->v.hash->size; i++) { if (strcasecmp(param->v.hash->name[i], "camera") == 0) { if (param->v.hash->value[i]->type == RHO_PARAM_STRING) { if (strcasecmp(param->v.hash->value[i]->v.string, "front") == 0) { camera_index = 1; } } } } } rho_param_free(param); } jstring objCallback = env->NewStringUTF(callback); if(objCallback != NULL) { env->CallStaticObjectMethod(cls, mid, objCallback, camera_index); env->DeleteLocalRef(objCallback); } else { RAWLOG_ERROR1("Cannot take barcode, no memory: %d", strlen(callback)); } }
void CRhoParams::free_params() { if ( m_pParams != null ) rho_param_free(m_pParams); }
LRESULT CRhoMapViewDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { SetWindowText(_T("MapView")); #if defined(_WIN32_WCE) #if !defined (OS_PLATFORM_MOTCE) SHINITDLGINFO shidi = { SHIDIM_FLAGS, m_hWnd, SHIDIF_SIZEDLGFULLSCREEN }; RHO_ASSERT(SHInitDialog(&shidi)); SHMENUBARINFO mbi = { sizeof(mbi), 0 }; mbi.hwndParent = m_hWnd; mbi.nToolBarId = IDR_GETURL_MENUBAR;//IDR_MAPVIEW; mbi.hInstRes = _AtlBaseModule.GetResourceInstance(); SHCreateMenuBar(&mbi); #else m_hWndCommandBar = CommandBar_Create(_AtlBaseModule.GetResourceInstance(), m_hWnd, 1); CommandBar_AddAdornments(m_hWndCommandBar, 0, 0 ); CommandBar_Show(m_hWndCommandBar, TRUE); #endif //OS_WINCE //::SetWindowLong(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, // GWL_EXSTYLE, // ::GetWindowLong(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT); RECT r; ::GetClientRect(m_hWnd, &r); RHO_MAP_TRACE2("execute rho_map_create( w = %d, h = %d )", r.right - r.left, r.bottom - r.top); ourMapView = rho_map_create(mParams, &ourDrawingDevice, r.right - r.left, r.bottom - r.top); rho_param_free(mParams); mParams = NULL; if (ourMapView != NULL) { int minz = ourMapView->minZoom(); int maxz = ourMapView->maxZoom(); RHO_MAP_TRACE2("request Zoom limits: minZoom = %d, maxZoom = %d", minz, maxz); ::SendMessage(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, TBM_SETRANGEMIN, FALSE, minz); ::SendMessage(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, TBM_SETRANGEMAX, FALSE, maxz); int dwPos = ourMapView->zoom(); dwPos = ourMapView->maxZoom() - (dwPos - ourMapView->minZoom()); ::SendMessage(GetDlgItem(IDC_SLIDER_ZOOM).m_hWnd, TBM_SETPOS, TRUE, dwPos); String strImagePath = "lib/res/blue_pushpin.png"; String fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath); IDrawingImage* pinImg = ourDrawingDevice.createImage(fullImagePath, true); PIN_INFO pin_info = {0}; pin_info.x_offset = -10; pin_info.y_offset = -35; pin_info.click_rect_x = -10; pin_info.click_rect_y = -35; pin_info.click_rect_width = 72; pin_info.click_rect_height = 72; ourMapView->setPinImage(pinImg, pin_info); strImagePath = "lib/res/callout.png"; fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath); IDrawingImage* pinCalloutImg = ourDrawingDevice.createImage(fullImagePath, true); PIN_INFO pin_callout_info = {0}; pin_callout_info.x_offset = 5; pin_callout_info.y_offset = 0; pin_callout_info.click_rect_width = 179; pin_callout_info.click_rect_height = 64; ourMapView->setPinCalloutImage(pinCalloutImg, pin_callout_info); strImagePath = "lib/res/callout_link.png"; fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath); IDrawingImage* pinCalloutLinkImg = ourDrawingDevice.createImage(fullImagePath, true); ourMapView->setPinCalloutLinkImage(pinCalloutLinkImg, pin_callout_info); strImagePath = "lib/res/esri.png"; fullImagePath = CFilePath::join( RHODESAPP().getRhoRuntimePath(), strImagePath); IDrawingImage* esriLogoImg = ourDrawingDevice.createImage(fullImagePath, true); ourMapView->setESRILogoImage(esriLogoImg); } #else //CreateButtons(); //GotoDlgCtrl(m_btnOk); #endif requestRedraw(); return FALSE; }