Back to index

texmacs  1.0.7.15
x_drawable.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : x_drawable.hpp
00004 * DESCRIPTION: Drawables under X11
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
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 X_DRAWABLE_H
00013 #define X_DRAWABLE_H
00014 #include "renderer.hpp"
00015 #include "X11/x_gui.hpp"
00016 #include "X11/x_font.hpp"
00017 #include "rectangles.hpp"
00018 #include "array.hpp"
00019 
00020 /******************************************************************************
00021 * The x_drawable class
00022 ******************************************************************************/
00023 
00024 class x_window_rep;
00025 class x_drawable_rep: public renderer_rep {
00026   x_gui          gui;
00027   Display*       dpy;
00028   Drawable       win;
00029   x_window_rep*  x_win;
00030   int            w, h;
00031   GC             gc;
00032   color          cur_fg, cur_bg;
00033 
00034 public:
00035 
00036   x_drawable_rep (x_gui gui, x_window_rep* x_win);
00037   x_drawable_rep (x_gui gui, int w, int h);
00038   ~x_drawable_rep ();
00039 
00040   bool is_x_drawable ();
00041   x_drawable_rep* as_x_drawable ();
00042   void get_extents (int& w, int& h);
00043   bool interrupted (bool check= false);
00044 
00045   void encode (SI& x, SI& y);  // X coordinates -> mathematical coordinates
00046   void decode (SI& x, SI& y);  // mathematical coordinates -> X coordinates
00047 
00048   /**************** subroutines for drawing text and xpms ********************/
00049 
00050   void draw_clipped (Pixmap pm, Pixmap bm, int w, int h, SI x, SI y);
00051   void draw (int char_code, font_glyphs fn, SI x, SI y);
00052   void xpm_initialize (url file_name);
00053 
00054   /********************** routines from renderer.hpp *************************/
00055 
00056   void  set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore= false);
00057   color get_color ();
00058   color get_background ();
00059   void  set_color (color c);
00060   void  set_background (color c);
00061   void  set_line_style (SI w, int type=0, bool round=true);
00062   void  line (SI x1, SI y1, SI x2, SI y2);
00063   void  lines (array<SI> x, array<SI> y);
00064   void  clear (SI x1, SI y1, SI x2, SI y2);
00065   void  fill (SI x1, SI y1, SI x2, SI y2);
00066   void  arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta);
00067   void  fill_arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta);
00068   void  polygon (array<SI> x, array<SI> y, bool convex=true);
00069   void  xpm (url file_name, SI x, SI y);
00070   void  image (url u, SI w, SI h, SI x, SI y,
00071               double cx1, double cy1, double cx2, double cy2,
00072                int alpha);
00073 
00074   void fetch (SI x1, SI y1, SI x2, SI y2, renderer ren, SI x, SI y);
00075   void new_shadow (renderer& ren);
00076   void delete_shadow (renderer& ren);
00077   void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00078   void put_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00079   void apply_shadow (SI x1, SI y1, SI x2, SI y2);
00080 
00081   /****************************** friends ************************************/
00082 
00083   friend class x_gui_rep;
00084   friend class x_window_rep;
00085   friend Bool my_selnotify_predicate (Display* dpy, XEvent* ev, XPointer arg);
00086 };
00087 
00088 #endif // defined X_DRAWABLE_H