#pragma once

#include "resource.h"

enum BKKeyType
{
	BKKEY_RESERVED,
	BKKEY_REGULAR,
	BKKEY_LSHIFT,
	BKKEY_RSHIFT,
	BKKEY_CTRL,
	BKKEY_ALT,
	BKKEY_ZAGL,
	BKKEY_STR,
	BKKEY_STOP,
	BKKEY_ENDARRAY
};

struct BKKey
{
	BKKeyType nType;
	int x1;
	int y1;
	int x2;
	int y2;
	BYTE nScanCode;
	BYTE nInt;
};


class CBKKbdButn :
	public CWnd
{
	protected:
		HBITMAP m_hBmp;
		int m_cx;
		int m_cy;
		int m_nKbdBitMapLeft;
		int m_nKbdBitmapTop;
		int m_nIdx;

		int m_nAR2Index;
		int m_nSUIndex;
		int m_nLShiftIndex;
		int m_nRShiftIndex;
		int m_nArraySize;

		BOOL m_bAR2Pressed;
		BOOL m_bSUPressed;
		BOOL m_bLShiftPressed;
		BOOL m_bRShiftPressed;
		BOOL m_bIsZag;
		BOOL m_bControlKeyPressed;
		BOOL m_bRegularKeyPressed;

		BKKey *m_pBKKeyboardArray;

		HBRUSH m_brsh;
		HPEN m_pen;

		static const BKKey m_ButnKbdKeys[];
		static const BKKey m_PlenKbdKeys[];

	public:
		CBKKbdButn(UINT nID = 0);
		virtual ~CBKKbdButn(void);

		inline int GetWidth()
		{
			return m_cx;
		}
		inline int GetHeihgt()
		{
			return m_cy;
		}

	protected:
		int GetKeyIndex(int x, int y);
		int GetKeyIndexById(BKKeyType nType);
		int GetArraySize();
		void FocusPressedkey(int nIdx);
		void UnFocusPressedkey(int nIdx);
		BYTE TranslateScanCode(BYTE nScanCode);
		afx_msg void OnPaint();
		afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
		afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
		DECLARE_MESSAGE_MAP()
};

