}
-void CtrlButton::draw( OSGraphics &rImage, int xDest, int yDest )
-{
- if( m_pImg )
+void CtrlButton::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_pImg )
{
// Draw the current image
- m_pImg->draw( rImage, xDest, yDest );
+ m_pImg->draw( rImage, inter.x, inter.y, inter.width, inter.height,
+ inter.x - pPos->getLeft(),
+ inter.y - pPos->getTop() );
}
}
-
void CtrlButton::setImage( AnimBitmap *pImg )
{
AnimBitmap *pOldImg = m_pImg;
void CtrlButton::onUpdate( Subject<AnimBitmap> &rBitmap, void *arg )
{
- notifyLayout();
+ notifyLayout( m_pImg->getWidth(), m_pImg->getHeight() );
}