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

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

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

revision 1.1 by dheck, Sun Jan 5 20:01:41 2003 UTC revision 1.2 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  #ifndef PX_VIDEO_HH_INCLUDED  #ifndef PX_VIDEO_HH_INCLUDED
21  #define PX_VIDEO_HH_INCLUDED  #define PX_VIDEO_HH_INCLUDED
22    
23  #include "pxfwd.hh"  #include "pxfwd.hh"
24  #include "drawable.hh"  #include "geom.hh"
25  #include "SDL.h"  #include "SDL.h"
26    
27  //----------------------------------------  //----------------------------------------
# Line 138  namespace px Line 140  namespace px
140  }  }
141    
142  //----------------------------------------  //----------------------------------------
143    // Graphics contexts / drawables
144    //----------------------------------------
145    namespace px
146    {
147        class Drawable {
148        public:
149            virtual ~Drawable() {}
150    
151            virtual Uint32 map_color(int r, int g, int b) = 0;
152            virtual Uint32 map_color(int r, int g, int b, int a) = 0;
153    
154            // Drawable interface.
155            virtual void blit(int x, int y, Surface* s) = 0;
156            virtual void blit(int x, int y, Surface* s, const Rect& r) = 0;
157    
158            virtual Uint32 get_pixel(int x, int y) = 0;
159            virtual void set_pixel(int x, int y, Uint32 color) = 0;
160    
161            virtual void set_pixels(int n, const int* x, const int* y, Uint32 color);
162            virtual void hline(int x, int y, int w, Uint32 color);
163            virtual void vline(int x, int y, int h, Uint32 color);
164            virtual void box(int x, int y, int w, int h, Uint32 color);
165            virtual void line(int x1, int y1, int x2, int y2, Uint32 color);
166    
167            virtual Rect size() const = 0;
168        };
169    }
170    
171    namespace px
172    {
173        class GC {
174        public:
175            GC(Drawable* d);
176            GC(Surface *s);
177    
178            void clip(const Rect& r) { cliprect.assign(r.x+xoff, r.y+yoff, r.w, r.h); }
179            Rect get_cliprect() const { return cliprect; }
180            void noclip() { cliprect = drawable->size(); }
181    
182            void set_color(int r, int g, int b, int a)
183            {color = drawable->map_color(r, g, b, a);}
184            void set_color(int r, int g, int b)
185            {color = drawable->map_color(r, g, b);}
186            void set_color(Uint32 c) { color=c; }
187    
188            void set_pixel(int x, int y) {
189                x+=xoff; y+=yoff;
190                if (cliprect.contains(x, y))
191                    drawable->set_pixel(x, y, color);
192            }
193            void set_offset(int xo, int yo) { xoff=xo; yoff=yo; }
194    
195            void blit(int x, int y, Surface* s) const;
196            void blit(int x, int y, Surface* s, const Rect &r) const;
197            void box(const Rect& r);
198            void hline(int x, int y, int w);
199            void vline(int x, int y, int h);
200            void line(int x1, int y1, int x2, int y2);
201        private:
202            Drawable*   drawable;
203            Rect        cliprect;   // current clipping rectangle
204            Uint32      color;      // current color
205            int         xoff, yoff;
206        };
207    
208        inline void clip(GC &gc, const Rect& r) { gc.clip(r); }
209    
210        inline void set_color(GC & gc, int r, int g, int b)
211        { gc.set_color(r, g, b); }
212    
213        inline void set_color(GC & gc, int r, int g, int b, int a)
214        { gc.set_color(r, g, b, a); }
215    
216        inline void blit (const GC & gc, int x, int y, Surface *s)
217        { gc.blit(x, y, s); }
218        inline void blit(const GC & gc, int x, int y, Surface *s, const Rect &r)
219        { gc.blit(x,y,s,r); }
220    
221        inline void set_pixel(GC & gc, int x, int y) { gc.set_pixel(x, y); }
222        inline void hline(GC & gc, int x, int y, int w) { gc.hline(x, y, w); }
223        inline void vline(GC & gc, int x, int y, int h) { gc.vline(x, y, h); }
224    
225        void frame(GC & gc, int x, int y, int w, int h);
226        inline void frame(GC & gc, const Rect& r) { frame(gc, r.x, r.y, r.w, r.h);}
227    
228        inline void box(GC & gc, const Rect& r) { gc.box(r); }
229        inline void box(GC & gc, int x, int y, int w, int h)
230        { gc.box(Rect(x, y, w, h)); }
231    }
232    
233    
234    //----------------------------------------
235  // Functions  // Functions
236  //----------------------------------------  //----------------------------------------
237  namespace px  namespace px

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

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