Use wxUILocale for date formatting in wxDataViewDateRenderer

Use the appropriate format for the dates by using the UI, rather than C,
locale, similarly to wxGrid.
This commit is contained in:
Vadim Zeitlin
2021-08-14 19:08:43 +01:00
parent 8373b14280
commit c746953f9b
2 changed files with 12 additions and 3 deletions

View File

@@ -527,6 +527,8 @@ public:
virtual wxSize GetSize() const wxOVERRIDE;
private:
wxString FormatDate() const;
wxDateTime m_date;
};
#else // !wxUSE_DATEPICKCTRL

View File

@@ -28,6 +28,8 @@
#include "wx/choice.h"
#include "wx/imaglist.h"
#include "wx/renderer.h"
#include "wx/uilocale.h"
#if wxUSE_ACCESSIBILITY
#include "wx/access.h"
#endif // wxUSE_ACCESSIBILITY
@@ -1986,23 +1988,28 @@ bool wxDataViewDateRenderer::GetValue(wxVariant& value) const
return true;
}
wxString wxDataViewDateRenderer::FormatDate() const
{
return m_date.Format(wxGetUIDateFormat());
}
#if wxUSE_ACCESSIBILITY
wxString wxDataViewDateRenderer::GetAccessibleDescription() const
{
return m_date.FormatDate();
return FormatDate();
}
#endif // wxUSE_ACCESSIBILITY
bool wxDataViewDateRenderer::Render(wxRect cell, wxDC* dc, int state)
{
wxString tmp = m_date.FormatDate();
wxString tmp = FormatDate();
RenderText( tmp, 0, cell, dc, state );
return true;
}
wxSize wxDataViewDateRenderer::GetSize() const
{
return GetTextExtent(m_date.FormatDate());
return GetTextExtent(FormatDate());
}
#endif // (defined(wxHAS_GENERIC_DATAVIEWCTRL) || defined(__WXGTK__)) && wxUSE_DATEPICKCTRL