Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Protected Attributes
cell_rep Class Reference

#include <table.hpp>

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

List of all members.

Public Member Functions

 cell_rep (edit_env env)
void typeset (tree fm, tree t, path ip)
void format_cell (tree fm)
void format_item (tree with)
void compute_width (SI &mw, SI &lw, SI &rw, bool large)
void compute_height (SI &mh, SI &bh, SI &th)
void position_horizontally (SI offset, SI mw, SI lw, SI rw)
void position_vertically (SI offset, SI mh, SI bh, SI th)
void finish_horizontal ()
void finish ()

Public Attributes

edit_env env
path ip
lazy lz
box b
SI xoff
SI yoff
SI x1
SI y1
SI x2
SI y2
SI shift
tree decoration
tree bg
bool orientation
SI width
SI height
double hpart
double vpart
SI lsep
SI rsep
SI bsep
SI tsep
SI lborder
SI rborder
SI bborder
SI tborder
string hmode
string vmode
string halign
string valign
string vcorrect
string hyphen
int row_span
int col_span
table D
table T
int ref_count

Protected Attributes

hashmap< string, treevar

Detailed Description

Definition at line 98 of file table.hpp.


Constructor & Destructor Documentation

Definition at line 20 of file cell.cpp.

: var (""), env (env2) {}

Member Function Documentation

void cell_rep::compute_height ( SI mh,
SI bh,
SI th 
)

Definition at line 273 of file cell.cpp.

                                                {
  char align_c= '\0'; if (N (valign) != 0) align_c= valign[0];
  if (is_nil (T)) {
    bh= th= mh= 0;
    if (align_c >= 'A' && align_c <= 'Z') {
      bh= -b->y1+ bsep + bborder;
      th=  b->y2+ tsep + tborder;
      mh=  bh + th;
    }
    else mh= b->h() + bsep + tsep + bborder + tborder;
  }
  else {
    if (N (T->valign) != 0) align_c= T->valign[0];
    T->compute_height (mh, bh, th);
    if (align_c >= 'A' && align_c <= 'Z') {
      bh += bborder;
      th += tborder;
    }
    else bh= th= 0;
    mh += bborder + tborder;
  }

  if (vmode == "exact") mh= height;
  else if (vmode == "max") mh= max (height, mh);
  else if (vmode == "min") mh= min (height, mh);
  if (mh < bh + th) {
    SI d= bh + th - mh;
    if (align_c == 'B' || align_c == 'O') th -= d;
    else if (align_c == 'C') { bh -= (d >> 1); th -= ((d+1) >> 1); }
    else bh -= d;
  }
}

Here is the call graph for this function:

void cell_rep::compute_width ( SI mw,
SI lw,
SI rw,
bool  large 
)

Definition at line 216 of file cell.cpp.

                                                           {
  //cout << "  large= " << large << "\n";
  char align_c= '\0'; if (N (halign) != 0) align_c= halign[0];
  bool lr_flag= (align_c >= 'A' && align_c <= 'Z');
  if (!is_nil (T)) {
    if (N (T->halign) > 0) align_c= T->halign[0];
    else align_c= '\0';
    lr_flag= (align_c >= 'A' && align_c <= 'Z');
    T->compute_width (mw, lw, rw);
    if (lr_flag) {
      lw += lborder;
      rw += rborder;
    }
    else lw= rw= 0;
    mw += lborder + rborder;
  }
  else if (!is_nil (lz) && large) {
    lw= rw= 0;
    format fm= lz->query (LAZY_BOX, make_query_vstream_width (0, 0));
    format_width fw= (format_width) fm;
    mw= fw->width + lsep + rsep + lborder + rborder;
    if (lr_flag) {
      lw= lsep + lborder;
      rw= fw->width + rsep + rborder;
    }
  }
  else {
    //cout << "  b= " << b << "\n";
    lw= rw= mw= 0;
    if (lr_flag) {
      if (N (halign) == 1) {
       lw= -b->x1+ lsep + lborder;
       rw=  b->x2+ rsep + rborder;
       mw=  lw + rw;
      }
      else {
       SI offset= b->get_leaf_offset (halign (1, N (halign)));
       lw= offset+ lsep+ lborder;
       rw= b->w()- offset+ rsep+ rborder;
       mw= lw + rw;
      }
    }
    else mw= b->w() + lsep + rsep + lborder + rborder;
  }

  if (hmode == "exact") mw= width;
  else if (hmode == "max") mw= max (width, mw);
  else if (hmode == "min") mw= min (width, mw);
  if (mw < lw + rw) {
    SI d= lw + rw - mw;
    if (align_c == 'L' || align_c == 'O') rw -= d;
    else if (align_c == 'C') { lw -= (d >> 1); rw -= ((d+1) >> 1); }
    else lw -= d;
  }
}

