/[enigma]/enigma/src/px/drawable.hh
ViewVC logotype

Diff of /enigma/src/px/drawable.hh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by dheck, Sun Jan 19 17:20:24 2003 UTC revision 1.3 by dheck, Wed Mar 5 22:06:50 2003 UTC
# Line 1  Line 1 
1  //======================================================================  /*
2  // Copyright (C) 2002 Daniel Heck   * Copyright (C) 2002,2003 Daniel Heck
3  //   *
4  // This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5  // modify it under the terms of the GNU General Public License   * modify it under the terms of the GNU General Public License
6  // as published by the Free Software Foundation; either version 2   * as published by the Free Software Foundation; either version 2
7  // of the License, or (at your option) any later version.   * of the License, or (at your option) any later version.
8  //     *  
9  // This program is distributed in the hope that it will be useful,   * This program is distributed in the hope that it will be useful,
10  // but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  // GNU General Public License for more details.   * GNU General Public License for more details.
13  //     *
14  // You should have received a copy of the GNU General Public License along   * You should have received a copy of the GNU General Public License along
15  // with this program; if not, write to the Free Software Foundation, Inc.,   * with this program; if not, write to the Free Software Foundation, Inc.,
16  // 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.   * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17  //======================================================================   *
18     * $Id$
19     */
20    
21  /*  /*
22   * Class `Drawable' is an abstract interface to nearly everything that   * Class `Drawable' is an abstract interface to nearly everything that
# Line 34  Line 36 
36  #include "SDL_types.h"  #include "SDL_types.h"
37  #include "geom.hh"  #include "geom.hh"
38    
 namespace px  
 {  
     class Surface;  
   
     class Drawable {  
     public:  
         virtual ~Drawable() {}  
   
         virtual Uint32 map_color(int r, int g, int b) = 0;  
         virtual Uint32 map_color(int r, int g, int b, int a) = 0;  
   
         // Drawable interface.  
         virtual void blit(int x, int y, Surface* s) = 0;  
         virtual void blit(int x, int y, Surface* s, const Rect& r) = 0;  
   
         virtual Uint32 get_pixel(int x, int y) = 0;  
         virtual void set_pixel(int x, int y, Uint32 color) = 0;  
   
         virtual void set_pixels(int n, const int* x, const int* y, Uint32 color);  
         virtual void hline(int x, int y, int w, Uint32 color);  
         virtual void vline(int x, int y, int h, Uint32 color);  
         virtual void box(int x, int y, int w, int h, Uint32 color);  
         virtual void line(int x1, int y1, int x2, int y2, Uint32 color);  
   
         virtual Rect size() const = 0;  
     };  
 }  
   
 namespace px  
 {  
     class GC {  
     public:  
         GC(Drawable* d);  
         GC(Surface *s);  
   
         void clip(const Rect& r) { cliprect.assign(r.x+xoff, r.y+yoff, r.w, r.h); }  
         Rect get_cliprect() const { return cliprect; }  
         void noclip() { cliprect = drawable->size(); }  
   
         void set_color(int r, int g, int b, int a)  
         {color = drawable->map_color(r, g, b, a);}  
         void set_color(int r, int g, int b)  
         {color = drawable->map_color(r, g, b);}  
         void set_color(Uint32 c) { color=c; }  
   
         void set_pixel(int x, int y) {  
             x+=xoff; y+=yoff;  
             if (cliprect.contains(x, y))  
                 drawable->set_pixel(x, y, color);  
         }  
         void set_offset(int xo, int yo) { xoff=xo; yoff=yo; }  
   
         void blit(int x, int y, Surface* s) const;  
         void blit(int x, int y, Surface* s, const Rect &r) const;  
         void box(const Rect& r);  
         void hline(int x, int y, int w);  
         void vline(int x, int y, int h);  
         void line(int x1, int y1, int x2, int y2);  
     private:  
         Drawable*   drawable;  
         Rect        cliprect;   // current clipping rectangle  
         Uint32      color;      // current color  
         int         xoff, yoff;  
     };  
   
     inline void clip(GC &gc, const Rect& r) { gc.clip(r); }  
   
     inline void set_color(GC & gc, int r, int g, int b)  
     { gc.set_color(r, g, b); }  
   
     inline void set_color(GC & gc, int r, int g, int b, int a)  
     { gc.set_color(r, g, b, a); }  
   
     inline void blit (const GC & gc, int x, int y, Surface *s)  
     { gc.blit(x, y, s); }  
     inline void blit(const GC & gc, int x, int y, Surface *s, const Rect &r)  
     { gc.blit(x,y,s,r); }  
   
     inline void set_pixel(GC & gc, int x, int y) { gc.set_pixel(x, y); }  
     inline void hline(GC & gc, int x, int y, int w) { gc.hline(x, y, w); }  
     inline void vline(GC & gc, int x, int y, int h) { gc.vline(x, y, h); }  
   
     void frame(GC & gc, int x, int y, int w, int h);  
     inline void frame(GC & gc, const Rect& r) { frame(gc, r.x, r.y, r.w, r.h);}  
   
     inline void box(GC & gc, const Rect& r) { gc.box(r); }  
     inline void box(GC & gc, int x, int y, int w, int h)  
     { gc.box(Rect(x, y, w, h)); }  
 }  
39  #endif  #endif

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26