• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kblackbox

kbbgraphicsitemlaser.cpp

Go to the documentation of this file.
00001 //
00002 // KBlackBox
00003 //
00004 // A simple game inspired by an emacs module
00005 //
00006 /***************************************************************************
00007  *   Copyright (c) 1999-2000, Robert Cimrman                               *
00008  *   cimrman3@students.zcu.cz                                              *
00009  *                                                                         *
00010  *   Copyright (c) 2007, Nicolas Roffet                                    *
00011  *   nicolas-kde@roffet.com                                                *
00012  *                                                                         *
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   (at your option) any later version.                                   *
00018  *                                                                         *
00019  *   This program is distributed in the hope that it will be useful,       *
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00022  *   GNU General Public License for more details.                          *
00023  *                                                                         *
00024  *   You should have received a copy of the GNU General Public License     *
00025  *   along with this program; if not, write to the                         *
00026  *   Free Software Foundation, Inc.,                                       *
00027  *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA               *
00028  ***************************************************************************/
00029 
00030 
00031 #include "kbbgraphicsitemlaser.h"
00032 
00033 #include <QGraphicsSceneMouseEvent>
00034 
00035 
00036 
00037 #include "kbbgraphicsitem.h"
00038 #include "kbbgraphicsitemborder.h"
00039 #include "kbbitemwithposition.h"
00040 #include "kbbscalablegraphicwidget.h"
00041 #include "kbbthememanager.h"
00042 
00043 
00044 
00045 //
00046 // Constructor / Destructor
00047 //
00048 
00049 KBBGraphicsItemLaser::KBBGraphicsItemLaser(KBBScalableGraphicWidget* parent, KBBThemeManager* themeManager, const int borderPosition, const int columns, const int rows) : KBBGraphicsItemBorder(borderPosition, columns, rows, 0), KBBGraphicsItem(((borderPosition<columns) ? KBBScalableGraphicWidget::laser0 : ((borderPosition<columns + rows) ? KBBScalableGraphicWidget::laser90 : ((borderPosition<2*columns + rows) ? KBBScalableGraphicWidget::laser180 : KBBScalableGraphicWidget::laser270))) , parent->scene(), themeManager), KBBItemWithPosition()
00050 {
00051     m_widget = parent;
00052     
00053     const int radius = KBBScalableGraphicWidget::RATIO/2;
00054     if (rotation()==90) {
00055         setPos(m_centerX - 3*radius, m_centerY - radius);
00056     } else if (rotation()==180) {
00057         setPos(m_centerX - radius, m_centerY - 3*radius);
00058     } else {
00059         setPos(m_centerX - radius, m_centerY - radius);
00060     }
00061     
00062     setAcceptsHoverEvents(true);
00063 }
00064 
00065 
00066 
00067 //
00068 // Public
00069 //
00070 
00071 const int KBBGraphicsItemLaser::position ()
00072 {
00073     return m_borderPosition;
00074 }
00075 
00076 
00077 
00078 //
00079 // Private
00080 //
00081 
00082 void KBBGraphicsItemLaser::hoverEnterEvent (QGraphicsSceneHoverEvent*)
00083 {
00084     m_widget->drawRay(position());
00085 }
00086 
00087 
00088 void KBBGraphicsItemLaser::hoverLeaveEvent (QGraphicsSceneHoverEvent*)
00089 {
00090     m_widget->removeRay();
00091 }
00092 
00093 
00094 void KBBGraphicsItemLaser::mousePressEvent (QGraphicsSceneMouseEvent* event)
00095 {
00096     if (event->buttons()==Qt::LeftButton) {
00097         m_widget->mouseBorderClick(position());
00098     }
00099 }

kblackbox

Skip menu "kblackbox"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal