Back to index

texmacs  1.0.7.15
stretch_boxes.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : stretch.cpp
00004 * DESCRIPTION: boxes whose dimensions are (partially) set by the user.
00005 *                - empty and plain boxes
00006 *                - parenthesis boxes
00007 *                - overline and underline like boxes
00008 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00009 *******************************************************************************
00010 * This software falls under the GNU general public license version 3 or later.
00011 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00012 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00013 ******************************************************************************/
00014 
00015 #include "boxes.hpp"
00016 #include "Boxes/construct.hpp"
00017 
00018 static void
00019 get_wide_parameters (SI x1, SI x2, SI penw, SI& width, SI& height) {
00020   if (x2 - x1 >= 20 * penw) width= x2 - x1 - 8 * penw;
00021   else if (x2 - x1 <= 2 * penw) width= 2 * penw;
00022   else width= 2 * penw + ((10 * (x2 - x1 - 2 * penw)) / 18);
00023   int ratio = width / penw;
00024   int srrat = (int) sqrt ((double) ratio);
00025   height= srrat * penw;
00026 }
00027 
00028 box
00029 wide_hat_box (path ip, SI x1, SI x2, SI penw, color col) {
00030   SI width, height;
00031   get_wide_parameters (x1, x2, penw, width, height);
00032   array<box> bs (2);
00033   array<SI>  xs (2);
00034   array<SI>  ys (2);
00035   xs[0]= ys[0]= xs[1]= ys[1]= 0;
00036   bs[0]= line_box (decorate_middle (ip), 0, 0, width/2, height, penw, col);
00037   bs[1]= line_box (decorate_middle (ip), width/2, height, width, 0, penw, col);
00038   return composite_box (ip, bs, xs, ys);
00039 }
00040 
00041 box
00042 wide_tilda_box (path ip, SI x1, SI x2, SI penw, color col) {
00043   SI width, height, w, h, uw, uh, ww, hh;
00044   get_wide_parameters (x1, x2, penw, width, height);
00045   h = height/2;
00046   uh= h;
00047   hh= (SI) (0.8660254 * ((double) h));
00048   w = width;
00049   uw= (SI) (((double) w) / 4.2679492);
00050   ww= (SI) (1.1339746 * ((double) h));
00051   array<box> bs (3);
00052   array<SI>  xs (3);
00053   array<SI>  ys (3);
00054   xs[0]= ys[0]= xs[1]= ys[1]= xs[2]= ys[2]= 0;
00055   bs[0]= arc_box (decorate_middle (ip),
00056                 0, -h, 2*uw, h, 60<<6, 180<<6, penw, col);
00057   bs[1]= line_box (decorate_middle (ip),
00058                  3*uw/2, hh, w-(3*uw/2), h-hh, penw, col);
00059   bs[2]= arc_box (decorate_middle (ip),
00060                 w- (2*uw), 0, w, 2*h, 240<<6, 360<<6, penw, col);
00061   return composite_box (ip, bs, xs, ys);
00062 }
00063 
00064 box
00065 wide_bar_box (path ip, SI x1, SI x2, SI penw, color col) {
00066   return line_box (ip, 0, 0, max (penw, x2- x1), 0, penw, col);
00067 }
00068 
00069 box
00070 wide_vect_box (path ip, SI x1, SI x2, SI penw, color col) {
00071   SI width, height, arrow= 2*penw, delta=penw/2;
00072   get_wide_parameters (x1, x2, penw, width, height);
00073   height= 10*penw;
00074   array<box> bs (3);
00075   array<SI>  xs (3);
00076   array<SI>  ys (3);
00077   xs[0]= ys[0]= xs[1]= ys[1]= xs[2]= ys[2]= 0;
00078   bs[0]= line_box (decorate_middle (ip), 0, arrow, width, arrow, penw, col);
00079   bs[1]= line_box (decorate_middle (ip),
00080                  width- arrow- delta, 0, width, arrow, penw, col);
00081   bs[2]= line_box (decorate_middle (ip),
00082                  width+ delta- arrow, 2*arrow, width, arrow, penw, col);
00083   return composite_box (ip, bs, xs, ys);
00084 }
00085 
00086 box
00087 wide_check_box (path ip, SI x1, SI x2, SI penw, color col) {
00088   SI width, height;
00089   get_wide_parameters (x1, x2, penw, width, height);
00090   array<box> bs (2);
00091   array<SI>  xs (2);
00092   array<SI>  ys (2);
00093   xs[0]= ys[0]= xs[1]= ys[1]= 0;
00094   bs[0]= line_box (decorate_middle (ip), 0, height, width/2, 0, penw, col);
00095   bs[1]= line_box (decorate_middle (ip), width/2, 0, width, height, penw, col);
00096   return composite_box (ip, bs, xs, ys);
00097 }
00098 
00099 box
00100 wide_breve_box (path ip, SI x1, SI x2, SI penw, color col) {
00101   SI width, height;
00102   get_wide_parameters (x1, x2, penw, width, height);
00103   return arc_box (ip, 0, 0, width, 2*height, 180<<6, 360<<6, penw, col);
00104 }
00105 
00106 box
00107 wide_squbr_box (path ip, SI x1, SI x2, SI penw, color col) {
00108   path dip= decorate_middle (ip);
00109   SI width= max (x2-x1, 6*penw), height= 6*penw;
00110   array<box> bs (3);
00111   array<SI>  xs (3);
00112   array<SI>  ys (3);
00113   xs[0]= ys[0]= xs[1]= ys[1]= xs[2]= ys[2]= 0;
00114   bs[0]= line_box (dip, 0, 0, width, 0, penw, col);
00115   bs[1]= line_box (dip, 0, height, 0, 0, penw/2, col);
00116   bs[2]= line_box (dip, width, height, width, 0, penw/2, col);
00117   return composite_box (ip, bs, xs, ys);
00118 }
00119 
00120 box
00121 wide_sqobr_box (path ip, SI x1, SI x2, SI penw, color col) {
00122   path dip= decorate_middle (ip);
00123   SI width= max (x2-x1, 6*penw), height= 6*penw;
00124   array<box> bs (3);
00125   array<SI>  xs (3);
00126   array<SI>  ys (3);
00127   xs[0]= ys[0]= xs[1]= ys[1]= xs[2]= ys[2]= 0;
00128   bs[0]= line_box (dip, 0, height, width, height, penw, col);
00129   bs[1]= line_box (dip, 0, height, 0, 0, penw/2, col);
00130   bs[2]= line_box (dip, width, height, width, 0, penw/2, col);
00131   return composite_box (ip, bs, xs, ys);
00132 }