Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Private Attributes | Friends
x_drawable_rep Class Reference

#include <x_drawable.hpp>

Inheritance diagram for x_drawable_rep:
Inheritance graph
[legend]
Collaboration diagram for x_drawable_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 x_drawable_rep (x_gui gui, x_window_rep *x_win)
 x_drawable_rep (x_gui gui, int w, int h)
 ~x_drawable_rep ()
bool is_x_drawable ()
x_drawable_repas_x_drawable ()
void get_extents (int &w, int &h)
bool interrupted (bool check=false)
void encode (SI &x, SI &y)
void decode (SI &x, SI &y)
void draw_clipped (Pixmap pm, Pixmap bm, int w, int h, SI x, SI y)
void draw (int char_code, font_glyphs fn, SI x, SI y)
void xpm_initialize (url file_name)
void set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore=false)
color get_color ()
color get_background ()
void set_color (color c)
void set_background (color c)
void set_line_style (SI w, int type=0, bool round=true)
void line (SI x1, SI y1, SI x2, SI y2)
void lines (array< SI > x, array< SI > y)
void clear (SI x1, SI y1, SI x2, SI y2)
void fill (SI x1, SI y1, SI x2, SI y2)
void arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta)
void fill_arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta)
void polygon (array< SI > x, array< SI > y, bool convex=true)
void xpm (url file_name, SI x, SI y)
void image (url u, SI w, SI h, SI x, SI y, double cx1, double cy1, double cx2, double cy2, int alpha)
void fetch (SI x1, SI y1, SI x2, SI y2, renderer ren, SI x, SI y)
void new_shadow (renderer &ren)
void delete_shadow (renderer &ren)
void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2)
void put_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2)
void apply_shadow (SI x1, SI y1, SI x2, SI y2)
virtual bool is_printer ()
virtual void next_page ()
virtual bool repainted ()
void set_origin (SI x, SI y)
void move_origin (SI dx, SI dy)
void set_shrinking_factor (int sfactor)
void round (SI &x, SI &y)
void inner_round (SI &x1, SI &y1, SI &x2, SI &y2)
void outer_round (SI &x1, SI &y1, SI &x2, SI &y2)
bool is_visible (SI x1, SI y1, SI x2, SI y2)
virtual tree get_background_pattern (int &alpha)
virtual void set_background_pattern (tree t, int alpha=255)
virtual void clear_pattern (SI x1, SI y1, SI x2, SI y2)
virtual void triangle (SI x1, SI y1, SI x2, SI y2, SI x3, SI y3)
virtual void get_clipping (SI &x1, SI &y1, SI &x2, SI &y2)
void extra_clipping (SI x1, SI y1, SI x2, SI y2)
void clip (SI x1, SI y1, SI x2, SI y2)
void unclip ()
virtual void anchor (string label, SI x, SI y)
virtual void href (string label, SI x1, SI y1, SI x2, SI y2)
virtual void draw_rectangles (rectangles rs)
virtual void draw_selection (rectangles rs)

Public Attributes

SI ox
SI oy
SI cx1
SI cy1
SI cx2
SI cy2
int sfactor
int pixel
int thicken
renderer master
tree pattern
int pattern_alpha
rectangles clip_stack

Private Attributes

x_gui gui
Display * dpy
Drawable win
x_window_repx_win
int w
int h
GC gc
color cur_fg
color cur_bg

Friends

class x_gui_rep
class x_window_rep
Bool my_selnotify_predicate (Display *dpy, XEvent *ev, XPointer arg)
void abs_round (SI &l)
void abs_round (SI &x, SI &y)
void abs_inner_round (SI &x1, SI &y1, SI &x2, SI &y2)
void abs_outer_round (SI &x1, SI &y1, SI &x2, SI &y2)

Detailed Description

Definition at line 25 of file x_drawable.hpp.


Constructor & Destructor Documentation

Definition at line 29 of file x_drawable.cpp.

                                                               :
  gui (gui2), x_win (x_win2), w (0), h (0)
{
  dpy         = gui->dpy;
  gc          = gui->gc;
  cur_fg      = black;
  cur_bg      = white;
}
x_drawable_rep::x_drawable_rep ( x_gui  gui,
int  w,
int  h 
)

Definition at line 38 of file x_drawable.cpp.

                                                         :
  gui (gui2), x_win (NULL), w (w2), h (h2)
{
  dpy         = gui->dpy;
  gc          = gui->gc;
  cur_fg      = black;
  cur_bg      = white;
  win= (Drawable) XCreatePixmap (gui->dpy, gui->root, w, h, gui->depth);
}

Definition at line 48 of file x_drawable.cpp.

                                 {
  if (x_win == NULL)
    XFreePixmap (gui->dpy, (Pixmap) win);
}

Member Function Documentation

void renderer_rep::anchor ( string  label,
SI  x,
SI  y 
) [virtual, inherited]

Reimplemented in printer_rep.

Definition at line 68 of file renderer.cpp.

                                             {
  (void) label; (void) x; (void) y;
  return;
}

Here is the caller graph for this function:

void x_drawable_rep::apply_shadow ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 108 of file x_shadow.cpp.

                                                        {
  if (master == NULL) return;
  outer_round (x1, y1, x2, y2);
  decode (x1, y1);
  decode (x2, y2);
  master->as_x_drawable()->encode (x1, y1);
  master->as_x_drawable()->encode (x2, y2);
  master->put_shadow (this, x1, y1, x2, y2);
}

