void CtrlSliderBg::draw( OSGraphics &rImage, int xDest, int yDest ) { if( m_pImgSeq ) { if( m_bgWidth > 0 && m_bgHeight > 0 ) { // Compute the resize factors float factorX, factorY; getResizeFactors( factorX, factorY ); // Rescale the image with the actual size of the control ScaledBitmap bmp( getIntf(), *m_pImgSeq, m_bgWidth * m_nbHoriz - (int)(m_padHoriz * factorX), m_bgHeight * m_nbVert - (int)(m_padVert * factorY) ); // Locate the right image in the background bitmap int x = m_bgWidth * ( m_position % m_nbHoriz ); int y = m_bgHeight * ( m_position / m_nbHoriz ); // Draw the background image rImage.drawBitmap( bmp, x, y, xDest, yDest, m_bgWidth - (int)(m_padHoriz * factorX), m_bgHeight - (int)(m_padVert * factorY) ); } } }
void AnimBitmap::draw( OSGraphics &rImage, int xDest, int yDest ) { // Draw the current frame int height = m_pImage->getHeight() / m_nbFrames; int ySrc = height * m_curFrame; // The old way .... transparency was not taken care of // rImage.drawGraphics( *m_pImage, 0, ySrc, xDest, yDest, // m_pImage->getWidth(), height ); // A new way .... needs to be tested thoroughly rImage.drawBitmap( m_rBitmap, 0, ySrc, xDest, yDest, m_pImage->getWidth(), height, true ); }
void AnimBitmap::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h, int xOffset, int yOffset ) { // Draw the current frame int height = m_pImage->getHeight() / m_nbFrames; int ySrc = height * m_curFrame; // The old way .... transparency was not taken care of // rImage.drawGraphics( *m_pImage, 0, ySrc, xDest, yDest, // m_pImage->getWidth(), height ); rImage.drawBitmap( m_rBitmap, xOffset, ySrc + yOffset, xDest, yDest, w, h, true ); }
void CtrlText::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h ) { rect clip( xDest, yDest, w, h ); const Position *pPos = getPosition(); if( m_pCurrImg ) { // Compute the dimensions to draw int width = min( m_pCurrImg->getWidth() + m_xPos, getPosition()->getWidth() ); int height = min( m_pCurrImg->getHeight(), getPosition()->getHeight() ); // Draw the current image if( width > 0 && height > 0 ) { int offset = 0; if( m_alignment == kLeft ) { // We align to the left offset = 0; } else if( m_alignment == kRight && width < getPosition()->getWidth() ) { // The text is shorter than the width of the control, so we // can align it to the right offset = getPosition()->getWidth() - width; } else if( m_alignment == kCenter && width < getPosition()->getWidth() ) { // The text is shorter than the width of the control, so we // can center it offset = (getPosition()->getWidth() - width) / 2; } rect region( pPos->getLeft() + offset, pPos->getTop(), width, height ); rect inter; if( rect::intersect( region, clip, &inter ) ) rImage.drawBitmap( *m_pCurrImg, -m_xPos + inter.x - region.x, inter.y - region.y, inter.x, inter.y, inter.width, inter.height, true ); } } }
void CtrlSliderBg::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h ) { if( !m_pImgSeq || m_bgWidth <=0 || m_bgHeight <= 0 ) return; // Compute the resize factors float factorX, factorY; getResizeFactors( factorX, factorY ); int width = m_bgWidth * m_nbHoriz - (int)(m_padHoriz * factorX); int height = m_bgHeight * m_nbVert - (int)(m_padVert * factorY); // Rescale the image with the actual size of the control if needed if( !m_pScaledBmp || m_pScaledBmp->getWidth() != width || m_pScaledBmp->getHeight() != height ) { delete m_pScaledBmp; m_pScaledBmp = new ScaledBitmap( getIntf(), *m_pImgSeq, width, height ); } // Locate the right image in the background bitmap int x = m_bgWidth * ( m_position % m_nbHoriz ); int y = m_bgHeight * ( m_position / m_nbHoriz ); // Draw the background image const Position *pPos = getPosition(); rect region( pPos->getLeft(), pPos->getTop(), m_bgWidth - (int)(m_padHoriz * factorX), m_bgHeight - (int)(m_padVert * factorY) ); rect clip( xDest, yDest, w, h ); rect inter; if( rect::intersect( region, clip, &inter ) ) rImage.drawBitmap( *m_pScaledBmp, x + inter.x - region.x, y + inter.y - region.y, inter.x, inter.y, inter.width, inter.height ); }
void CtrlText::draw( OSGraphics &rImage, int xDest, int yDest ) { if( m_pCurrImg ) { // Compute the dimensions to draw int width = min( m_pCurrImg->getWidth() + m_xPos, getPosition()->getWidth() ); int height = min( m_pCurrImg->getHeight(), getPosition()->getHeight() ); // Draw the current image if( width > 0 && height > 0 ) { int offset = 0; if( m_alignment == kLeft ) { // We align to the left offset = 0; } else if( m_alignment == kRight && width < getPosition()->getWidth() ) { // The text is shorter than the width of the control, so we // can align it to the right offset = getPosition()->getWidth() - width; } else if( m_alignment == kCenter && width < getPosition()->getWidth() ) { // The text is shorter than the width of the control, so we // can center it offset = (getPosition()->getWidth() - width) / 2; } rImage.drawBitmap( *m_pCurrImg, -m_xPos, 0, xDest + offset, yDest, width, height, true ); } } }