/////////////////////////////////////////////////////////////////////////////
// Name:        xh_datec.cpp
// Purpose:     XML resource for wxDateCtrl
// Author:      Aleksandras Gluchovas
// Created:     2000/09/09
// RCS-ID:      $Id: xh_datec.cpp,v 1.2 2001/04/19 21:09:25 georgetasker Exp $
// Copyright:   (c) 2000 Aleksandras Gluchovas
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////

//////
 
#ifdef __GNUG__
#pragma implementation "xh_datec.h"
#endif

// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif

#include "wx/wspp/xh_datec.h"
#include "wx/wspp/datectrl.h"

wxDateCtrlXmlHandler::wxDateCtrlXmlHandler() 
: wxXmlResourceHandler() 
{
    ADD_STYLE(wxLC_SORT_DESCENDING);
    AddWindowStyles();
}


wxObject *wxDateCtrlXmlHandler::DoCreateResource()
{ 
	wxString fmt = GetParamValue( "format" );
	if ( !fmt.Length() ) fmt = "%c";

	wxDateCtrl* date = wxDynamicCast(m_Instance, wxDateCtrl);

	if (date)

		date->Create( m_ParentAsWindow,
                               GetID(),
							   GetPosition(), 
							   GetSize(), 
							   fmt,
							   GetStyle(), 
							   GetName() );
							   
	else
		date = new wxDateCtrl( m_ParentAsWindow,
                               GetID(),
							   GetPosition(), 
							   GetSize(),
							   fmt,
                               GetStyle(),
	                           GetName() );

	date->SetValue( wxDateTime::Now() );
    SetupWindow(date);
    
    return date;
}

bool wxDateCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
    return IsOfClass(node, wxT("wxDateCtrl"));
}