/*--------------------------------------------------------------------------
  Project:  Manual 2D Library - m2d
  File:     uiElement.h

  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: 1758 $
 *-------------------------------------------------------------------------*/

#ifndef NTMV_M2D_UIELEMENT_H_
#define NTMV_M2D_UIELEMENT_H_

#if _MSC_VER > 1000 || defined(__CWCC__)
#pragma once
#endif

#include <ntmv/m2d/types.h>

namespace ntmv
{
namespace m2d
{

class ObjectConstructor;
class ObjG2dInfo;

/*
    UI element class
*/
class UIElement
{
public:
                        UIElement();

                        UIElement(
                            Point   position,
                            Size    size);

    virtual void        Finalize(const ObjectConstructor& objectConstructor);

    virtual void        Draw(
                            const ObjG2dInfo&   info,
                            Point               parentPos);

    bool                Contains(Point point) const;

    Point               GetPosition() const         { return mPosition; }

    virtual void        SetPosition(Point value);

    Size                GetSize() const             { return mSize; }

    virtual void        SetSize(Size value);

    Point               GetGlbPosition() const      { return mGlbPosition; }

    bool                IsEnabled() const           { return ! mFlags.disabled; }

    void                SetEnabled(bool value)      { mFlags.disabled = ! value; }

    bool                IsVisible() const           { return ! mFlags.invisible; }

    virtual void        SetVisible(bool value);

    bool                IsPointed() const       { return mFlags.pointed; }

    void                SetPointed(bool value)  { mFlags.pointed = value; }

    void                CheckHit(Point point);

protected:
    void                CalcGlbPosition(Point parentPos)
    {
        mGlbPosition = parentPos + mPosition;
    }

    Point               GetLTGlbPosition() const;

    bool                IsDrawn() const;

    bool                DrawTest(Point parentPos);

    Point               mPosition;
    Size                mSize;
    Point               mGlbPosition;

private:
    struct
    {
        u8                  invisible : 1;
        u8                  disabled  : 1;
        u8                  pointed   : 1;
    }                   mFlags;
};

}   // namespace m2d
}   // namespace ntmv

/* NTMV_M2D_UIELEMENT_H_ */
#endif
