Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
pager_rep Class Reference

#include <pager.hpp>

Collaboration diagram for pager_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 pager_rep (path ip, edit_env env, array< page_item > l)
box make_header (bool empty_flag)
box make_footer (bool empty_flag)
box make_pages ()

Public Attributes

path ip
edit_env env
hashmap< string, treestyle
array< page_iteml
bool paper
int quality
bool show_hf
SI text_width
SI text_height
SI width
SI height
SI odd
SI even
SI top
SI bot
SI may_extend
SI may_shrink
SI head_sep
SI foot_sep
SI col_sep
space fn_sep
space fnote_sep
SI fnote_bl
space float_sep
SI mnote_sep
int page_offset
SI cur_top
array< boxpages
array< boxlines_bx
array< spacelines_ht

Protected Member Functions

void papyrus_fnote_float (array< page_item > from, array< page_item > &to)
void papyrus_mcolumn (array< page_item > &l)
void papyrus_make (array< page_item > l)
box pages_format (array< page_item > l, SI ht, SI tcor, SI bcor)
box pages_format (insertion ins)
box pages_format (pagelet pg)
box pages_make_page (pagelet pg)
void pages_make ()
void papyrus_make ()

Protected Attributes

array< page_itempap_main
array< page_itempap_fnote

Friends

struct stacker_rep
box typeset_paragraph (edit_env env, tree t, path ip)
box typeset_document (edit_env env, tree t, path ip)

Detailed Description

Definition at line 20 of file pager.hpp.


Constructor & Destructor Documentation

pager_rep::pager_rep ( path  ip,
edit_env  env,
array< page_item l 
)

Definition at line 19 of file pager.cpp.

                                                                 :
  ip (ip2), env (env2), style (UNINIT), l (l2)
{
  style (PAGE_THE_PAGE)   = tree (MACRO, compound ("page-nr"));
  style (PAGE_ODD_HEADER) = env->read (PAGE_ODD_HEADER);
  style (PAGE_ODD_FOOTER) = env->read (PAGE_ODD_FOOTER);
  style (PAGE_EVEN_HEADER)= env->read (PAGE_EVEN_HEADER);
  style (PAGE_EVEN_FOOTER)= env->read (PAGE_EVEN_FOOTER);
  style (PAGE_THIS_HEADER)= "";
  style (PAGE_THIS_FOOTER)= "";

  int nr_cols= env->get_int (PAR_COLUMNS);
  paper= (env->get_string (PAGE_MEDIUM) == "paper");
  string pbr= env->get_string (PAGE_BREAKING);
  quality= (pbr == "sloppy"? 0: (pbr == "medium"? 1: 2));
  env->get_page_pars (text_width, text_height, width, height,
                    odd, even, top, bot);
  may_extend= env->get_length (PAGE_EXTEND);
  may_shrink= env->get_length (PAGE_SHRINK);
  head_sep  = env->get_length (PAGE_HEAD_SEP);
  foot_sep  = env->get_length (PAGE_FOOT_SEP);
  col_sep   = env->get_length (PAR_COLUMNS_SEP);
  fn_sep    = env->get_vspace (PAR_FNOTE_SEP);
  fnote_sep = env->get_vspace (PAGE_FNOTE_SEP) + (2*env->fn->sep);
  fnote_bl  = env->get_length (PAGE_FNOTE_BARLEN);
  float_sep = env->get_vspace (PAGE_FLOAT_SEP);
  mnote_sep = env->get_length (PAGE_MNOTE_SEP);
  show_hf   = env->get_bool (PAGE_SHOW_HF) && paper;
  if (nr_cols > 1) text_width = (text_width+col_sep+1) * nr_cols - col_sep;

  page_offset= 0;
  cur_top= 0;
}

Here is the call graph for this function:


Member Function Documentation

box pager_rep::make_footer ( bool  empty_flag)