Here is the call graph for this function:

void x_drawable_rep::arc ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
int  alpha,
int  delta 
) [virtual]

Implements renderer_rep.

Definition at line 212 of file x_drawable.cpp.

                                                                     {
  if ((x1>=x2) || (y1>=y2)) return;
  decode (x1, y1);
  decode (x2, y2);
  XDrawArc (dpy, win, gc, x1, y2, x2-x1, y1-y2, alpha, delta);
}

Here is the call graph for this function:

Reimplemented from renderer_rep.

Definition at line 59 of file x_drawable.cpp.

                               {
  return this;
}
void x_drawable_rep::clear ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 176 of file x_drawable.cpp.

                                                 {
  x1= max (x1, cx1-ox); y1= max (y1, cy1-oy);
  x2= min (x2, cx2-ox); y2= min (y2, cy2-oy);
  // outer_round (x1, y1, x2, y2); might still be needed somewhere
  decode (x1, y1);
  decode (x2, y2);
  if ((x1>=x2) || (y1<=y2)) return;
  XSetForeground (dpy, gc, CONVERT (cur_bg));
  XFillRectangle (dpy, win, gc, x1, y2, x2-x1, y1-y2);
  XSetForeground (dpy, gc, CONVERT (blend (cur_fg, cur_bg)));
}

Here is the call graph for this function:

void renderer_rep::clear_pattern ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual, inherited]

