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