/*****************************************************************************
* ctrl_image.cpp
*****************************************************************************
- * Copyright (C) 2003 VideoLAN
+ * Copyright (C) 2003 the VideoLAN team
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
CtrlImage::CtrlImage( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
+ CmdGeneric &rCommand, resize_t resizeMethod,
const UString &rHelp, VarBool *pVisible ):
- CtrlFlat( pIntf, rHelp, pVisible ), m_rBitmap( rBitmap )
+ CtrlFlat( pIntf, rHelp, pVisible ), m_rBitmap( rBitmap ),
+ m_rCommand( rCommand ), m_resizeMethod( resizeMethod )
{
OSFactory *pOsFactory = OSFactory::instance( pIntf );
// Create an initial unscaled image in the buffer
CmdDlgHidePopupMenu cmd( getIntf() );
cmd.execute();
}
-
+ else if( rEvent.getAsString() == "mouse:left:dblclick:none" )
+ {
+ m_rCommand.execute();
+ }
}
bool CtrlImage::mouseOver( int x, int y ) const
{
- return m_pImage->hit( x, y );
+ if( m_resizeMethod == kMosaic &&
+ x >= 0 && x < getPosition()->getWidth() &&
+ y >= 0 && y < getPosition()->getHeight() )
+ {
+ // In mosaic mode, convert the coordinates to make them fit to the
+ // size of the original image
+ return m_pImage->hit( x % m_pImage->getWidth(),
+ y % m_pImage->getHeight() );
+ }
+ else
+ {
+ return m_pImage->hit( x, y );
+ }
}
{
int width = pPos->getWidth();
int height = pPos->getHeight();
- if( width != m_pImage->getWidth() || height != m_pImage->getHeight() )
+
+ 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_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
{
- 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 );
+ // 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();
+ }
}
- rImage.drawGraphics( *m_pImage, 0, 0, xDest, yDest );
}
}