#pragma once
#include "skinnablewindow.h"
#include "textbox.h"
#include "skinnablebutton.h"
#include "atlcomtime.h"
#include "commctrl.h"


class DateBox :
	public SkinnableWindow
{
public:
	DateBox();
	~DateBox();

	void Load(const char * base);
	virtual int Create(HWND parent = 0);

	// button handler
	void OnButton(HWND h);
	// date picker handler
	virtual void OnNotify(int idCtrl, NMHDR * pnmh);
	// text box handler
	virtual void OnContentsChanged(WPARAM wParam, LPARAM lParam);

	virtual HWND GetTabToTarget(){ return text.GetTabToTarget();};
	virtual HWND GetTabFromTarget(){ return text.GetTabFromTarget();};

	virtual void Hide();
	virtual void OnMouseCaptureChanged();

	void SetValue(COleDateTime & date);


	HWND hDP; // the date picker
	TextBox text; // current date is displayed here
	SkinnableButton button; // a button to show the date picker

	bool CalendarIsVisible;
	TCHAR DateFormat[255]; // the date format

	COleDateTime date;

private:
	HRGN CollapsedRgn();
	HRGN ExpandedRgn();

};