-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
650 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) Kreogist Dev Team | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
#include <QPainter> | ||
|
||
#include "groundglobal.h" | ||
|
||
#include "gridwidget.h" | ||
|
||
GridWidget::GridWidget(QWidget *parent) : | ||
QWidget(parent), | ||
m_widget(nullptr) | ||
{ | ||
setAutoFillBackground(true); | ||
} | ||
|
||
void GridWidget::paintEvent(QPaintEvent *event) | ||
{ | ||
//Paint the widget. | ||
QWidget::paintEvent(event); | ||
//Paint the reference line. | ||
QPainter painter(this); | ||
painter.setPen(GroundGlobal::instance()->referenceLineColor()); | ||
painter.setBrush(QColor(0,0,0,0)); | ||
for(int i=30; i<=height(); i+=30) | ||
{ | ||
painter.drawLine(0, i, width(), i); | ||
} | ||
for(int i=30; i<=width(); i+=30) | ||
{ | ||
painter.drawLine(i, 0, i, height()); | ||
} | ||
} | ||
QWidget *GridWidget::widget() const | ||
{ | ||
return m_widget; | ||
} | ||
|
||
void GridWidget::setWidget(QWidget *widget) | ||
{ | ||
m_widget = widget; | ||
m_widget->setParent(this); | ||
} | ||
|
||
void GridWidget::resizeEvent(QResizeEvent *event) | ||
{ | ||
QWidget::resizeEvent(event); | ||
//If the widget is not null, resize it. | ||
if(m_widget) | ||
{ | ||
m_widget->resize(size()); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (C) Kreogist Dev Team | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef GRIDWIDGET_H | ||
#define GRIDWIDGET_H | ||
|
||
#include <QWidget> | ||
|
||
class GridWidget : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit GridWidget(QWidget *parent = 0); | ||
|
||
QWidget *widget() const; | ||
void setWidget(QWidget *widget); | ||
|
||
signals: | ||
|
||
public slots: | ||
|
||
protected: | ||
void resizeEvent(QResizeEvent *event); | ||
void paintEvent(QPaintEvent *event); | ||
|
||
private: | ||
QWidget *m_widget; | ||
}; | ||
|
||
#endif // GRIDWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.