QTfrontend/pages.h
author koda
Mon, 09 May 2011 16:56:29 +0200
changeset 5204 e1a5f4d5d86a
parent 5147 a2ae7702bb75
permissions -rw-r--r--
split pages.h into several header files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     1
/*
1066
1f1b3686a2b0 Update copyright headers a bit
unc0rr
parents: 788
diff changeset
     2
 * Hedgewars, a free turn based strategy game
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4870
diff changeset
     3
 * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     4
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     8
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    12
 * GNU General Public License for more details.
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    13
 *
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    15
 * along with this program; if not, write to the Free Software
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    17
 */
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    18
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    19
#ifndef PAGES_H
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    20
#define PAGES_H
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    21
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    22
#include <QWidget>
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    23
#include <QPushButton>
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    24
#include <QFont>
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    25
#include <QGridLayout>
1840
4747f0232b88 ttsmj2's random teams patch
unc0rr
parents: 1812
diff changeset
    26
#include <QSignalMapper>
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    27
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    28
#include "binds.h"
2515
51d3f4b6293a revert audio to use SDL_mixer -- also frontend uses it, so it needs sdlmixer sources
koda
parents: 2468
diff changeset
    29
#include "hwform.h"
322
e7175ae57945 first new widgets added to net game
displacer
parents: 314
diff changeset
    30
#include "mapContainer.h"
1932
f586d75c8b6a New schemes page look by TheXception
unc0rr
parents: 1924
diff changeset
    31
#include "togglebutton.h"
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    32
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    33
class QPushButton;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    34
class QGroupBox;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    35
class QComboBox;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    36
class QLabel;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    37
class QToolBox;
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
    38
class QLineEdit;
665
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 657
diff changeset
    39
class QListWidget;
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 657
diff changeset
    40
class QCheckBox;
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 657
diff changeset
    41
class QSpinBox;
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 657
diff changeset
    42
class QTextEdit;
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 657
diff changeset
    43
class QRadioButton;
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 657
diff changeset
    44
class QTableView;
1377
a9e768739345 - Customize QTextBrowser look
unc0rr
parents: 1315
diff changeset
    45
class QTextBrowser;
1399
ada2411c1d60 Show additional info in rooms list
unc0rr
parents: 1395
diff changeset
    46
class QTableWidget;
1409
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1399
diff changeset
    47
class QAction;
1885
75489216b5b0 Continue work on new schemes
unc0rr
parents: 1884
diff changeset
    48
class QDataWidgetMapper;
1887
d68939b3f7f0 - Share model between test table and widgets
unc0rr
parents: 1885
diff changeset
    49
class QAbstractItemModel;
2773
e94f240a8a41 Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents: 2762
diff changeset
    50
class QSettings;
3708
64e059b6f9c5 applied from experimental3D, use a slider to set up quality
koda
parents: 3695
diff changeset
    51
class QSlider;
665
5c7bfc8bac6a Start move from custom widgets to custom models
unc0rr
parents: 657
diff changeset
    52
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    53
class AbstractPage : public QWidget
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    54
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2915
diff changeset
    55
    Q_OBJECT
1885
75489216b5b0 Continue work on new schemes
unc0rr
parents: 1884
diff changeset
    56
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    57
 public:
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    58
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    59
 protected:
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    60
  AbstractPage(QWidget* parent = 0) {
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4520
diff changeset
    61
    Q_UNUSED(parent);
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4520
diff changeset
    62
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    63
    font14 = new QFont("MS Shell Dlg", 14);
4592
b1fe47b11b99 disable fix for issue 24 in order to fix issue 123, as suggested by koda
sheepluva
parents: 4586
diff changeset
    64
    //setFocusPolicy(Qt::StrongFocus);
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    65
  }
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    66
  virtual ~AbstractPage() {};
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    67
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1150
diff changeset
    68
  QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, bool iconed = false) {
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    69
    QPushButton* butt = new QPushButton(this);
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1150
diff changeset
    70
    if (!iconed) {
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    71
      butt->setFont(*font14);
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    72
      butt->setText(btname);
1409
d1cbe4a57ebf Add button for controlling room options (no usefull yet)
unc0rr
parents: 1399
diff changeset
    73
      //butt->setStyleSheet("background-color: #0d0544");
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    74
    } else {
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    75
      const QIcon& lp=QIcon(btname);
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1150
diff changeset
    76
      QSize sz = lp.actualSize(QSize(65535, 65535));
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    77
      butt->setIcon(lp);
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1150
diff changeset
    78
      butt->setFixedSize(sz);
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    79
      butt->setIconSize(sz);
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    80
      butt->setFlat(true);
1149
c2d3b4f71836 transparent background for buttons at main page
displacer
parents: 1148
diff changeset
    81
      butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    82
    }
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    83
    grid->addWidget(butt, wy, wx);
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    84
    return butt;
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    85
  };
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
    86
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1150
diff changeset
    87
  QPushButton* addButton(QString btname, QGridLayout* grid, int wy, int wx, int rowSpan, int columnSpan, bool iconed = false) {
692
07787e748831 code size reduse
displacer
parents: 686
diff changeset
    88
    QPushButton* butt = new QPushButton(this);
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1150
diff changeset
    89
    if (!iconed) {
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    90
      butt->setFont(*font14);
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    91
      butt->setText(btname);
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    92
    } else {
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    93
      const QIcon& lp=QIcon(btname);
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1150
diff changeset
    94
      QSize sz = lp.actualSize(QSize(65535, 65535));
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    95
      butt->setIcon(lp);
1152
c72b939c00df Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents: 1150
diff changeset
    96
      butt->setFixedSize(sz);
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    97
      butt->setIconSize(sz);
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
    98
      butt->setFlat(true);
1149
c2d3b4f71836 transparent background for buttons at main page
displacer
parents: 1148
diff changeset
    99
      butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
1148
e44de3416af4 images at main page
displacer
parents: 1129
diff changeset
   100
    }
692
07787e748831 code size reduse
displacer
parents: 686
diff changeset
   101
    grid->addWidget(butt, wy, wx, rowSpan, columnSpan);
07787e748831 code size reduse
displacer
parents: 686
diff changeset
   102
    return butt;
07787e748831 code size reduse
displacer
parents: 686
diff changeset
   103
  };
07787e748831 code size reduse
displacer
parents: 686
diff changeset
   104
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   105
  QPushButton* addButton(QString btname, QBoxLayout* box, int where, bool iconed = false) {
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
   106
    QPushButton* butt = new QPushButton(this);
1443
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   107
    if (!iconed) {
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   108
      butt->setFont(*font14);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   109
      butt->setText(btname);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   110
    } else {
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   111
      const QIcon& lp=QIcon(btname);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   112
      QSize sz = lp.actualSize(QSize(65535, 65535));
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   113
      butt->setIcon(lp);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   114
      butt->setFixedSize(sz);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   115
      butt->setIconSize(sz);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   116
      butt->setFlat(true);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   117
      butt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
e79e4b48c771 Reorganize single player menu
unc0rr
parents: 1409
diff changeset
   118
    }
684
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
   119
    box->addWidget(butt, where);
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
   120
    return butt;
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
   121
  };
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
   122
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
   123
  QFont * font14;
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
   124
};
257444d8429f some copy/paste code removed
displacer
parents: 683
diff changeset
   125
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 183
diff changeset
   126
#endif // PAGES_H