/*--------------------------------------------------------------------------
  Project:  Manual 2D Library - m2d
  File:     m2d_uiStatic.cpp

  Copyright (C)2007-2009 Nintendo  All Rights Reserved.

  These coded instructions, statements, and computer programs contain
  proprietary information of Nintendo of America Inc. and/or Nintendo
  Company Ltd., and are protected by Federal copyright law. They may
  not be disclosed to third parties or copied or duplicated in any form,
  in whole or in part, without the prior written consent of Nintendo.

  $Revision: 419 $
 *-------------------------------------------------------------------------*/

#include <ntmv/m2d/Rect.h>
#include <ntmv/m2d/uiStatic.h>
#include <ntmv/m2d/objG2dInfo.h>

namespace ntmv
{
namespace m2d
{

/*---------------------------------------------------------------------------*
  Name:         UIStatic::UIStatic

  Description:  Constructor.

  Arguments:    None.

  Returns:      None.
 *---------------------------------------------------------------------------*/
UIStatic::UIStatic()
:   
    mCell(ObjManager::InvalidCellHandle)
{}

/*---------------------------------------------------------------------------*
  Name:         UIStatic::Init

  Description:  Performs initialization. Sets the following content.
                    - Display position
                    - Cell animation handle.

  Arguments:    position:  Display position (center).
                size:      Size.
                cell :      Animation cell handle for the normal button.

  Returns:      None.
 *---------------------------------------------------------------------------*/
void
UIStatic::Init(
    Point                   position,
    Size                    size,
    ObjManager::CellHandle  cell
)
{
    mPosition  = position;
    mSize      = size;
    mCell      = cell;
}

/*---------------------------------------------------------------------------*
  Name:         UIStatic::Draw

  Description:  Performs rendering.

  Arguments:    info:      A reference to an ObjG2dInfo object.
                parentPos: Parent position (global coordinates).

  Returns:      None.
 *---------------------------------------------------------------------------*/
void
UIStatic::Draw(
    const ObjG2dInfo&   info,
    Point               parentPos
)
{
    if (! DrawTest(parentPos))
    {
        return;
    }

    info.GetOBJManager()->DrawCellAnim(
        mCell,
        mGlbPosition.x * FX32_ONE,
        mGlbPosition.y * FX32_ONE);
}

/*---------------------------------------------------------------------------*
  Name:         UIStatic::SetAnimFrame

  Description:  Sets the playback animation frame for a cell animation.

  Arguments:    pOamManager: A pointer to an ObjManager object.
                index:       Animation frame number.

  Returns:      None.
 *---------------------------------------------------------------------------*/
void
UIStatic::SetAnimFrame(
    ObjManager* pObjManager,
    u16         index
)
{
    pObjManager->SetCellAnimFrame(mCell, index);
}

/*---------------------------------------------------------------------------*
  Name:         UIStatic::Animate

  Description:  Update the cell animation.

  Arguments:    pObjManager: A pointer to an ObjManager object.

  Returns:      None.
 *---------------------------------------------------------------------------*/
void
UIStatic::Animate(ObjManager* pObjManager)
{
    pObjManager->TickCellAnim(mCell, FX32_ONE);
}


}   // namespace m2d
}   // namespace ntmv
