void DrawingImageImpl::draw(HDC hdc, int x, int y) { RHO_MAP_TRACE2("draw DrawingImage with x = %d, y = %d", x, y); if (mBitmap == NULL) { return; } mBitmap->draw(hdc, x, y); }
LRESULT CRhoMapViewDlg::OnUntouch(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { if ( (MABS(mInitialX - mLastX) < 8) && (MABS(mInitialY - mLastY) < 8) && mIsPossibleClick) { if (ourMapView != NULL) { RHO_MAP_TRACE2("MapView->handleClick( %d, %d)", mLastX, mLastY); if (ourMapView->handleClick(mLastX, mLastY)) { EndDialog(0); } } } return 0; }
LRESULT CRhoMapViewDlg::OnDrag(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { int xPos = LOWORD(lParam); int yPos = HIWORD(lParam); if (ourMapView != NULL && (abs(mInitialX-xPos) > 10 || abs(mInitialY-yPos) > 10) ) { RHO_MAP_TRACE2("MapView->move( %d, %d)", mLastX-xPos, mLastY-yPos); ourMapView->move(mLastX-xPos, mLastY-yPos); requestRedraw(); } mLastX = xPos; mLastY = yPos; return 0; }
void DrawingContextImpl::drawText(int x, int y, int nWidth, int nHeight, String const &text, int color) { RHO_MAP_TRACE2("DrawingContext drawText with x = %d, y = %d", x, y); HFONT hfontTahoma; LOGFONT logfont; HFONT hfontSave = NULL; memset (&logfont, 0, sizeof (logfont)); logfont.lfHeight = 18; logfont.lfWidth = 0; logfont.lfEscapement = 0; logfont.lfOrientation = 0; logfont.lfWeight = FW_BOLD; logfont.lfItalic = FALSE; logfont.lfUnderline = FALSE; logfont.lfStrikeOut = FALSE; logfont.lfCharSet = DEFAULT_CHARSET; logfont.lfOutPrecision = OUT_DEFAULT_PRECIS; logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; logfont.lfQuality = DEFAULT_QUALITY; logfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; _tcsncpy (logfont.lfFaceName, TEXT("Tahoma"), LF_FACESIZE); logfont.lfFaceName[LF_FACESIZE-1] = TEXT('\0'); // Ensure null termination hfontTahoma = CreateFontIndirect (&logfont); if (hfontTahoma) { hfontSave = (HFONT) SelectObject(mHDC, hfontTahoma); } StringW pathW = convertToStringW(text); SetBkMode(mHDC, TRANSPARENT); SetTextColor(mHDC, color & 0xFFFFFF); //TextOut(mHDC, x, y, pathW.c_str(), pathW.length()); RECT r; r.left = x; r.top = y; r.right = x+nWidth; r.bottom = y + nHeight; DrawText(mHDC, pathW.c_str(), -1, &r, DT_LEFT | DT_TOP); if (hfontTahoma) { SelectObject(mHDC, hfontSave); DeleteObject (hfontTahoma); } }
IDrawingImage *AndroidMapDevice::createImageEx(void const *p, size_t size, int x, int y, int w, int h, bool useAlpha) { RHO_MAP_TRACE2("createImageEx: p=%p, size=%llu", p, (unsigned long long)size); JNIEnv *env = jnienv(); jclass cls = getJNIClass(RHODES_JAVA_CLASS_MAPVIEW); if (!cls) return NULL; jmethodID mid = getJNIClassStaticMethod(env, cls, "createImageEx", "([BIIII)Landroid/graphics/Bitmap;"); if (!mid) return NULL; jholder<jbyteArray> data = jholder<jbyteArray>(env->NewByteArray(size)); if (!data) return NULL; env->SetByteArrayRegion(data.get(), 0, size, (jbyte const *)p); jobject bitmap = env->CallStaticObjectMethod(cls, mid, data.get(), x, y, w, h); IDrawingImage *image = new AndroidImage(bitmap); RHO_MAP_TRACE1("createImage: return image=%p", image); return image; }
void AndroidMapDevice::attach(JNIEnv *env, jobject jDevice) { RHO_MAP_TRACE2("AndroidMapDevice: attach m_jdevice=%p, jDevice=%p", m_jdevice, jDevice); m_jdevice = env->NewGlobalRef(jDevice); RHO_MAP_TRACE("AndroidMapDevice: attach done"); }
DrawingContextImpl::DrawingContextImpl(HDC hdc, int width, int height) { RHO_MAP_TRACE2("DrawingContext create with WIDTH = %d, HEIGHT = %d", width, height); mHDC = hdc; mWidth = width; mHeight = height; }
void DrawingImageImpl::init(const char* path, void const *p, int size, WMBitmap* bitmap, bool useAlpha) { mID = ++ourDrawingImageID; RHO_MAP_TRACE1("DrawingImage create with ID = %d", mID); #if defined(_WIN32_WCE) IImagingFactory *pImgFactory = NULL; IImage *pImage = NULL; mWidth = 0; mHeight = 0; mBitmap = NULL; if (bitmap != NULL) { mBitmap = bitmap; mBitmap->addRef(); mWidth = bitmap->width(); mHeight = bitmap->height(); return; } HRESULT co_init_result = CoInitializeEx(NULL, 0/*COINIT_APARTMENTTHREADED*/); if ( (co_init_result == S_OK) || (co_init_result == S_FALSE) ) { msg_out("CoInitializeEx OK"); if (SUCCEEDED(CoCreateInstance (CLSID_ImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IImagingFactory, (void **)&pImgFactory))) { HRESULT res = 0; if (p != NULL) { // from buf res = pImgFactory->CreateImageFromBuffer( p, size, BufferDisposalFlagNone, &pImage); } else { // from file msg_out("Create Image Factory OK"); wchar_t wc_filename[2048]; mbstowcs(wc_filename, path, 2048); res = pImgFactory->CreateImageFromFile( wc_filename, &pImage); } if (SUCCEEDED(res)) { IImage* mimage = pImage; ImageInfo imgInfo; mimage->GetImageInfo(&imgInfo); mWidth = imgInfo.Width; mHeight = imgInfo.Height; RHO_MAP_TRACE2("Drawing Image was created with WIDTH = %d, HEIGHT = %d", mWidth, mHeight); mBitmap = new WMBitmap(mimage, useAlpha); mimage->Release(); } else { err_out("Image not created !"); } pImgFactory->Release(); } else { err_out("ImageFactory not created !"); } CoUninitialize(); } else { err_out("CoInitializeEx not initialized !"); } #endif //#if defined(_WIN32_WCE) }
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; }