END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrl, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxCalendarEvent, wxCommandEvent)
+
+// ----------------------------------------------------------------------------
+// events
+// ----------------------------------------------------------------------------
+
+DEFINE_EVENT_TYPE(wxEVT_CALENDAR_SEL_CHANGED)
+DEFINE_EVENT_TYPE(wxEVT_CALENDAR_DAY_CHANGED)
+DEFINE_EVENT_TYPE(wxEVT_CALENDAR_MONTH_CHANGED)
+DEFINE_EVENT_TYPE(wxEVT_CALENDAR_YEAR_CHANGED)
+DEFINE_EVENT_TYPE(wxEVT_CALENDAR_DOUBLECLICKED)
+DEFINE_EVENT_TYPE(wxEVT_CALENDAR_WEEKDAY_CLICKED)
// ============================================================================
// implementation
}
SetSelection(m_cal->GetDate().GetMonth());
+ SetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT);
}
wxYearSpinCtrl::wxYearSpinCtrl(wxCalendarCtrl *cal)
wxCoord width = 7*m_widthCol,
height = 7*m_heightRow;
- wxSize sizeCombo = m_comboMonth->GetBestSize(),
- sizeSpin = m_spinYear->GetBestSize();
-
- height += VERT_MARGIN + wxMax(sizeCombo.y, sizeSpin.y);
+ // the combobox doesn't report its height correctly (it returns the
+ // height including the drop down list) so don't use it
+ height += VERT_MARGIN + m_spinYear->GetBestSize().y;
if ( GetWindowStyle() & (wxRAISED_BORDER | wxSUNKEN_BORDER) )
{
// the border would clip the last line otherwise
- height += 4;
+ height += 6;
}
return wxSize(width, height);
RecalcGeometry();
#if DEBUG_PAINT
- printf("--- starting to paint, selection: %s, week %u\n",
+ wxLogDebug("--- starting to paint, selection: %s, week %u\n",
m_date.Format("%a %d-%m-%Y %H:%M:%S").c_str(),
GetWeek(m_date));
#endif
if ( IsExposed(0, 0, 7*m_widthCol, m_heightRow) )
{
#if DEBUG_PAINT
- puts("painting the header");
+ wxLogDebug("painting the header");
#endif
dc.SetBackgroundMode(wxTRANSPARENT);
wxDateTime date = GetStartDate();
#if DEBUG_PAINT
- printf("starting calendar from %s\n",
+ wxLogDebug("starting calendar from %s\n",
date.Format("%a %d-%m-%Y %H:%M:%S").c_str());
#endif
}
#if DEBUG_PAINT
- printf("painting week %d at y = %d\n", nWeek, y);
+ wxLogDebug("painting week %d at y = %d\n", nWeek, y);
#endif
for ( size_t wd = 0; wd < 7; wd++ )
wxCalendarDateAttr *attr = m_attrs[day - 1];
- bool isSel = m_date == date;
+ bool isSel = date.IsSameDate(m_date);
if ( isSel )
{
dc.SetTextForeground(m_colHighlightFg);
}
}
#if DEBUG_PAINT
- puts("+++ finished painting");
+ wxLogDebug("+++ finished painting");
#endif
}
rect.width = 7*m_widthCol;
rect.height = m_heightRow;
+#ifdef __WXMSW__
+ // VZ: for some reason, the selected date seems to occupy more space under
+ // MSW - this is probably some bug in the font size calculations, but I
+ // don't know where exactly. This fix is ugly and leads to more
+ // refreshes than really needed, but without it the selected days
+ // leaves even more ugly underscores on screen.
+ rect.Inflate(0, 1);
+#endif // MSW
+
#if DEBUG_PAINT
- printf("*** refreshing week %d at (%d, %d)-(%d, %d)\n",
+ wxLogDebug("*** refreshing week %d at (%d, %d)-(%d, %d)\n",
GetWeek(date),
rect.x, rect.y,
rect.x + rect.width, rect.y + rect.height);