canvas.h
3.5 KB
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
/**
* \file canvas.h
*
* \brief Ein canvas ist etwas worauf gezeichnet werden kann.
*
* <p>Diese beschreibt einen Speicherbereich in dem gezeichnet werden kann
* und Methoden zum "blitten" also dem darstellen dieses Speicherbereichs
* auf dem Bildschirm. Außerdem werden Funktionen zur Farbverwaltung zur
* verfügung gestellt.</p>
* <p>canvas ist von event-source abgeleitet, da es events erzeugen kann
* wie z.B. ein redraw-request u.ä.</p>
*
* \author Georg Steffers <georg@steffers.org> [gs]
*
* \date 04.12.2003
*
* \version ..2002 [gs]: erste funktionierende Implementation
* \version 04.12.2003 [gs]: beginn der Dokumentation via doxygen
* \version 19.12.2003 [gs]: draw_text hinzugefügt, das ist hier eigentlich
* nicht ganz richtig, aber damit ich nicht meinen
* eigenen Font-Renderer schreiben muss um debug
* Ausgaben zu machen und dafüe die
* X11-Funktionen nutzen kann, ist der hier.
*/
/*
* Copyright (C)2003 Georg Steffers
*
* 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.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __canvas_h__
#define __canvas_h__
#include "canvas_imps/canvas_imp.h"
#include "event_source.h"
#include "rasterize.h"
#include <cstdio>
typedef enum blit_status {NO_BLIT, BLIT, DRAW};
class canvas : public event_source {
protected:
unsigned x_size, y_size;
canvas_imp* sinfo;
blit_status blit;
unsigned long draw_color;
public:
virtual void draw_text(int x, int y, char* text, int length) = 0;
canvas(unsigned xs, unsigned ys) : event_source() {
x_size=xs;
y_size=ys;
sinfo=NULL;
blit=NO_BLIT;
}
virtual ~canvas() {
close_screen();
}
virtual rasterizer* create_rasterizer(void) = 0;
virtual void refresh_palette(void) {};
virtual void open_screen(void)=0;
virtual void close_screen(void) {};
virtual void blit_screen(void)=0;
blit_status& blitting(void) { return blit; }
unsigned long get_color(unsigned red, unsigned green, unsigned blue) {
return sinfo->ext_to_native(red, green, blue);
}
void set_color(unsigned long col) { draw_color=col; }
void set_color(unsigned red, unsigned green, unsigned blue) {
draw_color=sinfo->ext_to_native(red, green, blue);
}
void light_native(unsigned long* col, unsigned intens) {
sinfo->light_native(col, intens);
}
char bpp(void) { return sinfo->bytes_per_pixel; }
virtual unsigned get_x_size(void) const { return x_size; }
virtual unsigned get_y_size(void) const { return y_size; }
};
class canvas_factory {
public:
virtual canvas* create(unsigned xs, unsigned ys) const=0;
};
#endif // __canvas_h__