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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
/*
Rosegarden
A MIDI and audio sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <[email protected]>,
Chris Cannam <[email protected]>,
Richard Bown <[email protected]>
The moral rights of Guillaume Laurent, Chris Cannam, and Richard
Bown to claim authorship of this work have been asserted.
Other copyrights also apply to some parts of this work. Please
see the AUTHORS file and individual file headers for details.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version. See the file
COPYING included with this distribution for more information.
*/
#ifndef _RG_NOTEPIXMAPPAINTER_H_
#define _RG_NOTEPIXMAPPAINTER_H_
#include <tqpainter.h>
namespace Rosegarden {
class NotePixmapPainter
{
// Just a trivial class that instructs two painters to do the
// same thing (one for the pixmap, one for the mask). We only
// duplicate those methods we actually use in NotePixmapFactory
public:
NotePixmapPainter() :
m_painter(&m_myPainter) { }
void beginExternal(TQPainter *painter) {
m_externalPainter = painter;
m_useMask = false;
painter->setPen(TQPen(Qt::black, 1, Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
if (m_externalPainter) {
m_painter = m_externalPainter;
} else {
m_painter = &m_myPainter;
}
}
bool begin(TQPaintDevice *device, TQPaintDevice *mask = 0, bool unclipped = false) {
m_externalPainter = 0;
if (mask) {
m_useMask = true;
m_maskPainter.tqbegin(mask, unclipped);
} else {
m_useMask = false;
}
m_painter = &m_myPainter;
return m_painter->tqbegin(device, unclipped);
}
bool end() {
if (m_useMask) m_maskPainter.end();
return m_painter->end();
}
TQPainter &painter() {
return *m_painter;
}
TQPainter &maskPainter() {
return m_maskPainter;
}
void drawPoint(int x, int y) {
m_painter->drawPoint(x, y);
if (m_useMask) m_maskPainter.drawPoint(x, y);
}
void drawLine(int x1, int y1, int x2, int y2) {
m_painter->drawLine(x1, y1, x2, y2);
if (m_useMask) m_maskPainter.drawLine(x1, y1, x2, y2);
}
void drawRect(int x, int y, int w, int h) {
m_painter->drawRect(x, y, w, h);
if (m_useMask) m_maskPainter.drawRect(x, y, w, h);
}
void drawArc(int x, int y, int w, int h, int a, int alen) {
m_painter->drawArc(x, y, w, h, a, alen);
if (m_useMask) m_maskPainter.drawArc(x, y, w, h, a, alen);
}
void drawPolygon(const TQPointArray &a, bool winding = false,
int index = 0, int n = -1) {
m_painter->tqdrawPolygon(a, winding, index, n);
if (m_useMask) m_maskPainter.tqdrawPolygon(a, winding, index, n);
}
void drawPolyline(const TQPointArray &a, int index = 0, int n = -1) {
m_painter->tqdrawPolyline(a, index, n);
if (m_useMask) m_maskPainter.tqdrawPolyline(a, index, n);
}
void drawPixmap(int x, int y, const TQPixmap &pm,
int sx = 0, int sy = 0, int sw = -1, int sh = -1) {
m_painter->tqdrawPixmap(x, y, pm, sx, sy, sw, sh);
if (m_useMask) m_maskPainter.tqdrawPixmap(x, y, *(pm.mask()), sx, sy, sw, sh);
}
void drawText(int x, int y, const TQString &string) {
m_painter->drawText(x, y, string);
if (m_useMask) m_maskPainter.drawText(x, y, string);
}
void drawNoteCharacter(int x, int y, const NoteCharacter &character) {
character.draw(m_painter, x, y);
if (m_useMask) character.drawMask(&m_maskPainter, x, y);
}
void drawEllipse(int x, int y, int w, int h) {
m_painter->drawEllipse(x, y, w, h);
if (m_useMask) m_maskPainter.drawEllipse(x, y, w, h);
}
private:
bool m_useMask;
TQPainter m_myPainter;
TQPainter m_maskPainter;
TQPainter *m_externalPainter;
TQPainter *m_painter;
};
}
#endif
|