]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_atom.C
Change the color of the background widget to red.
[lyx.git] / src / mathed / math_atom.C
index bcf72881cce99c386ffa57024577587021d6f221..bd5cda75be3aec9bbe5a9d2be7819ba77e7e862a 100644 (file)
@@ -1,27 +1,19 @@
-/*
- *  File:        math_inset.C
- *  Purpose:     Implementation of insets for mathed
- *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
- *  Created:     January 1996
- *  Description: 
+/**
+ * \file math_atom.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *  Dependencies: Xlib, XForms
+ * \author André Pönitz
  *
- *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
- *
- *   Version: 0.8beta.
- *
- *   You are free to use and modify this code under the terms of
- *   the GNU General Public Licence version 2 or later.
+ * Full author contact details are available in file CREDITS.
  */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
 #include "math_atom.h"
 #include "math_inset.h"
-#include "support/LAssert.h"
+
+using std::swap;
 
 
 MathAtom::MathAtom()
@@ -29,63 +21,29 @@ MathAtom::MathAtom()
 {}
 
 
-MathAtom::MathAtom(MathInset * p)
-       : nucleus_(p)
+MathAtom::MathAtom(InsetBase * p)
+       : nucleus_(static_cast<MathInset *>(p))
 {}
 
 
-MathAtom::MathAtom(MathAtom const & p)
+MathAtom::MathAtom(MathAtom const & at)
+       : nucleus_(0)
 {
-       copy(p);
+       if (at.nucleus_)
+               nucleus_ = static_cast<MathInset*>(at.nucleus_->clone().release());
 }
 
 
-void MathAtom::operator=(MathAtom const & p)
+void MathAtom::operator=(MathAtom const & at)
 {
-       if (this == &p)
+       if (&at == this)
                return;
-       done();
-       copy(p);
+       MathAtom tmp(at);
+       swap(tmp.nucleus_, nucleus_);
 }
 
 
 MathAtom::~MathAtom()
-{
-       done();
-}
-
-
-void MathAtom::reset(MathInset * p)
-{
-       done();
-       nucleus_ = p;
-}
-
-
-
-void MathAtom::done()
 {
        delete nucleus_;
 }
-
-
-void MathAtom::copy(MathAtom const & p)
-{
-       //cerr << "calling MathAtom::copy\n";
-       nucleus_   = p.nucleus_;
-       if (nucleus_)
-               nucleus_ = nucleus_->clone();
-}
-
-
-MathInset * MathAtom::nucleus() const
-{
-       lyx::Assert(nucleus_);
-       return nucleus_;
-}
-
-
-MathInset * MathAtom::operator->() const
-{
-       return nucleus();
-}