/*************************************************
*            BK Emulator for Window 3.0          *
*************************************************/

/*
File: MultiEditListCtrl.h
Version: 1.0.0
Written by: Yuriy Kalmykov <kalmykov@stoik.com>
    Copyright (c) 2002-2004 Yuriy Kalmykov

    BK Emulator is a program emulated hardware environment for running
code for BK 0010(01) in different configurations.

    This code may be used in compiled form in any way you desire.
This file or it's parts can't be redistributed without the authors
written consent, but can be modified for your private needs.
    Providing that this notice and the authors name and all copyright
notices remains intact.

    Please, an email me to know how you are using it and where. You can
ask me for any information about this below code or any attendant
knowledge.

    This file is provided "as is" with no expressed or implied warranty.
The author accepts no liability for any damage or loss of business that
this product may cause.
*/


#pragma once

// MultiEditListCtrl.h : header file
//

#include "Globals.h"

/////////////////////////////////////////////////////////////////////////////
// CMultiEdit window

class CMultiEditListCtrl;

class CMultiEdit : public CEdit
{
		CMultiEditListCtrl *m_pListCtrl;
		int                 m_nItem;
		int                 m_nSubItem;

		void                SetItem();

// Construction
	public:
		CMultiEdit();

// Attributes
	public:

// Operations
	public:
		void                Attach(CMultiEditListCtrl *pListCtrl, int nItem, int nSubItem);

// Overrides
		// ClassWizard generated virtual function overrides
		//{{AFX_VIRTUAL(CMultiEdit)
		//}}AFX_VIRTUAL

// Implementation
	public:
		virtual ~CMultiEdit();

		// Generated message map functions
	protected:
		afx_msg void OnKillFocus(CWnd *pNewWnd);
		afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
		afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
		DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////
// CMultiEditListCtrl window

class CMultiEditListCtrl : public CListCtrl
{
		CMultiEdit         *m_pEdit;
		CFont               m_font;

	protected:
		struct ITEM_INFO
		{
			BOOL            bEditable;
			BOOL            bModified;
			BOOL            bEdited;
			DWORD           nValue;
			COLORREF        clrText;
			COLORREF        clrTextBk;
			ITEM_INFO(): bEditable(TRUE), bModified(FALSE), bEdited(FALSE), nValue(0xffffffff) {};
		};
		CArray <ITEM_INFO *, ITEM_INFO *> m_colorTable;

		COLORREF            m_StdColor;
		COLORREF            m_StdBgColor;

		enum                {MODIFIED_COLOR = RGB(255, 0, 0)};

		void                InitColorTable();
		void                ClearColorTable();
		int                 GetColumnNumber();

	public:
		CMultiEditListCtrl();
		virtual ~CMultiEditListCtrl();

		void                EnableEdit(BOOL bEnable, int nItem, int nColumn);
		void                EnableRowEdit(BOOL bEnable, int nRow);
		void                EnableColumnEdit(BOOL bEnable, int nColumn);
		void                SetItemColor(COLORREF col, int nItem, int nColumn);
		void                SetRowColor(COLORREF col, int nRow);
		void                SetColumnColor(COLORREF col, int nColumn);
		void                SetItemBkColor(COLORREF col, int nItem, int nColumn);
		void                SetRowBkColor(COLORREF col, int nRow);
		void                SetColumnBkColor(COLORREF col, int nColumn);
		void                SetItemWithModified(WORD word, int nItem, int nSubitem, BOOL bColored = TRUE);
		void                SetItemWithModifiedASCII(CString &str, int nItem, int nSubitem);
		void                SetEndEdit(int nItem, int nSubitem);
// Overrides
	protected:
		virtual void        PreSubclassWindow();

// Generated message map functions
	protected:
		afx_msg BOOL OnDblclk(NMHDR *pNMHDR, LRESULT *pResult);
		afx_msg void OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult);
		afx_msg BOOL OnInsertitem(NMHDR *pNMHDR, LRESULT *pResult);
		afx_msg BOOL OnDeleteitem(NMHDR *pNMHDR, LRESULT *pResult);
		afx_msg BOOL OnDeleteallitems(NMHDR *pNMHDR, LRESULT *pResult);
		DECLARE_MESSAGE_MAP()
};


