1 /* |
1 /* |
2 * Hedgewars, a free turn based strategy game |
2 * Hedgewars, a free turn based strategy game |
3 * Copyright (c) 2012 Andrey Korotaev <unC0Rr@gmail.com> |
3 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
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 |
6 * it under the terms of the GNU General Public License as published by |
7 * the Free Software Foundation; version 2 of the License |
7 * the Free Software Foundation; version 2 of the License |
8 * |
8 * |
21 |
21 |
22 #include <QWidget> |
22 #include <QWidget> |
23 #include <QHBoxLayout> |
23 #include <QHBoxLayout> |
24 #include <QPushButton> |
24 #include <QPushButton> |
25 #include <QGraphicsView> |
25 #include <QGraphicsView> |
|
26 #include <QLabel> |
26 |
27 |
27 #include "qaspectratiolayout.h" |
28 #include "qaspectratiolayout.h" |
28 #include "drawmapscene.h" |
29 #include "drawmapscene.h" |
|
30 |
|
31 |
|
32 class DrawMapView : public QGraphicsView |
|
33 { |
|
34 Q_OBJECT |
|
35 |
|
36 public: |
|
37 explicit DrawMapView(QWidget *parent = 0); |
|
38 ~DrawMapView(); |
|
39 |
|
40 void setScene(DrawMapScene *scene); |
|
41 |
|
42 protected: |
|
43 void enterEvent(QEvent * event); |
|
44 void leaveEvent(QEvent * event); |
|
45 bool viewportEvent(QEvent * event); |
|
46 |
|
47 private: |
|
48 DrawMapScene * m_scene; |
|
49 }; |
29 |
50 |
30 namespace Ui |
51 namespace Ui |
31 { |
52 { |
32 class Ui_DrawMapWidget |
53 class Ui_DrawMapWidget |
33 { |
54 { |
34 public: |
55 public: |
35 QGraphicsView *graphicsView; |
56 DrawMapView *graphicsView; |
|
57 QLabel * lblPoints; |
36 |
58 |
37 void setupUi(QWidget *drawMapWidget) |
59 void setupUi(QWidget *drawMapWidget) |
38 { |
60 { |
39 QAspectRatioLayout * arLayout = new QAspectRatioLayout(drawMapWidget); |
61 QVBoxLayout * vbox = new QVBoxLayout(drawMapWidget); |
|
62 vbox->setMargin(0); |
|
63 lblPoints = new QLabel("0", drawMapWidget); |
|
64 vbox->addWidget(lblPoints); |
|
65 QAspectRatioLayout * arLayout = new QAspectRatioLayout(); |
40 arLayout->setMargin(0); |
66 arLayout->setMargin(0); |
|
67 vbox->addLayout(arLayout); |
41 |
68 |
42 graphicsView = new QGraphicsView(drawMapWidget); |
69 graphicsView = new DrawMapView(drawMapWidget); |
43 arLayout->addWidget(graphicsView); |
70 arLayout->addWidget(graphicsView); |
44 |
71 |
45 retranslateUi(drawMapWidget); |
72 retranslateUi(drawMapWidget); |
46 |
73 |
47 QMetaObject::connectSlotsByName(drawMapWidget); |
74 QMetaObject::connectSlotsByName(drawMapWidget); |