]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/atom.cc
release: 1.3.25
[lilypond.git] / lily / atom.cc
index 0f1f2052891710a10d25883ab588aa3e53a12580..cc2bde40be01f211d289b59360968f200294e2f9 100644 (file)
@@ -3,75 +3,78 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
+
+#include <math.h>
+#include "ly-smobs.icc"
+
 #include "atom.hh"
-#include "tex.hh"
 #include "interval.hh"
-#include "dimen.hh"
 #include "string.hh"
-#include "varray.hh"
+#include "array.hh"
 #include "debug.hh"
+#include "dimensions.hh"
+#include "lookup.hh"
+#include "main.hh"
+#include "global-ctor.hh"
+#include "font-metric.hh"
 
-void
-Atom::print() const
+Atom::Atom(SCM s)
 {
-#ifndef NPRINT
-  DOUT << "texstring: " <<tex_<<"\n";    
-#endif
+  SCM onstack = s;             // protection. just to be sure.
+  func_ = s;
+  self_scm_ = SCM_EOL;
+  smobify_self ();
 }
 
-Box
-Atom::extent() const
+SCM
+Atom::mark_smob (SCM s)
 {
-  Box b (dim_);
-  b.translate (off_);
-  return b;
+  Atom*  a = SMOB_TO_TYPE(Atom, s);
+  assert (s == a->self_scm_);
+  return a->func_;
 }
 
-
-Atom::Atom()
-  : dim_ (Interval (0,0),Interval (0,0))
+void
+Atom::fontify (Font_metric * met)
 {
-  tex_ = "\\unknown";
+  SCM desc = ly_quote_scm (met->description ());
+  SCM font_switch = gh_list (ly_symbol2scm ("select-font"),
+                            desc,
+                            SCM_UNDEFINED);
+
+  SCM f =func_;
+  func_ = gh_list (ly_symbol2scm ("string-append"),
+                  font_switch , f,
+                  SCM_UNDEFINED);
 }
 
-Atom::Atom (String s, Box b)
-  :  dim_ (b)
+void
+Atom::do_smobify_self ()
 {
-  tex_ = s;
 }
 
-
-String
-Atom::str() const 
+Atom::Atom (Atom const &s)
 {
-  return "Atom (\'"+tex_+"\', (" + dim_.x().str () + ", " 
-    + dim_.y ().str () + "))";
+  off_ = s.off_;
+  func_ = s.func_;
+  self_scm_= SCM_EOL;
+  smobify_self ();
 }
-
-String
-Atom::TeX_string() const
+int
+Atom::print_smob (SCM s, SCM p, scm_print_state*)
 {
-  String tex_str = tex_;
-  Offset off = off_;
+  Atom * a = unsmob_atom (s);
 
-  /* infinity checks. */
-  for (int a =X_AXIS; a < NO_AXES; a++)
-    {
-      Axis ax = (Axis)a;
-      if (abs (off[ax]) >= 100 CM)
-       {
-         warning ("ridiculous dimension " + axis_name_str (ax)  + ", " 
-                  +print_dimen(off[ax]));
-         off[ax] = 0.0;
-         tex_str += "\errormark"; 
-       }
-    }
-  // whugh.. Hard coded...
-  String s ("\\placebox{");
-  s += print_dimen (off[Y_AXIS])+"}{";
-  s += print_dimen (off[X_AXIS]) + "}{";
-  s += tex_str + "}";
-  return s;
+  scm_puts ("#<Atom off ",p);
+  String str(a->off_.str ());
+  scm_puts ((char *)str.ch_C(), p);
+  scm_display (a->func_, p);
+  scm_puts ("> ",p);  
+  return 1;
 }
+  
+IMPLEMENT_UNSMOB(Atom, atom)
+IMPLEMENT_SMOBS(Atom)
+