box pager_rep::make_pages () { 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); }
box pager_rep::pages_format (insertion ins) { 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); SI xh= stretch_space (ins->xh, ins->stretch); return pages_format (sub_l, ht, ins->top_cor, ins->bot_cor + xh); } }
box pager_rep::pages_format (pagelet pg) { // 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 dummy_box (decorate_middle (ip)); return dummy_box (decorate_middle (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) { pencil pen= env->pen->set_width (env->fn->wline); bs << line_box (decorate(), 0, 0, fnote_bl, 0, pen); bx << 0; by << (fnote_y + env->fn->sep); } // cout << UNINDENT << "Formatted pagelet " << (N(pages)+1) << LF << LF; return scatter_box (ip, bs, bx, by); } }