~ubuntu-branches/ubuntu/hardy/texmacs/hardy

« back to all changes in this revision

Viewing changes to src/Typeset/Page/vpenalty.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Treinen
  • Date: 2004-04-19 20:34:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040419203400-g4e34ih0315wcn8v
Tags: upstream-1.0.3-R2
ImportĀ upstreamĀ versionĀ 1.0.3-R2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/******************************************************************************
 
3
* MODULE     : vpenalty.cpp
 
4
* DESCRIPTION: Vertical penalties
 
5
* COPYRIGHT  : (C) 1999  Joris van der Hoeven
 
6
*******************************************************************************
 
7
* This software falls under the GNU general public license and comes WITHOUT
 
8
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
 
9
* If you don't have this file, write to the Free Software Foundation, Inc.,
 
10
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
11
*******************************************************************************
 
12
*   The main 'pen' parameter is (mainly) determined at the typesetting process
 
13
* It is 0 on paragraph borders, 1 inside paragraphs, 10 when two lines near
 
14
* a paragraph border, 100 when one line from a paragraph border and
 
15
* HYPH_INVALID if a page break is prohibited.
 
16
*   The main penalty is adjusted when a given break is really not good
 
17
* enough for a given page: if the page length is flexible and we can make
 
18
* material between two breaks fit on a page of extended (or reduced) length,
 
19
* then we add EXTEND_PAGE_PENALTY resp. REDUCE_PAGE_PENALTY to
 
20
* the main penalty.
 
21
*   At equal main penalties, we look at the excentricity parameter 'exc',
 
22
* which is determined as the square of the difference between the default
 
23
* length of the material between two breaks and the default required
 
24
* page height.
 
25
******************************************************************************/
 
26
 
 
27
#ifndef VPENALTY_H
 
28
#define VPENALTY_H
 
29
#include "basic.hpp"
 
30
 
 
31
#define EXTEND_PAGE_PENALTY   33
 
32
#define REDUCE_PAGE_PENALTY   33
 
33
#define TOO_SHORT_PENALTY     10000
 
34
#define TOO_LONG_PENALTY      100000
 
35
#define UNBALANCED_COLUMNS    1000
 
36
#define LONGER_LATTER_COLUMN  1000
 
37
 
 
38
struct vpenalty_rep: concrete_struct {
 
39
  int pen;   // main penalty
 
40
  int exc;   // excentricity: square of shift with respect to ideal position
 
41
  inline vpenalty_rep (): pen (0), exc (0) {}
 
42
  inline vpenalty_rep (int pen2): pen (pen2), exc (0) {}
 
43
  inline vpenalty_rep (int pen2, int exc2): pen (pen2), exc (exc2) {}
 
44
};
 
45
 
 
46
class vpenalty {
 
47
  CONCRETE(vpenalty);
 
48
  inline vpenalty (): rep (new vpenalty_rep ()) {}
 
49
  inline vpenalty (int pen): rep (new vpenalty_rep (pen)) {}
 
50
  inline vpenalty (int pen, int exc): rep (new vpenalty_rep (pen, exc)) {}
 
51
  inline bool operator == (vpenalty pen) {
 
52
    return (rep->pen == pen->pen) && (rep->exc == pen->exc); }
 
53
  inline bool operator != (vpenalty pen) {
 
54
    return (rep->pen != pen->pen) || (rep->exc != pen->exc); }
 
55
  inline bool operator < (vpenalty pen) {
 
56
    return
 
57
      (rep->pen < pen->pen) ||
 
58
      ((rep->pen == pen->pen) && (rep->exc < pen->exc)); }
 
59
  inline void operator += (vpenalty pen) {
 
60
    rep->pen += pen->pen; rep->exc += pen->exc; }
 
61
  inline vpenalty operator + (vpenalty pen) {
 
62
    return vpenalty (rep->pen + pen->pen, rep->exc + pen->exc); }
 
63
};
 
64
CONCRETE_CODE(vpenalty);
 
65
 
 
66
ostream& operator << (ostream& out, vpenalty pen);
 
67
 
 
68
#endif // defined VPENALTY_H