Back to index

texmacs  1.0.7.15
Classes | Functions
text_boxes.cpp File Reference
#include "boxes.hpp"
#include "font.hpp"
#include "Boxes/construct.hpp"
#include "analyze.hpp"

Go to the source code of this file.

Classes

struct  text_box_rep

Functions

static string get_delimiter (string s, font fn, SI height)
static string get_wide (string s, font fn, SI width)
box delimiter_box (path ip, string s, font fn, color col, SI bot, SI top)
box big_operator_box (path ip, string s, font fn, color col, int n)
box wide_box (path ip, string s, font fn, color col, SI width)
box text_box (path ip, int pos, string s, font fn, color col)

Function Documentation

box big_operator_box ( path  ip,
string  s,
font  fn,
color  col,
int  n 
)

Definition at line 355 of file text_boxes.cpp.

                                                                {
  ASSERT (N(s) >= 2 && s[0] == '<' && s[N(s)-1] == '>',
         "invalid rubber character");
  string r= s (0, N(s)-1) * "-" * as_string (n) * ">";
  metric ex;
  fn->get_extents (r, ex);
  SI y= fn->yfrac - ((ex->y1 + ex->y2) >> 1);
  box mvb= move_box (ip, text_box (ip, 0, r, fn, col), 0, y, false, true);
  return macro_box (ip, mvb, fn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

box delimiter_box ( path  ip,
string  s,
font  fn,
color  col,
SI  bot,
SI  top 
)

Definition at line 343 of file text_boxes.cpp.

                                                                      {
  SI h= top - bot;
  string r= get_delimiter (s, fn, h);
  metric ex;
  fn->get_extents (r, ex);
  SI x= -ex->x1;
  SI y= (top+ bot- ex->y1- ex->y2) >> 1;
  box mvb= move_box (ip, text_box (ip, 0, r, fn, col), x, y, false, true);
  return macro_box (ip, mvb, fn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string get_delimiter ( string  s,
font  fn,
SI  height 
) [static]

Definition at line 278 of file text_boxes.cpp.

                                             {
  ASSERT (N(s) >= 2 && s[0] == '<' && s[N(s)-1] == '>',
         "invalid rubber character");
  height -= PIXEL;
  string radical= s (0, N(s)-1) * "-";
  string first  = radical * "0>";
  metric ex;
  fn->get_extents (first, ex);
  if ((ex->y2- ex->y1) >= height) return first;

  string second  = radical * "1>";
  fn->get_extents (second, ex);
  SI h1= ex->y2- ex->y1;
  if (h1 >= (height-PIXEL)) return second;

  string third = radical * "2>";
  metric ey;
  fn->get_extents (third, ey);
  SI h2= ey->y2- ey->y1;
  if (h2 <= h1) return second;
  SI  d= h2- h1;
  int n= (height + (d-1) - h1) / d;

  while (true) {
    string test= radical * as_string (n+1) * ">";
    fn->get_extents (test, ey);
    if (ey->y2- ey->y1 >= height) return test;
    if ((ey->y2- ey->y1 <= h2) && (n>1)) return radical * as_string (n) * ">";
    h2= ey->y2- ey->y1;
    n++;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string get_wide ( string  s,
font  fn,
SI  width 
) [static]

Definition at line 312 of file text_boxes.cpp.

                                       {
  ASSERT (N(s) >= 2 && s[0] == '<' && s[N(s)-1] == '>',
         "invalid rubber character");
  string radical= s (0, N(s)-1) * "-";
  string first  = radical * "0>";
  metric ex;
  fn->get_extents (first, ex);
  if ((ex->x2- ex->x1) >= width) return first;

  string second = radical * "1>";
  metric ey;
  fn->get_extents (second, ey);
  SI w1= ex->x2- ex->x1;
  SI w2= ey->x2- ey->x1;
  if ((w2 <= w1) || (w2 > width)) return first;
  SI  d= w2- w1;
  int n= (width-w1) / (d+1);

  while (true) {
    string test= radical * as_string (n+1) * ">";
    fn->get_extents (test, ey);
    if (ey->x2- ey->x1 > width) return radical * as_string (n) * ">";
    n++;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

box text_box ( path  ip,
int  pos,
string  s,
font  fn,
color  col 
)

Definition at line 376 of file text_boxes.cpp.

                                                          {
  return tm_new<text_box_rep> (ip, pos, s, fn, col);
}

Here is the caller graph for this function:

box wide_box ( path  ip,
string  s,
font  fn,
color  col,
SI  width 
)

Definition at line 367 of file text_boxes.cpp.

                                                           {
  string r= get_wide (s, fn, width);
  metric ex;
  fn->get_extents (r, ex);
  box b= text_box (ip, 0, r, fn, col);
  return macro_box (ip, b, fn);
}

Here is the call graph for this function:

Here is the caller graph for this function: