UINT BitPack1Bit::GetAdjustedRows() { if (m_orientation == 0 || m_orientation == 1) { return (m_img_height >> 3) + (GetYOffset()?1:0); } else { return m_img_height;
void ScheduleViewEx::OnDraw(CDC* pDC) { Periods& periods = static_cast<CScheduleApp*>(AfxGetApp())->m_periods; Period& period = periods.GetCurrentPeriod(); CTime startDay = period.m_dateRange.GetStartDate(); startDay = startDay + CTimeSpan(xDelta*GetXOffset(),0,0,0); CTime stopDay = startDay + CTimeSpan(xDelta,0,0,0); Truncate(startDay,period.m_dateRange.GetStartDate(), period.m_dateRange.GetEndDate()); Truncate(stopDay,period.m_dateRange.GetStartDate(), period.m_dateRange.GetEndDate()); int startNurse = yDelta * GetYOffset(); int stopNurse = startNurse + yDelta; CString outputText = ViewOutput(startDay,stopDay, startNurse,stopNurse); CFont tmpcourierFont; if (pDC->m_bPrinting) tmpcourierFont.CreatePointFont(printFontSize,_T("Lucida Console")); else tmpcourierFont.CreatePointFont(viewFontSize,_T("Lucida Console")); LOGFONT logFont; tmpcourierFont.GetLogFont(&logFont); logFont.lfUnderline = 1; CFont courierFont; courierFont.CreateFontIndirect(&logFont); CFont * oldFont; oldFont = pDC->SelectObject(&courierFont); pDC->DrawText(outputText,CRect(250,-250,250,-250),DT_NOCLIP); if (!pDC->m_bPrinting) { CRect rcOut(0,0,0,0); VERIFY(pDC->DrawText(outputText,&rcOut,DT_NOCLIP | DT_CALCRECT)); CSize newSize(rcOut.right*1.1,(rcOut.bottom*-1)*1.1); if (newSize != m_oldSize) { SetScrollSizes(MM_HIENGLISH,newSize); m_oldSize = newSize; } } CFont * tmpFont = pDC->SelectObject(oldFont); ASSERT(tmpFont = &courierFont); }
void CViewport::Render() { CGraphicsContext *graphics=mProgram->CheckGraphicsMode(); if (graphics->GetType()==CGraphicsContext::kBlastGraphicsContext) { CCanvas *fromCanvas=graphics->mCanvasManager.GetCanvas(mCanvas); if ((mUpdateAll) || (((CBLCanvas*)fromCanvas)->GetDrawBuffer()->GetUsedBlitRects())) { CCanvas *toCanvas=graphics->mCanvasManager.GetCanvas(0); toCanvas->Copy(fromCanvas,GetViewportRect(),mBounds.left,mBounds.top); ((CBLCanvas*)fromCanvas)->GetDrawBuffer()->ClearBlitList(); mUpdateAll=false; } } else { CGraphicsContextGL *glGraphics=(CGraphicsContextGL*)graphics; CGLCanvas *fromCanvas=(CGLCanvas*)graphics->mCanvasManager.GetCanvas(mCanvas); float screenWidth=glGraphics->GetWidth()/2.0f; float screenHeight=glGraphics->GetHeight()/2.0f; float across=(mBounds.left/screenWidth)-1.0f; float down=-((mBounds.bottom/screenHeight)-1.0f); glPixelStorei(GL_UNPACK_ROW_LENGTH,fromCanvas->GetWidth()); glPixelStorei(GL_UNPACK_SKIP_ROWS,fromCanvas->GetHeight()-GetHeight()-GetYOffset()); glPixelStorei(GL_UNPACK_SKIP_PIXELS,GetXOffset()); glRasterPos2f(across,down); glDrawPixels(GetWidth(),GetHeight(),GL_RGB,GL_UNSIGNED_BYTE,fromCanvas->GetPixels()); glRasterPos2f(0,0); glPixelStorei(GL_UNPACK_SKIP_PIXELS,0); glPixelStorei(GL_UNPACK_SKIP_ROWS,0); glPixelStorei(GL_UNPACK_ROW_LENGTH,0); RenderSprites(); } }
void CCamera::Update( float fElapsedTime ) { int width( int( theCamera->GetWidth( )-theCamera->GetXOffset( ) ) ); int height( int( theCamera->GetHeight( )-theCamera->GetYOffset( ) ) ); RECT rCamera; rCamera.left = LONG( GetXOffset() ); rCamera.right = LONG( rCamera.left + GetWidth() ); rCamera.top = LONG( GetYOffset() ); rCamera.bottom = LONG( rCamera.top + GetHeight() ); CBase* pCurPlayer; RECT rPlayer; if( !((CPlayer*)thePlayer)->GetFainted() || thePlayer2 == NULL ) { pCurPlayer = thePlayer; rPlayer = thePlayer->GetCollisionRect( fElapsedTime ); } else if( thePlayer2 ) { pCurPlayer = thePlayer2; rPlayer = thePlayer2->GetCollisionRect( fElapsedTime ); } int CenterOfScreenX( int( theCamera->GetXOffset( ) + width / 2 ) ); int CenterOfScreenY( int( theCamera->GetYOffset( ) + height / 2 ) ); RECT rHook, r; int x = thePlayer->GetWidth( ); rHook.left = CenterOfScreenX - ( thePlayer->GetWidth( ) << 1 ); rHook.top = CenterOfScreenY - ( thePlayer->GetHeight( ) ); rHook.right = CenterOfScreenX + ( thePlayer->GetWidth( ) << 1 ); rHook.bottom = CenterOfScreenY + ( thePlayer->GetHeight( ) ); if( !IntersectRect( &r, &rPlayer, &rCamera ) ) { theCamera->SetCameraXOffset( pCurPlayer->GetPosX( ) - width / 2 ); theCamera->SetCameraYOffset( pCurPlayer->GetPosY( ) - height / 2 ); } if (IntersectRect( &r, &rHook, &rPlayer ) ) { theCamera->SetVelocityX( theCamera->GetVelocityX( ) * 0.95f ); theCamera->SetVelocityY( theCamera->GetVelocityY( ) * 0.95f ); } { if( rPlayer.left < rHook.left && pCurPlayer->GetVelX() < -110) theCamera->SetVelocityX( pCurPlayer->GetVelX()); else if( rPlayer.left < rHook.left ) theCamera->SetVelocityX( -100 ); else if( rPlayer.right > rHook.right && pCurPlayer->GetVelX() > 110) theCamera->SetVelocityX( pCurPlayer->GetVelX() ); else if( rPlayer.right > rHook.right ) theCamera->SetVelocityX( 100 ); if( rPlayer.top < rHook.top ) theCamera->SetVelocityY( -100 ); else if( rPlayer.bottom > rHook.bottom && pCurPlayer->GetVelY() > 200) theCamera->SetVelocityY( pCurPlayer->GetVelY() ); else if(rPlayer.bottom > rHook.bottom) theCamera->SetVelocityY( 200 ); } theCamera->SetCameraXOffset( theCamera->GetXOffset( ) + theCamera->GetVelocityX( ) * fElapsedTime ); theCamera->SetCameraYOffset( theCamera->GetYOffset( ) + theCamera->GetVelocityY( ) * fElapsedTime ); }