File indexing completed on 2024-05-19 04:04:50

0001 /*
0002     This file is part of Killbots.
0003 
0004     SPDX-FileCopyrightText: 2007-2009 Parker Coates <coates@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KILLBOTS_NUMERICDISPLAYITEM_H
0010 #define KILLBOTS_NUMERICDISPLAYITEM_H
0011 
0012 #include <KGameRenderedItem>
0013 
0014 #include <QFont>
0015 
0016 namespace Killbots
0017 {
0018 
0019 class NumericDisplayItem : public QObject, public KGameRenderedItem
0020 {
0021     Q_OBJECT
0022 
0023 public: // functions
0024     explicit NumericDisplayItem(const QString &label = QString(), QGraphicsItem *parent = nullptr);
0025     ~NumericDisplayItem() override;
0026 
0027     int value() const;
0028     QString label() const;
0029     int digits() const;
0030     QFont font() const;
0031     QSize preferredSize();
0032 
0033     void paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
0034 
0035 public Q_SLOTS:
0036     void setValue(int value);
0037     void setLabel(const QString &label);
0038     void setDigits(int digits);
0039     void setFont(const QFont &font);
0040 
0041 private: // data members
0042     QString m_label;
0043     int m_value;
0044     int m_digits;
0045 
0046     int m_margin;
0047 
0048     QFont m_font;
0049     QFont m_boldFont;
0050 };
0051 }
0052 
0053 #endif