else
style |= wxCAL_NO_MONTH_CHANGE;
SetWindowStyle(style);
-
+
ShowCurrentControls();
if ( GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION )
{
bool wxCalendarCtrl::SetDate(const wxDateTime& date)
{
- bool retval = false;
+ bool retval = FALSE;
bool sameMonth = m_date.GetMonth() == date.GetMonth(),
sameYear = m_date.GetYear() == date.GetYear();
if ( sameMonth && sameYear )
{
// just change the day
- retval = true;
+ retval = TRUE;
ChangeDay(date);
}
else
}
// change everything
- retval = true;
+ retval = TRUE;
m_date = date;
if ( !(GetWindowStyle() & wxCAL_SEQUENTIAL_MONTH_SELECTION) )
bool wxCalendarCtrl::SetLowerDateLimit(const wxDateTime& date /* = wxDefaultDateTime */)
{
- bool retval = true;
+ bool retval = TRUE;
- if ( !(date.IsValid()) || ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : true ) )
+ if ( !(date.IsValid()) || ( ( m_highdate.IsValid() ) ? ( date <= m_highdate ) : TRUE ) )
{
m_lowdate = date;
}
else
{
- retval = false;
+ retval = FALSE;
}
return retval;
bool wxCalendarCtrl::SetUpperDateLimit(const wxDateTime& date /* = wxDefaultDateTime */)
{
- bool retval = true;
+ bool retval = TRUE;
- if ( !(date.IsValid()) || ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : true ) )
+ if ( !(date.IsValid()) || ( ( m_lowdate.IsValid() ) ? ( date >= m_lowdate ) : TRUE ) )
{
m_highdate = date;
}
else
{
- retval = false;
+ retval = FALSE;
}
return retval;
bool wxCalendarCtrl::SetDateRange(const wxDateTime& lowerdate /* = wxDefaultDateTime */, const wxDateTime& upperdate /* = wxDefaultDateTime */)
{
- bool retval = true;
+ bool retval = TRUE;
if (
- ( !( 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
{
- retval = false;
+ retval = FALSE;
}
-
+
return retval;
}
bool wxCalendarCtrl::IsDateInRange(const wxDateTime& date) const
{
- bool retval = true;
+ bool retval = TRUE;
// 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
{
- bool retval = false;
+ bool retval = FALSE;
if ( !(IsDateInRange(*target)) )
{
if ( target->GetYear() >= GetLowerDateLimit().GetYear() )
{
*target = GetLowerDateLimit();
- retval = true;
+ retval = TRUE;
}
else
{
if ( target->GetYear() <= GetUpperDateLimit().GetYear() )
{
*target = GetUpperDateLimit();
- retval = true;
+ retval = TRUE;
}
else
{
}
else
{
- retval = true;
+ retval = TRUE;
}
return retval;
bool wxCalendarCtrl::ChangeMonth(wxDateTime* target) const
{
- bool retval = true;
+ bool retval = TRUE;
if ( !(IsDateInRange(*target)) )
{
- retval = false;
+ retval = FALSE;
if ( target->GetMonth() < m_date.GetMonth() )
{
// rewind back
datetest.SetToPrevWeekDay(GetWindowStyle() & wxCAL_MONDAY_FIRST
? wxDateTime::Mon : wxDateTime::Sun);
-
+
if ( datetest.GetDay() == 1 )
{
retval += 1;
}
}
-
+
return retval;
}
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);
-
+
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);
// 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;
-
+
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
- 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));
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));
bool changedColours = FALSE,
changedFont = FALSE;
- bool isSel = false;
+ bool isSel = FALSE;
wxCalendarDateAttr *attr = NULL;
if ( date.GetMonth() != m_date.GetMonth() || !IsDateInRange(date) )
if ( !IsDateInRange(date) )
{
wxDateTime firstOOR = GetUpperDateLimit() + wxDateSpan::Day(); // first out-of-range
-
+
wxBrush oorbrush = *wxLIGHT_GREY_BRUSH;
oorbrush.SetStyle(wxFDIAGONAL_HATCH);
{
// do stuff
// date-coordinates
- int fd, fw;
+ int fd, fw;
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++;
-
+
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++;
-
+
numpoints = cidx;
}
bool wxCalendarCtrl::GetDateCoord(const wxDateTime& date, int *day, int *week) const
{
- bool retval = true;
+ bool retval = TRUE;
#if DEBUG_PAINT
wxLogDebug("+++ GetDateCoord: (%s) +++", date.Format("%d %m %Y"));
if ( IsDateShown(date) )
{
bool startOnMonday = ( GetWindowStyle() & wxCAL_MONDAY_FIRST ) != 0;
-
+
// Find day
*day = date.GetWeekDay();
-
+
if ( *day == 0 ) // sunday
{
*day = ( startOnMonday ) ? 7 : 1;
{
*day = -1;
*week = -1;
- retval = false;
+ retval = FALSE;
}
#if DEBUG_PAINT
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 )
{
tm.mday = wxDateTime::GetNumberOfDays(tm.mon, year);
}
-
+
wxDateTime target = wxDateTime(tm.mday, tm.mon, year);
if ( ChangeYear(&target) )