Back to index

texmacs  1.0.7.15
skeleton.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : skeleton.hpp
00004 * DESCRIPTION: Line breaking facility for paragraphs
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 SKELETON_H
00013 #define SKELETON_H
00014 #include "Page/vpenalty.hpp"
00015 #include "tree.hpp"
00016 #include "space.hpp"
00017 #include "path.hpp"
00018 
00019 /******************************************************************************
00020 * Abstract definitions of skeletons, pagelets and insertions
00021 ******************************************************************************/
00022 
00023 struct pagelet;
00024 struct insertion_rep;
00025 struct insertion {
00026   CONCRETE(insertion);
00027   inline insertion ();
00028   inline insertion (tree type, path begin, path end);
00029   inline insertion (tree type, array<pagelet> sk);
00030   friend bool operator == (insertion ins1, insertion ins2);
00031   friend bool operator != (insertion ins1, insertion ins2);
00032   friend tm_ostream& operator << (tm_ostream& out, insertion ins);
00033 };
00034 struct pagelet_rep: concrete_struct {
00035   array<insertion> ins;
00036   space            ht;
00037   vpenalty         pen;
00038   double           stretch;
00039 
00040   inline pagelet_rep (space ht2);
00041 };
00042 
00043 struct pagelet {
00044   CONCRETE_NULL(pagelet);
00045   inline pagelet (space ht);
00046   void operator << (insertion ins);
00047   void operator << (space ht);
00048   friend bool operator == (pagelet pg1, pagelet pg2);
00049   friend bool operator != (pagelet pg1, pagelet pg2);
00050   friend tm_ostream& operator << (tm_ostream& out, pagelet pg);
00051 };
00052 typedef array<pagelet> skeleton;
00053 
00054 /******************************************************************************
00055 * Code for insertions
00056 ******************************************************************************/
00057 
00058 struct insertion_rep: concrete_struct {
00059   tree      type;     // type of insertion
00060   path      begin;    // begin location in array of page_items
00061   path      end;      // end location in array of page_items
00062   skeleton  sk;       // or possible subpagelets (used for multicolumns)
00063   space     ht;       // height of pagelet
00064   vpenalty  pen;      // penalty associated to pagelet
00065   double    stretch;  // between -1 and 1 for determining final height
00066   SI        top_cor;  // top correction
00067   SI        bot_cor;  // bottom correction
00068 
00069   inline insertion_rep () {}
00070   inline insertion_rep (tree type2, path begin2, path end2):
00071     type (type2), begin (begin2), end (end2) {}
00072   insertion_rep (tree type, skeleton sk);
00073 };
00074 CONCRETE_CODE(insertion);
00075 
00076 inline
00077 insertion::insertion () {
00078   rep= tm_new<insertion_rep> ();
00079 }
00080 
00081 inline
00082 insertion::insertion (tree type, path begin, path end) {
00083   rep= tm_new<insertion_rep> (type, begin, end);
00084 }
00085 
00086 inline
00087 insertion::insertion (tree type, skeleton sk) {
00088   rep= tm_new<insertion_rep> (type, sk);
00089 }
00090 
00091 /******************************************************************************
00092 * Code for pagelets
00093 ******************************************************************************/
00094 
00095 CONCRETE_NULL_CODE(pagelet);
00096 
00097 inline pagelet_rep::pagelet_rep (space ht2): ht (ht2) {}
00098 
00099 inline
00100 pagelet::pagelet (space ht) {
00101   rep= tm_new<pagelet_rep> (ht);
00102 }
00103 
00104 inline void
00105 pagelet::operator << (insertion ins) {
00106   rep->ht  += ins->ht;
00107   rep->pen += ins->pen;
00108   rep->ins << ins;
00109 }
00110 
00111 inline void
00112 pagelet::operator << (space spc) {
00113   rep->ht += spc;
00114 }
00115 
00116 bool operator == (pagelet pg1, pagelet pg2);
00117 bool operator != (pagelet pg1, pagelet pg2);
00118 tm_ostream& operator << (tm_ostream& out, pagelet pg);
00119 
00120 #endif // defined SKELETON_H