+// ---------------------------------------------------------
+// wxDataViewDateCell
+// ---------------------------------------------------------
+
+class wxDataViewDateCellPopupTransient: public wxPopupTransientWindow
+{
+public:
+ wxDataViewDateCellPopupTransient( wxWindow* parent, wxDateTime *value,
+ wxDataViewListModel *model, size_t col, size_t row ) :
+ wxPopupTransientWindow( parent, wxBORDER_SIMPLE )
+ {
+ m_model = model;
+ m_col = col;
+ m_row = row;
+ m_cal = new wxCalendarCtrl( this, -1, *value );
+ wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
+ sizer->Add( m_cal, 1, wxGROW );
+ SetSizer( sizer );
+ sizer->Fit( this );
+ }
+
+ virtual void OnDismiss()
+ {
+ }
+
+ void OnCalendar( wxCalendarEvent &event );
+
+ wxCalendarCtrl *m_cal;
+ wxDataViewListModel *m_model;
+ size_t m_col;
+ size_t m_row;
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(wxDataViewDateCellPopupTransient,wxPopupTransientWindow)
+ EVT_CALENDAR( -1, wxDataViewDateCellPopupTransient::OnCalendar )
+END_EVENT_TABLE()
+
+void wxDataViewDateCellPopupTransient::OnCalendar( wxCalendarEvent &event )
+{
+ wxDateTime date = event.GetDate();
+ wxVariant value = date;
+ m_model->SetValue( value, m_col, m_row );
+ m_model->ValueChanged( m_col, m_row );
+ DismissAndNotify();
+}
+
+IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateCell, wxDataViewCustomCell)
+
+wxDataViewDateCell::wxDataViewDateCell( const wxString &varianttype,
+ wxDataViewCellMode mode ) :
+ wxDataViewCustomCell( varianttype, mode )
+{
+}
+
+bool wxDataViewDateCell::SetValue( const wxVariant &value )
+{
+ m_date = value.GetDateTime();
+
+ return true;
+}
+
+bool wxDataViewDateCell::Render( wxRect cell, wxDC *dc, int state )
+{
+ dc->SetFont( GetOwner()->GetOwner()->GetFont() );
+ wxString tmp = m_date.FormatDate();
+ dc->DrawText( tmp, cell.x, cell.y );
+
+ return true;
+}
+
+wxSize wxDataViewDateCell::GetSize()
+{
+ wxDataViewCtrl* view = GetOwner()->GetOwner();
+ wxString tmp = m_date.FormatDate();
+ wxCoord x,y,d;
+ view->GetTextExtent( tmp, &x, &y, &d );
+ return wxSize(x,y+d);
+}
+
+bool wxDataViewDateCell::Activate( wxRect cell, wxDataViewListModel *model, size_t col, size_t row )
+{
+ wxVariant variant;
+ model->GetValue( variant, col, row );
+ wxDateTime value = variant.GetDateTime();
+
+ wxDataViewDateCellPopupTransient *popup = new wxDataViewDateCellPopupTransient(
+ GetOwner()->GetOwner()->GetParent(), &value, model, col, row );
+ wxPoint pos = wxGetMousePosition();
+ popup->Move( pos );
+ popup->Layout();
+ popup->Popup( popup->m_cal );
+
+ return true;
+}
+