1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* Copyright (C) 2003 Cies Breijs <cies # kde ! nl>
This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General Public
License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _CANVAS_H_
#define _CANVAS_H_
#include <tqcanvas.h>
class Canvas : public TQCanvasView
{
Q_OBJECT
TQ_OBJECT
public:
Canvas(TQWidget *parent = 0, const char *name = 0);
~Canvas();
TQPixmap* canvas2Pixmap();
public slots:
void slotClear();
void slotClearSpriteToo();
void slotGo(double x, double y);
void slotGoX(double x);
void slotGoY(double y);
void slotForward(double x);
void slotBackward(double x);
void slotDirection(double deg);
void slotTurnLeft(double deg);
void slotTurnRight(double deg);
void slotCenter();
void slotSetPenWidth(int w);
void slotPenUp();
void slotPenDown();
void slotSetFgColor(int r, int g, int b);
void slotSetBgColor(int r, int g, int b);
void slotResizeCanvas(int x, int y);
void slotSpriteShow();
void slotSpriteHide();
void slotSpritePress();
void slotSpriteChange(int x);
void slotPrint(TQString text);
void slotFontType(TQString family, TQString extra);
void slotFontSize(int px);
void slotWrapOn();
void slotWrapOff();
void slotReset();
signals:
void CanvasResized();
private:
void initValues();
void line(double xa, double ya, double xb, double yb);
void lineShell(double xa, double ya, double xb, double yb);
bool endlessLoop(TQPoint begin, TQPoint end);
bool pointInRange(double px, double py, double xa, double ya, double xb, double yb);
TQPoint offset(int x, int y);
TQPoint translationFactor(double xa, double ya, double xb, double yb);
void loadSpriteFrames(TQString name);
void updateSpritePos();
void updateSpriteAngle();
TQCanvas *canvas;
TQPixmap pixmap;
TQCanvasSprite *sprite;
TQCanvasPixmapArray *spriteFrames;
TQFont font;
double posX, posY;
int canvasWidth, canvasHeight;
int penWidth;
double direction;
int fgR, fgG, fgB;
bool pen;
bool wrap;
bool cutLoop;
TQPoint prevStartPos3, prevStartPos2, prevStartPos1, prevEndPos3, prevEndPos2, prevEndPos1;
};
#endif // _CANVAS_H_
|