Definition at line 206 of file pager.cpp.

                                       {
  if (!show_hf || empty_flag) return empty_box (decorate ());
  env->write (PAGE_NR, as_string (N(pages)+1+page_offset));
  env->write (PAGE_THE_PAGE, style[PAGE_THE_PAGE]);
  tree old= env->local_begin (PAR_COLUMNS, "1");
  string which= (N(pages)&1)==0? PAGE_ODD_FOOTER: PAGE_EVEN_FOOTER;
  if (style [PAGE_THIS_FOOTER] != "") which= PAGE_THIS_FOOTER;
  box b= typeset_as_concat (env, attach_here (tree (PARA, style[which]),
                                         decorate()));
  style (PAGE_THIS_FOOTER) = "";
  env->local_end (PAR_COLUMNS, old);
  return b;
}

Here is the call graph for this function:

Here is the caller graph for this function:

box pager_rep::make_header ( bool  empty_flag)

Definition at line 191 of file pager.cpp.

                                       {
  if (!show_hf || empty_flag) return empty_box (decorate ());
  env->write (PAGE_NR, as_string (N(pages)+1+page_offset));
  env->write (PAGE_THE_PAGE, style[PAGE_THE_PAGE]);
  tree old= env->local_begin (PAR_COLUMNS, "1");
  string which= (N(pages)&1)==0? PAGE_ODD_HEADER: PAGE_EVEN_HEADER;
  if (style [PAGE_THIS_HEADER] != "") which= PAGE_THIS_HEADER;
  box b= typeset_as_concat (env, attach_here (tree (PARA, style[which]),
                                         decorate()));
  style (PAGE_THIS_HEADER) = "";
  env->local_end (PAR_COLUMNS, old);
  return b;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 225 of file pager.cpp.

                       {
  if (paper) pages_make ();
  else papyrus_make ();
  int i, nr_pages= N(pages);
  array<SI>  x  (nr_pages);
  array<SI>  y  (nr_pages);
  for (i=0; i<nr_pages; i++) {
    x[i]= 0;
    y[i]= (i==0? 0: y[i-1]- pages[i-1]->h());
  }
  return move_box (ip, scatter_box (ip, pages, x, y), 0, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

box pager_rep::pages_format ( array< page_item l,
SI  ht,
SI  tcor,
SI  bcor 
) [protected]

Definition at line 27 of file make_pages.cpp.

                                                                    {
  // cout << "Formatting insertion of height " << ht << LF;
  ht -= (tcor + bcor);
  int i, n= N(l);
  array<box>   bs;
  array<space> spc;
  for (i=0; i<n; i++) {
    page_item item= l[i];
    if (item->type == PAGE_CONTROL_ITEM) {
      if (is_tuple (item->t, "env_page")) {
       if (((item->t[1] == PAGE_THIS_HEADER) ||
            (item->t[1] == PAGE_THIS_FOOTER)) &&
           (item->t[2] == "")) style (item->t[1]->label)= " ";
       else if (item->t[1] == PAGE_NR)
         page_offset= as_int (item->t[2]->label)- N(pages)- 1;
       else style (item->t[1]->label)= copy (item->t[2]);
      }
    }
    else {
      bs  << item->b;
      spc << item->spc;
    }
  }
  ASSERT (N(bs) != 0, "zero lines in insertion");
  box b= format_stack (ip, bs, spc, ht, true);
  return vcorrect_box (b->ip, b, tcor, bcor);
}

Here is the call graph for this function:

Here is the caller graph for this function:

box pager_rep::pages_format ( insertion  ins) [protected]

Definition at line 56 of file make_pages.cpp.

                                      {
  if (is_tuple (ins->type, "multi-column")) {
    // cout << "Format multicolumn " << ins->sk << LF << LF << INDENT;
    int col, nr_cols= N (ins->sk), real_nr_cols= as_int (ins->type[1]);
    SI w= (text_width + col_sep) / real_nr_cols;
    array<box> bs (nr_cols);
    array<SI>  x  (nr_cols);
    array<SI>  y  (nr_cols);
    for (col=0; col<nr_cols; col++) {
      bs[col]= pages_format (ins->sk[col]);
      x [col]= col * w;
      y [col]= 0;
    }
    // cout << UNINDENT << "Formatted multicolumn" << LF;
    return scatter_box (ip, bs, x, y);
  }
  else {
    array<page_item> sub_l= sub (l, ins->begin, ins->end);
    SI ht= stretch_space (ins->ht, ins->stretch);
    return pages_format (sub_l, ht, ins->top_cor, ins->bot_cor);
  }
}

Here is the call graph for this function:

box pager_rep::pages_format ( pagelet  pg) [protected]

Definition at line 80 of file make_pages.cpp.

                                   {
  // cout << "Formatting pagelet " << (N(pages)+1)
  //      << " stretch " << pg->stretch
  //      << " height " << stretch_space (pg->ht, pg->stretch) << LF << INDENT;
  if (N (pg->ins) == 0) {
    if (N(pages) == 0) return empty_box (ip);
    return empty_box (pages[N(pages)-1]->find_rip());
  }
  else if (N (pg->ins) == 1) {
    insertion ins= pg->ins[0];
    // cout << ins << " stretch " << ins->stretch
    //      << " height " << stretch_space (ins->ht, ins->stretch) << LF;
    //      << UNINDENT << "Formatted pagelet " << (N(pages)+1) << LF << LF;
    return pages_format (ins);
  }
  else {
    int i, n= N(pg->ins);
    array<box> bs (n);
    array<SI>  bx (n);
    array<SI>  by (n);
    SI y= 0, fnote_y= MAX_SI;
    for (i=0; i<n; i++) {
      insertion ins= pg->ins[i];
      // cout << ins << " at " << y << " stretch " << ins->stretch
      //      << " height " << stretch_space (ins->ht, ins->stretch) << LF;
      bs[i]= pages_format (ins);
      bx[i]= 0;
      by[i]= y;
      y -= bs[i]->h();
      if (i < n-1) {
       insertion next= pg->ins[i+1];
       if (ins->type != next->type) {
         if (is_tuple (next->type, "footnote")) {
           // cout << "sep " << stretch_space (fnote_sep, ins->stretch) << LF;
           y -= stretch_space (fnote_sep, ins->stretch);
           fnote_y= y;
         }
         else if (is_tuple (ins->type, "float")) {
           if (!is_tuple (next->type, "float")) {
             // cout << "sep " << stretch_space(float_sep, ins->stretch) << LF;
             y -= stretch_space (float_sep, ins->stretch);
           }
         }
         else if (is_tuple (ins->type, "multi-column") ||
                 is_tuple (next->type, "multi-column")) {
           page_item item= access (l, path_dec (ins->end));
           // cout << "sep " << stretch_space (item->spc, ins->stretch) << LF;
           y -= stretch_space (item->spc, ins->stretch);
         }
       }
       if (is_tuple (ins->type, "footnote"))
         if (is_tuple (next->type, "footnote")) {
           page_item item= access (l, path_dec (ins->end));
           SI sep= stretch_space (item->spc + fn_sep, ins->stretch);
           // cout << "sep " << sep << LF;
           y -= sep;
         }
       if (is_tuple (next->type, "float")) {
         // cout << "sep " << stretch_space (float_sep, ins->stretch) << LF;
         y -= stretch_space (float_sep, ins->stretch);
       }
      }
    }
    if (fnote_y != MAX_SI) {
      bs << line_box (decorate(), 0, 0, fnote_bl, 0, env->fn->wline, env->col);
      bx << 0;
      by << (fnote_y + env->fn->sep);
    }
    // cout << UNINDENT << "Formatted pagelet " << (N(pages)+1) << LF << LF;
    return scatter_box (ip, bs, bx, by);
  }
}

Here is the call graph for this function:

void pager_rep::pages_make ( ) [protected]

Definition at line 169 of file make_pages.cpp.

                       {
  space ht (text_height- may_shrink, text_height, text_height+ may_extend);
  skeleton sk=
    break_pages (l, ht, quality, fn_sep, fnote_sep, float_sep, env->fn);
  int i, n= N(sk);
  for (i=0; i<n; i++)
    pages << pages_make_page (sk[i]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

box pager_rep::pages_make_page ( pagelet  pg) [protected]

Definition at line 154 of file make_pages.cpp.

                                      {
  box sb= pages_format (pg);
  box lb= move_box (ip, sb, 0, 0);
  SI  left= (N(pages)&1)==0? odd: even;
  env->write (PAGE_NR, as_string (N(pages)+1+page_offset));
  env->write (PAGE_THE_PAGE, style[PAGE_THE_PAGE]);
  tree page_t= env->exec (compound (PAGE_THE_PAGE));
  box header= make_header (N (pg->ins) == 0);
  box footer= make_footer (N (pg->ins) == 0);
  return page_box (ip, lb, page_t,
                 width, height, left, top, top+ text_height,
                 header, footer, head_sep, foot_sep);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pager_rep::papyrus_fnote_float ( array< page_item from,
array< page_item > &  to 
) [protected]
void pager_rep::papyrus_make ( array< page_item l) [protected]
void pager_rep::papyrus_make ( ) [protected]

Definition at line 179 of file make_pages.cpp.

                         {
  space ht (MAX_SI >> 1);
  skeleton sk=
    break_pages (l, ht, quality, fn_sep, fnote_sep, float_sep, env->fn);
  if (N(sk) != 1) {
    cerr << "Number of pages: " << N(sk) << "\n";
    FAILED ("unexpected situation");
  }

  box sb= pages_format (sk[0]);
  box b = move_box (ip, sb, 0, 0);
  SI left  = (odd+even) >> 1;
  SI height= top + bot + b->h();
  array<box> bs   (1); bs   [0]= b;
  array<SI>  bs_x (1); bs_x [0]= left;
  array<SI>  bs_y (1); bs_y [0]= -top;
  box pb= page_box (ip, "?", width, height,
                  bs, bs_x, bs_y, 0, 0, 0);
  pages << pb;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pager_rep::papyrus_mcolumn ( array< page_item > &  l) [protected]

Friends And Related Function Documentation

friend struct stacker_rep [friend]

Definition at line 82 of file pager.hpp.

box typeset_document ( edit_env  env,
tree  t,
path  ip 
) [friend]
box typeset_paragraph ( edit_env  env,
tree  t,
path  ip 
) [friend]

Member Data Documentation

Definition at line 37 of file pager.hpp.

Definition at line 42 of file pager.hpp.

Definition at line 50 of file pager.hpp.

Definition at line 23 of file pager.hpp.

Definition at line 35 of file pager.hpp.

Definition at line 46 of file pager.hpp.

Definition at line 43 of file pager.hpp.

Definition at line 45 of file pager.hpp.

Definition at line 44 of file pager.hpp.

Definition at line 41 of file pager.hpp.

Definition at line 40 of file pager.hpp.

Definition at line 33 of file pager.hpp.

Definition at line 22 of file pager.hpp.

Definition at line 25 of file pager.hpp.

Definition at line 53 of file pager.hpp.

Definition at line 54 of file pager.hpp.

Definition at line 38 of file pager.hpp.

Definition at line 39 of file pager.hpp.

Definition at line 47 of file pager.hpp.

Definition at line 34 of file pager.hpp.

Definition at line 49 of file pager.hpp.

Definition at line 51 of file pager.hpp.

Definition at line 58 of file pager.hpp.

Definition at line 57 of file pager.hpp.

Definition at line 27 of file pager.hpp.

Definition at line 28 of file pager.hpp.

Definition at line 29 of file pager.hpp.

Definition at line 24 of file pager.hpp.

Definition at line 31 of file pager.hpp.

Definition at line 30 of file pager.hpp.

Definition at line 36 of file pager.hpp.

Definition at line 32 of file pager.hpp.


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