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

kmahjongg

  • sources
  • kde-4.14
  • kdegames
  • kmahjongg
FrameImage.cpp
Go to the documentation of this file.
1 /* Copyright (C) 1997 Mathias Mueller <in5y158@public.uni-hamburg.de>
2  * Copyright (C) 2006 Mauricio Piacentini <mauricio@tabuleiro.com>
3  *
4  * Kmahjongg 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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 
18 #include "FrameImage.h"
19 #include "prefs.h"
20 
21 #include <qevent.h>
22 #include <qimage.h>
23 #include <qpainter.h>
24 #include <qtextstream.h>
25 
26 #include <kcomponentdata.h>
27 #include <kfiledialog.h>
28 #include <klocale.h>
29 #include <kmessagebox.h>
30 #include <kpushbutton.h>
31 #include <kstandarddirs.h>
32 #include <KStandardGuiItem>
33 #include <kimageio.h>
34 #include <kvbox.h>
35 
36 
37 FrameImage::FrameImage(QWidget *parent, const QSize &initialImageSize)
38  : KGameCanvasWidget(parent)
39 {
40  rx = -1;
41  thePixmap = new QPixmap(initialImageSize);
42 }
43 
44 FrameImage::~FrameImage()
45 {
46  delete thePixmap;
47 }
48 
49 void FrameImage::resizeEvent(QResizeEvent *ev)
50 {
51  *thePixmap = QPixmap(ev->size());
52 }
53 
54 void FrameImage::paintEvent(QPaintEvent *pa)
55 {
56  //QFrame::paintEvent(pa);
57 
58  QPainter p(this);
59 
60  QPen line;
61 // line.setStyle(Qt::DotLine);
62  line.setWidth(1);
63  line.setColor(Qt::red);
64  p.setPen(line);
65  p.setBackgroundMode(Qt::OpaqueMode);
66  p.setBackground(Qt::black);
67 
68  int x = pa->rect().left();
69  int y = pa->rect().top();
70  int h = pa->rect().height();
71  int w = pa->rect().width();
72 
73 // p.drawPixmap(x+frameWidth(),y+frameWidth(),*thePixmap,x+frameWidth(),y+frameWidth(),w-(2*frameWidth()),h-(2*frameWidth()));
74  p.drawPixmap(x, y, *thePixmap, x, y, w - 2, h - 2);
75  if (rx >=0) {
76  p.drawRect(rx + rs, ry, rw - rs, rh - rs);
77  p.drawLine(rx, ry + rs, rx, ry + rh);
78  p.drawLine(rx, ry + rs, rx + rs, ry);
79  p.drawLine(rx, ry + rh, rx + rs, ry + rh - rs);
80  p.drawLine(rx, ry + rh, rx + rw - rs, ry + rh);
81  p.drawLine(rx + rw - rs, ry + rh, rx + rw, ry + rh - rs);
82 
83  int midX = rx + rs + ((rw - rs) / 2);
84  int midY = ry + ((rh - rs) / 2);
85  switch (rt) {
86  case 0: // delete mode cursor
87  p.drawLine(rx + rs, ry, rx + rw, ry + rh - rs);
88  p.drawLine(rx + rw, ry, rx + rs, ry + rh - rs);
89 
90  break;
91  case 1: // insert cursor
92  p.drawLine(midX, ry, midX, ry + rh - rs);
93  p.drawLine(rx + rs, midY, rx + rw, midY);
94 
95  break;
96  case 2: // move mode cursor
97  p.drawLine(midX, ry, rx + rw, midY);
98  p.drawLine(rx + rw, midY, midX, ry + rh - rs);
99  p.drawLine(midX, ry + rh - rs, rx + rs, midY);
100  p.drawLine(rx + rs, midY, midX, ry);
101 
102  break;
103  }
104  }
105 }
106 
107 void FrameImage::setRect(int x, int y, int w, int h, int s, int t)
108 {
109  rx = x;
110  ry = y;
111  rw = w;
112  rh = h;
113  rt = t;
114  rs = s;
115 }
116 
117 void FrameImage::mousePressEvent(QMouseEvent *m)
118 {
119  emit mousePressed(m);
120 }
121 
122 void FrameImage::mouseMoveEvent(QMouseEvent *e)
123 {
124  emit mouseMoved(e);
125 }
126 
127 
128 #include "FrameImage.moc"
QResizeEvent
QWidget
QPainter::setBackgroundMode
void setBackgroundMode(Qt::BGMode mode)
KGameCanvasWidget
QPainter::setBackground
void setBackground(const QBrush &brush)
QRect::height
int height() const
prefs.h
QMouseEvent
QPainter::drawLine
void drawLine(const QLineF &line)
FrameImage::paintEvent
void paintEvent(QPaintEvent *pa)
Event Description.
Definition: FrameImage.cpp:54
FrameImage::mouseMoved
void mouseMoved(QMouseEvent *e)
Signal Description.
QPaintEvent::rect
const QRect & rect() const
QPainter::drawRect
void drawRect(const QRectF &rectangle)
FrameImage::FrameImage
FrameImage(QWidget *parent, const QSize &initialImageSize)
Constructor.
Definition: FrameImage.cpp:37
FrameImage::resizeEvent
void resizeEvent(QResizeEvent *e)
Event Description.
Definition: FrameImage.cpp:49
QRect::top
int top() const
FrameImage::mousePressed
void mousePressed(QMouseEvent *e)
Signal Description.
QPainter::setPen
void setPen(const QColor &color)
QRect::left
int left() const
QPainter::drawPixmap
void drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source)
QPainter
QPen::setColor
void setColor(const QColor &color)
QPixmap
QResizeEvent::size
const QSize & size() const
QSize
QRect::width
int width() const
FrameImage::mousePressEvent
void mousePressEvent(QMouseEvent *e)
Event Description.
Definition: FrameImage.cpp:117
QPen::setWidth
void setWidth(int width)
FrameImage::~FrameImage
~FrameImage()
Default Destructor.
Definition: FrameImage.cpp:44
FrameImage::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *e)
Event Description.
Definition: FrameImage.cpp:122
QPen
FrameImage.h
QPaintEvent
FrameImage::setRect
void setRect(int x, int y, int w, int h, int ss, int type)
Method Description.
Definition: FrameImage.cpp:107
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:33 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmahjongg

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

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