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

« back to all changes in this revision

Viewing changes to src/Typeset/Boxes/Basic/stretch_boxes.cpp

  • 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     : stretch.cpp
 
4
* DESCRIPTION: boxes whose dimensions are (partially) set by the user.
 
5
*                - empty and plain boxes
 
6
*                - parenthesis boxes
 
7
*                - overline and underline like boxes
 
8
* COPYRIGHT  : (C) 1999  Joris van der Hoeven
 
9
*******************************************************************************
 
10
* This software falls under the GNU general public license and comes WITHOUT
 
11
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
 
12
* If you don't have this file, write to the Free Software Foundation, Inc.,
 
13
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
14
******************************************************************************/
 
15
 
 
16
#include "boxes.hpp"
 
17
#include "Boxes/construct.hpp"
 
18
 
 
19
#include <math.h>
 
20
 
 
21
static void
 
22
get_wide_parameters (SI x1, SI x2, SI penw, SI& width, SI& height) {
 
23
  width = max (x2-x1, 10*penw)- (8*penw);
 
24
  int ratio = width / penw;
 
25
  int srrat = (int) sqrt ((double) ratio);
 
26
  height= srrat * penw;
 
27
}
 
28
 
 
29
box
 
30
wide_hat_box (path ip, SI x1, SI x2, SI penw, color col) {
 
31
  SI width, height;
 
32
  get_wide_parameters (x1, x2, penw, width, height);
 
33
  array<box> bs (2);
 
34
  array<SI>  xs (2);
 
35
  array<SI>  ys (2);
 
36
  xs[0]= ys[0]= xs[1]= ys[1]= 0;
 
37
  bs[0]= line_box (decorate_middle (ip), 0, 0, width/2, height, penw, col);
 
38
  bs[1]= line_box (decorate_middle (ip), width/2, height, width, 0, penw, col);
 
39
  return composite_box (ip, bs, xs, ys);
 
40
}
 
41
 
 
42
box
 
43
wide_tilda_box (path ip, SI x1, SI x2, SI penw, color col) {
 
44
  SI width, height, w, h, uw, uh, ww, hh;
 
45
  get_wide_parameters (x1, x2, penw, width, height);
 
46
  h = height/2;
 
47
  uh= h;
 
48
  hh= (SI) (0.8660254 * ((double) h));
 
49
  w = width;
 
50
  uw= (SI) (((double) w) / 4.2679492);
 
51
  ww= (SI) (1.1339746 * ((double) h));
 
52
  array<box> bs (3);
 
53
  array<SI>  xs (3);
 
54
  array<SI>  ys (3);
 
55
  xs[0]= ys[0]= xs[1]= ys[1]= xs[2]= ys[2]= 0;
 
56
  bs[0]= arc_box (decorate_middle (ip),
 
57
                  0, -h, 2*uw, h, 60<<6, 180<<6, penw, col);
 
58
  bs[1]= line_box (decorate_middle (ip),
 
59
                   3*uw/2, hh, w-(3*uw/2), h-hh, penw, col);
 
60
  bs[2]= arc_box (decorate_middle (ip),
 
61
                  w- (2*uw), 0, w, 2*h, 240<<6, 360<<6, penw, col);
 
62
  return composite_box (ip, bs, xs, ys);
 
63
}
 
64
 
 
65
box
 
66
wide_bar_box (path ip, SI x1, SI x2, SI penw, color col) {
 
67
  return line_box (ip, 0, 0, max (penw, x2- x1), 0, penw, col);
 
68
}
 
69
 
 
70
box
 
71
wide_vect_box (path ip, SI x1, SI x2, SI penw, color col) {
 
72
  SI width, height, arrow= 2*penw, delta=penw/2;
 
73
  get_wide_parameters (x1, x2, penw, width, height);
 
74
  height= 10*penw;
 
75
  array<box> bs (3);
 
76
  array<SI>  xs (3);
 
77
  array<SI>  ys (3);
 
78
  xs[0]= ys[0]= xs[1]= ys[1]= xs[2]= ys[2]= 0;
 
79
  bs[0]= line_box (decorate_middle (ip), 0, arrow, width, arrow, penw, col);
 
80
  bs[1]= line_box (decorate_middle (ip),
 
81
                   width- arrow- delta, 0, width, arrow, penw, col);
 
82
  bs[2]= line_box (decorate_middle (ip),
 
83
                   width+ delta- arrow, 2*arrow, width, arrow, penw, col);
 
84
  return composite_box (ip, bs, xs, ys);
 
85
}
 
86
 
 
87
box
 
88
wide_check_box (path ip, SI x1, SI x2, SI penw, color col) {
 
89
  SI width, height;
 
90
  get_wide_parameters (x1, x2, penw, width, height);
 
91
  array<box> bs (2);
 
92
  array<SI>  xs (2);
 
93
  array<SI>  ys (2);
 
94
  xs[0]= ys[0]= xs[1]= ys[1]= 0;
 
95
  bs[0]= line_box (decorate_middle (ip), 0, height, width/2, 0, penw, col);
 
96
  bs[1]= line_box (decorate_middle (ip), width/2, 0, width, height, penw, col);
 
97
  return composite_box (ip, bs, xs, ys);
 
98
}
 
99
 
 
100
box
 
101
wide_breve_box (path ip, SI x1, SI x2, SI penw, color col) {
 
102
  SI width, height;
 
103
  get_wide_parameters (x1, x2, penw, width, height);
 
104
  return arc_box (ip, 0, 0, width, 2*height, 180<<6, 360<<6, penw, col);
 
105
}