Definition at line 254 of file renderer.cpp.

                                                       {
  if (pattern == "");
  else if (is_atomic (pattern))
    clear (x1, y1, x2, y2);
  else if (is_func (pattern, PATTERN)) {
    outer_round (x1, y1, x2, y2);
    //cout << "A: " << x1 << ", " << y1 << ", " << x2 << ", " << y2 << "\n";
    //cout << "A: " << x/pixel1 << ", " << y1 << ", " << x2 << ", " << y2 << "\n";
    SI cx1, cy1, cx2, cy2;
    get_clipping (cx1, cy1, cx2, cy2);
    extra_clipping (x1, y1, x2, y2);

    url u= as_string (pattern[0]);
    int imw_pt, imh_pt;
    image_size (u, imw_pt, imh_pt);
    double pt= ((double) 600*PIXEL) / 72.0;
    SI imw= (SI) (((double) imw_pt) * pt);
    SI imh= (SI) (((double) imh_pt) * pt);

    SI w= x2 - x1, h= y2 - y1;
    if (pattern[1] == "") w= imw;
    else if (is_int (pattern[1])) w= as_int (pattern[1]);
    else if (is_percentage (pattern[1]))
      w= (SI) (as_percentage (pattern[1]) * ((double) w));
    else if (is_percentage (pattern[1], "@"))
      w= (SI) (as_percentage (pattern[1]) * ((double) h));
    if (pattern[1] == "") h= imh;
    else if (is_int (pattern[2])) h= as_int (pattern[2]);
    else if (is_percentage (pattern[2]))
      h= (SI) (as_percentage (pattern[2]) * ((double) h));
    else if (is_percentage (pattern[2], "@"))
      h= (SI) (as_percentage (pattern[2]) * ((double) w));
    w= ((w + pixel - 1) / pixel) * pixel;
    h= ((h + pixel - 1) / pixel) * pixel;

    SI sx= 0; //is_percentage (pattern[1])? 0: ox;
    SI sy= 0; //is_percentage (pattern[2])? 0: oy;
    for (int i= ((x1+sx)/w) - 1; i <= ((x2+sx)/w) + 1; i++)
      for (int j= ((y1+sy)/h) - 1; j <= ((y2+sy)/h) + 1; j++) {
       SI X1= i*w     - sx, Y1= j*h     - sy;
       SI X2= (i+1)*w - sx, Y2= (j+1)*h - sy;
       if (X1 < x2 && X2 > x1 && Y1 < y2 && Y2 > y1)
         image (u, w, h, X1, Y1, 0.0, 0.0, 1.0, 1.0, pattern_alpha);
      }
    set_clipping (cx1, cy1, cx2, cy2, true);
  }
  else clear (x1, y1, x2, y2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::clip ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [inherited]

Definition at line 138 of file renderer.cpp.

                                              {
  rectangle r (cx1, cy1, cx2, cy2);
  clip_stack= rectangles (r, clip_stack);
  set_clipping (x1, y1, x2, y2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_drawable_rep::decode ( SI x,
SI y 
)

Definition at line 88 of file x_drawable.cpp.

                                    {
  x += ox; y += oy;
  if (x>=0) x= x/pixel; else x= (x-pixel+1)/pixel;
  if (y>=0) y= -(y/pixel); else y= -((y-pixel+1)/pixel);
}

Here is the caller graph for this function:

void x_drawable_rep::delete_shadow ( renderer ren) [virtual]

Implements renderer_rep.

Definition at line 59 of file x_shadow.cpp.

                                            {
  if (ren != NULL) {
    tm_delete (ren->as_x_drawable ());
    ren= NULL;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_drawable_rep::draw ( int  char_code,
font_glyphs  fn,
SI  x,
SI  y 
) [virtual]

Implements renderer_rep.

Definition at line 69 of file x_font.cpp.

                                                        {
  // get the pixmap
  x_character xc (c, fng, sfactor, cur_fg, cur_bg);
  Pixmap pm= (Pixmap) gui->character_pixmap [xc];
  if (pm == 0) {
    gui->prepare_color (sfactor, cur_fg, cur_bg);
    x_character col_entry (0, font_glyphs (), sfactor, cur_fg, cur_bg);
    color* cols= (color*) gui->color_scale [col_entry];
    SI xo, yo;
    glyph pre_gl= fng->get (c); if (is_nil (pre_gl)) return;
    glyph gl= shrink (pre_gl, sfactor, sfactor, xo, yo);
    int i, j, w= gl->width, h= gl->height;
    pm= XCreatePixmap (gui->dpy, gui->root, w, h, gui->depth);
    for (j=0; j<h; j++)
      for (i=0; i<w; i++) {
       color col= cols [gl->get_x(i,j)];
       XSetForeground (gui->dpy, gui->pixmap_gc, CONVERT (col));
       XDrawPoint (gui->dpy, (Drawable) pm, gui->pixmap_gc, i, j);
      }
    gui->character_pixmap (xc)= (pointer) pm;
  }

  // get the bitmap
  xc= x_character (c, fng, sfactor, 0, 0);
  Bitmap bm= (Bitmap) gui->character_bitmap [xc];
  if (bm == NULL) {
    SI xo, yo;
    glyph pre_gl= fng->get (c); if (is_nil (pre_gl)) return;
    glyph gl= shrink (pre_gl, sfactor, sfactor, xo, yo);
    int i, j, b, on, w= gl->width, h= gl->height;
    int byte_width= ((w-1)>>3)+1;
    char* data= tm_new_array<char> (byte_width * h);
    for (i=0; i<(byte_width * h); i++) data[i]=0;

    for (j=0; j<h; j++)
      for (i=0; i<w; i++) {
       b = j*byte_width + (i>>3);
       on= (gl->get_x(i,j)!=0 ? 1:0);
       if (on) data[b]= data[b] | (1<<(i&7));
      }
    bm= tm_new<Bitmap_rep> ();
    bm->bm    = XCreateBitmapFromData (gui->dpy, gui->root, data, w, h);
    bm->width = gl->width;
    bm->height= gl->height;
    bm->xoff  = xo;
    bm->yoff  = yo;
    gui->character_bitmap (xc)= (pointer) bm;
    tm_delete_array (data);
  }

  // draw the character
  draw_clipped (pm, bm->bm, bm->width, bm->height,
              x- bm->xoff*sfactor, y+ bm->yoff*sfactor);
}

Here is the call graph for this function:

void x_drawable_rep::draw_clipped ( Pixmap  pm,
Pixmap  bm,
int  w,
int  h,
SI  x,
SI  y 
)

Definition at line 26 of file x_font.cpp.

                                                                            {
  int x1=cx1-ox, y1=cy2-oy, x2= cx2-ox, y2= cy1-oy;
  decode (x , y );
  decode (x1, y1);
  decode (x2, y2);
  y--; // top-left origin to bottom-left origin conversion
  int X1= max (x1- x, 0); if (X1>=w) return;
  int Y1= max (y1- y, 0); if (Y1>=h) return;
  int X2= min (x2- x, w); if (X2<0) return;
  int Y2= min (y2- y, h); if (Y2<0) return;

  if (char_clip) {
#ifdef OS_WIN32_LATER
    /*
    int X, Y, N;
    for (Y=Y1; Y<Y2; Y++) {
      for (X=X1, N=0; X<X2; X++) {
       if (XGetBitmapPixel (bm, X, Y)) N++;
       else {
         if (N > 0)
           XCopyArea (dpy, (Drawable)pm, win, gc, X-N, Y, N, 1, x+X1-N, y+Y1);
         N= 0;
       }
      }
      if (N > 0)
       XCopyArea (dpy, (Drawable)pm, win, gc, X, Y-N, N, 1, x+X1-N, y+Y1);
    }
    */
    XCopyClipped (dpy, (Drawable) pm, (Drawable) bm, win, gc,
                X, Y-N, N, 1, x+X1-N, y+Y1);
    // FIXME: Dan should write a routine for this.
#else
    XSetClipMask (dpy, gc, bm);
    XSetClipOrigin (dpy, gc, x, y);
    XCopyArea (dpy, (Drawable) pm, win, gc, X1, Y1, X2-X1, Y2-Y1, x+X1, y+Y1);
    set_clipping (cx1- ox, cy1- oy, cx2- ox, cy2- oy);
#endif
  }
  else
    XCopyArea (dpy, (Drawable) pm, win, gc, X1, Y1, X2-X1, Y2-Y1, x+X1, y+Y1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::draw_rectangles ( rectangles  rs) [virtual, inherited]

Definition at line 310 of file renderer.cpp.

                                            {
  rectangles it= rs;
  while (!is_nil (it)) {
    fill (it->item->x1, it->item->y1, it->item->x2, it->item->y2);
    it= it->next;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::draw_selection ( rectangles  rs) [virtual, inherited]

Definition at line 319 of file renderer.cpp.

                                           {
  color fg= get_color ();
  int r, g, b, a;
  get_rgb_color (fg, r, g, b, a);
  color pfg= rgb_color (r, g, b, (a + 1) / 16);
  rectangles inn= ::thicken (rs, -pixel, -pixel);
  rectangles out= ::simplify (::correct (rs - inn));
  set_color (pfg);
  draw_rectangles (::simplify (inn));
  set_color (fg);
  draw_rectangles (out);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_drawable_rep::encode ( SI x,
SI y 
)

Definition at line 82 of file x_drawable.cpp.

                                    {
  x= (x*pixel) - ox;
  y= ((-y)*pixel) - oy;
}

Here is the caller graph for this function:

void renderer_rep::extra_clipping ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [inherited]

Definition at line 129 of file renderer.cpp.

                                                        {
  SI ox1, oy1, ox2, oy2;
  get_clipping (ox1, oy1, ox2, oy2);
  x1= max (x1, ox1); y1= max (y1, oy1);
  x2= max (x1, min (x2, ox2)); y2= max (y1, min (y2, oy2));
  set_clipping (x1, y1, x2, y2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_drawable_rep::fetch ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
renderer  ren,
SI  x,
SI  y 
) [virtual]

Implements renderer_rep.

Definition at line 19 of file x_shadow.cpp.

                                                                           {
  ASSERT (ren != NULL, "invalid situation");
  if (ren->is_printer ()) return;
  x_drawable_rep* src= ren->as_x_drawable ();
  if (src->win == win && x1 == x && y1 == y) return;
  outer_round (x1, y1, x2, y2);
  SI X1= x1, Y1= y1;
  x1= max (x1, cx1- ox);
  y1= max (y1, cy1- oy);
  x2= min (x2, cx2- ox);
  y2= min (y2, cy2- oy);
  src->decode (X1, Y1);
  src->decode (x1, y1);
  src->decode (x2, y2);
  decode (x, y);
  x += x1 - X1;
  y += y2 - Y1;
  if (x1<x2 && y2<y1)
    XCopyArea (dpy, src->win, win, gc, x, y, x2-x1, y1-y2, x1, y2);
}

Here is the call graph for this function:

void x_drawable_rep::fill ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 189 of file x_drawable.cpp.

                                                {
  if ((x2>x1) && ((x2-x1)<pixel)) {
    SI d= pixel-(x2-x1);
    x1 -= (d>>1);
    x2 += ((d+1)>>1);
  }
  if ((y2>y1) && ((y2-y1)<pixel)) {
    SI d= pixel-(y2-y1);
    y1 -= (d>>1);
    y2 += ((d+1)>>1);
  }

  x1= max (x1, cx1-ox); y1= max (y1, cy1-oy);
  x2= min (x2, cx2-ox); y2= min (y2, cy2-oy);
  // outer_round (x1, y1, x2, y2); might still be needed somewhere
  if ((x1>=x2) || (y1>=y2)) return;

  decode (x1, y1);
  decode (x2, y2);
  XFillRectangle (dpy, win, gc, x1, y2, x2-x1, y1-y2);
}

Here is the call graph for this function:

void x_drawable_rep::fill_arc ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
int  alpha,
int  delta 
) [virtual]

Implements renderer_rep.

Definition at line 220 of file x_drawable.cpp.

                                                                          {
  if ((x1>=x2) || (y1>=y2)) return;
  decode (x1, y1);
  decode (x2, y2);
  XFillArc (dpy, win, gc, x1, y2, x2-x1, y1-y2, alpha, delta);
}

Here is the call graph for this function:

Implements renderer_rep.

Definition at line 126 of file x_drawable.cpp.

                                {
  return cur_bg;
}
tree renderer_rep::get_background_pattern ( int &  alpha) [virtual, inherited]

Definition at line 238 of file renderer.cpp.

                                                {
  alpha= pattern_alpha;
  if (is_atomic (pattern) || is_func (pattern, PATTERN, 4))
    return pattern;
  else {
    tree s= get_named_color (get_background ());
    if (is_func (pattern, PATTERN, 3))
      return pattern * tree (PATTERN, s);
    else return s;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::get_clipping ( SI x1,
SI y1,
SI x2,
SI y2 
) [virtual, inherited]

Definition at line 115 of file renderer.cpp.

                                                          {
  x1= cx1- ox; y1= cy1- oy;
  x2= cx2- ox; y2= cy2- oy;
}

Here is the caller graph for this function:

Implements renderer_rep.

Definition at line 121 of file x_drawable.cpp.

                           {
  return cur_fg;
}
void x_drawable_rep::get_extents ( int &  w,
int &  h 
) [virtual]

Reimplemented from renderer_rep.

Definition at line 64 of file x_drawable.cpp.

                                             {
  if (x_win != NULL) return x_win->get_extents (w2, h2);
  else {
    w2= w;
    h2= h;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_drawable_rep::get_shadow ( renderer  ren,
SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 67 of file x_shadow.cpp.

                                                                    {
  // FIXME: we should use the routine fetch later
  ASSERT (ren != NULL, "invalid renderer");
  if (ren->is_printer ()) return;
  x_drawable_rep* shadow= ren->as_x_drawable ();
  outer_round (x1, y1, x2, y2);
  x1= max (x1, cx1- ox);
  y1= max (y1, cy1- oy);
  x2= min (x2, cx2- ox);
  y2= min (y2, cy2- oy);
  shadow->ox= ox;
  shadow->oy= oy;
  shadow->cx1= x1+ ox;
  shadow->cy1= y1+ oy;
  shadow->cx2= x2+ ox;
  shadow->cy2= y2+ oy;
  shadow->master= this;
  decode (x1, y1);
  decode (x2, y2);
  if (x1<x2 && y2<y1)
    XCopyArea (dpy, win, shadow->win, gc, x1, y2, x2-x1, y1-y2, x1, y2);
}

Here is the call graph for this function:

void renderer_rep::href ( string  label,
SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual, inherited]

Reimplemented in printer_rep.

Definition at line 74 of file renderer.cpp.

                                                           {
  (void) label;
  (void) x1; (void) y1; (void) x2; (void) y2;
  return;
}

Here is the caller graph for this function:

void x_drawable_rep::image ( url  u,
SI  w,
SI  h,
SI  x,
SI  y,
double  cx1,
double  cy1,
double  cx2,
double  cy2,
int  alpha 
) [virtual]

Implements renderer_rep.

Definition at line 376 of file x_drawable.cpp.

{
  // Given an image of original size (W, H),
  // we display the part (cx1 * W, xy1 * H, cx2 * W, cy2 * H)
  // at position (x, y) in a rectangle of size (w, h)
  (void) alpha; // FIXME

  w= w/pixel; h= h/pixel;
  decode (x, y);

  if (gui->gswindow == NULL) {
    SI max_w= gui->screen_width  * PIXEL;
    SI max_h= gui->screen_height * PIXEL;
    //widget dummy= text_widget (0, "ghostscript window");
    if (ghostscript_bugged ()) {
      max_w *= 2;
      max_h *= 2;
      //dummy= glue_widget (false, false, max_w, max_h);
    }
    widget dummy = glue_widget (false, false, max_w, max_h);
    widget win   = plain_window_widget (dummy, "Ghostscript");
    gui->gswindow= get_x_window (win);
    //gui->gswindow= tm_new<x_window_rep> (dummy, gui, "ghostscript", 0, 0);
    //gui->gswindow= tm_new<x_window_rep> (dummy, gui, "ghostscript",
    //max_w, max_h, max_w, max_h, max_w, max_h);
    nr_windows--; // the dummy window should not be counted
  }

  Pixmap pm;
  tree lookup= tuple (u->t);
  lookup << as_string (w ) << as_string (h )
        << as_string (cx1) << as_string (cy1)
        << as_string (cx2) << as_string (cy2);
  if (cache_image->contains (lookup)) pm= (Pixmap) cache_image [lookup];
  else {
    // rendering
    Window gs_win= gui->gswindow->win;

    // XCreatePixmap does not allow for zero sized images.
    // This fixes bug #10425.
    w = (w==0 ? 1 : w);
    h = (h==0 ? 1 : h);

    pm= XCreatePixmap (gui->dpy, gs_win, w, h, gui->depth);
    if (imlib2_supports (u))
      imlib2_display (dpy, pm, u, w, h, cx1, cy1, cx2, cy2);
    else {
      //XSetForeground (dpy, gc, white);
      //XFillRectangle (dpy, pm, gc, 0, 0, w, h);
      ghostscript_run (dpy, gs_win, pm, u, w, h, cx1, cy1, cx2, cy2);
    }

    // caching
    if (N(cache_image_nr) == 0) cache_image_last_gc= texmacs_time ();
    cache_image      (lookup)= (int) pm;
    cache_image_w    (lookup)= w;
    cache_image_h    (lookup)= h;
    cache_image_time (lookup)= texmacs_time ();
    cache_image_nr   (lookup)= cache_image_nr [lookup] + 1;
    cache_image_tot_size += w*h;
    if (cache_image_tot_size > cache_image_max_size) {
      gui->image_auto_gc ();
      if (cache_image_tot_size > cache_image_max_size)
       cache_image_max_size= cache_image_tot_size << 1;
    }
  }

  XCopyArea (dpy, (Drawable) pm, win, gc, 0, 0, w, h, x, y-h);
}

Here is the call graph for this function:

void renderer_rep::inner_round ( SI x1,
SI y1,
SI x2,
SI y2 
) [inherited]

Definition at line 167 of file renderer.cpp.

                                                         {
  x1= RND (x1+ox+pixel-1) - ox;
  y1= RND (y1+oy+pixel-1) - oy;
  x2= RND (x2+ox) - ox;
  y2= RND (y2+oy) - oy;
}
bool x_drawable_rep::interrupted ( bool  check = false) [virtual]

Reimplemented from renderer_rep.

Definition at line 73 of file x_drawable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool renderer_rep::is_printer ( ) [virtual, inherited]

Reimplemented in pdf_renderer_rep, and printer_rep.

Definition at line 33 of file renderer.cpp.

                          {
  return false;
}

Here is the caller graph for this function:

bool renderer_rep::is_visible ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [inherited]

Definition at line 152 of file renderer.cpp.

                                                    {
  return
    (x2 >= (cx1- ox)) && (y2 >= (cy1- oy)) &&
    (x1 <  (cx2- ox)) && (y1 <  (cy2- oy));
}

Here is the caller graph for this function:

bool x_drawable_rep::is_x_drawable ( ) [virtual]

Reimplemented from renderer_rep.

Definition at line 54 of file x_drawable.cpp.

                               {
  return true;
}
void x_drawable_rep::line ( SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 153 of file x_drawable.cpp.

                                                {
  decode (x1, y1);
  decode (x2, y2);
  y1--; y2--; // top-left origin to bottom-left origin conversion
  XDrawLine (dpy, win, gc, x1, y1, x2, y2);
}

Here is the call graph for this function:

void x_drawable_rep::lines ( array< SI x,
array< SI y 
) [virtual]

Implements renderer_rep.

Definition at line 161 of file x_drawable.cpp.

                                               {
  int i, n= N(x);
  if ((N(y) != n) || (n<1)) return;
  STACK_NEW_ARRAY (pnt, XPoint, n);
  for (i=0; i<n; i++) {
    SI xx= x[i], yy= y[i];
    decode (xx, yy);
    pnt[i].x= xx;
    pnt[i].y= yy;
  }
  XDrawLines (dpy, win, gc, pnt, n, CoordModeOrigin);
  STACK_DELETE_ARRAY (pnt);
}

Here is the call graph for this function:

void renderer_rep::move_origin ( SI  dx,
SI  dy 
) [inherited]

Definition at line 92 of file renderer.cpp.

                                       {
  ox += dx;
  oy += dy;
}

Here is the caller graph for this function:

void x_drawable_rep::new_shadow ( renderer ren) [virtual]

Implements renderer_rep.

Definition at line 45 of file x_shadow.cpp.

                                         {
  SI mw, mh, sw, sh;
  ((renderer) this) -> get_extents (mw, mh);
  if (ren != NULL) {
    ren->get_extents (sw, sh);
    if (sw == mw && sh == mh) return;
    //cout << "Old: " << sw << ", " << sh << "\n";
    delete_shadow (ren);
  }
  //cout << "Create " << mw << ", " << mh << "\n";
  ren= (renderer) tm_new<x_drawable_rep> (gui, mw, mh);
}

Here is the call graph for this function:

void renderer_rep::next_page ( ) [virtual, inherited]

Reimplemented in pdf_renderer_rep, printer_rep, and cg_renderer_rep.

Definition at line 53 of file renderer.cpp.

                         {
}

Here is the caller graph for this function:

void renderer_rep::outer_round ( SI x1,
SI y1,
SI x2,
SI y2 
) [inherited]

Definition at line 175 of file renderer.cpp.

                                                         {
  x1= RND (x1+ox) - ox;
  y1= RND (y1+oy) - oy;
  x2= RND (x2+ox+pixel-1) - ox;
  y2= RND (y2+oy+pixel-1) - oy;
}

Here is the caller graph for this function:

void x_drawable_rep::polygon ( array< SI x,
array< SI y,
bool  convex = true 
) [virtual]

Implements renderer_rep.

Definition at line 228 of file x_drawable.cpp.

                                                              {
  int i, n= N(x);
  if ((N(y) != n) || (n<1)) return;
  STACK_NEW_ARRAY (pnt, XPoint, n);
  for (i=0; i<n; i++) {
    SI xx= x[i], yy= y[i];
    decode (xx, yy);
    pnt[i].x= xx;
    pnt[i].y= yy;
  }
  XFillPolygon (dpy, win, gc, pnt, n, convex?Convex:Complex, CoordModeOrigin);
  STACK_DELETE_ARRAY (pnt);
}

Here is the call graph for this function:

void x_drawable_rep::put_shadow ( renderer  ren,
SI  x1,
SI  y1,
SI  x2,
SI  y2 
) [virtual]

Implements renderer_rep.

Definition at line 91 of file x_shadow.cpp.

                                                                    {
  // FIXME: we should use the routine fetch later
  ASSERT (ren != NULL, "invalid renderer");
  if (ren->is_printer ()) return;
  x_drawable_rep* shadow= ren->as_x_drawable ();
  outer_round (x1, y1, x2, y2);
  x1= max (x1, cx1- ox);
  y1= max (y1, cy1- oy);
  x2= min (x2, cx2- ox);
  y2= min (y2, cy2- oy);
  decode (x1, y1);
  decode (x2, y2);
  if (x1<x2 && y2<y1)
    XCopyArea (dpy, shadow->win, win, gc, x1, y2, x2-x1, y1-y2, x1, y2);
}

Here is the call graph for this function:

bool renderer_rep::repainted ( ) [virtual, inherited]

Definition at line 57 of file renderer.cpp.

                         {
  return true;
}
void renderer_rep::round ( SI x,
SI y 
) [inherited]

Definition at line 161 of file renderer.cpp.

                                 {
  x= RND (x+ ox)- ox;
  y= RND (y+ oy)- oy;
}
void x_drawable_rep::set_background ( color  c) [virtual]

Implements renderer_rep.

Definition at line 137 of file x_drawable.cpp.

                                       {
  cur_bg= c;
  XSetBackground (dpy, gc, CONVERT (cur_bg));
}
void renderer_rep::set_background_pattern ( tree  t,
int  alpha = 255 
) [virtual, inherited]

Definition at line 227 of file renderer.cpp.

                                                         {
  pattern= pat;
  pattern_alpha= alpha;
  if (pattern == "");
  else if (is_atomic (pattern))
    set_background (named_color (pat->label, alpha));
  else if (is_func (pattern, PATTERN, 4))
    set_background (named_color (as_string (pattern[3]), alpha));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_drawable_rep::set_clipping ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
bool  restore = false 
) [virtual]

Reimplemented from renderer_rep.

Definition at line 99 of file x_drawable.cpp.

                                                                      {
  (void) restore;
  outer_round (x1, y1, x2, y2);
  renderer_rep::set_clipping (x1, y1, x2, y2);
  Region region= XCreateRegion ();
  decode (x1, y1);
  decode (x2, y2);
  XRectangle r;
  r.x     = x1;
  r.y     = y2;
  r.width = x2-x1;
  r.height= y1-y2;
  XUnionRectWithRegion (&r, region, region);
  XSetRegion (dpy, gc, region);
  XDestroyRegion (region);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_drawable_rep::set_color ( color  c) [virtual]

Implements renderer_rep.

Definition at line 131 of file x_drawable.cpp.

                                  {
  cur_fg= c;
  XSetForeground (dpy, gc, CONVERT (blend (cur_fg, cur_bg)));
}

Here is the call graph for this function:

void x_drawable_rep::set_line_style ( SI  w,
int  type = 0,
bool  round = true 
) [virtual]

Implements renderer_rep.

Definition at line 143 of file x_drawable.cpp.

                                                           { (void) type;
  if (lw <= pixel)
    XSetLineAttributes (dpy, (GC) gc, 1,
                     LineSolid, round?CapRound:CapButt, JoinRound);
  else
    XSetLineAttributes (dpy, (GC) gc, (lw+thicken) / pixel,
                     LineSolid, round?CapRound:CapButt, JoinRound);
}
void renderer_rep::set_origin ( SI  x,
SI  y 
) [inherited]

Definition at line 86 of file renderer.cpp.

                                    {
  ox= x;
  oy= y;
}

Here is the caller graph for this function:

void renderer_rep::set_shrinking_factor ( int  sfactor) [inherited]

Definition at line 98 of file renderer.cpp.

                                          {
  ox  /= sfactor; oy  /= sfactor;
  cx1 /= sfactor; cy1 /= sfactor;
  cx2 /= sfactor; cy2 /= sfactor;
  sfactor= sf;
  pixel  = sf*PIXEL;
  thicken= (sf>>1)*PIXEL;
  ox  *= sfactor; oy  *= sfactor;
  cx1 *= sfactor; cy1 *= sfactor;
  cx2 *= sfactor; cy2 *= sfactor;
}

Here is the caller graph for this function:

void renderer_rep::triangle ( SI  x1,
SI  y1,
SI  x2,
SI  y2,
SI  x3,
SI  y3 
) [virtual, inherited]

Definition at line 218 of file renderer.cpp.

                                                                {
  array<SI> x (3), y (3);
  x[0]= x1; y[0]= y1;
  x[1]= x2; y[1]= y2;
  x[2]= x3; y[2]= y3;
  polygon (x, y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void renderer_rep::unclip ( ) [inherited]

Definition at line 145 of file renderer.cpp.

                      {
  rectangle r (clip_stack->item);
  set_clipping (r->x1- ox, r->y1- oy, r->x2- ox, r->y2- oy);
  clip_stack= clip_stack->next;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void x_drawable_rep::xpm ( url  file_name,
SI  x,
SI  y 
) [virtual]

Implements renderer_rep.

Definition at line 347 of file x_drawable.cpp.

                                              {
  y -= pixel; // counter balance shift in draw_clipped
  if (!gui->xpm_pixmap->contains (as_string (file_name)))
    xpm_initialize (file_name);
  ASSERT (sfactor == 1, "shrinking factor should be 1");
  int w, h;
  xpm_size (file_name, w, h);
  Pixmap bm= (Pixmap) gui->xpm_bitmap [as_string (file_name)];
  Pixmap pm= (Pixmap) gui->xpm_pixmap [as_string (file_name)];
  int old_clip= char_clip;
  char_clip= true;
  draw_clipped (pm, bm, w, h, x, y);
  char_clip=old_clip;
}

Here is the call graph for this function:

void x_drawable_rep::xpm_initialize ( url  file_name)

Definition at line 247 of file x_drawable.cpp.

                                             {
  tree t= xpm_load (file_name);

  // get main info
  int ok, i=0, j, k, w, h, c, b, x, y;
  string s= as_string (t[0]);
  skip_spaces (s, i);
  ok= read_int (s, i, w);
  skip_spaces (s, i);
  ok= read_int (s, i, h) && ok;
  skip_spaces (s, i);
  ok= read_int (s, i, c) && ok;
  skip_spaces (s, i);
  ok= read_int (s, i, b) && ok;
  if ((!ok) || (N(t)<(c+1)) || (c<=0)) {
    cerr << "file_name= " << file_name << "\n";
    FAILED ("invalid xpm");
  }

  // setup colors
  string first_name;
  hashmap<string,int> pmcs(0);
  hashmap<string,int> bmcs(1);
  for (k=0; k<c; k++) {
    string s   = as_string (t[k+1]);
    string name= "";
    string def = "none";
    if (N(s)<b) i=N(s);
    else { name= s(0,b); i=b; }
    if (k==0) first_name= name;

    skip_spaces (s, i);
    if ((i<N(s)) && (s[i]=='s')) {
      i++;
      skip_spaces (s, i);
      while ((i<N(s)) && (s[i]!=' ') && (s[i]!='\t')) i++;
      skip_spaces (s, i);
    }
    if ((i<N(s)) && (s[i]=='c')) {
      i++;
      skip_spaces (s, i);
      j=i;
      while ((i<N(s)) && (s[i]!=' ') && (s[i]!='\t')) i++;
      def= locase_all (s (j, i));
    }
    if (def == "none") {
      bmcs(name)= 0;
      def= "lightgrey";
    }
    else bmcs(name)= 1;
 /* FIXME: to avoid code duplication, replace this code by
      a call to xpm_colors(), plus the appropriate code to
      fill bmcs() & set first_name. */

    char* _def= as_charp (def);
    XColor exact, closest;
    XLookupColor (gui->dpy, gui->cols, _def, &exact, &closest);
    if (!reverse_colors && XAllocColor (gui->dpy, gui->cols, &exact))
      pmcs(name)= exact.pixel;
    else if (!reverse_colors && XAllocColor (gui->dpy, gui->cols, &closest))
      pmcs(name)= closest.pixel;
    else {
      color myc= rgb_color (exact.red/256, exact.green/256, exact.blue/256);
      pmcs(name)= CONVERT (myc);
    }
    tm_delete_array (_def);
  }

  // setup bitmap and pixmap
  Pixmap pm= XCreatePixmap (gui->dpy, gui->root, w, h, gui->depth);
  int byte_width= ((w-1)>>3)+1;
  char* data= tm_new_array<char> (byte_width * h);
  for (i=0; i<(byte_width * h); i++) data[i]=0;
  for (y=0; y<h; y++) {
    if (N(t)< (y+c+1)) s= "";
    else s= as_string (t[y+c+1]);
    for (x=0; x<w; x++) {
      string name;
      int bit;
      if (N(s)<(b*(x+1))) name= first_name;
      else name= s (b*x, b*(x+1));
      int bmc= bmcs[name];
      int pmc= pmcs[name];
      if (!bmcs->contains (name)) bmc= bmcs[first_name];
      if (!pmcs->contains (name)) pmc= pmcs[first_name];
      XSetForeground (gui->dpy, gui->pixmap_gc, pmc);
      XDrawPoint (gui->dpy, (Drawable) pm, gui->pixmap_gc, x, y);
      bit= y*byte_width + (x>>3);
      if (bmc!=0) data[bit]= data[bit] | (1<<(x&7));      
    }
  }
  Pixmap bm= XCreateBitmapFromData (gui->dpy, gui->root, data, w, h);
  gui->xpm_pixmap (as_string (file_name))= (int) pm;
  gui->xpm_bitmap (as_string (file_name))= (int) bm;
  tm_delete_array (data);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

void abs_inner_round ( SI x1,
SI y1,
SI x2,
SI y2 
) [friend, inherited]

Definition at line 198 of file renderer.cpp.

                                                 {
  x1= RND (x1+PIXEL-1);
  y1= RND (y1+PIXEL-1);
  x2= RND (x2);
  y2= RND (y2);
}
void abs_outer_round ( SI x1,
SI y1,
SI x2,
SI y2 
) [friend, inherited]

Definition at line 206 of file renderer.cpp.

                                                 {
  x1= RND (x1);
  y1= RND (y1);
  x2= RND (x2+PIXEL-1);
  y2= RND (y2+PIXEL-1);
}
void abs_round ( SI l) [friend, inherited]

Definition at line 187 of file renderer.cpp.

                  {
  l= RND (l);
}
void abs_round ( SI x,
SI y 
) [friend, inherited]

Definition at line 192 of file renderer.cpp.

                         {
  x= RND (x);
  y= RND (y);
}
Bool my_selnotify_predicate ( Display *  dpy,
XEvent *  ev,
XPointer  arg 
) [friend]

Definition at line 196 of file x_gui.cpp.

                                                                { (void) dpy;
  x_window win= (x_window) arg;
  return (win->win==ev->xany.window) && (ev->type==SelectionNotify);
}
friend class x_gui_rep [friend]

Definition at line 83 of file x_drawable.hpp.

friend class x_window_rep [friend]

Definition at line 84 of file x_drawable.hpp.


Member Data Documentation

Definition at line 44 of file renderer.hpp.

Definition at line 32 of file x_drawable.hpp.

Definition at line 32 of file x_drawable.hpp.

SI renderer_rep::cx1 [inherited]

Definition at line 37 of file renderer.hpp.

SI renderer_rep::cx2 [inherited]

Definition at line 37 of file renderer.hpp.

SI renderer_rep::cy1 [inherited]

Definition at line 37 of file renderer.hpp.

SI renderer_rep::cy2 [inherited]

Definition at line 37 of file renderer.hpp.

Display* x_drawable_rep::dpy [private]

Definition at line 27 of file x_drawable.hpp.

GC x_drawable_rep::gc [private]

Definition at line 31 of file x_drawable.hpp.

Definition at line 26 of file x_drawable.hpp.

int x_drawable_rep::h [private]

Definition at line 30 of file x_drawable.hpp.

Reimplemented in qt_shadow_renderer_rep.

Definition at line 41 of file renderer.hpp.

SI renderer_rep::ox [inherited]

Definition at line 36 of file renderer.hpp.

SI renderer_rep::oy [inherited]

Definition at line 36 of file renderer.hpp.

Definition at line 42 of file renderer.hpp.

int renderer_rep::pattern_alpha [inherited]

Definition at line 43 of file renderer.hpp.

int renderer_rep::pixel [inherited]

Definition at line 39 of file renderer.hpp.

int renderer_rep::sfactor [inherited]

Definition at line 38 of file renderer.hpp.

int renderer_rep::thicken [inherited]

Definition at line 40 of file renderer.hpp.

int x_drawable_rep::w [private]

Definition at line 30 of file x_drawable.hpp.

Drawable x_drawable_rep::win [private]

Definition at line 28 of file x_drawable.hpp.

Definition at line 29 of file x_drawable.hpp.


The documentation for this class was generated from the following files: