void CtrlRadialSlider::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h ) { const Position *pPos = getPosition(); rect region( pPos->getLeft(), pPos->getTop(), m_width, m_height ); rect clip( xDest, yDest, w ,h ); rect inter; if( rect::intersect( region, clip, &inter ) ) rImage.drawGraphics( *m_pImgSeq, inter.x - region.x, inter.y - region.y + m_position * m_height, inter.x, inter.y, inter.width, inter.height ); }
void CtrlTree::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h) { const Position *pPos = getPosition(); rect region( pPos->getLeft(), pPos->getTop(), pPos->getWidth(), pPos->getHeight() ); rect clip( xDest, yDest, w, h ); rect inter; if( rect::intersect( region, clip, &inter ) && m_pImage ) rImage.drawGraphics( *m_pImage, inter.x - pPos->getLeft(), inter.y - pPos->getTop(), inter.x, inter.y, inter.width, inter.height ); }
void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h ) { if( m_pImg ) { // Draw the current image rect inter; rect clip( xDest, yDest, w, h); if( rect::intersect( m_currentCursorRect, clip, &inter ) ) rImage.drawGraphics( *m_pImg, inter.x - m_currentCursorRect.x, inter.y - m_currentCursorRect.y, inter.x, inter.y, inter.width, inter.height ); } }
void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest ) { if( m_pImg ) { // Compute the position of the cursor int xPos, yPos; m_rCurve.getPoint( m_rVariable.get(), xPos, yPos ); // Compute the resize factors float factorX, factorY; getResizeFactors( factorX, factorY ); xPos = (int)(xPos * factorX); yPos = (int)(yPos * factorY); // Draw the current image rImage.drawGraphics( *m_pImg, 0, 0, xDest + xPos - m_pImg->getWidth() / 2, yDest + yPos - m_pImg->getHeight() / 2 ); } }
void CtrlImage::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h ) { const Position *pPos = getPosition(); if( !pPos ) return; int width = pPos->getWidth(); int height = pPos->getHeight(); if( width <= 0 || height <= 0 ) return; rect region( pPos->getLeft(), pPos->getTop(), pPos->getWidth(), pPos->getHeight() ); rect clip( xDest, yDest, w, h ); rect inter; if( !rect::intersect( region, clip, &inter ) ) return; if( m_resizeMethod == kScale ) { // Use scaling method if( width != m_pImage->getWidth() || height != m_pImage->getHeight() ) { OSFactory *pOsFactory = OSFactory::instance( getIntf() ); // Rescale the image with the actual size of the control ScaledBitmap bmp( getIntf(), *m_pBitmap, width, height ); delete m_pImage; m_pImage = pOsFactory->createOSGraphics( width, height ); m_pImage->drawBitmap( bmp, 0, 0 ); } rImage.drawGraphics( *m_pImage, inter.x - pPos->getLeft(), inter.y - pPos->getTop(), inter.x, inter.y, inter.width, inter.height ); } else if( m_resizeMethod == kMosaic ) { int xDest0 = pPos->getLeft(); int yDest0 = pPos->getTop(); // Use mosaic method while( width > 0 ) { int curWidth = __MIN( width, m_pImage->getWidth() ); height = pPos->getHeight(); int curYDest = yDest0; while( height > 0 ) { int curHeight = __MIN( height, m_pImage->getHeight() ); rect region1( xDest0, curYDest, curWidth, curHeight ); rect inter1; if( rect::intersect( region1, clip, &inter1 ) ) { rImage.drawGraphics( *m_pImage, inter1.x - region1.x, inter1.y - region1.y, inter1.x, inter1.y, inter1.width, inter1.height ); } curYDest += curHeight; height -= m_pImage->getHeight(); } xDest0 += curWidth; width -= m_pImage->getWidth(); } } else if( m_resizeMethod == kScaleAndRatioPreserved ) { int w0 = m_pBitmap->getWidth(); int h0 = m_pBitmap->getHeight(); int scaled_height = width * h0 / w0; int scaled_width = height * w0 / h0; // new image scaled with aspect ratio preserved // and centered inside the control boundaries int w, h; if( scaled_height > height ) { w = scaled_width; h = height; m_x = ( width - w ) / 2; m_y = 0; } else { w = width; h = scaled_height; m_x = 0; m_y = ( height - h ) / 2; } // rescale the image if size changed if( w != m_pImage->getWidth() || h != m_pImage->getHeight() ) { OSFactory *pOsFactory = OSFactory::instance( getIntf() ); ScaledBitmap bmp( getIntf(), *m_pBitmap, w, h ); delete m_pImage; m_pImage = pOsFactory->createOSGraphics( w, h ); m_pImage->drawBitmap( bmp, 0, 0 ); } // draw the scaled image at offset (m_x, m_y) from control origin rect region1( pPos->getLeft() + m_x, pPos->getTop() + m_y, w, h ); rect inter1; if( rect::intersect( region1, inter, &inter1 ) ) { rImage.drawGraphics( *m_pImage, inter1.x - pPos->getLeft() - m_x, inter1.y - pPos->getTop() - m_y, inter1.x, inter1.y, inter1.width, inter1.height ); } } }
void CtrlRadialSlider::draw( OSGraphics &rImage, int xDest, int yDest ) { rImage.drawGraphics( *m_pImgSeq, 0, m_position * m_height, xDest, yDest, m_width, m_height ); }