git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12305
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
else
style |= wxCAL_NO_MONTH_CHANGE;
SetWindowStyle(style);
else
style |= wxCAL_NO_MONTH_CHANGE;
SetWindowStyle(style);
ShowCurrentControls();
if ( GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION )
{
ShowCurrentControls();
if ( GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION )
{
bool wxCalendarCtrl::SetDate(const wxDateTime& date)
{
bool wxCalendarCtrl::SetDate(const wxDateTime& date)
{
bool sameMonth = m_date.GetMonth() == date.GetMonth(),
sameYear = m_date.GetYear() == date.GetYear();
bool sameMonth = m_date.GetMonth() == date.GetMonth(),
sameYear = m_date.GetYear() == date.GetYear();
if ( sameMonth && sameYear )
{
// just change the day
if ( sameMonth && sameYear )
{
// just change the day
m_date = date;
if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) )
m_date = date;
if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) )
bool wxCalendarCtrl::SetLowerDateLimit(const wxDateTime& date /* = wxDefaultDateTime */)
{
bool wxCalendarCtrl::SetLowerDateLimit(const wxDateTime& date /* = wxDefaultDateTime */)
{
- if ( !(date.IsValid()) || ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : true ) )
+ if ( !(date.IsValid()) || ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : TRUE ) )
{
m_lowdate = date;
}
else
{
{
m_lowdate = date;
}
else
{
bool wxCalendarCtrl::SetUpperDateLimit(const wxDateTime& date /* = wxDefaultDateTime */)
{
bool wxCalendarCtrl::SetUpperDateLimit(const wxDateTime& date /* = wxDefaultDateTime */)
{
- if ( !(date.IsValid()) || ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : true ) )
+ if ( !(date.IsValid()) || ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : TRUE ) )
{
m_highdate = date;
}
else
{
{
m_highdate = date;
}
else
{
bool wxCalendarCtrl::SetDateRange(const wxDateTime& lowerdate /* = wxDefaultDateTime */, const wxDateTime& upperdate /* = wxDefaultDateTime */)
{
bool wxCalendarCtrl::SetDateRange(const wxDateTime& lowerdate /* = wxDefaultDateTime */, const wxDateTime& upperdate /* = wxDefaultDateTime */)
{
- ( !( lowerdate.IsValid() ) || ( ( upperdate.IsValid() ) ? ( lowerdate <= upperdate ) : true ) ) &&
- ( !( upperdate.IsValid() ) || ( ( lowerdate.IsValid() ) ? ( upperdate >= lowerdate ) : true ) ) )
+ ( !( lowerdate.IsValid() ) || ( ( upperdate.IsValid() ) ? ( lowerdate <= upperdate ) : TRUE ) ) &&
+ ( !( upperdate.IsValid() ) || ( ( lowerdate.IsValid() ) ? ( upperdate >= lowerdate ) : TRUE ) ) )
{
m_lowdate = lowerdate;
m_highdate = upperdate;
}
else
{
{
m_lowdate = lowerdate;
m_highdate = upperdate;
}
else
{
bool wxCalendarCtrl::IsDateInRange(const wxDateTime& date) const
{
bool wxCalendarCtrl::IsDateInRange(const wxDateTime& date) const
{
// Check if the given date is in the range specified
// Check if the given date is in the range specified
- retval = ( ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : true )
- && ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : true ) );
+ retval = ( ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : TRUE )
+ && ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : TRUE ) );
return retval;
}
bool wxCalendarCtrl::ChangeYear(wxDateTime* target) const
{
return retval;
}
bool wxCalendarCtrl::ChangeYear(wxDateTime* target) const
{
if ( !(IsDateInRange(*target)) )
{
if ( !(IsDateInRange(*target)) )
{
if ( target->GetYear() >= GetLowerDateLimit().GetYear() )
{
*target = GetLowerDateLimit();
if ( target->GetYear() >= GetLowerDateLimit().GetYear() )
{
*target = GetLowerDateLimit();
if ( target->GetYear() <= GetUpperDateLimit().GetYear() )
{
*target = GetUpperDateLimit();
if ( target->GetYear() <= GetUpperDateLimit().GetYear() )
{
*target = GetUpperDateLimit();
bool wxCalendarCtrl::ChangeMonth(wxDateTime* target) const
{
bool wxCalendarCtrl::ChangeMonth(wxDateTime* target) const
{
if ( !(IsDateInRange(*target)) )
{
if ( !(IsDateInRange(*target)) )
{
if ( target->GetMonth() < m_date.GetMonth() )
{
if ( target->GetMonth() < m_date.GetMonth() )
{
// rewind back
datetest.SetToPrevWeekDay(GetWindowStyle() & wxCAL_MONDAY_FIRST
? wxDateTime::Mon : wxDateTime::Sun);
// rewind back
datetest.SetToPrevWeekDay(GetWindowStyle() & wxCAL_MONDAY_FIRST
? wxDateTime::Mon : wxDateTime::Sun);
if ( datetest.GetDay() == 1 )
{
retval += 1;
}
}
if ( datetest.GetDay() == 1 )
{
retval += 1;
}
}
wxSize sizeStatic = m_staticMonth->GetSize();
int dy = (sizeCombo.y - sizeStatic.y) / 2;
wxSize sizeStatic = m_staticMonth->GetSize();
int dy = (sizeCombo.y - sizeStatic.y) / 2;
m_comboMonth->Move(x, y);
m_staticMonth->SetSize(x, y + dy, sizeCombo.x, sizeStatic.y);
m_comboMonth->Move(x, y);
m_staticMonth->SetSize(x, y + dy, sizeCombo.x, sizeStatic.y);
xDiff = sizeCombo.x + HORZ_MARGIN;
xDiff = sizeCombo.x + HORZ_MARGIN;
m_spinYear->SetSize(x + xDiff, y, width - xDiff, sizeCombo.y);
m_staticYear->SetSize(x + xDiff, y + dy, width - xDiff, sizeStatic.y);
m_spinYear->SetSize(x + xDiff, y, width - xDiff, sizeCombo.y);
m_staticYear->SetSize(x + xDiff, y + dy, width - xDiff, sizeStatic.y);
// draw month-name centered above weekdays
wxCoord monthx = ((m_widthCol * 7) - monthw) / 2;
wxCoord monthy = ((m_heightRow - monthh) / 2) + y;
// draw month-name centered above weekdays
wxCoord monthx = ((m_widthCol * 7) - monthw) / 2;
wxCoord monthy = ((m_heightRow - monthh) / 2) + y;
- dc.DrawText(headertext, monthx, monthy);
+ dc.DrawText(headertext, monthx, monthy);
// calculate the "month-arrows"
wxPoint leftarrow[3];
wxPoint rightarrow[3];
int arrowheight = monthh / 2;
// calculate the "month-arrows"
wxPoint leftarrow[3];
wxPoint rightarrow[3];
int arrowheight = monthh / 2;
leftarrow[0] = wxPoint(0, arrowheight / 2);
leftarrow[1] = wxPoint(arrowheight / 2, 0);
leftarrow[2] = wxPoint(arrowheight / 2, arrowheight - 1);
leftarrow[0] = wxPoint(0, arrowheight / 2);
leftarrow[1] = wxPoint(arrowheight / 2, 0);
leftarrow[2] = wxPoint(arrowheight / 2, arrowheight - 1);
{
wxDateTime ldpm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) - wxDateSpan::Day(); // last day prev month
// Check if range permits change
{
wxDateTime ldpm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) - wxDateSpan::Day(); // last day prev month
// Check if range permits change
- if ( IsDateInRange(ldpm) && ( ( ldpm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) )
+ if ( IsDateInRange(ldpm) && ( ( ldpm.GetYear() == m_date.GetYear() ) ? TRUE : AllowYearChange() ) )
{
m_leftArrowRect = wxRect(larrowx - 3, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6));
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
{
m_leftArrowRect = wxRect(larrowx - 3, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6));
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
dc.DrawRectangle(m_leftArrowRect);
}
wxDateTime fdnm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) + wxDateSpan::Month(); // first day next month
dc.DrawRectangle(m_leftArrowRect);
}
wxDateTime fdnm = wxDateTime(1,m_date.GetMonth(), m_date.GetYear()) + wxDateSpan::Month(); // first day next month
- if ( IsDateInRange(fdnm) && ( ( fdnm.GetYear() == m_date.GetYear() ) ? true : AllowYearChange() ) )
+ if ( IsDateInRange(fdnm) && ( ( fdnm.GetYear() == m_date.GetYear() ) ? TRUE : AllowYearChange() ) )
{
m_rightArrowRect = wxRect(rarrowx - 4, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6));
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
{
m_rightArrowRect = wxRect(rarrowx - 4, arrowy - 3, (arrowheight / 2) + 8, (arrowheight + 6));
dc.SetBrush(wxBrush(*wxBLACK, wxSOLID));
bool changedColours = FALSE,
changedFont = FALSE;
bool changedColours = FALSE,
changedFont = FALSE;
wxCalendarDateAttr *attr = NULL;
if ( date.GetMonth() != m_date.GetMonth() || !IsDateInRange(date) )
wxCalendarDateAttr *attr = NULL;
if ( date.GetMonth() != m_date.GetMonth() || !IsDateInRange(date) )
if ( !IsDateInRange(date) )
{
wxDateTime firstOOR = GetUpperDateLimit() + wxDateSpan::Day(); // first out-of-range
if ( !IsDateInRange(date) )
{
wxDateTime firstOOR = GetUpperDateLimit() + wxDateSpan::Day(); // first out-of-range
wxBrush oorbrush = *wxLIGHT_GREY_BRUSH;
oorbrush.SetStyle(wxFDIAGONAL_HATCH);
wxBrush oorbrush = *wxLIGHT_GREY_BRUSH;
oorbrush.SetStyle(wxFDIAGONAL_HATCH);
{
// do stuff
// date-coordinates
{
// do stuff
// date-coordinates
int td, tw;
// implicit: both dates must be currently shown - checked by GetDateCoord
int td, tw;
// implicit: both dates must be currently shown - checked by GetDateCoord
int cidx = 0;
// "complex" polygon
corners[cidx] = wxPoint((fd - 1) * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++;
int cidx = 0;
// "complex" polygon
corners[cidx] = wxPoint((fd - 1) * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++;
if ( fd > 1 )
{
corners[cidx] = wxPoint((fd - 1) * m_widthCol, ((fw + 1) * m_heightRow) + m_rowOffset); cidx++;
if ( fd > 1 )
{
corners[cidx] = wxPoint((fd - 1) * m_widthCol, ((fw + 1) * m_heightRow) + m_rowOffset); cidx++;
}
corners[cidx] = wxPoint(7 * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++;
}
corners[cidx] = wxPoint(7 * m_widthCol, (fw * m_heightRow) + m_rowOffset); cidx++;
bool wxCalendarCtrl::GetDateCoord(const wxDateTime& date, int *day, int *week) const
{
bool wxCalendarCtrl::GetDateCoord(const wxDateTime& date, int *day, int *week) const
{
#if DEBUG_PAINT
wxLogDebug("+++ GetDateCoord: (%s) +++", date.Format("%d %m %Y"));
#if DEBUG_PAINT
wxLogDebug("+++ GetDateCoord: (%s) +++", date.Format("%d %m %Y"));
if ( IsDateShown(date) )
{
bool startOnMonday = ( GetWindowStyle() & wxCAL_MONDAY_FIRST ) != 0;
if ( IsDateShown(date) )
{
bool startOnMonday = ( GetWindowStyle() & wxCAL_MONDAY_FIRST ) != 0;
// Find day
*day = date.GetWeekDay();
// Find day
*day = date.GetWeekDay();
if ( *day == 0 ) // sunday
{
*day = ( startOnMonday ) ? 7 : 1;
if ( *day == 0 ) // sunday
{
*day = ( startOnMonday ) ? 7 : 1;
if ( (GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) )
{
// Header: month
if ( (GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) )
{
// Header: month
// we need to find out if the hit is on left arrow, on month or on right arrow
// left arrow?
if ( wxRegion(m_leftArrowRect).Contains(pos) == wxInRegion )
// we need to find out if the hit is on left arrow, on month or on right arrow
// left arrow?
if ( wxRegion(m_leftArrowRect).Contains(pos) == wxInRegion )
{
tm.mday = wxDateTime::GetNumberOfDays(tm.mon, year);
}
{
tm.mday = wxDateTime::GetNumberOfDays(tm.mon, year);
}
wxDateTime target = wxDateTime(tm.mday, tm.mon, year);
if ( ChangeYear(&target) )
wxDateTime target = wxDateTime(tm.mday, tm.mon, year);
if ( ChangeYear(&target) )
wxMouseEvent& mouseEv )
{
bool claimed;
wxMouseEvent& mouseEv )
{
bool claimed;
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
{
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
{
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
mouseEv.ShiftDown(),
mouseEv.AltDown(),
mouseEv.MetaDown() );
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
}
claimed = GetEventHandler()->ProcessEvent(gridEvt);
vetoed = !gridEvt.IsAllowed();
}
-
- // A Veto'd event may not be `claimed' so test this first
+
+ // A Veto'd event may not be `claimed' so test this first
if (vetoed) return -1;
return claimed ? 1 : 0;
if (vetoed) return -1;
return claimed ? 1 : 0;
int row, int col )
{
bool claimed;
int row, int col )
{
bool claimed;
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
{
if ( type == wxEVT_GRID_ROW_SIZE || type == wxEVT_GRID_COL_SIZE )
{
vetoed = !gridEvt.IsAllowed();
}
vetoed = !gridEvt.IsAllowed();
}
- // A Veto'd event may not be `claimed' so test this first
+ // A Veto'd event may not be `claimed' so test this first
if (vetoed) return -1;
return claimed ? 1 : 0;
if (vetoed) return -1;
return claimed ? 1 : 0;
- if (SendEvent( wxEVT_GRID_EDITOR_SHOWN) <0)
- return;
+ if (SendEvent( wxEVT_GRID_EDITOR_SHOWN) <0)
+ return;
// this should be checked by the caller!
wxASSERT_MSG( CanEnableCellControl(),
// this should be checked by the caller!
wxASSERT_MSG( CanEnableCellControl(),