void CGameImageLoader::CreateSurface() { TSize imagesize = iBitmap->SizeInPixels(); if (iPixelFormat) { // the image must be converted to the requested pixel format int x, y; TRgb pixel; TPoint point; TRAPD(error, iSurface = new Game::Surface(iPixelFormat, imagesize.iWidth, imagesize.iHeight)); if( error != KErrNone ) { iErrorCode = error; return; } if (!iSurface) { iErrorCode = KErrNoMemory; return; } for(y=0; y<imagesize.iHeight; y++) for(x=0; x<imagesize.iWidth; x++) { point.iX = x; point.iY = y; iBitmap->GetPixel(pixel, point); iSurface->setPixel(x, y, iPixelFormat->makePixel(pixel.Red(), pixel.Green(), pixel.Blue())); } } else { // no pixel conversion required Game::PixelFormat bitmapPixelFormat(12); Game::Surface tmpSurface(&bitmapPixelFormat, (Game::Pixel*)iBitmap->DataAddress(), imagesize.iWidth, imagesize.iHeight); // TRAPD(error, iSurface = new Game::Surface(&bitmapPixelFormat, (Game::Pixel*)iBitmap->DataAddress(), imagesize.iWidth, imagesize.iHeight)); TRAPD(error, iSurface = new Game::Surface(&bitmapPixelFormat, &tmpSurface)); if( error != KErrNone ) { delete iSurface; iSurface = NULL; iErrorCode = error; return; } if (!iSurface) { iErrorCode = KErrNoMemory; return; } } }
ListElement* dlgMultiSelectListShowModal(void) { ItemIndex = -1; if (iNO_ELEMENTS == 0) { return NULL; } wf = dlgLoadFromXML(CallBackTable, ScreenLandscape ? IDR_XML_MULTISELECTLIST_L : IDR_XML_MULTISELECTLIST_P); if (!wf) return NULL; wf->SetTimerNotify(1000, OnTimer); wMultiSelectListList = (WndListFrame*) wf->FindByName(TEXT("frmMultiSelectListList")); LKASSERT(wMultiSelectListList != NULL); wMultiSelectListList->SetBorderKind(BORDERLEFT); wMultiSelectListList->SetEnterCallback(OnMultiSelectListListEnter); wMultiSelectListListEntry = (WndOwnerDrawFrame*) wf->FindByName(TEXT("frmMultiSelectListListEntry")); if(wMultiSelectListListEntry) { /* * control height must contains 2 text Line * Check and update Height if necessary */ LKWindowSurface windowSurface(MainWindow); LKBitmapSurface tmpSurface(windowSurface, 1, 1); const auto oldFont = tmpSurface.SelectObject(wMultiSelectListListEntry->GetFont()); const int minHeight = 2 * tmpSurface.GetTextHeight(_T("dp")) + 2 * DLGSCALE(2); tmpSurface.SelectObject(oldFont); const int wHeight = wMultiSelectListListEntry->GetHeight(); if(minHeight > wHeight) { wMultiSelectListListEntry->SetHeight(minHeight); } wMultiSelectListListEntry->SetCanFocus(true); } else LKASSERT(0); UpdateList(); wf->ShowModal(); delete wf; wf = NULL; iNO_ELEMENTS = 0; NoAirfields = 0; NoOutlands = 0; NoWaypoints = 0; NoAirspace = 0; NoTaskPoints = 0; return pResult; }
int dlgTaskSelectListShowModal(void) { TaskIndex = -1; if (iNO_Tasks == 0) return mrCancel; wf = dlgLoadFromXML(TaskCallBackTable, ScreenLandscape ? IDR_XML_MULTISELECTLIST_L : IDR_XML_MULTISELECTLIST_P); if (!wf) return mrCancel; wTaskSelectListList = (WndListFrame*) wf->FindByName(TEXT("frmMultiSelectListList")); LKASSERT(wTaskSelectListList != NULL); wTaskSelectListList->SetBorderKind(BORDERLEFT); wTaskSelectListList->SetEnterCallback(OnTaskSelectListListEnter); wTaskSelectListListEntry = (WndOwnerDrawFrame*) wf->FindByName(TEXT("frmMultiSelectListListEntry")); if(wTaskSelectListListEntry) { /* * control height must contains 2 text Line * Check and update Height if necessary */ LKWindowSurface windowSurface(MainWindow); LKBitmapSurface tmpSurface(windowSurface, 1, 1); const auto oldFont = tmpSurface.SelectObject(wTaskSelectListListEntry->GetFont()); const int minHeight = 2 * tmpSurface.GetTextHeight(_T("dp")) + 2 * DLGSCALE(2); tmpSurface.SelectObject(oldFont); const int wHeight = wTaskSelectListListEntry->GetHeight(); if(minHeight > wHeight) { wTaskSelectListListEntry->SetHeight(minHeight); } wTaskSelectListListEntry->SetCanFocus(true); } else LKASSERT(0); UpdateList(); int result = wf->ShowModal(); wTaskSelectListList->Redraw(); delete wf; wf = NULL; iNO_Tasks = 0; return result; }