/* libsswf_tag_setbackgroundcolor.c++ -- written by Alexis WILKE for Made to Order Software Corp. (c) 2002-2008 */

/*

Copyright (c) 2002-2008 Made to Order Software Corp.

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/

/** \file
 *
 * \brief The implementation of the sswf::TagSetBackgroundColor class
 *
 * This file declares the body of the functions which are not
 * inline. It is part of the SSWF library.
 */

#include	"sswf/libsswf.h"

using namespace sswf;



/////////////////////////////////////////// TagSetBackgroundColor

/** \class sswf::TagSetBackgroundColor
 *
 * \brief Set the background color of the movie
 *
 * This tag is used to defined the default background color of the
 * movie. When unspecified, the background of a Flash animation is
 * white.
 *
 * Note however that the default color of a TagSetBackgroundColor
 * is black.
 *
 * The background color uses a solid color (no transparency). This
 * prevents the Browsers from showing anything behind the Flash
 * animation.
 *
 * \sa <a href="../SWFalexref.html#tag_setbackgroundcolor">SWF Alexis' Reference&mdash;Set Background Color</a>
 * \sa <a href="../SWFalexref.html#swf_tag">SWF Alexis' Reference&mdash;swf_tag</a>
 */


/** \brief Initializes the background color object
 *
 * Initializes the background object.
 *
 * \param[in] parent The header in which this tag is added
 */
TagSetBackgroundColor::TagSetBackgroundColor(TagBase *parent)
	: TagBase("setbackgroundcolor", parent)
{
}


/** \brief Defines the different types of the background color tag
 *
 * This function defines the SetBackgroundColor tag as:
 *
 * \li SWF_TYPE_DEFINE&mdash;a definition
 * \li SWF_TYPE_UNIQUE&mdash;must be defined only once in the entire movie
 * \li SWF_TYPE_START&mdash;must be close to the start of the movie
 *
 * \return a set of TagBase::swf_type_t flags
 */
TagBase::swf_type_t TagSetBackgroundColor::TypeFlags(void) const
{
	return SWF_TYPE_DEFINE | SWF_TYPE_UNIQUE | SWF_TYPE_START;
}


/** \brief Defines the color of the background
 *
 * This function copies the user color as the new background color.
 *
 * \param[in] color The new background color
 */
void TagSetBackgroundColor::SetColor(Color& color)
{
	f_color = color;
}


/** \brief Retrive the current background color
 *
 * This function returns a copy of the current background color.
 *
 * \return The current background color
 */
Color& TagSetBackgroundColor::GetColor(void)
{
	return f_color;
}


/** \brief Save the background color
 *
 * This function saves the background color in the specified Data buffer.
 *
 * The red, green and blue components are saved. The alpha channel is
 * ignored.
 *
 * \return An ErrorManager::error_code_t error, ErrorManager::ERROR_CODE_NONE when no error occured
 */
ErrorManager::error_code_t TagSetBackgroundColor::Save(Data& data)
{
	SaveTag(data, SWF_TAG_SET_BACKGROUND_COLOR, 3);

	data.PutByte(f_color.Red());
	data.PutByte(f_color.Green());
	data.PutByte(f_color.Blue());

	return ErrorManager::ERROR_CODE_NONE;
}





/* The following options fold the documentation; use 'zi' to turn on and off
 *
 * vim: foldexpr=getline(v\:lnum)!~'^/\\*\\*'&&getline(v\:lnum)!~'^\ \\*'?0\:1 foldcolumn=2 foldmethod=expr
 */
