/*--------------------------------------------------------------------------
  Project:  Manual 2D Library - m2d
  File:     pane.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: 1.43 $
 *-------------------------------------------------------------------------*/

#ifndef NTMV_M2D_PANE_H_
#define NTMV_M2D_PANE_H_

#if defined(__CWCC__)
#pragma once
#endif

#include <ntmv/m2d/types.h>
#include <ntmv/m2d/RuntimeTypeInfo.h>
#include <ntmv/m2d/resources.h>
#include <ntmv/m2d/common.h>
#include <ntmv/m2d/Rect.h>
#include <cstddef>

namespace ntmv
{
namespace m2d
{

struct Rect;
class DrawInfo;
class Page;
class Pane;

class Pane
{
public:
    NTMV_RNT_RUNTIME_TYPEINFO;

                        Pane(
                            const res::Pane*    pBlock,
                            const ResBlockSet&  resBlockSet);

    virtual void        Finalize(const ObjectConstructor& objectConstructor);

    void                Calc(
                            const DrawInfo& drawInfo,
                            Point           parentPosition);

    void                Draw(const DrawInfo& drawInfo);

    #if defined(NTMV_M2D_NAMEEMBEDDED)
        const char*         GetName() const             { return mName; }

        virtual Pane*       FindPaneByName(
                                const char* findName,
                                bool        bRecursive = true);
    #endif

    Pane*               GetParent() const           { return mpParent; }
    Pane**              GetChildArray() const       { return mChildAry; }

    void                AllocChild(
                            const ObjectConstructor&    objectConstructor,
                            u16                         paneNum);

    void                AppendChild(Pane* pChild);

    const Point&        GetPosition() const                     { return mPosition; }
    void                SetPosition(const Point& value)         { mPosition = value; }

    const Size&         GetSize() const                         { return mSize; }
    void                SetSize(const Size& value)              { mSize = value; }

    const Rect          GetPaneRect() const;

    bool                Contains(Point point) const { return GetPaneRect().Contains(point); }

    const Point&        GetLocalPosition() const                { return mLocalPosition; }
    void                SetLocalPosition(const Point& value)    { mLocalPosition = value; }

    u16                 GetChildNum() const         { return mChildNum; }

protected:
    virtual void        CalcSelf(
                            const DrawInfo& drawInfo,
                            Point           parentPosition);

    virtual void        DrawSelf(const DrawInfo& drawInfo);

    Pane*               mpParent;
    Pane**              mChildAry;
    #if defined(NTMV_M2D_NAMEEMBEDDED)
        const char*         mName;
    #endif

    Point               mLocalPosition;
    Point               mPosition;
    Size                mSize;

    u16                 mChildNum;
    u16                 mChildMax;

    u8                  mFlag;

private:
                        // Prohibit calling the copy constructor and assignment operator. This must not be implemented.
                        Pane(const Pane& other);
                        Pane& operator = (const Pane& other);

    void                Init();
};

}   // namespace m2d
}   // namespace ntmv

/* NTMV_M2D_PANE_H_ */
#endif

