• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

kigo

  • sources
  • kde-4.14
  • kdegames
  • kigo
  • src
  • gui
  • graphicsview
gameview.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2008 Sascha Peilicke <sasch.pe@gmx.de>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License as
6  published by the Free Software Foundation; either version 2 of
7  the License or (at your option) version 3 or any later version
8  accepted by the membership of KDE e.V. (or its successor approved
9  by the membership of KDE e.V.), which shall act as a proxy
10  defined in Section 14 of version 3 of the license.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include "gameview.h"
22 #include "gamescene.h"
23 
24 #include <QResizeEvent>
25 
26 namespace Kigo {
27 
28 GameView::GameView(GameScene *scene, QWidget *parent)
29  : QGraphicsView(scene, parent)
30  , m_gameScene(scene)
31 {
32  setCacheMode(QGraphicsView::CacheBackground);
33  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
34  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
35  setFrameStyle(QFrame::NoFrame);
36  setOptimizationFlags(QGraphicsView::DontClipPainter |
37  QGraphicsView::DontSavePainterState |
38  QGraphicsView::DontAdjustForAntialiasing);
39 
40  connect(m_gameScene, SIGNAL(cursorPixmapChanged(QPixmap)), this, SLOT(changeCursor(QPixmap)));
41 }
42 
43 void GameView::changeCursor(const QPixmap &cursorPixmap)
44 {
45  if (!isInteractive() || cursorPixmap.isNull()) {
46  unsetCursor();
47  } else {
48  setCursor(QCursor(cursorPixmap));
49  }
50 }
51 
52 /*void GameView::drawForeground(QPainter *painter, const QRectF &rect)
53 {
54  if (!isInteractive()) {
55  painter->save();
56  painter->setBrush(QBrush(QColor(60,60,60,100), Qt::Dense4Pattern));
57  painter->drawRect(rect);
58  painter->restore();
59  }
60 }*/
61 
62 void GameView::showEvent(QShowEvent *)
63 {
64  // Make sure that the game scene has the correct size according to the current view
65  // This is necessary because one scene is shared by multiple views but changing them
66  // creates no resizeEvent, so resize when another view is shown.
67  m_gameScene->resizeScene(width(), height());
68 }
69 
70 void GameView::resizeEvent(QResizeEvent *event)
71 {
72  m_gameScene->resizeScene(event->size().width(), event->size().height());
73 }
74 
75 } // End of namespace Kigo
76 
77 #include "moc_gameview.cpp"
QResizeEvent
QWidget
Kigo::GameScene
This class provides a graphical representation of the go game using QGraphicsScene.
Definition: gamescene.h:43
QSize::width
int width() const
QWidget::unsetCursor
void unsetCursor()
QGraphicsView::setOptimizationFlags
void setOptimizationFlags(QFlags< QGraphicsView::OptimizationFlag > flags)
Kigo::GameView::GameView
GameView(GameScene *scene, QWidget *parent=0)
Standard constructor.
Definition: gameview.cpp:28
QFrame::setFrameStyle
void setFrameStyle(int style)
QWidget::width
int width() const
gameview.h
QGraphicsView::isInteractive
bool isInteractive() const
QShowEvent
QAbstractScrollArea::setHorizontalScrollBarPolicy
void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy)
Kigo::GameScene::resizeScene
void resizeScene(int width, int height)
Definition: gamescene.cpp:53
QGraphicsView::setCacheMode
void setCacheMode(QFlags< QGraphicsView::CacheModeFlag > mode)
gamescene.h
QPixmap
QResizeEvent::size
const QSize & size() const
QPixmap::isNull
bool isNull() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QCursor
QAbstractScrollArea::setVerticalScrollBarPolicy
void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy)
QGraphicsView
QWidget::height
int height() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:29 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kigo

Skip menu "kigo"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal