// This function is used in your Ship need those parts. // This special Messagebox can hold up to 4 images void CMessageBoxVort::addTileAt(Uint16 tile, Uint16 x, Uint16 y) { CTilemap &tilemap = g_pGfxEngine->getTileMap(1); const int tileDim = tilemap.getDimension(); // now we'll create a new surface on which the Tile will be printed. SDL_Rect rect; rect.x = rect.y = 0; rect.w = rect.h = tileDim; SmartPointer<SDL_Surface> bmpSfc = CG_CreateRGBSurface(rect); SDL_FillRect(bmpSfc.get(), NULL, 0xFFFFFFFF); tilemap.drawTile(bmpSfc.get(), 0, 0, tile); rect.x = x; rect.y = y; CRect<float> fRect( x, y, 16.0f, 16.0f); CRect<float> gameRect = g_pVideoDriver->getGameResolution(); fRect.transformInverse(gameRect); fRect.transform(mRect); SmartPointer<CBitmap> pBitmap = new CBitmap(bmpSfc); addControl( new CGUIBitmap(pBitmap), fRect ); }
fRect fRect::operator | (const fRect &a) { if (isEmpty()) return a; if (a.isEmpty()) return *this; return fRect(std::min(min.x, a.min.x), std::min(min.y, a.min.y), std::max(max.x, a.max.x), std::max(max.y, a.max.y)); }
fRect fRect::operator | (const fRect &a) { if (getIsEmpty()) { return a; } else if (a.getIsEmpty()) { return *this; } return fRect(std::min(min.x, a.min.x), std::min(min.y, a.min.y), std::max(max.x, a.max.x), std::max(max.y, a.max.y)); }
FloatRect ChromeClientAndroid::windowRect() { ASSERT(m_webFrame); if (!m_webFrame) return FloatRect(); FrameView* frameView = m_webFrame->page()->mainFrame()->view(); if (!frameView) return FloatRect(); const WebCoreViewBridge* bridge = frameView->platformWidget(); const IntRect& rect = bridge->getWindowBounds(); FloatRect fRect(rect.x(), rect.y(), rect.width(), rect.height()); return fRect; }
void BlackDogState::draw_feather_ui() { // constants static const int SIZE = 32, SPACING = 2; static Animation* feather_ui = GraphicsManager::getInstance()->get_animation("feather_ui"); // cache fRect src, dest = fRect(SPACING, SPACING, SIZE, SIZE); int n_feathers = ((AngelThing*)getHero())->countFeathers(); // iterate through each feather of total possible storage for(int i = 0; i < AngelThing::MAX_FEATHERS; i++, dest.x += SIZE+SPACING) { // frame 0 is a full feather, 1 is an empty one src = feather_ui->getFrame(i < n_feathers ? 0 : 1); feather_ui->getTexture()->draw(&src, &dest); } }
void BlackDogState::draw_orb_ui() { // constants static const int SIZE = 32, SPACING = 2; static Animation* orb_ui = GraphicsManager::getInstance()->get_animation("orb_ui"); // cache fRect src, dest = fRect(WINDOW_DEFAULT_W-(SIZE+SPACING)*AngelThing::MAX_ORBS, SPACING, SIZE, SIZE); int n_orbs = ((AngelThing*)getHero())->countOrbs(); // iterate through each feather of total possible storage for(int i = 0; i < AngelThing::MAX_ORBS; i++, dest.x += SIZE+SPACING) { // frame 0 is a full feather, 1 is an empty one src = orb_ui->getFrame(i < n_orbs ? 1 : 0); orb_ui->getTexture()->draw(&src, &dest); } }
// This function is used in your Ship need those parts. // This special Messagebox can hold up to 4 images void CMessageBoxVort::addTileAt(Uint16 tile, Uint16 x, Uint16 y) { GsTilemap &tilemap = gGraphics.getTileMap(1); const int tileDim = tilemap.getDimension(); // now we'll create a new surface on which the Tile will be printed. SDL_Rect rect; rect.x = rect.y = 0; rect.w = rect.h = tileDim; #if SDL_VERSION_ATLEAST(2, 0, 0) std::shared_ptr<SDL_Surface> bmpSfc( CG_CreateRGBSurface( rect ), &SDL_FreeSurface ); bmpSfc.reset(gVideoDriver.convertThroughBlitSfc(bmpSfc.get()), &SDL_FreeSurface); #else std::shared_ptr<SDL_Surface> bmpSfc( CG_CreateRGBSurface(rect), &SDL_FreeSurface ); #endif SDL_FillRect(bmpSfc.get(), NULL, 0xFF00FFFF); tilemap.drawTile(bmpSfc.get(), 0, 0, tile); rect.x = x; rect.y = y; GsRect<float> fRect( x, y, 16.0f, 16.0f); GsRect<float> gameRect = gVideoDriver.getGameResolution(); fRect.transformInverse(gameRect); GsRect<float> scaleRect = mRect; scaleRect.x = 0; scaleRect.y = 0; fRect.transformInverse(scaleRect); std::shared_ptr<GsBitmap> pBitmap(new GsBitmap(bmpSfc)); addControl( new CGUIBitmap(pBitmap), fRect ); }
fRect Transformable::getBox() const { return fRect(m_pos, m_size); }
/*static*/ void EWASiteDrawer::drawSiteStateInfo( EWASiteHandle *pSite, QPainter *pPainter, const QRect& qrRect, bool bShowPercentsAndText, bool bSelected, bool bUnderMouse ) { if( !pSite || !pPainter ) return; pPainter->save(); pPainter->setRenderHints( EWAApplication::getRenderHints() ); QColor textColor = QColor( 0, 0, 127, 255 ); QColor baseColor = Qt::white; if ( bSelected ) { textColor = Qt::white; //-- <draw visible selection> baseColor = EWASiteDelegateBase::m_selectedColor; pPainter->fillRect( qrRect, baseColor ); //-- </draw visible selection> } //-- <draw download progress> int dwnProgress = pSite->getDownloadProgress(); if( dwnProgress && !pSite->getTypingProgress() ) { QColor loadingColor( 227, 214, 28 ); QRect dwnProgressRect = getSlicedRect( qrRect, dwnProgress ); pPainter->setBrush( generateGradient( loadingColor, dwnProgressRect, baseColor ) ); pPainter->setPen( Qt::transparent ); pPainter->drawRoundedRect( dwnProgressRect, 4,4 ); if ( bSelected ) { textColor = QColor( 0, 0, 127, 255 ); } } //-- </draw download progress> else {//-- <draw time progress> dwnProgress = pSite->getCountdownCurrent(); double fullPeriod = pSite->getCountdownOriginal(); if( !dwnProgress || dwnProgress == (int)fullPeriod || pSite->getTypingProgress() ) { dwnProgress = pSite->getTypingProgress(); fullPeriod = 100; } if( dwnProgress && fullPeriod ) { double fullPeriodPercent = fullPeriod/100; int progress = dwnProgress; progress = ( int )( dwnProgress/fullPeriodPercent ); QColor loadingColor( 200, 200, 200 ); QRect dwnProgressRect = getSlicedRect( qrRect, progress ); pPainter->setBrush( generateGradient( loadingColor, dwnProgressRect, baseColor ) ); pPainter->setPen( Qt::transparent ); pPainter->drawRoundedRect( dwnProgressRect, 4,4 ); if ( bSelected ) { textColor = QColor( 0, 0, 127, 255 ); } } dwnProgress ^= dwnProgress; }//-- </draw time progress> if( bShowPercentsAndText ) { //-- <draw url> QRect txtRect = qrRect; txtRect.adjust( 2, 1, -2, -1 ); pPainter->setPen( textColor ); if( bUnderMouse ) { QFont font = pPainter->font(); font.setBold( true ); pPainter->setFont( font ); } pPainter->drawText( txtRect, Qt::AlignVCenter|Qt::AlignLeft, pSite->getVisibleMsgTitle() ); //-- </draw url> } if( dwnProgress && bShowPercentsAndText ) { QFont paintersFont = pPainter->font(); paintersFont.setBold( true ); pPainter->setFont( paintersFont ); QString strProgress = QString( " %1% " ).arg( dwnProgress ); QRect percentsBackgroundRect = pPainter->fontMetrics().boundingRect( strProgress ); percentsBackgroundRect.moveCenter( qrRect.center() ); pPainter->setBrush( Qt::black ); pPainter->setOpacity( 0.5 ); pPainter->drawRoundedRect( percentsBackgroundRect, 4,4 ); pPainter->setOpacity( 1.0 ); pPainter->setPen( Qt::white ); QRectF fRect( qrRect ); fRect.setLeft( fRect.left() - 25 ); //-- white space on left fRect.setRight( fRect.right() + 25 ); //-- and right of the text pPainter->drawText( fRect, Qt::AlignCenter, strProgress, &fRect ); } pPainter->restore(); }
//绘制按钮,只有菜单按钮才需要该函数 //图标按钮不是自画方式,使用系统函数进行绘制 void CIconBut::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { // TODO: Add your message handler code here and/or call default //CButton::OnDrawItem(nIDCtl, lpDrawItemStruct); if( ( GetStyle( ) & BS_OWNERDRAW ) == BS_OWNERDRAW ) { //该控件为自画方式 //if(m_bStayDown&&m_bLockDown) return; CRect rect(lpDrawItemStruct->rcItem); CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC); UINT state=lpDrawItemStruct->itemState; UINT action=lpDrawItemStruct->itemAction; //得到系统的按钮各部分颜色 HBRUSH hbrText=GetSysColorBrush(COLOR_BTNTEXT); HBRUSH hbrFace=GetSysColorBrush(COLOR_3DFACE); HBRUSH hOldBrush=(HBRUSH)SelectObject(pDC->m_hDC,hbrFace); //绘制边界 CRect edgeRect(rect); pDC->Rectangle(rect); if(state&ODS_FOCUS) edgeRect.InflateRect(-1,-1); //绘制按钮体 /*if((state&ODS_SELECTED)&&(action&ODA_SELECT)&&(state&ODS_FOCUS)) { //按钮被选中 CPen pen(PS_SOLID,1,GetSysColor(COLOR_3DSHADOW)); CPen* pOldPen=pDC->SelectObject(&pen); pDC->Rectangle(edgeRect); pDC->SelectObject(pOldPen); } else*/ pDC->DrawEdge(edgeRect,EDGE_RAISED,BF_RECT|BF_SOFT); //m_bStayDown=FALSE; } //绘制按钮文字标题 CSize szTri=pDC->GetOutputTextExtent(_T("M"),1); CString text; GetWindowText(text); CSize szText=pDC->GetOutputTextExtent(text,text.GetLength()); CSize szTotal(szText); szTotal.cx+=szTri.cx; CRect textRect=rect; textRect.InflateRect(-((rect.Width()-szTotal.cx)/2), -((rect.Height()-szTotal.cy)/2)); textRect.top--; CRect triRect=textRect; triRect.left=textRect.right-szTri.cx; triRect.InflateRect(0,-((textRect.Height()-szTri.cy)/2)); pDC->SetBkMode(TRANSPARENT); if(state&ODS_SELECTED) textRect.OffsetRect(1,1); pDC->DrawText(text,textRect,DT_SINGLELINE|DT_LEFT); SelectObject(pDC->m_hDC,hbrText); CPoint ptTri(textRect.left+szText.cx,textRect.top+3); DrawTriangle(pDC,ptTri,10); if(state&ODS_FOCUS) { CRect fRect(rect); fRect.InflateRect(-4,-4); pDC->DrawFocusRect(fRect); } SelectObject(pDC->m_hDC,hOldBrush); if((action&ODA_SELECT)&& (state&ODS_FOCUS)&&(state&ODS_SELECTED)) DisplayMenu(); } }
fRect Sprite::GetFrameRect(uint32 f) { return fRect(_frames[f].rect * _texture->GetSize()); }
void cGUIEdit::OnDraw() { iRect rc = scrRect(); dword col = color[0]; if(m_edit) col = GUIColorShift(col,GUICOLORSHIFT/2); int width = rect.Width(); int height = rect.Height(); int cursorx = Chr2Pos(m_sel2); int deltax = 0; if(cursorx>width-height/2) deltax = -(cursorx-(width-height/2)); // background if( style & GUISTYLE_BACKGR ) GUIDrawBar(rc, col ); else if( style & GUISTYLE_GRADIENT ) GUIDrawGradient( rc, color[0], color[1]); // image GUIDrawImg( rc, img0, imgColor, imgAlign); // clip content fRect oldclip = R9_GetClipping(); fRect newclip = fRect(rc); R9_AddClipping(newclip); if( R9_IsClipping() ) { // selection fRect rc1; if(m_sel1!=m_sel2) { rc1 = rc; rc1.p2.x = rc1.p1.x; rc1.p1.x += Chr2Pos(m_sel1) + deltax; rc1.p2.x += Chr2Pos(m_sel2) + deltax; R9_ClipBar(rc1); GUIDrawBar( rc1, color[3]); } // text iRect rr = rc; rr.Offset(iV2(deltax, 0)); GUIDrawText( rr, txt, txtColor, GUIALIGN_LEFT|GUIALIGN_CENTERY, txtOffset); // cursor if(m_edit) { static dword s_time = 0; s_time += Editor::app->DeltaTime(); if(s_time<=400) { rc1.p1.x = (float)rc.p1.x + Chr2Pos(m_sel2) + deltax; rc1.p1.y = (float)rc.p1.y+2; rc1.p2.x = rc1.p1.x+1; rc1.p2.y = (float)rc.p2.y-2; R9_ClipBar(rc1); GUIDrawBar( rc1, txtColor); } if(s_time>700) s_time = 0; } } R9_SetClipping(oldclip); // border if( style & GUISTYLE_BORDER ) GUIDrawRect(rc, color[2]); else if( style & GUISTYLE_BORDER3D ) GUIDrawRect3D(rc, color[2], style & GUISTYLE_PRESSED ); }