void Win32Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc, int ySrc, int xDest, int yDest, int width, int height ) { if( width == -1 ) { width = rGraphics.getWidth(); } if( height == -1 ) { height = rGraphics.getHeight(); } // Create the mask for transparency HRGN mask = CreateRectRgn( xSrc, ySrc, xSrc + width, ySrc + height ); CombineRgn( mask, ((Win32Graphics&)rGraphics).getMask(), mask, RGN_AND ); OffsetRgn( mask, xDest - xSrc, yDest - ySrc ); // Copy the image HDC srcDC = ((Win32Graphics&)rGraphics).getDC(); SelectClipRgn( m_hDC, mask ); BitBlt( m_hDC, xDest, yDest, width, height, srcDC, xSrc, ySrc, SRCCOPY ); // Add the source mask to the mask of the graphics CombineRgn( m_mask, mask, m_mask, RGN_OR ); DeleteObject( mask ); }
void Win32Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc, int ySrc, int xDest, int yDest, int width, int height ) { // check and adapt to source if needed if( !checkBoundaries( 0, 0, rGraphics.getWidth(), rGraphics.getHeight(), xSrc, ySrc, width, height ) ) { msg_Err( getIntf(), "nothing to draw from graphics source" ); return; } // check destination if( !checkBoundaries( 0, 0, m_width, m_height, xDest, yDest, width, height ) ) { msg_Err( getIntf(), "out of reach destination! pls, debug your skin" ); return; } // Create the mask for transparency HRGN mask = CreateRectRgn( xSrc, ySrc, xSrc + width, ySrc + height ); CombineRgn( mask, ((Win32Graphics&)rGraphics).getMask(), mask, RGN_AND ); OffsetRgn( mask, xDest - xSrc, yDest - ySrc ); // Copy the image HDC srcDC = ((Win32Graphics&)rGraphics).getDC(); SelectClipRgn( m_hDC, mask ); BitBlt( m_hDC, xDest, yDest, width, height, srcDC, xSrc, ySrc, SRCCOPY ); // Add the source mask to the mask of the graphics CombineRgn( m_mask, mask, m_mask, RGN_OR ); DeleteObject( mask ); }
void TopWindow::updateShape() { // Set the shape of the window if( m_pActiveLayout ) { OSGraphics *pImage = m_pActiveLayout->getImage(); if( pImage ) { pImage->applyMaskToWindow( *getOSWindow() ); } } }
void X11Tooltip::show( int left, int top, OSGraphics &rText ) { // Source drawable Drawable src = ((X11Graphics&)rText).getDrawable(); int width = rText.getWidth(); int height = rText.getHeight(); XMoveResizeWindow( XDISPLAY, m_wnd, left, top, width, height ); // Show the window XMapRaised( XDISPLAY, m_wnd ); // Move it again if the window manager forgets the position XMoveWindow( XDISPLAY, m_wnd, left, top ); XCopyArea( XDISPLAY, src, m_wnd, XGC, 0, 0, width, height, 0, 0 ); }
void Win32Tooltip::show( int left, int top, OSGraphics &rText ) { // Source drawable HDC srcDC = ((Win32Graphics&)rText).getDC(); int width = rText.getWidth(); int height = rText.getHeight(); // Set the window on top, resize it and show it SetWindowPos( m_hWnd, HWND_TOPMOST, left, top, width, height, 0 ); ShowWindow( m_hWnd, SW_SHOW ); HDC wndDC = GetDC( m_hWnd ); BitBlt( wndDC, 0, 0, width, height, srcDC, 0, 0, SRCCOPY ); ReleaseDC( m_hWnd, wndDC ); }
void CtrlImage::draw( OSGraphics &rImage, int xDest, int yDest ) { const Position *pPos = getPosition(); if( pPos ) { int width = pPos->getWidth(); int height = pPos->getHeight(); if( m_resizeMethod == kScale ) { // Use scaling method if( width > 0 && height > 0 ) { 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_rBitmap, width, height ); SKINS_DELETE( m_pImage ); m_pImage = pOsFactory->createOSGraphics( width, height ); m_pImage->drawBitmap( bmp, 0, 0 ); } rImage.drawGraphics( *m_pImage, 0, 0, xDest, yDest ); } } else { // Use mosaic method while( width > 0 ) { int curWidth = __MIN( width, m_pImage->getWidth() ); height = pPos->getHeight(); int curYDest = yDest; while( height > 0 ) { int curHeight = __MIN( height, m_pImage->getHeight() ); rImage.drawGraphics( *m_pImage, 0, 0, xDest, curYDest, curWidth, curHeight ); curYDest += curHeight; height -= m_pImage->getHeight(); } xDest += curWidth; width -= m_pImage->getWidth(); } } } }
void CtrlTree::draw( OSGraphics &rImage, int xDest, int yDest ) { if( m_pImage ) { rImage.drawGraphics( *m_pImage, 0, 0, xDest, yDest ); } }
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 CtrlButton::draw( OSGraphics &rImage, int xDest, int yDest ) { if( m_pImg ) { // Draw the current image rImage.drawGraphics( *m_pImg, 0, 0, xDest, yDest ); } }
void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest ) { const Position *pPos = getPosition(); if( pPos ) { // Draw a black rectangle under the video to avoid transparency rImage.fillRect( pPos->getLeft(), pPos->getTop(), pPos->getWidth(), pPos->getHeight(), 0 ); } }
void X11Graphics::drawGraphics( const OSGraphics &rGraphics, int xSrc, int ySrc, int xDest, int yDest, int width, int height ) { if( width == -1 ) { width = rGraphics.getWidth(); } if( height == -1 ) { height = rGraphics.getHeight(); } // Source drawable Drawable src = ((X11Graphics&)rGraphics).getDrawable(); // Create the mask for transparency Region voidMask = XCreateRegion(); XRectangle rect; rect.x = xSrc; rect.y = ySrc; rect.width = width; rect.height = height; Region clipMask = XCreateRegion(); XUnionRectWithRegion( &rect, voidMask, clipMask ); Region mask = XCreateRegion(); XIntersectRegion( ((X11Graphics&)rGraphics).getMask(), clipMask, mask ); XDestroyRegion( clipMask ); XDestroyRegion( voidMask ); XOffsetRegion( mask, xDest - xSrc, yDest - ySrc ); // Copy the pixmap XSetRegion( XDISPLAY, m_gc, mask ); XCopyArea( XDISPLAY, src, m_pixmap, m_gc, xSrc, ySrc, width, height, xDest, yDest ); // Add the source mask to the mask of the graphics Region newMask = XCreateRegion(); XUnionRegion( m_mask, mask, newMask ); XDestroyRegion( mask ); XDestroyRegion( m_mask ); m_mask = newMask; }
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 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 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 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 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 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 CtrlVideo::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 ) ) { // Draw a black rectangle under the video to avoid transparency rImage.fillRect( inter.x, inter.y, inter.width, inter.height, 0 ); } if( m_pVoutWindow ) { m_pVoutWindow->show(); } }
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 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 ); } } }
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 ); }