]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.65
authorfred <fred>
Sun, 25 May 1997 22:09:14 +0000 (22:09 +0000)
committerfred <fred>
Sun, 25 May 1997 22:09:14 +0000 (22:09 +0000)
lily/elem-group.cc [new file with mode: 0644]
lily/include/elem-group.hh [new file with mode: 0644]

diff --git a/lily/elem-group.cc b/lily/elem-group.cc
new file mode 100644 (file)
index 0000000..e4a012d
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+  elem-group.cc -- implement Element_group
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "elem-group.hh"
+#include "interval.hh"
+#include "item.hh"
+#include "debug.hh"
+
+Interval
+Element_group::do_height()const 
+{
+    Interval r;
+    for (int i=0; i < elem_l_arr_.size(); i++) 
+       r.unite(elem_l_arr_[i]->height());
+    return r;
+}
+
+Interval
+Element_group::do_width()const 
+{
+    Interval r;
+    for (int i=0; i < elem_l_arr_.size(); i++) 
+       if (elem_l_arr_[i]->item()) // makes no at preprocessing for spanners. 
+           r.unite(elem_l_arr_[i]->width());
+    return r;
+}
+
+void
+Element_group::add_element(Score_elem*i_l)
+{
+    i_l->group_element_i_ ++;
+    
+    assert(! elem_l_arr_.find_l(i_l));
+    elem_l_arr_.push(i_l);
+    add_dependency(i_l);
+}
+
+void
+Element_group::translate(Offset o)
+{
+    for (int i=0; i < elem_l_arr_.size(); i++) 
+       elem_l_arr_[i]->translate(o);
+}
+
+IMPLEMENT_STATIC_NAME(Element_group);
+
+void
+Element_group::do_print() const
+{
+#ifndef NPRINT
+    for (int i=0; i < elem_l_arr_.size(); i++) 
+       mtor << elem_l_arr_[i]->name() << ' ';
+#endif
+}
+
+void
+Element_group::do_substitute_dependency(Score_elem* old, Score_elem *new_l)
+{
+    int i;
+
+    while ((i=elem_l_arr_.find_i(old))>=0) {
+       
+       old->group_element_i_--;
+       if (new_l){ 
+           new_l->group_element_i_ ++;
+           elem_l_arr_[i] = new_l;
+       }else {     
+           elem_l_arr_.del(i);
+       }
+    }
+
+}
+
+String
+Element_group::TeX_string()const
+{
+    return "";
+}
+
+Element_group::Element_group(Element_group const&s)
+    :elem_l_arr_(s.elem_l_arr_)
+{
+   for (int i=0; i < elem_l_arr_.size(); i++) 
+       elem_l_arr_[i]->group_element_i_ ++;   
+}
+
+Element_group::Element_group()
+{}
diff --git a/lily/include/elem-group.hh b/lily/include/elem-group.hh
new file mode 100644 (file)
index 0000000..0e544ad
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+  elem-group.hh -- declare Element_group
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef ELEM_GROUP_HH
+#define ELEM_GROUP_HH
+#include "score-elem.hh"
+
+/** A class to treat a group of elements as a single entity. The
+  dimensions are the unions of the dimensions of what it contains.
+  Translation means translating the contents.
+  */
+class Element_group : virtual Score_elem{  
+protected:
+    Link_array<Score_elem> elem_l_arr_;
+    virtual void do_substitute_dependency(Score_elem* old, Score_elem* new_l);
+    virtual Interval do_height()const;
+    virtual Interval do_width()const;
+    virtual void do_print() const ;
+    virtual Element_group* elem_group() { return this; }
+    
+    
+public:
+    Element_group();
+    Element_group(Element_group const&);
+    NAME_MEMBERS(Element_group);
+    virtual void translate(Offset);
+    virtual void add_element(Score_elem*);
+    virtual String TeX_string()const;
+};
+
+#endif // ELEM_GROUP_HH