SVN_SILENT made messages (.desktop file)
[kdegames.git] / kmahjongg / FrameImage.cpp
blob5a3dc0d00c331670c9ce89257521a0cba8e4f4a7
1 /*
2 Copyright (C) 1997 Mathias Mueller <in5y158@public.uni-hamburg.de>
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.
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, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "FrameImage.h"
21 #include <kcomponentdata.h>
22 #include <kfiledialog.h>
23 #include <klocale.h>
24 #include <kmessagebox.h>
25 #include <kpushbutton.h>
26 #include <kstandarddirs.h>
27 #include <KStandardGuiItem>
28 #include <kimageio.h>
30 #include <qevent.h>
31 #include <qimage.h>
32 #include <qpainter.h>
33 #include <qtextstream.h>
34 #include <kvbox.h>
37 #include "prefs.h"
39 FrameImage::FrameImage (QWidget *parent, const QSize& initialImageSize)
40 : KGameCanvasWidget(parent)
42 rx = -1;
43 thePixmap = new QPixmap(initialImageSize);
46 FrameImage::~FrameImage()
48 delete thePixmap;
51 void FrameImage::resizeEvent( QResizeEvent* ev )
53 *thePixmap = QPixmap(ev->size());
56 void FrameImage::paintEvent( QPaintEvent* pa )
58 //QFrame::paintEvent(pa);
60 QPainter p(this);
63 QPen line;
64 line.setStyle(Qt::DotLine);
65 line.setWidth(2);
66 line.setColor(Qt::yellow);
67 p.setPen(line);
68 p.setBackgroundMode(Qt::OpaqueMode);
69 p.setBackground(Qt::black);
71 int x = pa->rect().left();
72 int y = pa->rect().top();
73 int h = pa->rect().height();
74 int w = pa->rect().width();
76 //p.drawPixmap(x+frameWidth(),y+frameWidth(),*thePixmap,x+frameWidth(),y+frameWidth(),w-(2*frameWidth()),h-(2*frameWidth()));
77 p.drawPixmap(x,y,*thePixmap,x,y,w-(2),h-(2));
78 if (rx >=0) {
80 p.drawRect(rx, ry, rw, rh);
81 p.drawRect(rx+rs, ry, rw-rs, rh-rs);
82 p.drawLine(rx, ry+rh, rx+rs, ry+rh-rs);
84 int midX = rx+rs+((rw-rs)/2);
85 int midY = ry+((rh-rs)/2);
86 switch (rt) {
87 case 0: // delete mode cursor
88 p.drawLine(rx+rs, ry, rx+rw, ry+rh-rs);
89 p.drawLine(rx+rw, ry, rx+rs, ry+rh-rs);
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 break;
95 case 2: // move mode cursor
96 p.drawLine(midX, ry, rx+rw, midY);
97 p.drawLine(rx+rw, midY, midX, ry+rh-rs);
98 p.drawLine(midX, ry+rh-rs, rx+rs, midY);
99 p.drawLine(rx+rs, midY, midX, ry);
101 break;
107 void FrameImage::setRect(int x,int y,int w,int h, int s, int t)
109 rx = x;
110 ry = y;
111 rw = w;
112 rh = h;
113 rt = t;
114 rs = s;
117 // Pass on the mouse presed event to our owner
119 void FrameImage::mousePressEvent(QMouseEvent *m) {
120 emit mousePressed(m);
123 void FrameImage::mouseMoveEvent(QMouseEvent *e) {
124 emit mouseMoved(e);
127 #include "FrameImage.moc"