#endif // generic or Carbon versions
+#if defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__)
+
+// ----------------------------------------------------------------------------
+// wxDataViewDateRenderer
+// ----------------------------------------------------------------------------
+
+#if wxUSE_DATEPICKCTRL
+class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
+{
+public:
+ wxDataViewDateRenderer(const wxString &varianttype = wxT("datetime"),
+ wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
+ int align = wxDVR_DEFAULT_ALIGNMENT);
+
+ virtual bool HasEditorCtrl() const { return true; }
+ virtual wxWindow *CreateEditorCtrl(wxWindow *parent, wxRect labelRect, const wxVariant &value);
+ virtual bool GetValueFromEditorCtrl(wxWindow* editor, wxVariant &value);
+ virtual bool SetValue(const wxVariant &value);
+ virtual bool GetValue(wxVariant& value) const;
+ virtual bool Render( wxRect cell, wxDC *dc, int state );
+ virtual wxSize GetSize() const;
+
+private:
+ wxDateTime m_date;
+};
+#else // !wxUSE_DATEPICKCTRL
+typedef wxDataViewTextRenderer wxDataViewDateRenderer;
+#endif
+
+#endif // generic or GTK+ versions
+
// this class is obsolete, its functionality was merged in
// wxDataViewTextRenderer itself now, don't use it any more
#define wxDataViewTextRendererAttr wxDataViewTextRenderer
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
};
-// ---------------------------------------------------------
-// wxDataViewDateRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewRenderer
-{
-public:
- wxDataViewDateRenderer( const wxString &varianttype = wxT("datetime"),
- wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
- int align = wxDVR_DEFAULT_ALIGNMENT );
-
- bool SetValue( const wxVariant &value );
- bool GetValue( wxVariant& value ) const;
-
- virtual bool Render( wxRect cell, wxDC *dc, int state );
- virtual wxSize GetSize() const;
-
- // Implementation only, don't use nor override
- virtual bool WXOnActivate(const wxRect& cell,
- wxDataViewModel *model,
- const wxDataViewItem& item,
- unsigned int col);
-
-private:
- wxDateTime m_date;
-
-protected:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
-};
-
-
#endif // _WX_GENERIC_DVRENDERERS_H_
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
};
-// ---------------------------------------------------------
-// wxDataViewDateRenderer
-// ---------------------------------------------------------
-
-class WXDLLIMPEXP_ADV wxDataViewDateRenderer: public wxDataViewCustomRenderer
-{
-public:
- wxDataViewDateRenderer( const wxString &varianttype = "datetime",
- wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE,
- int align = wxDVR_DEFAULT_ALIGNMENT );
-
- bool SetValue( const wxVariant &value );
- bool GetValue( wxVariant &value ) const;
-
- virtual bool Render( wxRect cell, wxDC *dc, int state );
- virtual wxSize GetSize() const;
- virtual bool Activate( const wxRect& cell,
- wxDataViewModel *model,
- const wxDataViewItem &item,
- unsigned int col );
-
-private:
- wxDateTime m_date;
-
-protected:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewDateRenderer)
-};
-
// -------------------------------------
// wxDataViewChoiceRenderer
// -------------------------------------
#include "wx/crt.h"
#endif
+#include "wx/datectrl.h"
#include "wx/spinctrl.h"
#include "wx/choice.h"
#include "wx/imaglist.h"
#endif
+// ---------------------------------------------------------
+// wxDataViewDateRenderer
+// ---------------------------------------------------------
+
+#if (defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__)) && wxUSE_DATEPICKCTRL
+
+wxDataViewDateRenderer::wxDataViewDateRenderer(const wxString& varianttype,
+ wxDataViewCellMode mode, int align)
+ : wxDataViewCustomRenderer(varianttype, mode, align)
+{
+}
+
+wxWindow *
+wxDataViewDateRenderer::CreateEditorCtrl(wxWindow *parent, wxRect labelRect, const wxVariant& value)
+{
+ return new wxDatePickerCtrl
+ (
+ parent,
+ wxID_ANY,
+ value.GetDateTime(),
+ labelRect.GetTopLeft(),
+ labelRect.GetSize()
+ );
+}
+
+bool wxDataViewDateRenderer::GetValueFromEditorCtrl(wxWindow *editor, wxVariant& value)
+{
+ wxDatePickerCtrl *ctrl = static_cast<wxDatePickerCtrl*>(editor);
+ value = ctrl->GetValue();
+ return true;
+}
+
+bool wxDataViewDateRenderer::SetValue(const wxVariant& value)
+{
+ m_date = value.GetDateTime();
+ return true;
+}
+
+bool wxDataViewDateRenderer::GetValue(wxVariant& value) const
+{
+ value = m_date;
+ return true;
+}
+
+bool wxDataViewDateRenderer::Render(wxRect cell, wxDC* dc, int state)
+{
+ wxString tmp = m_date.FormatDate();
+ RenderText( tmp, 0, cell, dc, state );
+ return true;
+}
+
+wxSize wxDataViewDateRenderer::GetSize() const
+{
+ return GetTextExtent(m_date.FormatDate());
+}
+
+#endif // (defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__)) && wxUSE_DATEPICKCTRL
+
//-----------------------------------------------------------------------------
// wxDataViewListStore
//-----------------------------------------------------------------------------
#endif
#include "wx/stockitem.h"
-#include "wx/calctrl.h"
#include "wx/popupwin.h"
#include "wx/renderer.h"
#include "wx/dcbuffer.h"
return wxSize(40,12);
}
-// ---------------------------------------------------------
-// wxDataViewDateRenderer
-// ---------------------------------------------------------
-
-#define wxUSE_DATE_RENDERER_POPUP (wxUSE_CALENDARCTRL && wxUSE_POPUPWIN)
-
-#if wxUSE_DATE_RENDERER_POPUP
-
-class wxDataViewDateRendererPopupTransient: public wxPopupTransientWindow
-{
-public:
- wxDataViewDateRendererPopupTransient( wxWindow* parent, wxDateTime *value,
- wxDataViewModel *model, const wxDataViewItem & item, unsigned int col) :
- wxPopupTransientWindow( parent, wxBORDER_SIMPLE ),
- m_item( item )
- {
- m_model = model;
- m_col = col;
- m_cal = new wxCalendarCtrl( this, wxID_ANY, *value );
- wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
- sizer->Add( m_cal, 1, wxGROW );
- SetSizer( sizer );
- sizer->Fit( this );
- }
-
- void OnCalendar( wxCalendarEvent &event );
-
- wxCalendarCtrl *m_cal;
- wxDataViewModel *m_model;
- unsigned int m_col;
- const wxDataViewItem & m_item;
-
-protected:
- virtual void OnDismiss()
- {
- }
-
-private:
- DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient,wxPopupTransientWindow)
- EVT_CALENDAR( wxID_ANY, wxDataViewDateRendererPopupTransient::OnCalendar )
-END_EVENT_TABLE()
-
-void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent &event )
-{
- m_model->ChangeValue( event.GetDate(), m_item, m_col );
- DismissAndNotify();
-}
-
-#endif // wxUSE_DATE_RENDERER_POPUP
-
-IMPLEMENT_ABSTRACT_CLASS(wxDataViewDateRenderer, wxDataViewRenderer)
-
-wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString &varianttype,
- wxDataViewCellMode mode, int align ) :
- wxDataViewRenderer( varianttype, mode, align )
-{
-}
-
-bool wxDataViewDateRenderer::SetValue( const wxVariant &value )
-{
- m_date = value.GetDateTime();
-
- return true;
-}
-
-bool wxDataViewDateRenderer::GetValue( wxVariant &value ) const
-{
- value = m_date;
- return true;
-}
-
-bool wxDataViewDateRenderer::Render( wxRect cell, wxDC *dc, int state )
-{
- wxString tmp = m_date.FormatDate();
- RenderText( tmp, 0, cell, dc, state );
- return true;
-}
-
-wxSize wxDataViewDateRenderer::GetSize() const
-{
- return GetTextExtent(m_date.FormatDate());
-}
-
-bool wxDataViewDateRenderer::WXOnActivate(const wxRect& WXUNUSED(cell),
- wxDataViewModel *model,
- const wxDataViewItem& item,
- unsigned int col)
-{
- wxDateTime dtOld = m_date;
-
-#if wxUSE_DATE_RENDERER_POPUP
- wxDataViewDateRendererPopupTransient *popup = new wxDataViewDateRendererPopupTransient(
- GetOwner()->GetOwner()->GetParent(), &dtOld, model, item, col);
- wxPoint pos = wxGetMousePosition();
- popup->Move( pos );
- popup->Layout();
- popup->Popup( popup->m_cal );
-#else // !wxUSE_DATE_RENDERER_POPUP
- wxMessageBox(dtOld.Format());
-#endif // wxUSE_DATE_RENDERER_POPUP/!wxUSE_DATE_RENDERER_POPUP
-
- return true;
-}
-
// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------
#endif
#include "wx/stockitem.h"
-#include "wx/calctrl.h"
#include "wx/popupwin.h"
#include "wx/listimpl.cpp"
return true;
}
-// ---------------------------------------------------------
-// wxDataViewDateRenderer
-// ---------------------------------------------------------
-
-class wxDataViewDateRendererPopupTransient: public wxPopupTransientWindow
-{
-public:
- wxDataViewDateRendererPopupTransient( wxWindow* parent, wxDateTime *value,
- wxDataViewModel *model, const wxDataViewItem &item, unsigned int col ) :
- wxPopupTransientWindow( parent, wxBORDER_SIMPLE )
- {
- m_model = model;
- m_item = item;
- m_col = col;
- 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;
- wxDataViewModel *m_model;
- wxDataViewItem m_item;
- unsigned int m_col;
-
-private:
- DECLARE_EVENT_TABLE()
-};
-
-BEGIN_EVENT_TABLE(wxDataViewDateRendererPopupTransient,wxPopupTransientWindow)
- EVT_CALENDAR( -1, wxDataViewDateRendererPopupTransient::OnCalendar )
-END_EVENT_TABLE()
-
-void wxDataViewDateRendererPopupTransient::OnCalendar( wxCalendarEvent &event )
-{
- m_model->ChangeValue( event.GetDate(), m_item, m_col );
- DismissAndNotify();
-}
-
-IMPLEMENT_CLASS(wxDataViewDateRenderer, wxDataViewCustomRenderer)
-
-wxDataViewDateRenderer::wxDataViewDateRenderer( const wxString &varianttype,
- wxDataViewCellMode mode, int align ) :
- wxDataViewCustomRenderer( varianttype, mode, align )
-{
- SetMode(mode);
- SetAlignment(align);
-}
-
-bool wxDataViewDateRenderer::SetValue( const wxVariant &value )
-{
- m_date = value.GetDateTime();
-
- return true;
-}
-
-bool wxDataViewDateRenderer::GetValue( wxVariant &WXUNUSED(value) ) const
-{
- return false;
-}
-
-bool wxDataViewDateRenderer::Render( wxRect cell, wxDC *dc, int state )
-{
- dc->SetFont( GetOwner()->GetOwner()->GetFont() );
- wxString tmp = m_date.FormatDate();
- RenderText( tmp, 0, cell, dc, state );
- return true;
-}
-
-wxSize wxDataViewDateRenderer::GetSize() const
-{
- wxString tmp = m_date.FormatDate();
- wxCoord x,y,d;
- GetView()->GetTextExtent( tmp, &x, &y, &d );
- return wxSize(x,y+d);
-}
-
-bool wxDataViewDateRenderer::Activate( const wxRect& WXUNUSED(cell), wxDataViewModel *model,
- const wxDataViewItem &item, unsigned int col )
-{
- wxVariant variant;
- model->GetValue( variant, item, col );
- wxDateTime value = variant.GetDateTime();
-
- wxDataViewDateRendererPopupTransient *popup = new wxDataViewDateRendererPopupTransient(
- GetOwner()->GetOwner()->GetParent(), &value, model, item, col );
- wxPoint pos = wxGetMousePosition();
- popup->Move( pos );
- popup->Layout();
- popup->Popup( popup->m_cal );
-
- return true;
-}
-
-
// ---------------------------------------------------------
// wxDataViewIconTextRenderer
// ---------------------------------------------------------