nice ellipses :)

This commit is contained in:
Max-Wilhelm Bruker 2009-05-23 01:58:11 +02:00
parent 7e13352a95
commit 175512a2ad
13 changed files with 144 additions and 101 deletions

View file

@ -45,7 +45,7 @@ void CardZone::addCard(CardItem *card, bool reorganize, int x, int y)
view->addCard(new CardItem(player->getDb(), card->getName(), card->getId()), reorganize, x, y);
addCardImpl(card, x, y);
if (reorganize)
reorganizeCards();
}
@ -67,9 +67,9 @@ CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName)
{
if (position >= cards->size())
return NULL;
CardItem *c = cards->takeAt(position);
if (view)
view->removeCard(position);
@ -103,3 +103,26 @@ void CardZone::moveAllToZone(const QString &targetZone, int targetX)
for (int i = cards->size() - 1; i >= 0; i--)
player->client->moveCard(cards->at(i)->getId(), getName(), targetZone, targetX);
}
void CardZone::paintCardNumberEllipse(QPainter *painter)
{
painter->save();
QString numStr = QString::number(cards->size());
QFont font("Times", 32, QFont::Bold);
QFontMetrics fm(font);
QRect br = fm.boundingRect(numStr);
double w = br.width() * 1.42;
double h = br.height() * 1.42;
if (w < h)
w = h;
painter->setPen(QPen(QColor("black")));
painter->setBrush(QColor(255, 255, 255, 150));
painter->drawEllipse(QRectF((boundingRect().width() - w) / 2.0, (boundingRect().height() - h) / 2.0, w, h));
painter->setFont(font);
painter->drawText(boundingRect(), Qt::AlignCenter, numStr);
painter->restore();
}