Back to index

texmacs  1.0.7.15
basic_renderer.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : basic_renderer.hpp
00004 * DESCRIPTION: common drawing interface class
00005 * COPYRIGHT  : (C) 2008 Massimiliano Gubinelli
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef BASIC_RENDERER_HPP
00013 #define BASIC_RENDERER_HPP
00014 
00015 #include "renderer.hpp"
00016 #include "gui.hpp" // for black, white
00017 /******************************************************************************
00018  * structure for caching font pixmaps
00019  ******************************************************************************/
00020 
00021 struct basic_character_rep: concrete_struct {
00022        int          c;
00023        font_glyphs  fng;
00024        int          sf;
00025        color        fg;
00026        color        bg;
00027        basic_character_rep (int c2, font_glyphs fng2, int sf2, color fg2, color bg2)
00028   : c (c2), fng (fng2), sf (sf2), fg (fg2), bg (bg2) {};
00029   
00030        friend class basic_character;
00031 };
00032 
00033 class basic_character {
00034        CONCRETE(basic_character);
00035        basic_character (int c=0, font_glyphs fng= font_glyphs (),
00036                    int sf=1, color fg= 0, color bg= 1):
00037   rep (tm_new<basic_character_rep> (c, fng, sf, fg, bg)) {};
00038        operator tree ();
00039 };
00040 CONCRETE_CODE(basic_character);
00041 
00042 bool operator == (basic_character xc1, basic_character xc2);
00043 bool operator != (basic_character xc1, basic_character xc2);
00044 int hash (basic_character xc);
00045 
00046 
00047 
00048 /******************************************************************************
00049  * structure for caching images
00050  ******************************************************************************/
00051 
00052 struct cache_image_element_rep: concrete_struct {
00053        int w,h,nr;
00054   time_t time;
00055   void *ptr;
00056        cache_image_element_rep (int w2, int h2,  time_t time2, void *ptr2) :
00057    w(w2), h(h2), nr(0), time(time2), ptr(ptr2) {};
00058        virtual ~cache_image_element_rep() {};
00059        friend class cache_image_element;
00060 };
00061 
00062 class cache_image_element {
00063        ABSTRACT_NULL(cache_image_element);
00064        //basic_image (basic_surface_t* img2, SI xo2, SI yo2, int w2, int h2);
00065        //cache_image () 
00066 };
00067 
00068 ABSTRACT_NULL_CODE(cache_image_element);
00069 
00070 
00071 /******************************************************************************
00072  * basic_renderer_rep
00073  ******************************************************************************/
00074 
00075 
00076 class basic_renderer_rep:   public renderer_rep {
00077 public:
00078   int   w, h;
00079   color cur_fg, cur_bg;
00080 
00081 public:
00082   basic_renderer_rep (int w2 = 0, int h2 = 0) :
00083   w (w2), h (h2), cur_fg(black), cur_bg(white) {};
00084   virtual ~basic_renderer_rep () {};
00085   
00086   virtual void get_extents (int& w, int& h);
00087   virtual bool interrupted (bool check= false);
00088   
00089   /***** routines from renderer.hpp ******************************************/
00090 
00091   color rgb (int r, int g, int b, int a= 255);
00092   void  get_rgb (color col, int& r, int& g, int& b, int& a);
00093   color get_color ();
00094   // color get_color (string s);
00095   color get_background ();
00096 
00097   void  set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore= false);
00098   void  set_color (color c);
00099   void  set_background (color c);
00100 
00101   virtual void begin (void* handle);
00102   virtual void end ();
00103 
00104   void encode (SI& x, SI& y);
00105   void decode (SI& x, SI& y);
00106   
00107   void fetch (SI x1, SI y1, SI x2, SI y2, renderer ren, SI x, SI y);
00108   void new_shadow (renderer& ren);
00109   void delete_shadow (renderer& ren);
00110   void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00111   void put_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00112   void apply_shadow (SI x1, SI y1, SI x2, SI y2);
00113 
00114   cache_image_element  get_image_cache (tree lookup);
00115   void set_image_cache (tree lookup, cache_image_element ci);
00116   void image_auto_gc ();
00117   void image_gc (string name);
00118 
00119 };
00120 
00121 typedef basic_renderer_rep* basic_renderer;
00122 
00123 //extern bool reverse_colors;
00124 //extern int CSCALES, CFACTOR, GREYS, CTOTAL;
00125 
00126 color xpm_to_color (string s);
00127 
00128 
00129 
00130 #endif // defined BASIC_RENDERER_HPP