Back to index

kdeartwork  4.3.2
screen.h
Go to the documentation of this file.
00001 /*
00002  * Asciiquarium - Native KDE Screensaver based on the Asciiquarium program
00003  *    (c) Kirk Baucom <kbaucom@schizoid.com>, which you can find at
00004  *    http://www.robobunny.com/projects/asciiquarium/
00005  *
00006  * Ported to KDE by Maksim Orlovich <maksim@kde.org> and
00007  * Michael Pyne <michael.pyne@kdemail.net>.
00008  *
00009  * Copyright (c) 2003 Kirk Baucom     <kbaucom@schizoid.com>
00010  * Copyright (c) 2005 Maksim Orlovich <maksim@kde.org>
00011  * Copyright (c) 2005, 2008 Michael Pyne <michael.pyne@kdemail.net>
00012  *
00013  * This program is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU General Public License
00015  * as published by the Free Software Foundation; either version 2
00016  * of the License, or (at your option) any later version.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License along with
00024  * this program; if not, write to the Free Software Foundation, Inc., 51
00025  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
00026  */
00027 
00028 #ifndef AA_SCREEN_H
00029 #define AA_SCREEN_H
00030 
00031 #include <QObject>
00032 #include <QList>
00033 #include <QPixmap>
00034 
00035 class Sprite;
00036 class AASaver;
00037 class QPaintEvent;
00038 class QPainter;
00039 
00050 class Screen: public QObject
00051 {
00052     Q_OBJECT
00053 
00054 public:
00058     struct Pixel {
00059         char letter; 
00060         QRgb color;  
00061 
00063         Pixel(): letter(' '), color(0)
00064         {
00065         }
00066     };
00067 
00068 private:
00069     AASaver* m_widget; 
00070     int      m_width;  
00071     int      m_height; 
00072     int      m_offX;   
00073     int      m_offY;   
00074 
00079     QPixmap  m_backBuffer;
00080     QPainter *m_curPainter;
00081 
00082     int      m_cellW; 
00083     int      m_cellH; 
00084 
00085     QList<Sprite*> m_sprites; 
00086     QList<Sprite*> m_addedSprites; 
00087 
00088 private slots:
00092     void doAnimate();
00093 
00094 public:
00100     Screen(AASaver* widget);
00101     ~Screen();
00102 
00104     int width() const
00105     {
00106         return m_width;
00107     }
00108 
00110     int height() const
00111     {
00112         return m_height;
00113     }
00114 
00116     int cellWidth() const
00117     {
00118         return m_cellW;
00119     }
00120 
00122     int cellHeight() const
00123     {
00124         return m_cellH;
00125     }
00126 
00132     void addSprite(Sprite* sprite)
00133     {
00134         m_addedSprites.append(sprite);
00135     }
00136 
00138     int msPerTick() const;
00139 
00149     void updateSpan(int x, int y, const QPixmap &updatePixmap);
00150 
00160     void clearSpan(int x, int y, const QPixmap &clearPixmap);
00161 
00167     void paint(QPaintEvent *pe);
00168 };
00169 
00170 #endif
00171 
00172 // vim: set et ts=8 sw=4: