void Knob::render( ImageObject& img, const Rect& r ) { if ( !visible() ) return; if ( pImage != NULL ) { img.drawImage( *pImage, Rect( 0, 0, pImage->sectionWidth(), pImage->sectionHeight() ), pImage->sectionRect( pValue ) ); } else if ( pImages != NULL ) { ImageObject* tmp = pImages->get( pValue ); if ( tmp != NULL ) { img.drawImage( *tmp, Rect( 0, 0, tmp->width(), tmp->height()), pImage->sectionRect( pValue ) ); } } else { Widget::render( img, r ); } }
void PushButton::render( ImageObject& img, const Rect& r ) { if ( !visible() ) return; Rect r2 = Rect( 0, 0, clientVisibleWidth(), clientVisibleHeight() ); int theight = 0; int twidth = 0; if ( (font() != NULL) && ( text() != L"" ) ) { theight = font()->textHeight(); twidth = font()->textWidth( pText ) + 2; } if ( pImage != NULL ) { twidth += pImage->width(); r2.top = ( r2.height / 2 - pImage->height() / 2 ); r2.left = ( r2.width / 2 - twidth / 2 ); r2.width = pImage->width(); r2.height = pImage->height(); if ( pressed() ) { r2.top += 1; r2.left += 1; } img.drawImage( *pImage, r2 ); r2.left += pImage->width() + 2; r2.width = clientVisibleWidth(); r2.height = clientVisibleHeight(); } else { r2.left = ( r2.width / 2 - (twidth-2) / 2 ); } r2.top = ( r2.height / 2 - theight / 2 ); if ( font() != NULL ) { if ( pressed() ) { img.outText( pText, *font(), (int)r2.left+1, (int)r2.top+1, fontColor() ); } else { img.outText( pText, *font(), (int)r2.left, (int)r2.top, fontColor() ); } } }