initial port for Cevo game in C++ (libs)
This commit is contained in:
commit
8436242032
375 files changed
+46282
No files matched your search
@@ -0,0 +1,34 @@
|
||||
#include "Cevo/CevoListBoxEx.h"
|
||||
#include "Cevo/CevoScreenTools.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
namespace Cevo {
|
||||
|
||||
void ListBoxExDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
const QColor orange = colorFromDelphi(0x5F77CB);
|
||||
const QColor blue = colorFromDelphi(0xd77800);
|
||||
const bool selected = option.state & QStyle::State_Selected;
|
||||
const QColor background = selected ? blue : Qt::black;
|
||||
const QColor textColor = selected ? Qt::white : orange;
|
||||
|
||||
painter->fillRect(option.rect, Qt::black);
|
||||
const QRect inner = option.rect.adjusted(2, 1, -2, -2);
|
||||
painter->fillRect(inner, background);
|
||||
painter->setPen(textColor);
|
||||
painter->setFont(option.font);
|
||||
painter->drawText(inner, Qt::AlignVCenter | Qt::AlignLeft, index.data(Qt::DisplayRole).toString());
|
||||
if (selected) {
|
||||
painter->setPen(QPen(orange, 1, Qt::DotLine));
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->drawRect(inner);
|
||||
}
|
||||
}
|
||||
|
||||
ListBoxEx::ListBoxEx(QWidget *parent) : Dpi::ListBox(parent)
|
||||
{
|
||||
setItemDelegate(new ListBoxExDelegate(this));
|
||||
}
|
||||
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user