///////////////////////////////////////////////////////////
// File:			pg_date_dlg.h
//
// Author:			Stefan Liersch
// Contact:			stefan.liersch@googlemail.com,
//					stefan.liersch@ufz.de
//
// Date:			2007-02-05
// last modified:	2007-08-10
//
//---------------------------------------------------------
// DESCRIPTION
//---------------------------------------------------------
// DIALOG for
// Selecting a period (begin and end date)
//
//---------------------------------------------------------
// ToDo
//---------------------------------------------------------
// 
//
///////////////////////////////////////////////////////////

//---------------------------------------------------------

#ifndef __DateDLG_H
#define __DateDLG_H

#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
    #pragma interface "DateDLG.h"
#endif

// Include wxWidgets' headers
#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

#include "wx/datetime.h"

#include "pgsql/pgdatabase.h"
//---------------------------------------------------------------------


// Declare window functions
enum {
	TXT_Date1 = 10000,
	CHOICE_Day1,
	TXT_Month1,
	CHOICE_Month1,
	TXT_Year1,
	CHOICE_Year1,
	TXT_Date2,
	CHOICE_Day2,
	TXT_Month2,
	CHOICE_Month2,
	TXT_Year2,
	CHOICE_Year2
};

//---------------------------------------------------------------------

class CDateDLG : public wxDialog
{
public:
	CDateDLG();
	CDateDLG(wxWindow *parent, wxWindowID id, const wxString &title);
	~CDateDLG();

	// ------------- GET FUNCTIONS --------------
	int				Get_Day1();
	int				Get_Month1();
	int				Get_Year1();
	int				Get_Day2();
	int				Get_Month2();
	int				Get_Year2();

	wxDateTime		Get_Date1();
	wxDateTime		Get_Date2();


	// ------------- SET FUNCTIONS --------------
	bool			Set_Date1(wxDateTime date1);
	bool			Set_Date2(wxDateTime date2);
	bool			Set_Range1(wxDateTime date1,
							   wxDateTime date2,
							   wxChoice* ch_d,
							   wxChoice* ch_m,
							   wxComboBox* ch_y);

private:

	// ------------- VARIABLES ------------------
	bool			bLimitRange1, bLimitRange2;

	wxChoice		*Choice_Day1;
	wxChoice		*Choice_Month1;
	wxComboBox		*Choice_Year1;
	wxChoice		*Choice_Day2;
	wxChoice		*Choice_Month2;
	wxComboBox		*Choice_Year2;

	wxDateTime		_date1;
	wxDateTime		_date2;
	//-------------------------------------------


	//-------------- FUNCTIONS ------------------
	// create Date Input Dialog
	void			CreateDateDLG();

	wxDateTime		_Get_Date(wxChoice* ch_d, wxChoice* ch_m, wxComboBox* ch_y);
	void			_AssignMonthByInt(wxDateTime& date, int month);


	// if a choice box is modified it will be checked whether
	// the new date is still valid
	void			OnChoiceSelected1(wxCommandEvent& event);
	void			OnChoiceSelected2(wxCommandEvent& event);
	void			_ModifyDateBoxes(int d, wxChoice* cDay, wxChoice* cMonth, wxComboBox* cYear);
	bool			_SetDate(int d, wxDateTime date, wxChoice* cDay, wxChoice* cMonth, wxComboBox* cYear);

	wxArrayString	CreateChoiceEntries(int start, int end);

	// create entries for MyChoice::Choice_Month
	wxArrayString	CreateChoiceEntries_Month();
	//-------------------------------------------


//---------------------------------------------------------------------
	DECLARE_EVENT_TABLE()
};

#endif