Back to index

texmacs  1.0.7.15
qt_renderer.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : qt_renderer.hpp
00004 * DESCRIPTION: QT drawing interface class
00005 * COPYRIGHT  : (C) 2006 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 QT_RENDERER_HPP
00013 #define QT_RENDERER_HPP
00014 
00015 #include "basic_renderer.hpp"
00016 #include <QPainter>
00017 #include <QPixmap>
00018 #include <QImage>
00019 #include <QtGlobal>
00020 #include <QWidget>
00021 
00022 // if QTMPIXMAPS is defined we use QPixmap for characters
00023 // otherwise we use QImage (which support alpha also under X11)
00024 
00025 #ifdef Q_WS_MAC
00026 #define QTMPIXMAPS
00027 #else
00028 #undef QTMPIXMAPS
00029 #endif
00030 
00031 #ifdef QTMPIXMAPS
00032 #define QTMImage QPixmap
00033 #else
00034 #define QTMImage QImage
00035 #endif
00036 
00037 
00038 class qt_renderer_rep:  public basic_renderer_rep {
00039 public:
00040   QPainter *painter; // FIXME: painter needs begin/end
00041 
00042 public:
00043   qt_renderer_rep (QPainter *_painter, int w = 0, int h = 0);
00044   ~qt_renderer_rep ();
00045 
00046   void begin (void* handle);
00047   void end ();
00048 
00049   //void set_extent (int _w, int _h) { w = _w; h = _h; }
00050   void get_extents (int& w, int& h);
00051 
00052   void set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore = false);
00053 
00054   void  draw (int char_code, font_glyphs fn, SI x, SI y);
00055   void  set_color (color c);
00056   void  set_line_style (SI w, int type=0, bool round=true);
00057   void  line (SI x1, SI y1, SI x2, SI y2);
00058   void  lines (array<SI> x, array<SI> y);
00059   void  clear (SI x1, SI y1, SI x2, SI y2);
00060   void  fill (SI x1, SI y1, SI x2, SI y2);
00061   void  arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta);
00062   void  fill_arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta);
00063   void  polygon (array<SI> x, array<SI> y, bool convex=true);
00064   void  xpm (url file_name, SI x, SI y);
00065   void  image (url u, SI w, SI h, SI x, SI y,
00066                double cx1, double cy1, double cx2, double cy2,
00067                int alpha);
00068 
00069   void draw_clipped (QImage * im, int w, int h, SI x, SI y);
00070   void draw_clipped (QPixmap * im, int w, int h, SI x, SI y);
00071   
00072   
00073   void new_shadow (renderer& ren);
00074   void delete_shadow (renderer& ren);
00075   void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00076   void put_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00077   
00078   void apply_shadow (SI x1, SI y1, SI x2, SI y2);
00079 
00080   /***** private section *****************************************************/
00081 
00082   QPixmap *xpm_image(url file_name);
00083 
00084 };
00085 
00086 
00087 class qt_shadow_renderer_rep:  public qt_renderer_rep {
00088 public:
00089   QPixmap px;   
00090   qt_renderer_rep *master;
00091   
00092 public:
00093   qt_shadow_renderer_rep (QPixmap _px = QPixmap());
00094   ~qt_shadow_renderer_rep ();
00095   
00096   void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00097 };
00098 
00099 
00100 class qt_proxy_renderer_rep:  public qt_renderer_rep {
00101 public:
00102   qt_renderer_rep *base;
00103   
00104 public:
00105   qt_proxy_renderer_rep (qt_renderer_rep *_base) 
00106   : qt_renderer_rep(_base->painter), base(_base) {}
00107   ~qt_proxy_renderer_rep () {};
00108   
00109   void new_shadow (renderer& ren);
00110   void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00111 };
00112 
00113 qt_renderer_rep* the_qt_renderer();
00114 
00115 #endif // defined QT_RENDERER_HPP