QTfrontend/ui/widget/drawmapwidget.h
changeset 6060 fdfc01419815
parent 5252 ded882439548
child 6616 f77bb02b669f
equal deleted inserted replaced
6059:ddf020d0941a 6060:fdfc01419815
       
     1 /*
       
     2  * Hedgewars, a free turn based strategy game
       
     3  * Copyright (c) 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 DRAWMAPWIDGET_H
       
    20 #define DRAWMAPWIDGET_H
       
    21 
       
    22 #include <QWidget>
       
    23 #include <QHBoxLayout>
       
    24 #include <QPushButton>
       
    25 #include <QGraphicsView>
       
    26 
       
    27 #include "qaspectratiolayout.h"
       
    28 #include "drawmapscene.h"
       
    29 
       
    30 namespace Ui {
       
    31     class Ui_DrawMapWidget
       
    32     {
       
    33     public:
       
    34         QGraphicsView *graphicsView;
       
    35 
       
    36         void setupUi(QWidget *drawMapWidget)
       
    37         {
       
    38             QAspectRatioLayout * arLayout = new QAspectRatioLayout(drawMapWidget);
       
    39             arLayout->setMargin(0);
       
    40 
       
    41             graphicsView = new QGraphicsView(drawMapWidget);
       
    42             arLayout->addWidget(graphicsView);
       
    43 
       
    44             retranslateUi(drawMapWidget);
       
    45 
       
    46             QMetaObject::connectSlotsByName(drawMapWidget);
       
    47         } // setupUi
       
    48 
       
    49         void retranslateUi(QWidget *drawMapWidget)
       
    50         {
       
    51             Q_UNUSED(drawMapWidget);
       
    52         } // retranslateUi
       
    53 
       
    54     };
       
    55 
       
    56     class DrawMapWidget: public Ui_DrawMapWidget {};
       
    57 }
       
    58 
       
    59 class DrawMapWidget : public QWidget
       
    60 {
       
    61     Q_OBJECT
       
    62 
       
    63 public:
       
    64     explicit DrawMapWidget(QWidget *parent = 0);
       
    65     ~DrawMapWidget();
       
    66 
       
    67     void setScene(DrawMapScene * scene);
       
    68 
       
    69 public slots:
       
    70     void undo();
       
    71     void clear();
       
    72     void save(const QString & fileName);
       
    73     void load(const QString & fileName);
       
    74 
       
    75 protected:
       
    76     void changeEvent(QEvent *e);
       
    77     virtual void resizeEvent(QResizeEvent * event);
       
    78     virtual void showEvent(QShowEvent * event);
       
    79 
       
    80 private:
       
    81     Ui::DrawMapWidget *ui;
       
    82 
       
    83     DrawMapScene * m_scene;
       
    84 };
       
    85 
       
    86 #endif // DRAWMAPWIDGET_H