wxDateTime date = wxDateTime(1, tm.mon, tm.year);
// rewind back
- date.SetToPrevWeekDay(GetWindowStyle() & wxCAL_MONDAY_FIRST
- ? wxDateTime::Mon : wxDateTime::Sun);
+ date.SetToPrevWeekDay(GetWeekStart());
if ( GetWindowStyle() & wxCAL_SHOW_SURROUNDING_WEEKS )
{
size_t wxGenericCalendarCtrl::GetWeek(const wxDateTime& date) const
{
- size_t retval = date.GetWeekOfMonth(GetWindowStyle() & wxCAL_MONDAY_FIRST
+ size_t retval = date.GetWeekOfMonth(HasFlag(wxCAL_MONDAY_FIRST)
? wxDateTime::Monday_First
: wxDateTime::Sunday_First);
wxDateTime datetest = wxDateTime(1, tm.mon, tm.year);
// rewind back
- datetest.SetToPrevWeekDay(GetWindowStyle() & wxCAL_MONDAY_FIRST
- ? wxDateTime::Mon : wxDateTime::Sun);
+ datetest.SetToPrevWeekDay(GetWeekStart());
if ( datetest.GetDay() == 1 )
{
dc.SetPen(wxPen(m_colHeaderBg, 1, wxPENSTYLE_SOLID));
dc.DrawRectangle(0, y, GetClientSize().x, m_heightRow);
- bool startOnMonday = (GetWindowStyle() & wxCAL_MONDAY_FIRST) != 0;
+ bool startOnMonday = HasFlag(wxCAL_MONDAY_FIRST);
for ( int wd = 0; wd < 7; wd++ )
{
size_t n;
if ( IsDateShown(date) )
{
- bool startOnMonday = ( GetWindowStyle() & wxCAL_MONDAY_FIRST ) != 0;
+ bool startOnMonday = HasFlag(wxCAL_MONDAY_FIRST);
// Find day
*day = date.GetWeekDay();
*date += wxDateSpan::Week() * (( pos.y - m_rowOffset ) / m_heightRow - 1 );
}
if ( wd )
- *wd = ( GetWindowStyle() & wxCAL_MONDAY_FIRST ) ? wxDateTime::Mon : wxDateTime::Sun;
+ *wd = GetWeekStart();
return wxCAL_HITTEST_WEEK;
}
else // early exit -> the rest of the function checks for clicks on days
{
if ( wd )
{
- if ( GetWindowStyle() & wxCAL_MONDAY_FIRST )
+ if ( HasFlag(wxCAL_MONDAY_FIRST) )
{
wday = wday == 6 ? 0 : wday + 1;
}
case WXK_RIGHT:
if ( event.ControlDown() )
{
- wxDateTime
- target = m_date.SetToNextWeekDay(
- GetWindowStyle() & wxCAL_MONDAY_FIRST
- ? wxDateTime::Sun : wxDateTime::Sat);
- if ( !IsDateInRange(target) )
- {
- target = GetUpperDateLimit();
- }
+ wxDateTime target = m_date.SetToNextWeekDay(GetWeekEnd());
+ AdjustDateToRange(&target);
SetDateAndNotify(target);
}
else
case WXK_LEFT:
if ( event.ControlDown() )
{
- wxDateTime
- target = m_date.SetToPrevWeekDay(
- GetWindowStyle() & wxCAL_MONDAY_FIRST
- ? wxDateTime::Mon : wxDateTime::Sun);
- if ( !IsDateInRange(target) )
- {
- target = GetLowerDateLimit();
- }
+ wxDateTime target = m_date.SetToPrevWeekDay(GetWeekStart());
+ AdjustDateToRange(&target);
SetDateAndNotify(target);
}
else