QTfrontend/ui/widget/itemNum.h
changeset 6060 fdfc01419815
parent 4976 088d40d8aba2
child 6153 3881126e06e8
equal deleted inserted replaced
6059:ddf020d0941a 6060:fdfc01419815
       
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2006-2011 Igor Ulyanov <iulyanov@gmail.com>
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation; version 2 of the License
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    17  */
       
    18 
       
    19 #include <QFrame>
       
    20 #include <QImage>
       
    21 
       
    22 #ifndef _ITEM_NUM_INCLUDED
       
    23 #define _ITEM_NUM_INCLUDED
       
    24 
       
    25 class ItemNum : public QFrame
       
    26 {
       
    27   Q_OBJECT
       
    28 
       
    29   public:
       
    30     void setInfinityState(bool value);
       
    31     void setEnabled(bool value);
       
    32     unsigned char getItemsNum() const;
       
    33     void setItemsNum(const unsigned char num);
       
    34 
       
    35   private:
       
    36     QImage m_im;
       
    37     QImage m_img;
       
    38     bool infinityState;
       
    39     bool enabled;
       
    40 
       
    41   protected:
       
    42     ItemNum(const QImage& im, const QImage& img, QWidget * parent, unsigned char min=2, unsigned char max=8);
       
    43     virtual QSize sizeHint () const;
       
    44     virtual ~ItemNum()=0;
       
    45 
       
    46     bool nonInteractive;
       
    47     unsigned char minItems;
       
    48     unsigned char maxItems;
       
    49     unsigned char numItems;
       
    50 
       
    51     // from QWidget
       
    52     virtual void mousePressEvent ( QMouseEvent * event );
       
    53     virtual void paintEvent(QPaintEvent* event);
       
    54 
       
    55     // to be implemented in child
       
    56     virtual void incItems()=0;
       
    57     virtual void decItems()=0;
       
    58 };
       
    59 
       
    60 #endif // _ITEM_NUM_INCLUDED