/***************************************************************************
 *   Copyright (C) 2004 by Hans Oischinger                                 *
 *   hans.oischinger@kdemail.net                                           *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/
#include "stylable.h"

// Elements
#include "fillattribute.h"
#include "strokeattribute.h"
#include "animatednumber.h"

// Qt
#include <qstring.h>

Stylable::Stylable(const QString & name, State state )
    : ElementNode( name, state )
{
  init();
}

Stylable::~Stylable()
{
  delete m_fill;
  delete m_stroke;
}

Stylable::Stylable( const Stylable &other ) : ElementNode()
{
  init();
  (*this) = other;
}

Stylable& Stylable::operator=(const Stylable &other)
{
  ElementNode::operator=(other);
  *m_fill = other.fill();
  *m_stroke = other.stroke();
  return *this;
}

void Stylable::init()
{
  m_fill = new FillAttribute(this);
  m_stroke = new StrokeAttribute(this);
}

Attribute* Stylable::getAttrByName( const QString & name )
{
  if (name == "fill")
    return m_fill;
  else if (name == "stroke")
    return m_stroke;
  else if (name == "fill-opacity")
    return &m_fill->fillOpacity();
  else if (name == "stroke-opacity")
    return &m_stroke->strokeOpacity();
  else if (name == "stroke-width")
    return &m_stroke->strokeWidth();
  else
    return 0;
}


#include "stylable.moc"
