You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
3.5 KiB
103 lines
3.5 KiB
/**
|
|
* \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__
|