
#include <Symbol.h>
#include <MyFrame.h>

extern int SystemFontSize;

class CCustom:public CObject
{
private:
        BOOL m_bState;

public:
       void SetState(BOOL bState){m_bState = bState;}
       BOOL GetState(){return(m_bState);}

public:
       virtual BOOL  Show();

       virtual void  KillFocus();
       virtual void  SetFocus();

       virtual int   Swapping();

public:
       CCustom(CObject* pParent);
       ~CCustom();
};


CCustom::CCustom(CObject* pParent):CObject(pParent)
{
    m_bTab = TRUE;

    m_nForeColor = BLACK;
    m_nBackColor = LIGHTBLUE;


    //===================
    m_bState = TRUE;
}

CCustom::~CCustom()
{
}

void CCustom::SetFocus()
{
    viewporttype mView;
    BOOL bMouse = CCustom::StartControlView(&mView);
    //----------------------------------------------
    int nLeft, nTop;


    ::SetColor (RED);
    ::Rectangle(m_ClientRect.left, m_ClientRect.top,
        m_ClientRect.right, m_ClientRect.bottom);


    char *pString1 = "YES-Focus";
    char *pString2 = "NO--Focus";

    //Kill String
    nLeft =   (m_ClientRect.left + m_ClientRect.right) / 2 -
        (_fstrlen(pString2) * 8) / 2;
    nTop = (m_ClientRect.top + m_ClientRect.bottom) / 2 - 8;

    ::ChPrintf (nLeft, nTop, m_nBackColor, m_nBackColor, 1, 1, pString2);

    //Draw String
    nLeft =   (m_ClientRect.left + m_ClientRect.right) / 2 -
        (_fstrlen(pString1) * 8) / 2;
    nTop = (m_ClientRect.top + m_ClientRect.bottom) / 2 - 8;

    ::ChPrintf (nLeft, nTop, WHITE, m_nBackColor, 1, 0, pString1);

    //----------------------------------------------
  	CObject::EndControlView(&mView, bMouse);
    return;
}

void CCustom::KillFocus()
{
    viewporttype mView;
    BOOL bMouse = CCustom::StartControlView(&mView);
    //----------------------------------------------
    int nLeft, nTop;

    //Draw Rectange
    ::SetColor(m_nBackColor);
    ::Rectangle(m_ClientRect.left, m_ClientRect.top,
        m_ClientRect.right, m_ClientRect.bottom);

    char *pString1 = "YES-Focus";
    char *pString2 = "NO--Focus";

    //Kill String
    nLeft =   (m_ClientRect.left + m_ClientRect.right) / 2 -
        (_fstrlen(pString1) * 8) / 2;
    nTop = (m_ClientRect.top + m_ClientRect.bottom) / 2 - 8;

    ::ChPrintf (nLeft, nTop, m_nBackColor, m_nBackColor, 1, 1, pString1);


    //Draw String
    nLeft =   (m_ClientRect.left + m_ClientRect.right) / 2 -
        (_fstrlen(pString2) * 8) / 2;
    nTop = (m_ClientRect.top + m_ClientRect.bottom) / 2 - 8;

    ::ChPrintf (nLeft, nTop, WHITE, m_nBackColor, 1, 0, pString2);

    //----------------------------------------------
  	CObject::EndControlView(&mView, bMouse);
    return;

}

BOOL CCustom::Show()
{
    viewporttype mView;
    BOOL bMouse = CCustom::StartControlView(&mView);
    //----------------------------------------------
    ::SetFillStyle(1, m_nBackColor);
    this->EditShow();


    //Draw Ellise
    ::SetColor(WHITE);
    ::SetFillStyle(1, GREEN);
    ::FillEllipse((m_ClientRect.left + m_ClientRect.right) / 2,
        m_ClientRect.top + 8, 5, 5);

    this->KillFocus();

    //----------------------------------------------
  	CObject::EndControlView(&mView, bMouse);
    return (TRUE);
}

int CCustom::Swapping()
{
    int nKey = CObject::DefaultSwapping();

    switch (nKey)
    {
        case VK_MOUSE_SCREEN_OUT:
        {
            break;
        }
        case VK_MOUSE_CLIENT_OUT:
        {
            nKey = 0;

            break;
        }
        case VK_MOUSE_DOWN_LEFT: //Mouse Left Button is Down.
        {
            int nMouseX = ::GetMouseX();
            int nMouseY = ::GetMouseY();

            //left mouse button is down?
            while (::IsMouseDown(MOUSE_LEFT))
            {
            }

            break;
        }
        case VK_F1:
        {
            AfxMessageBox("Debug", "F1 Key");

            nKey = 0;
            break;
        }
        case VK_0:
        case VK_1:
        case VK_2:
        case VK_3:
        case VK_4:
        case VK_5:
        case VK_6:
        case VK_7:
        case VK_8:
        case VK_9:
        {
            char buf[100];
            ::sprintf (buf, "This is Number Key");

            AfxMessageBox("Debug", buf);

            nKey = 0;
            break;
        }
        default:
        {
            break;
        }
    }

    return (nKey);
}




void MyCustom(CObject* pParent,int nLeft, int nTop)
{
    CCustom* pCustom1 = new CCustom(pParent);
    pCustom1->CreateObject (nLeft,nTop, 100, 60, NULL);




}