Here is the call graph for this function:

void cell_rep::finish ( )

Definition at line 355 of file cell.cpp.

                  {
  if (!is_nil (T)) {
    T->finish ();
    b= T->b;
  }

  color fc= env->col;

  b= cell_box (ip, b, xoff, yoff, 0, 0, x2-x1, y2-y1,
              lborder, rborder, bborder, tborder,
               fc, bg, env->alpha);
}

Here is the call graph for this function:

Definition at line 346 of file cell.cpp.

                             {
  SI  w= width- lsep- lborder- rsep- rborder;
  int v= hyphen == "t"? 1: (hyphen == "c"? 0: -1);
  SI  d= ((vcorrect == "b") || (vcorrect == "a"))? -env->fn->y1: 0;
  SI  h= ((vcorrect == "t") || (vcorrect == "a"))?  env->fn->y2: 0;
  b= (box) lz->produce (LAZY_BOX, make_format_cell (w, v, d, h));
}

Here is the call graph for this function:

Definition at line 122 of file cell.cpp.

                              {
  int i, l= N(fm);
  for (i=0; i<l; i++)
    format_item (fm[i]);

  if (var->contains (CELL_DECORATION))
    decoration= env->exec (var[CELL_DECORATION]);
  else decoration= "";
  if (var->contains (CELL_BACKGROUND)) {
    bg= env->exec (var[CELL_BACKGROUND]);
    if (bg == "foreground") bg= env->get_string (COLOR);
  }
  else bg= "";
  if (var->contains (CELL_WIDTH)) {
    width= env->as_length (env->exec (var[CELL_WIDTH]));
    if (var->contains (CELL_HMODE))
      hmode= as_string (env->exec (var[CELL_HMODE]));
    else hmode= "exact";
  }
  else {
    width= 0;
    hmode= "auto";
  }
  if (var->contains (CELL_HEIGHT)) {
    height= env->as_length (env->exec (var[CELL_HEIGHT]));
    if (var->contains (CELL_VMODE))
      vmode= as_string (env->exec (var[CELL_VMODE]));
    else vmode= "exact";
  }
  else {
    height= 0;
    vmode = "auto";
  }
  if (var->contains (CELL_HPART))
    hpart= as_double (env->exec (var[CELL_HPART]));
  else hpart= 0.0;
  if (var->contains (CELL_VPART))
    vpart= as_double (env->exec (var[CELL_VPART]));
  else vpart= 0.0;
  if (var->contains (CELL_LSEP))
    lsep= env->as_length (env->exec (var[CELL_LSEP]));
  else lsep= env->fn->spc->def;
  if (var->contains (CELL_RSEP))
    rsep= env->as_length (env->exec (var[CELL_RSEP]));
  else rsep= env->fn->spc->def;
  if (var->contains (CELL_BSEP))
    bsep= env->as_length (env->exec (var[CELL_BSEP]));
  else bsep= env->fn->sep;
  if (var->contains (CELL_TSEP))
    tsep= env->as_length (env->exec (var[CELL_TSEP]));
  else tsep= env->fn->sep;
  if (var->contains (CELL_LBORDER))
    lborder= env->as_length (env->exec (var[CELL_LBORDER])) >> 1;
  else lborder= 0;
  if (var->contains (CELL_RBORDER))
    rborder= env->as_length (env->exec (var[CELL_RBORDER])) >> 1;
  else rborder= 0;
  if (var->contains (CELL_BBORDER))
    bborder= env->as_length (env->exec (var[CELL_BBORDER])) >> 1;
  else bborder= 0;
  if (var->contains (CELL_TBORDER))
    tborder= env->as_length (env->exec (var[CELL_TBORDER])) >> 1;
  else tborder= 0;
  if (var->contains (CELL_HALIGN))
    halign= as_string (env->exec (var[CELL_HALIGN]));
  else halign= "l";
  if (var->contains (CELL_VALIGN))
    valign= as_string (env->exec (var[CELL_VALIGN]));
  else valign= "B";
  if (var->contains (CELL_VCORRECT))
    vcorrect= as_string (env->exec (var[CELL_VCORRECT]));
  else vcorrect= "a";
  if (var->contains (CELL_HYPHEN))
    hyphen= as_string (env->exec (var[CELL_HYPHEN]));
  else hyphen= "n";
  if (var->contains (CELL_ROW_SPAN))
    row_span= as_int (env->exec (var[CELL_ROW_SPAN]));
  else row_span= 1;
  if (var->contains (CELL_COL_SPAN))
    col_span= as_int (env->exec (var[CELL_COL_SPAN]));
  else col_span= 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cell_rep::format_item ( tree  with)

Definition at line 206 of file cell.cpp.

                                {
  if (is_func (with, CWITH, 2))
    var (as_string (with[0]))= with[1];
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cell_rep::position_horizontally ( SI  offset,
SI  mw,
SI  lw,
SI  rw 
)

Definition at line 307 of file cell.cpp.

                                                               {
  x1= offset;
  x2= offset + mw;
  if (is_nil (T)) {
    char align_c= '\0'; if (N (halign) != 0) align_c= halign[0];
    if (align_c == 'l') xoff= -b->x1 + (lsep + lborder);
    else if (align_c == 'c') xoff= (mw - b->x1 - b->x2) >> 1;
    else if (align_c == 'r') xoff= mw - b->x2 - (rsep + rborder);
    else if (align_c == 'L') xoff= lw;
    else if (align_c == 'C') xoff= (mw + lw - rw) >> 1;
    else if (align_c == 'R') xoff= mw - rw;
    else xoff= lw;
    if (N(halign) > 1) xoff -= b->get_leaf_offset (halign (1, N (halign)));
  }
  else xoff= -T->x1 + lborder;
}

Here is the call graph for this function:

void cell_rep::position_vertically ( SI  offset,
SI  mh,
SI  bh,
SI  th 
)

Definition at line 325 of file cell.cpp.

                                                             {
  y1= offset - mh;
  y2= offset;
  if (is_nil (T)) {
    char align_c= '\0'; if (N (valign) != 0) align_c= valign[0];
    if (align_c == 'b') yoff= -b->y1 + (bsep + bborder);
    else if (align_c == 'c') yoff= (mh - b->y1 - b->y2) >> 1;
    else if (align_c == 't') yoff= mh - b->y2 - (tsep + tborder);
    else if (align_c == 'B') yoff= bh;
    else if (align_c == 'C') yoff= (mh + bh - th) >> 1;
    else if (align_c == 'T') yoff= mh - th;
    else yoff= bh;
  }
  else yoff= -T->y1 + bborder;
}

Here is the call graph for this function:

void cell_rep::typeset ( tree  fm,
tree  t,
path  ip 
)

Definition at line 23 of file cell.cpp.

                                           {
  ip= iq;
  format_cell (fm);
  if (is_func (t, CELL, 1)) {
    iq= descend (iq, 0);
    t = t[0];
  }

  if (is_func (t, SUBTABLE, 1)) {
    lsep= rsep= bsep= tsep= 0;
    T= table (env, 2);
    T->typeset (t[0], descend (iq, 0));
  }
  else {
    if (hyphen == "n") {
      b= typeset_as_concat (env, t, iq);
      if (vcorrect != "n") {
       SI y1= b->y1;
       SI y2= b->y2;
       if ((vcorrect == "a") || (vcorrect == "b")) y1= min (y1, env->fn->y1);
       if ((vcorrect == "a") || (vcorrect == "t")) y2= max (y2, env->fn->y2);
       b= resize_box (iq, b, b->x1, y1, b->x2, y2);
      }
    }
    else {
      b= empty_box (iq);

      tree len = env->as_tmlen ("1par");
      tree old1= env->local_begin (PAGE_MEDIUM, "papyrus");
      tree old2= env->local_begin (PAR_LEFT, "0tmpt");
      tree old3= env->local_begin (PAR_RIGHT, "0tmpt");
      tree old4= env->local_begin (PAR_MODE, "justify");
      tree old5= env->local_begin (PAR_NO_FIRST, "true");
      tree old6= env->local_begin (PAR_WIDTH, len);

      lz= make_lazy (env, t, iq);
      
      env->local_end (PAR_WIDTH, old6);
      env->local_end (PAR_NO_FIRST, old5);
      env->local_end (PAR_MODE, old4);
      env->local_end (PAR_RIGHT, old3);
      env->local_end (PAR_LEFT, old2);
      env->local_end (PAGE_MEDIUM, old1);
    }
  }

  if (decoration != "") {
    int i, j, or_row= -1, or_col= -1;
    tree dt= decoration;
    while (is_func (dt, TFORMAT)) dt= dt [N(dt)-1];
    for (i=0; i<N(dt); i++) {
      tree dr= dt[i];
      while (is_func (dr, TFORMAT)) dr= dr [N(dr)-1];
      for (j=0; j<N(dr); j++) {
       tree dc= dr[j];
       while (is_func (dc, TFORMAT)) dc= dc [N(dc)-1];
       if (dc == tree (TMARKER)) {
         or_row= i;
         or_col= j;
       }
      }
    }

    if (or_row != -1) {
      D= table (env, 1, or_row, or_col);
      D->typeset (attach_deco (decoration, iq));
    }
  }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 106 of file table.hpp.

Definition at line 128 of file table.hpp.

Definition at line 116 of file table.hpp.

Definition at line 124 of file table.hpp.

Definition at line 137 of file table.hpp.

Definition at line 138 of file table.hpp.

Definition at line 115 of file table.hpp.

Definition at line 103 of file table.hpp.

Definition at line 132 of file table.hpp.

Definition at line 119 of file table.hpp.

Definition at line 130 of file table.hpp.

Definition at line 120 of file table.hpp.

Definition at line 135 of file table.hpp.

Definition at line 104 of file table.hpp.

Definition at line 126 of file table.hpp.

Definition at line 122 of file table.hpp.

Definition at line 105 of file table.hpp.

Definition at line 117 of file table.hpp.

Definition at line 127 of file table.hpp.

int concrete_struct::ref_count [inherited]

Definition at line 135 of file basic.hpp.

Definition at line 136 of file table.hpp.

Definition at line 123 of file table.hpp.

Definition at line 113 of file table.hpp.

Definition at line 139 of file table.hpp.

Definition at line 129 of file table.hpp.

Definition at line 125 of file table.hpp.

Definition at line 133 of file table.hpp.

Definition at line 100 of file table.hpp.

Definition at line 134 of file table.hpp.

Definition at line 131 of file table.hpp.

Definition at line 121 of file table.hpp.

Definition at line 118 of file table.hpp.

Definition at line 109 of file table.hpp.

Definition at line 111 of file table.hpp.

Definition at line 107 of file table.hpp.

Definition at line 110 of file table.hpp.

Definition at line 112 of file table.hpp.

Definition at line 108 of file table.hpp.


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