Automatically determine the first weekday for a calendar control
If neither wxCAL_SUNDAY_FIRST or wxCAL_MONDAY_FIRST was given, use wxDateTime::GetFirstWeekDay() to automatically determine the preferred day. This changes the earlier default behaviour, which was to use Sunday if not otherwise specified. However, the wxGTK native calendar control ignored this behaviour anyway.
This commit is contained in:
@@ -195,5 +195,26 @@ bool wxCalendarCtrlBase::SetHolidayAttrs()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxCalendarCtrlBase::WeekStartsOnMonday() const
|
||||
{
|
||||
if ( HasFlag(wxCAL_MONDAY_FIRST) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( HasFlag(wxCAL_SUNDAY_FIRST) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Neither flag was explicitly given, let's make a best guess
|
||||
// based on locale and/or OS settings.
|
||||
|
||||
wxDateTime::WeekDay firstDay;
|
||||
wxDateTime::GetFirstWeekDay(&firstDay);
|
||||
return firstDay == wxDateTime::Mon;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_CALENDARCTRL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user