// AsOptionRow.h: interface for the CAsOptionRow class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(_ASOPTIONROW_H_)
#define _ASOPTIONROW_H_

#include "AsBaseCell.h"
#include "AsFontInfo.h"
#include "AsCellEnum.h"
#include "cmString.h"

class IAsOptionRowListener;

class CAsOptionRow  
{
public:
	CAsOptionRow();
	virtual ~CAsOptionRow();

	enum enOptionRowHitTest {
		enOptionRowHitTest_None = 0,
		enOptionRowHitTest_Caption,
		enOptionRowHitTest_Value,
		enOptionRowHitTest_Splitter
	};

	void RegisterListener(IAsOptionRowListener* listener);

	CAsBaseCell* GetCaptionCell();
	CAsBaseCell* GetValueCell();

	void SetValueCellType(enCellType cellType);
	void Draw(CDC* pDC);

	void SetDrawArea(const CRect& drawArea);
	CRect GetDrawArea() const;

	void SetVerticalSplitterPos(int pos);
	int GetVerticalSplitterPos() const;

	void SetParentWindow(CWnd* parentWnd);

	bool ProcessMessage(DWORD msg, DWORD lParam, DWORD wParam, const CPoint& pt, const CRect& parentRect, bool& needRedraw);

	static int SplitterArea_;

	void SetFontInfo(const cmString& fontName, int fontSize = 10, bool fontBold = false);
	void SetFontInfo(const CAsFontInfo& fontInfo);

	enOptionRowHitTest HitTest(const CPoint& pt);

	void Select(bool selection, bool redraw);
	bool IsSelected() const;

	bool HasFocus();

	void SetCaption(const cmString& caption);
	cmString GetCaption() const;

	void SetDescription(const cmString& description);
	cmString GetDescription() const;

protected:

	CAsBaseCell* CreateCell(enCellType cellType);
	void UpdateColors();
	
	CAsBaseCell captionCell_;
	CAsBaseCell* valueCell_;

	CRect drawArea_;

	int verticalSplitterPos_;

	COLORREF borderColor_;

	CWnd* parentWnd_;

	CAsFontInfo fontInfo_;

	bool selected_;

	cmString caption_;
	cmString description_;

	IAsOptionRowListener* listener_;
};

#endif // !defined(_ASOPTIONROW_H_)
