#include <QPainter>
#include <Standard_WarningsRestore.hxx>
+const int ICON_SIZE = 20;
+
// =======================================================================
// function : Constructor
// purpose :
void DFBrowserPane_ItemDelegateButton::paint (QPainter* thePainter, const QStyleOptionViewItem& theOption,
const QModelIndex& theIndex) const
{
- if (!myFreeRows.contains (theIndex.row()))
- thePainter->drawPixmap (theOption.rect, myIcon.pixmap (20,20));
+ if (myFreeRows.contains (theIndex.row()))
+ return;
+
+ int aWidth = std::min (theOption.rect.width(), ICON_SIZE);
+ int aHeight = std::min (theOption.rect.height(), ICON_SIZE);
+ QPoint aTopLeft = theOption.rect.topLeft();
+ thePainter->drawPixmap (QRect (theOption.rect.topLeft(), QPoint (aTopLeft.x() + aWidth, aTopLeft.y() + aHeight)),
+ myIcon.pixmap (ICON_SIZE, ICON_SIZE));
}
// =======================================================================