SVN_SILENT made messages (.desktop file)
[kdegames.git] / knetwalk / src / view.h
blob4a9446cd7b78b7f120e3654471c39230d50b8d5c
1 /*
2 Copyright 2007-2008 Fela Winkelmolen <fela.kde@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
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.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef VIEW_H
19 #define VIEW_H
21 #include <QFrame>
23 #include "mainwindow.h"
25 class View : public QFrame
27 public:
28 View(QWidget *parent=0) : QFrame(parent) {
29 setFrameStyle(QFrame::NoFrame);
30 setMinimumSize(MinimumWidth, MinimumHeight);
33 protected:
34 void paintEvent(QPaintEvent *e) {
35 //void resizeEvent(QResizeEvent *) {
36 int size = qMin(width(), height());
37 size = qRound(size * (1.0 - 2*BoardBorder)); // add a border
39 // assure all the squares being of the same size
40 // by making the size a multiple of the boardSize
41 int boardSize = MainWindow::boardSize();
42 size = (size / boardSize) * boardSize;
44 int borderLeft = (width() - size)/2;
45 int borderTop = (height() - size)/2;
47 setFrameRect(QRect(borderLeft, borderTop, size, size));
49 QFrame::paintEvent(e);
53 #endif //VIEW_H