QTfrontend/pages.h
changeset 5205 78138ae93820
parent 5204 e1a5f4d5d86a
child 5206 db775bddf771
equal deleted inserted replaced
5204:e1a5f4d5d86a 5205:78138ae93820
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@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 #ifndef PAGES_H
       
    20 #define PAGES_H
       
    21 
       
    22 #include <QWidget>
       
    23 #include <QPushButton>
       
    24 #include <QFont>
       
    25 #include <QGridLayout>
       
    26 #include <QSignalMapper>
       
    27 
       
    28 #include "binds.h"
       
    29 #include "hwform.h"
       
    30 #include "mapContainer.h"
       
    31 #include "togglebutton.h"
       
    32 
       
    33 class QPushButton;
       
    34 class QGroupBox;
       
    35 class QComboBox;
       
    36 class QLabel;
       
    37 class QToolBox;
       
    38 class QLineEdit;
       
    39 class QListWidget;
       
    40 class QCheckBox;
       
    41 class QSpinBox;
       
    42 class QTextEdit;
       
    43 class QRadioButton;
       
    44 class QTableView;
       
    45 class QTextBrowser;
       
    46 class QTableWidget;
       
    47 class QAction;
       
    48 class QDataWidgetMapper;
       
    49 class QAbstractItemModel;
       
    50 class QSettings;
       
    51 class QSlider;
       
    52 
       
    53 class AbstractPage : public QWidget
       
    54 {
       
    55     Q_OBJECT
       
    56 
       
    57  public:
       
    58 
       
    59  protected:
       
    60   AbstractPage(QWidget* parent = 0) {
       
    61     Q_UNUSED(parent);
       
    62 
       
    63     font14 = new QFont("MS Shell Dlg", 14);
       
    64     //setFocusPolicy(Qt::StrongFocus);
       
    65   }
       
    66   virtual ~AbstractPage() {};
       
    67 
       
    68   QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, bool iconed = false) {
       
    69     QPushButton* butt = new QPushButton(this);
       
    70     if (!iconed) {
       
    71       butt->setFont(*font14);
       
    72       butt->setText(btname);
       
    73       //butt->setStyleSheet("background-color: #0d0544");
       
    74     } else {
       
    75       const QIcon& lp=QIcon(btname);
       
    76       QSize sz = lp.actualSize(QSize(65535, 65535));
       
    77       butt->setIcon(lp);
       
    78       butt->setFixedSize(sz);
       
    79       butt->setIconSize(sz);
       
    80       butt->setFlat(true);
       
    81       butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
       
    82     }
       
    83     grid->addWidget(butt, wy, wx);
       
    84     return butt;
       
    85   };
       
    86 
       
    87   QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool iconed = false) {
       
    88     QPushButton* butt = new QPushButton(this);
       
    89     if (!iconed) {
       
    90       butt->setFont(*font14);
       
    91       butt->setText(btname);
       
    92     } else {
       
    93       const QIcon& lp=QIcon(btname);
       
    94       QSize sz = lp.actualSize(QSize(65535, 65535));
       
    95       butt->setIcon(lp);
       
    96       butt->setFixedSize(sz);
       
    97       butt->setIconSize(sz);
       
    98       butt->setFlat(true);
       
    99       butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
       
   100     }
       
   101     grid->addWidget(butt, wy, wx, rowSpan, columnSpan);
       
   102     return butt;
       
   103   };
       
   104 
       
   105   QPushButton* addButton(QString btname, QBoxLayout* box, int where, bool iconed = false) {
       
   106     QPushButton* butt = new QPushButton(this);
       
   107     if (!iconed) {
       
   108       butt->setFont(*font14);
       
   109       butt->setText(btname);
       
   110     } else {
       
   111       const QIcon& lp=QIcon(btname);
       
   112       QSize sz = lp.actualSize(QSize(65535, 65535));
       
   113       butt->setIcon(lp);
       
   114       butt->setFixedSize(sz);
       
   115       butt->setIconSize(sz);
       
   116       butt->setFlat(true);
       
   117       butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
       
   118     }
       
   119     box->addWidget(butt, where);
       
   120     return butt;
       
   121   };
       
   122 
       
   123   QFont * font14;
       
   124 };
       
   125 
       
   126 #endif // PAGES_H