Back to index

texmacs  1.0.7.15
Classes | Functions
tm_button.cpp File Reference
#include "boxes.hpp"
#include "Boxes/construct.hpp"
#include "font.hpp"
#include "tm_frame.hpp"
#include "message.hpp"
#include "Widkit/simple_wk_widget.hpp"
#include "gui.hpp"
#include "drd_std.hpp"
#include "drd_info.hpp"
#include "convert.hpp"
#include "formatter.hpp"
#include "Format/format.hpp"
#include "new_style.hpp"

Go to the source code of this file.

Classes

class  box_widget_rep

Functions

void use_modules (tree t)
edit_env get_init_environment (tree doc, drd_info &drd)
tree tree_extents (tree doc)
widget box_widget (box b, bool tr)
widget box_widget (scheme_tree p, string s, color col, bool trans, bool ink)
tree enrich_embedded_document (tree body)
widget texmacs_output_widget (tree doc)

Function Documentation

widget box_widget ( box  b,
bool  tr 
)

Definition at line 149 of file tm_button.cpp.

                            {
  color col= light_grey;
  return widget (tm_new<box_widget_rep> (b, col, tr, 6, 3*PIXEL, 3*PIXEL));
}

Here is the call graph for this function:

widget box_widget ( scheme_tree  p,
string  s,
color  col,
bool  trans,
bool  ink 
)

Definition at line 155 of file tm_button.cpp.

                                                                      {
  string family  = "roman";
  string fn_class= "mr";
  string series  = "medium";
  string shape   = "normal";
  int    sz      = 10;
  int    dpi     = 600;
  int    n       = arity (p);
  if ((n >= 1) && is_atomic (p[0])) family  = as_string (p[0]);
  if ((n >= 2) && is_atomic (p[1])) fn_class= as_string (p[1]);
  if ((n >= 3) && is_atomic (p[2])) series  = as_string (p[2]);
  if ((n >= 4) && is_atomic (p[3])) shape   = as_string (p[3]);
  if ((n >= 5) && is_atomic (p[4])) sz      = as_int (p[4]);
  if ((n >= 6) && is_atomic (p[5])) dpi     = as_int (p[5]);
  font fn= find_font (family, fn_class, series, shape, sz, dpi);
  box  b = text_box (decorate (), 0, s, fn, col);
  if (ink) b= resize_box (decorate (), b, b->x3, b->y3, b->x4, b->y4, true);
  return box_widget (b, trans);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 121 of file tm_window.cpp.

                                     {
  tree orig= body;
  if (is_func (body, WITH)) body= body[N(body)-1];
  if (!is_func (body, DOCUMENT)) body= tree (DOCUMENT, body);
  tree style= "generic";
  hashmap<string,tree> initial (UNINIT);
  initial (PAGE_MEDIUM)= "automatic";
  initial (PAGE_SCREEN_LEFT)= "4px";
  initial (PAGE_SCREEN_RIGHT)= "4px";
  initial (PAGE_SCREEN_TOP)= "2px";
  initial (PAGE_SCREEN_BOT)= "2px";
  if (is_func (orig, WITH))
    for (int i=0; i+2<N(orig); i++)
      if (is_atomic (orig[i]))
        initial (orig[i]->label)= orig[i+1];
  tree doc (DOCUMENT);
  doc << compound ("TeXmacs", TEXMACS_VERSION);
  doc << compound ("style", tree (TUPLE, "generic"));
  doc << compound ("body", body);
  doc << compound ("initial", make_collection (initial));
  return doc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 43 of file tm_button.cpp.

                                               {
  hashmap<string,tree> h1 (UNINIT), h2 (UNINIT), h3 (UNINIT), h4 (UNINIT);
  edit_env env (drd, "none", h1, h2, h3, h4);
  env->write_default_env ();
  bool ok;
  tree t, style= extract (doc, "style");
  hashmap<string,tree> H;
  style_get_cache (style, H, t, ok);
  if (ok) {
    env->patch_env (H);
    ok= drd->set_locals (t);
    drd->set_environment (H);
  }
  if (!ok) {
    ASSERT (is_tuple (style), "tuple expected as style");
    tree t (USE_PACKAGE, A (style));
    env->exec (t);
    env->read_env (H);
    drd->heuristic_init (H);
  }
  use_modules (env->read (THE_MODULES));
  // FIXME: extract (doc, "init")
  // env->write (PAGE_TYPE, "a5");
  env->update ();
  return env;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file tm_button.cpp.

                                 {
  doc= enrich_embedded_document (doc);
  drd_info drd ("none", std_drd);
  edit_env env= get_init_environment (doc, drd);
  tree t= extract (doc, "body");
  lazy lz= make_lazy (env, t, path ());
  format vf= make_query_vstream_width (array<line_item>(), array<line_item>());
  format rf= lz->query (LAZY_BOX, vf);
  SI w= ((format_vstream) rf)->width;
  box b= (box) lz->produce (LAZY_BOX, make_format_width (w));
  //cout << (b->w()>>8) << ", " << (b->h()>>8) << "\n";
  //SI dw1= env->get_length (PAGE_SCREEN_LEFT);
  //SI dw2= env->get_length (PAGE_SCREEN_RIGHT);
  //SI dh1= env->get_length (PAGE_SCREEN_BOT);
  //SI dh2= env->get_length (PAGE_SCREEN_TOP);
  color col= light_grey;
  return widget (tm_new<box_widget_rep> (b, col, false, 5, 0, 0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 71 of file tm_button.cpp.

                        {
  drd_info drd ("none", std_drd);
  edit_env env= get_init_environment (doc, drd);
  tree t= extract (doc, "body");
  lazy lz= make_lazy (env, t, path ());
  format vf= make_query_vstream_width (array<line_item>(), array<line_item>());
  format rf= lz->query (LAZY_BOX, vf);
  SI w= ((format_vstream) rf)->width;
  box b= (box) lz->produce (LAZY_BOX, make_format_width (w));
  SI h= b->h ();
  w += env->get_length (PAGE_SCREEN_LEFT);
  w += env->get_length (PAGE_SCREEN_RIGHT);
  h += env->get_length (PAGE_SCREEN_TOP);
  h += env->get_length (PAGE_SCREEN_BOT);
  return tuple (as_tree ((w / (5*PIXEL)) + 1), as_tree ((h / (5*PIXEL)) + 1));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void use_modules ( tree  t)

Definition at line 126 of file edit_typeset.cpp.

                     {
  if (is_tuple (t))
    for (int i=0; i<N(t); i++) {
      string s= as_string (t[i]);
      if (starts (s, "(")) eval ("(use-modules " * s * ")");
      else if (s != "") eval ("(plugin-initialize '" * s * ")");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: