]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/break.hh
release: 0.0.76
[lilypond.git] / lily / include / break.hh
1 /*
2   break.hh -- declare  Break_algorithm
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #ifndef BREAK_HH
11 #define BREAK_HH
12 #include "varray.hh"
13 #include "lily-proto.hh"
14 #include "colhpos.hh"
15
16 /** Class representation of an algorithm which decides where to put
17   the column, and where to break lines.
18   
19   TODO: a decent algorithm, based on dynamic programming or something
20   a like. A "parindent", caching of breakpoints
21   
22   */
23 class Break_algorithm {
24     Line_spacer* generate_spacing_problem(Line_of_cols)const;
25 protected:
26     PScore *pscore_l_;
27     Real linelength;
28
29     /// search all pcols which are breakable.
30     Line_of_cols find_breaks() const;
31
32      /// helper: solve for the columns in #curline#.
33     Col_hpositions solve_line(Line_of_cols) const;
34
35     /// does curline fit on the paper?    
36     bool feasible(Line_of_cols)const;
37     
38
39     /** generate a solution with no regard to idealspacings or
40       constraints.  should always work */
41     Col_hpositions stupid_solution(Line_of_cols) const;
42     virtual Array<Col_hpositions> do_solve()const=0;
43 public:
44     Line_spacer* (*get_line_spacer)();
45     
46     Break_algorithm(PScore&);
47
48     /// check if the spacing/breaking problem is well-stated
49     void problem_OK()const;
50     void OK()const;
51     Array<Col_hpositions> solve()const;
52 };
53
54 #endif // BREAK_HH
55