Back to index

texmacs  1.0.7.15
env_semantics.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : env_semantics.cpp
00004 * DESCRIPTION: attaching numerical values to the environment variables
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #include "env.hpp"
00013 #include "page_type.hpp"
00014 #include "typesetter.hpp"
00015 
00016 /******************************************************************************
00017 * Retrieving the page size
00018 ******************************************************************************/
00019 
00020 /*static*/ hashmap<string,int> default_var_type (Env_User);
00021 
00022 /*static*/ void
00023 initialize_default_var_type () {
00024   if (N(default_var_type) != 0) return;
00025   hashmap<string,int>& var_type= default_var_type;
00026 
00027   var_type (DPI)               = Env_Fixed;
00028   var_type (SFACTOR)           = Env_Fixed;
00029   var_type (PREAMBLE)          = Env_Preamble;
00030   var_type (SAVE_AUX)          = Env_Fixed;
00031   var_type (MODE)              = Env_Mode;
00032   var_type (INFO_FLAG)         = Env_Info_Level;
00033 
00034   var_type (FONT)              = Env_Font;
00035   var_type (FONT_FAMILY)       = Env_Font;
00036   var_type (FONT_SERIES)       = Env_Font;
00037   var_type (FONT_SHAPE)        = Env_Font;
00038   var_type (FONT_SIZE)         = Env_Font_Size;
00039   var_type (FONT_BASE_SIZE)    = Env_Font_Size;
00040   var_type (MAGNIFICATION)     = Env_Magnification;
00041   var_type (MAGNIFY)           = Env_Magnify;
00042   var_type (COLOR)             = Env_Color;
00043   var_type (OPACITY)           = Env_Color;
00044   var_type (LANGUAGE)          = Env_Language;
00045 
00046   var_type (MATH_LANGUAGE)     = Env_Language;
00047   var_type (MATH_FONT)         = Env_Font;
00048   var_type (MATH_FONT_FAMILY)  = Env_Font;
00049   var_type (MATH_FONT_SERIES)  = Env_Font;
00050   var_type (MATH_FONT_SHAPE)   = Env_Font;
00051   var_type (MATH_LEVEL)        = Env_Index_Level;
00052   var_type (MATH_DISPLAY)      = Env_Display_Style;
00053   var_type (MATH_CONDENSED)    = Env_Math_Condensed;
00054   var_type (MATH_VPOS)         = Env_Vertical_Pos;
00055 
00056   var_type (PROG_LANGUAGE)     = Env_Language;
00057   var_type (PROG_FONT)         = Env_Font;
00058   var_type (PROG_FONT_FAMILY)  = Env_Font;
00059   var_type (PROG_FONT_SERIES)  = Env_Font;
00060   var_type (PROG_FONT_SHAPE)   = Env_Font;
00061 
00062   var_type (PAR_MODE)          = Env_Paragraph;
00063   var_type (PAR_HYPHEN)        = Env_Paragraph;
00064   var_type (PAR_WIDTH)         = Env_Paragraph;
00065   var_type (PAR_LEFT)          = Env_Paragraph;
00066   var_type (PAR_RIGHT)         = Env_Paragraph;
00067   var_type (PAR_FIRST)         = Env_Paragraph;
00068   var_type (PAR_NO_FIRST)      = Env_Paragraph;
00069   var_type (PAR_SEP)           = Env_Paragraph;
00070   var_type (PAR_HOR_SEP)       = Env_Paragraph;
00071   var_type (PAR_VER_SEP)       = Env_Paragraph;
00072   var_type (PAR_LINE_SEP)      = Env_Paragraph;
00073   var_type (PAR_PAR_SEP)       = Env_Paragraph;
00074 
00075   var_type (PAGE_TYPE)         = Env_Fixed;
00076   var_type (PAGE_BREAKING)     = Env_Fixed;
00077   var_type (PAGE_FLEXIBILITY)  = Env_Fixed;
00078   var_type (PAGE_WIDTH)        = Env_Page_Extents;
00079   var_type (PAGE_HEIGHT)       = Env_Page_Extents;
00080   var_type (PAGE_WIDTH_MARGIN) = Env_Page;
00081   var_type (PAGE_SCREEN_MARGIN)= Env_Page;
00082   var_type (PAGE_NR)           = Env_Page;
00083   var_type (PAGE_THE_PAGE)     = Env_Page;
00084   var_type (PAGE_ODD)          = Env_Page;
00085   var_type (PAGE_EVEN)         = Env_Page;
00086   var_type (PAGE_RIGHT)        = Env_Page;
00087   var_type (PAGE_TOP)          = Env_Page;
00088   var_type (PAGE_BOT)          = Env_Page;
00089   var_type (PAGE_USER_HEIGHT)  = Env_Page;
00090   var_type (PAGE_ODD_SHIFT)    = Env_Page;
00091   var_type (PAGE_EVEN_SHIFT)   = Env_Page;
00092   var_type (PAGE_SHRINK)       = Env_Page;
00093   var_type (PAGE_EXTEND)       = Env_Page;
00094   var_type (PAGE_HEAD_SEP)     = Env_Page;
00095   var_type (PAGE_FOOT_SEP)     = Env_Page;
00096   var_type (PAGE_ODD_HEADER)   = Env_Page;
00097   var_type (PAGE_ODD_FOOTER)   = Env_Page;
00098   var_type (PAGE_EVEN_HEADER)  = Env_Page;
00099   var_type (PAGE_EVEN_FOOTER)  = Env_Page;
00100   var_type (PAGE_THIS_HEADER)  = Env_Page;
00101   var_type (PAGE_THIS_FOOTER)  = Env_Page;
00102   var_type (PAGE_FNOTE_SEP)    = Env_Page;
00103   var_type (PAGE_FNOTE_BARLEN) = Env_Page;
00104   var_type (PAGE_FLOAT_SEP)    = Env_Page;
00105   var_type (PAGE_MNOTE_SEP)    = Env_Page;
00106   var_type (PAGE_MNOTE_WIDTH)  = Env_Page;
00107 
00108   var_type (POINT_STYLE)       = Env_Point_Style;
00109   var_type (LINE_WIDTH)        = Env_Line_Width;
00110   var_type (DASH_STYLE)        = Env_Dash_Style;
00111   var_type (DASH_STYLE_UNIT)   = Env_Dash_Style_Unit;
00112   var_type (FILL_COLOR)        = Env_Fill_Color;
00113   var_type (ARROW_BEGIN)       = Env_Line_Arrows;
00114   var_type (ARROW_END)         = Env_Line_Arrows;
00115   var_type (ARROW_LENGTH)      = Env_Line_Arrows;
00116   var_type (ARROW_HEIGHT)      = Env_Line_Arrows;
00117   var_type (TEXT_AT_HALIGN)    = Env_Text_At_Halign;
00118   var_type (TEXT_AT_VALIGN)    = Env_Text_At_Valign;
00119   var_type (GR_FRAME)          = Env_Frame;
00120   var_type (GR_GEOMETRY)       = Env_Geometry;
00121   var_type (GR_GRID)           = Env_Grid;
00122   var_type (GR_GRID_ASPECT)    = Env_Grid_Aspect;
00123   var_type (GR_EDIT_GRID)        = Env_Grid;
00124   var_type (GR_EDIT_GRID_ASPECT) = Env_Grid_Aspect;
00125 
00126   var_type (SRC_STYLE)         = Env_Src_Style;
00127   var_type (SRC_SPECIAL)       = Env_Src_Special;
00128   var_type (SRC_COMPACT)       = Env_Src_Compact;
00129   var_type (SRC_CLOSE)         = Env_Src_Close;
00130 }
00131 
00132 /******************************************************************************
00133 * Retrieving the page size
00134 ******************************************************************************/
00135 
00136 #define get_page_par(which) \
00137   (get_string (which) == "auto"? \
00138    as_length (page_get_feature (page_type, which, page_landscape)): \
00139    get_length (which))
00140 
00141 void
00142 edit_env_rep::update_page_pars () {
00143   page_type         = get_string (PAGE_TYPE);
00144   page_landscape    = (get_string (PAGE_ORIENTATION) == "landscape");
00145   page_automatic    = (get_string (PAGE_MEDIUM) == "automatic");
00146   string width_flag = get_string (PAGE_WIDTH_MARGIN);
00147   string height_flag= get_string (PAGE_HEIGHT_MARGIN);
00148   bool   screen_flag= get_bool   (PAGE_SCREEN_MARGIN);
00149 
00150   if (page_automatic) {
00151     page_width        = get_length (PAGE_SCREEN_WIDTH);
00152     page_height       = get_length (PAGE_SCREEN_HEIGHT);
00153     page_odd_margin   = get_length (PAGE_SCREEN_LEFT);
00154     page_right_margin = get_length (PAGE_SCREEN_RIGHT);
00155     page_even_margin  = page_odd_margin;
00156     page_top_margin   = get_length (PAGE_SCREEN_TOP);
00157     page_bottom_margin= get_length (PAGE_SCREEN_BOT);
00158     page_user_width   = page_width - page_odd_margin - page_right_margin;
00159     page_user_height  = page_height - page_top_margin - page_bottom_margin;
00160   }
00161   else {
00162     page_width        = get_page_par (PAGE_WIDTH);
00163     page_height       = get_page_par (PAGE_HEIGHT);
00164 
00165     if (width_flag == "false") {
00166       page_odd_margin   = get_page_par (PAGE_ODD);
00167       page_even_margin  = get_page_par (PAGE_EVEN);
00168       page_right_margin = get_page_par (PAGE_RIGHT);
00169       page_user_width   = page_width - page_odd_margin - page_right_margin;
00170     }
00171     else if (width_flag == "true") {
00172       page_user_width   = get_page_par (PAR_WIDTH);
00173       SI odd_sh         = get_length (PAGE_ODD_SHIFT);
00174       SI even_sh        = get_length (PAGE_EVEN_SHIFT);
00175       page_odd_margin   = ((page_width - page_user_width) >> 1) + odd_sh;
00176       page_even_margin  = ((page_width - page_user_width) >> 1) + even_sh;
00177       page_right_margin = page_width - page_odd_margin - page_user_width;
00178     }
00179     else {
00180       page_odd_margin   = get_page_par (PAGE_ODD);
00181       page_even_margin  = get_page_par (PAGE_EVEN);
00182       page_user_width   = get_page_par (PAR_WIDTH);
00183       page_right_margin = page_width - page_odd_margin - page_user_width;
00184     }
00185 
00186     if (height_flag == "false") {
00187       page_top_margin   = get_page_par (PAGE_TOP);
00188       page_bottom_margin= get_page_par (PAGE_BOT);
00189       page_user_height  = page_height - page_top_margin - page_bottom_margin;
00190     }
00191     else if (height_flag == "true") {
00192       page_user_height  = get_length (PAGE_USER_HEIGHT);
00193       page_top_margin   = (page_height - page_user_width) >> 1;
00194       page_bottom_margin= page_top_margin;
00195     }
00196     else {
00197       page_user_height  = get_length (PAGE_USER_HEIGHT);
00198       page_top_margin   = get_page_par (PAGE_TOP);
00199       page_bottom_margin= page_height - page_top_margin - page_user_height;
00200     }
00201 
00202     if (screen_flag) {
00203       page_odd_margin   = get_length (PAGE_SCREEN_LEFT);
00204       page_right_margin = get_length (PAGE_SCREEN_RIGHT);
00205       page_top_margin   = get_length (PAGE_SCREEN_TOP);
00206       page_bottom_margin= get_length (PAGE_SCREEN_BOT);
00207       page_even_margin  = page_odd_margin;
00208       page_width = page_user_width + page_odd_margin + page_right_margin;
00209       page_height= page_user_height + page_top_margin + page_bottom_margin;
00210     }
00211   }
00212 }
00213 
00214 void
00215 edit_env_rep::get_page_pars (SI& w, SI& h, SI& width, SI& height,
00216                           SI& odd, SI& even, SI& top, SI& bot)
00217 {
00218   w     = page_user_width;
00219   h     = page_user_height;
00220   width = page_width;
00221   height= page_height;
00222   odd   = page_odd_margin;
00223   even  = page_even_margin;
00224   top   = page_top_margin;
00225   bot   = page_bottom_margin;
00226 
00227   int nr_cols= get_int (PAR_COLUMNS);
00228   if (nr_cols > 1) {
00229     SI col_sep= get_length (PAR_COLUMNS_SEP);
00230     w= ((w+col_sep) / nr_cols) - col_sep;
00231   }
00232 
00233   /*
00234   cout << "w     = " << (w/PIXEL) << "\n";
00235   cout << "h     = " << (h/PIXEL) << "\n";
00236   cout << "width = " << (width/PIXEL) << "\n";
00237   cout << "height= " << (height/PIXEL) << "\n";
00238   cout << "odd   = " << (odd/PIXEL) << "\n";
00239   cout << "even  = " << (even/PIXEL) << "\n";
00240   cout << "top   = " << (top/PIXEL) << "\n";
00241   cout << "bot   = " << (bot/PIXEL) << "\n";
00242   cout << "cols  = " << nr_cols << "\n";
00243   */
00244 }
00245 
00246 /******************************************************************************
00247 * Updating the environment from the variables
00248 ******************************************************************************/
00249 
00250 void
00251 edit_env_rep::update_font () {
00252   fn_size= (int) ((((double) get_int (FONT_BASE_SIZE))+0.5)*
00253                 get_double (FONT_SIZE));
00254   switch (mode) {
00255   case 0:
00256   case 1:
00257     fn= find_font (get_string (FONT), get_string (FONT_FAMILY),
00258                  get_string (FONT_SERIES), get_string (FONT_SHAPE),
00259                  script (fn_size, index_level), (int) (magn*dpi));
00260     break;
00261   case 2:
00262     fn= find_font (get_string (MATH_FONT), get_string (MATH_FONT_FAMILY),
00263                  get_string (MATH_FONT_SERIES), get_string (MATH_FONT_SHAPE),
00264                  script (fn_size, index_level), (int) (magn*dpi));
00265     break;
00266   case 3:
00267     fn= find_font (get_string (PROG_FONT), get_string (PROG_FONT_FAMILY),
00268                  get_string (PROG_FONT_SERIES), get_string (PROG_FONT_SHAPE),
00269                  script (fn_size, index_level), (int) (magn*dpi));
00270     break;
00271   }
00272 }
00273 
00274 int
00275 decode_alpha (string s) {
00276   if (N(s) == 0) return 255;
00277   else if (s[N(s)-1] == '%')
00278     return (int) (2.55 * as_double (s (0, N(s)-1)));
00279   else return (int) (255.0 * as_double (s));
00280 }
00281 
00282 void
00283 edit_env_rep::update_color () {
00284   alpha= decode_alpha (get_string (OPACITY));
00285   string c = get_string (COLOR);
00286   string fc= get_string (FILL_COLOR);
00287   if (c == "none") {
00288     if (fc == "none") fill_mode= FILL_MODE_NOTHING;
00289     else fill_mode= FILL_MODE_INSIDE;
00290   }
00291   else {
00292     if (fc == "none") fill_mode= FILL_MODE_NONE;
00293     else fill_mode= FILL_MODE_BOTH;
00294   }
00295   col= named_color (c, alpha);
00296   fill_color= named_color (fc, alpha);
00297 }
00298 
00299 void
00300 edit_env_rep::update_mode () {
00301   string s= get_string (MODE);
00302   if (s == "text") mode=1;
00303   else if (s == "math") mode=2;
00304   else if (s == "prog") mode=3;
00305   else mode=0;
00306   if (mode == 2) mode_op= OP_SYMBOL;
00307   else mode_op= OP_TEXT;
00308 }
00309 
00310 void
00311 edit_env_rep::update_info_level () {
00312   string s= get_string (INFO_FLAG);
00313   if (s == "none") info_level= INFO_NONE;
00314   else if (s == "minimal") info_level= INFO_MINIMAL;
00315   else if (s == "short") info_level= INFO_SHORT;
00316   else if (s == "detailed") info_level= INFO_DETAILED;
00317   else if (s == "paper") info_level= INFO_PAPER;
00318   else info_level= INFO_MINIMAL;
00319 }
00320 
00321 void
00322 edit_env_rep::update_language () {
00323   switch (mode) {
00324   case 0:
00325   case 1:
00326     lan= text_language (get_string (LANGUAGE));
00327     break;
00328   case 2:
00329     lan= math_language (get_string (MATH_LANGUAGE));
00330     break;
00331   case 3:
00332     lan= prog_language (get_string (PROG_LANGUAGE));
00333     break;
00334   }
00335   hl_lan= lan->hl_lan;
00336 }
00337 
00338 void
00339 edit_env_rep::update_geometry () {
00340   tree t= env [GR_GEOMETRY];
00341   gw= as_length ("1par");
00342   gh= as_length ("0.6par");
00343   gvalign= as_string ("center");
00344   if (is_tuple (t, "geometry", 2) || is_tuple (t, "geometry", 3)) {
00345     if (is_length (as_string (t[1]))) gw= as_length (t[1]);
00346     if (is_length (as_string (t[2]))) gh= as_length (t[2]);
00347     if (is_tuple (t, "geometry", 3))
00348       gvalign= as_string (t[3]);
00349   }
00350   update_frame ();
00351 }
00352 
00353 void
00354 edit_env_rep::update_frame () {
00355   tree t= env [GR_FRAME];
00356   SI yinc= gvalign == "top"    ? - gh
00357         : gvalign == "bottom" ? 0
00358          : gvalign == "axis" ? - (gh/2) + as_length ("1yfrac")
00359         : - gh / 2;
00360   if (is_tuple (t, "scale", 2) && is_func (t[2], TUPLE, 2)) {
00361     SI magn= as_length (t[1]);
00362     SI x   = as_length (t[2][0]);
00363     SI y   = as_length (t[2][1]);
00364     fr= scaling (magn, point (x, y + yinc));
00365   }
00366   else {
00367     SI cm   = as_length (string ("1cm"));
00368     SI par  = as_length (string ("1par"));
00369     SI yfrac= as_length (string ("1yfrac"));
00370     fr= scaling (cm, point (par >> 1, yfrac + yinc));
00371   }
00372   point p0= fr (as_point (tuple ("0par", "0par")));
00373   if (gvalign == "top") {
00374     clip_lim1= fr [point (p0[0], p0[1] - gh)];
00375     clip_lim2= fr [point (p0[0] + gw, p0[1])];
00376   }
00377   else if (gvalign == "bottom") {
00378     clip_lim1= fr [point (p0[0], p0[1])];
00379     clip_lim2= fr [point (p0[0] + gw, p0[1] + gh)];
00380   }
00381   else if (gvalign == "axis") {
00382     clip_lim1= fr [point (p0[0], p0[1] - (gh/2) + as_length ("1yfrac"))];
00383     clip_lim2= fr [point (p0[0] + gw, p0[1] + (gh/2) + as_length ("1yfrac"))];
00384   }
00385   else {
00386     clip_lim1= fr [point (p0[0], p0[1] - gh/2)];
00387     clip_lim2= fr [point (p0[0] + gw, p0[1] + gh/2)];
00388   }
00389 }
00390 
00391 void
00392 edit_env_rep::update_src_style () {
00393   string s= as_string (env [SRC_STYLE]);
00394   if (s == "angular") src_style= STYLE_ANGULAR;
00395   else if (s == "scheme") src_style= STYLE_SCHEME;
00396   else if (s == "latex") src_style= STYLE_LATEX;
00397   else if (s == "functional") src_style= STYLE_FUNCTIONAL;
00398 }
00399 
00400 void
00401 edit_env_rep::update_src_special () {
00402   string s= as_string (env [SRC_SPECIAL]);
00403   if (s == "raw") src_special= SPECIAL_RAW;
00404   else if (s == "format") src_special= SPECIAL_FORMAT;
00405   else if (s == "normal") src_special= SPECIAL_NORMAL;
00406   else if (s == "maximal") src_special= SPECIAL_MAXIMAL;
00407 }
00408 
00409 void
00410 edit_env_rep::update_src_compact () {
00411   string s= as_string (env [SRC_COMPACT]);
00412   if (s == "all") src_compact= COMPACT_ALL;
00413   else if (s == "inline args") src_compact= COMPACT_INLINE_ARGS;
00414   else if (s == "normal") src_compact= COMPACT_INLINE_START;
00415   else if (s == "inline") src_compact= COMPACT_INLINE;
00416   else if (s == "none") src_compact= COMPACT_NONE;
00417 }
00418 
00419 void
00420 edit_env_rep::update_src_close () {
00421   string s= as_string (env [SRC_CLOSE]);
00422   if (s == "minimal") src_close= CLOSE_MINIMAL;
00423   else if (s == "compact") src_close= CLOSE_COMPACT;
00424   else if (s == "long") src_close= CLOSE_LONG;
00425   else if (s == "repeat") src_close= CLOSE_REPEAT;
00426 }
00427 
00428 void
00429 edit_env_rep::update_dash_style () {
00430   tree t= env [DASH_STYLE];
00431   dash_style= array<bool> (0);
00432   if (is_string (t)) {
00433     string s= as_string (t);
00434     if (N(s) > 0 && (s[0] == '0' || s[0] == '1')) {
00435       int i, n= N(s);
00436       dash_style= array<bool> (n);
00437       for (i=0; i<n; i++)
00438         dash_style[i]= (s[i] != '0');
00439     }
00440   }
00441 }
00442 
00443 void
00444 decompose_length (string s, double& x, string& un) {
00445   int i;
00446   for (i=0; i<N(s); i++)
00447     if ((s[i]>='a') && (s[i]<='z')) break;
00448   x = as_double (s (0, i));
00449   un= s (i, N(s));
00450 }
00451 
00452 tree
00453 edit_env_rep::decode_arrow (tree t, string l, string h) {
00454   if (is_string (t)) {
00455     string s= t->label;
00456     if (s == "" || s == "none") return "";
00457     double lx, hx;
00458     string lun, hun;
00459     decompose_length (l, lx, lun);
00460     decompose_length (h, hx, hun);
00461     if (s == "<less>")
00462       return tree (LINE,
00463                    tree (_POINT, l, h),
00464                    tree (_POINT, "0" * lun, "0" * hun),
00465                    tree (_POINT, l, as_string (-hx) * hun));
00466     if (s == "<gtr>")
00467       return tree (LINE,
00468                    tree (_POINT, as_string (-lx) * lun, h),
00469                    tree (_POINT, "0" * lun, "0" * hun),
00470                    tree (_POINT, as_string (-lx) * lun,
00471                                  as_string (-hx) * hun));
00472     if (s == "<less>|")
00473       return tree (WITH, FILL_COLOR, tree (VALUE, COLOR),
00474                    LINE_WIDTH, "0ln",
00475                    tree (CLINE,
00476                          tree (_POINT, l, h),
00477                          tree (_POINT, "0" * lun, "0" * hun),
00478                          tree (_POINT, l, as_string (-hx) * hun)));
00479     if (s == "|<gtr>")
00480       return tree (WITH, FILL_COLOR, tree (VALUE, COLOR),
00481                    LINE_WIDTH, "0ln",
00482                    tree (CLINE,
00483                          tree (_POINT, as_string (-lx) * lun, h),
00484                          tree (_POINT, "0" * lun, "0" * hun),
00485                          tree (_POINT, as_string (-lx) * lun,
00486                                as_string (-hx) * hun)));
00487     if (s == "<gtr>")
00488       return tree (LINE,
00489                    tree (_POINT, as_string (-lx) * lun, h),
00490                    tree (_POINT, "0" * lun, "0" * hun),
00491                    tree (_POINT, as_string (-lx) * lun,
00492                                  as_string (-hx) * hun));
00493     if (s == "<less><less>")
00494       return tree (GR_GROUP,
00495                    tree (LINE,
00496                          tree (_POINT, l, h),
00497                          tree (_POINT, "0" * lun, "0" * hun),
00498                          tree (_POINT, l, as_string (-hx) * hun)),
00499                    tree (LINE,
00500                          tree (_POINT, as_string (0 * lx) * lun, h),
00501                          tree (_POINT, as_string (-lx) * lun, "0" * hun),
00502                          tree (_POINT, as_string (0 * lx) * lun,
00503                                as_string (-hx) * hun)));
00504     if (s == "<gtr><gtr>")
00505       return tree (GR_GROUP,
00506                    tree (LINE,
00507                          tree (_POINT, as_string (-lx) * lun, h),
00508                          tree (_POINT, "0" * lun, "0" * hun),
00509                          tree (_POINT, as_string (-lx) * lun,
00510                                as_string (-hx) * hun)),
00511                    tree (LINE,
00512                          tree (_POINT, as_string (0 * lx) * lun, h),
00513                          tree (_POINT, as_string (lx) * lun, "0" * hun),
00514                          tree (_POINT, as_string (0 * lx) * lun,
00515                                as_string (-hx) * hun)));                   
00516     if (s == "|")
00517       return tree (LINE,
00518                    tree (_POINT, "0" * lun, h),
00519                    tree (_POINT, "0" * lun, as_string (-hx) * hun));
00520     if (s == "o")
00521       return tree (WITH, FILL_COLOR, tree (VALUE, COLOR),
00522                    LINE_WIDTH, "0ln",
00523                    tree (CARC,
00524                          tree (_POINT, "0" * lun, h),
00525                          tree (_POINT, l, "0" * hun),
00526                          tree (_POINT, "0" * lun, as_string (-hx) * hun)));
00527     return "";
00528   }
00529   else return t;
00530 }
00531 
00532 void
00533 edit_env_rep::update_line_arrows () {
00534   line_arrows= array<tree> (2);
00535   string l= get_string (ARROW_LENGTH);
00536   string h= get_string (ARROW_HEIGHT);
00537   line_arrows[0]= decode_arrow (env [ARROW_BEGIN], l, h);
00538   line_arrows[1]= decode_arrow (env [ARROW_END], l, h);
00539 }
00540 
00541 void
00542 edit_env_rep::update () {
00543   magn           = get_double (MAGNIFICATION);
00544   index_level    = get_int (MATH_LEVEL);
00545   display_style  = get_bool (MATH_DISPLAY);
00546   math_condensed = get_bool (MATH_CONDENSED);
00547   vert_pos       = get_int (MATH_VPOS);
00548   preamble       = get_bool (PREAMBLE);
00549 
00550   update_color ();
00551   update_mode ();
00552   update_info_level ();
00553   update_language ();
00554   update_font ();
00555 
00556   update_geometry ();
00557   update_frame ();
00558   point_style= get_string (POINT_STYLE);
00559   lw= get_length (LINE_WIDTH);
00560   update_dash_style ();
00561   dash_style_unit= get_length (DASH_STYLE_UNIT);
00562   update_line_arrows ();
00563   text_at_halign= get_string (TEXT_AT_HALIGN);
00564   text_at_valign= get_string (TEXT_AT_VALIGN);
00565 
00566   update_src_style ();
00567   update_src_special ();
00568   update_src_compact ();
00569   update_src_close ();
00570 }
00571 
00572 /******************************************************************************
00573 * Update a particular changed variable
00574 ******************************************************************************/
00575 
00576 void
00577 edit_env_rep::update (string s) {
00578   switch (var_type[s]) {
00579   case Env_User:
00580     break;
00581   case Env_Fixed:
00582     break;
00583   case Env_Magnification:
00584     magn= get_double (MAGNIFICATION);
00585     update_font ();
00586     lw= get_length (LINE_WIDTH);
00587     break;
00588   case Env_Magnify:
00589     mgfy= get_double (MAGNIFY);
00590     break;
00591   case Env_Language:
00592     update_language ();
00593     break;
00594   case Env_Mode:
00595     update_mode ();
00596     update_language ();
00597     update_font ();
00598     break;
00599   case Env_Font:
00600     update_font ();
00601     break;
00602   case Env_Font_Size:
00603     update_font ();
00604     break;
00605   case Env_Index_Level:
00606     index_level= get_int (MATH_LEVEL);
00607     update_font ();
00608     break;
00609   case Env_Display_Style:
00610     display_style= get_bool (MATH_DISPLAY);
00611     break;
00612   case Env_Math_Condensed:
00613     math_condensed= get_bool (MATH_CONDENSED);
00614     break;
00615   case Env_Vertical_Pos:
00616     vert_pos= get_int (MATH_VPOS);
00617     break;
00618   case Env_Color:
00619     update_color ();
00620     break;
00621   case Env_Paragraph:
00622     break;
00623   case Env_Page:
00624     break;
00625   case Env_Page_Extents:
00626     update_page_pars ();
00627     break;
00628   case Env_Preamble:
00629     preamble= get_bool (PREAMBLE);
00630     break;
00631   case Env_Geometry:
00632     update_geometry ();
00633     break;
00634   case Env_Frame:
00635     update_frame ();
00636     break;
00637   case Env_Point_Style:
00638     point_style= get_string (POINT_STYLE);
00639     break;
00640   case Env_Line_Width:
00641     lw= get_length (LINE_WIDTH);
00642     break;
00643   case Env_Dash_Style:
00644     update_dash_style();
00645     break;
00646   case Env_Dash_Style_Unit:
00647     dash_style_unit= get_length (DASH_STYLE_UNIT);
00648     break;
00649   case Env_Fill_Color:
00650     update_color ();
00651     break;
00652   case Env_Line_Arrows:
00653     update_line_arrows();
00654     break;
00655   case Env_Text_At_Halign:
00656     text_at_halign= get_string (TEXT_AT_HALIGN);
00657     break;
00658   case Env_Text_At_Valign:
00659     text_at_valign= get_string (TEXT_AT_VALIGN);
00660     break;
00661   case Env_Src_Style:
00662     update_src_style ();
00663     break;
00664   case Env_Src_Special:
00665     update_src_special ();
00666     break;
00667   case Env_Src_Compact:
00668     update_src_compact ();
00669     break;
00670   case Env_Src_Close:
00671     update_src_close ();
00672     break;
00673   }
00674 }