NS_IMETHODIMP nsBox::GetDebugBoxAt( const nsPoint& aPoint, nsIBox** aBox) { nsRect thisRect(nsPoint(0,0), GetSize()); if (!thisRect.Contains(aPoint)) return NS_ERROR_FAILURE; nsIBox* child = GetChildBox(); nsIBox* hit = nsnull; *aBox = nsnull; while (nsnull != child) { nsresult rv = child->GetDebugBoxAt(aPoint - child->GetOffsetTo(this), &hit); if (NS_SUCCEEDED(rv) && hit) { *aBox = hit; } child = child->GetNextBox(); } // found a child if (*aBox) { return NS_OK; } return NS_ERROR_FAILURE; }
uint32_t TileEngine::registerNewSprite(std::string spriteName, std::string textureName, int x,int y, int w, int h){ sf::Texture thisTexture=TextureMap[textureName]; sf::IntRect thisRect(x,y,w,h); sf::Sprite *thisSprite=new sf::Sprite(thisTexture, thisRect); SpriteMap[spriteName]=thisSprite; SpriteArray.push_back(thisSprite); return SpriteArray.size()-1; }
void OSD::paintEvent(QPaintEvent *) { QPainter painter (this); painter.setPen( QColor (Qt::black) ); // draw the background and the frame QRect thisRect(0, 0, width() - 1 , height() - 1); painter.fillRect(thisRect, QColor::fromRgb(58, 117, 177) ); if (! osd_interr) { // progress graph painter.setPen(QColor ("#3AD5FF")); int square_width_each = ( width() - 2 ) / sizeof(osd_data); int max_square_height = height() * 0.6; int x = 0.5 * ( width() - sizeof(osd_data) * square_width_each ) , y = 0; for (size_t i = osd_idx ; i < sizeof(osd_data) + osd_idx; ++ i) { if ( osd_data [i % sizeof(osd_data)] > osd_maxSpeed ) { QRect rect (x, height() - 1 - max_square_height, square_width_each , max_square_height); painter.fillRect(rect, QBrush (QColor ("#3AD5FF")) ); } else { y = max_square_height * (double)osd_data [i % sizeof(osd_data)] / osd_maxSpeed; QRect rect (x, height() - 1 - y , square_width_each , y ); painter.fillRect( rect , QBrush (QColor ("#3AD5FF")) ); } x += square_width_each; } // progress text painter.setPen(QColor(Qt::white)); QFontMetrics fm (font ()); QRect fontRect ( (width() - fm.width(m_text)) / 2, 2, fm.width(m_text), fm.height()); painter.drawText(fontRect, Qt::AlignCenter, m_text); } // frame painter.setPen( QColor (Qt::black) ); painter.drawRect( thisRect ); }
void LapsusOSD::renderOSD() { // ---------------------------------------- // | | // | Icon Message | // | | // ---------------------------------------- // calculate needed size //if( K3bTheme* theme = k3bappcore->themeManager()->currentTheme() ) { if( true ) { QPixmap icon = KGlobal::iconLoader()->loadIcon( "laptop", KIcon::NoGroup, 32 ); int margin = 10; int textWidth = fontMetrics().width( _text ); // do not change the size every time the text changes, just in case we are too small //QSize newSize( QMAX( QMAX( 2*margin + icon.width() + margin + textWidth, 100 ), width() ), // QMAX( 2*margin + icon.height(), 2*margin + fontMetrics().height()*2 ) ); // change every time QSize newSize( QMAX( 2*margin + icon.width() + margin + textWidth, 100 ), QMAX( 2*margin + icon.height(), 2*margin + fontMetrics().height()*2 ) ); _osdBuffer.resize( newSize ); QPainter p( &_osdBuffer ); //p.setPen( theme->foregroundColor() ); p.setPen( KGlobalSettings::activeTextColor() ); // draw the background and the frame QRect thisRect( 0, 0, newSize.width(), newSize.height() ); //p.fillRect( thisRect, theme->backgroundColor() ); p.fillRect( thisRect, KGlobalSettings::activeTitleColor() ); p.drawRect( thisRect ); // draw the icon p.drawPixmap( margin, (newSize.height()-icon.height())/2, icon ); // draw the text QSize textSize = fontMetrics().size( 0, _text ); int textX = 2*margin + icon.width(); int textY = (newSize.height() + (fontMetrics().ascent()*5)/6)/2; p.drawText( textX, textY, _text ); /* // draw the progress textY += fontMetrics().descent() + 4; QRect progressRect( textX, textY, newSize.width()-textX-margin, newSize.height()-textY-margin ); p.drawRect( progressRect ); progressRect.setWidth( _progress > 0 ? _progress*progressRect.width()/100 : 0 ); //p.fillRect( progressRect, theme->foregroundColor() ); p.fillRect( progressRect, KGlobalSettings::activeTextColor() ); */ // reposition the osd reposition( newSize ); _dirty = false; update(); } }