/*****************************************************************************
* tooltip.cpp
*****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: tooltip.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
- * Olivier Teulière <ipkiss@via.ecp.fr>
+ * Olivier Teulière <ipkiss@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "tooltip.hpp"
Tooltip::Tooltip( intf_thread_t *pIntf, const GenericFont &rFont, int delay ):
SkinObject( pIntf ), m_rFont( rFont ), m_delay( delay ), m_pImage( NULL ),
- m_xPos( -1 ), m_yPos( -1 )
+ m_xPos( -1 ), m_yPos( -1 ), m_cmdShow( this )
{
OSFactory *pOsFactory = OSFactory::instance( pIntf );
- m_pTimer = pOsFactory->createOSTimer( Callback( this, &doShow ) );
+ m_pTimer = pOsFactory->createOSTimer( m_cmdShow );
m_pOsTooltip = pOsFactory->createOSTooltip();
// Observe the tooltip text variable
}
-void Tooltip::onUpdate( Subject<VarText> &rVariable )
+void Tooltip::onUpdate( Subject<VarText, void*> &rVariable , void *arg)
{
// Redisplay the tooltip
displayText( ((VarText&)rVariable).get() );
{
// Render the text on a bitmap
GenericBitmap *pBmpTip = m_rFont.drawString( rText, 0 );
+ if( !pBmpTip )
+ {
+ return;
+ }
int w = pBmpTip->getWidth() + 10;
int h = m_rFont.getSize() + 8;
m_pImage = OSFactory::instance( getIntf() )->createOSGraphics( w, h );
m_pImage->fillRect( 0, 0, w, h, 0xffffd0 );
m_pImage->drawRect( 0, 0, w, h, 0x000000 );
- m_pImage->drawBitmap( *pBmpTip, 0, 0, 5, 5 );
+ m_pImage->drawBitmap( *pBmpTip, 0, 0, 5, 5, -1, -1, true );
delete pBmpTip;
}
-void Tooltip::doShow( SkinObject *pObj )
+void Tooltip::CmdShow::execute()
{
- Tooltip *pThis = (Tooltip*)pObj;
-
- if( pThis->m_pImage )
+ if( m_pParent->m_pImage )
{
- if( pThis->m_xPos == -1 )
+ if( m_pParent->m_xPos == -1 )
{
// Get the mouse coordinates and the image size
- OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
+ OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
int x, y;
pOsFactory->getMousePos( x, y );
int scrWidth = pOsFactory->getScreenWidth();
int scrHeight = pOsFactory->getScreenHeight();
- int w = pThis->m_pImage->getWidth();
- int h = pThis->m_pImage->getHeight();
+ int w = m_pParent->m_pImage->getWidth();
+ int h = m_pParent->m_pImage->getHeight();
// Compute the position of the tooltip
x -= (w / 2 + 4);
if( y + h > scrHeight )
y -= (2 * h + 20);
- pThis->m_xPos = x;
- pThis->m_yPos = y;
+ m_pParent->m_xPos = x;
+ m_pParent->m_yPos = y;
}
// Show the tooltip window
- pThis->m_pOsTooltip->show( pThis->m_xPos, pThis->m_yPos,
- *(pThis->m_pImage) );
+ m_pParent->m_pOsTooltip->show( m_pParent->m_xPos, m_pParent->m_yPos,
+ *(m_pParent->m_pImage) );
}
}