\r
/**\r
* FocusChangeListener is notified when the panel changes its _focused_\r
- * value. It can be set with\r
+ * value.\r
*/\r
public interface FocusChangeListener {\r
void focusChanged(Date focusedDate);\r
}\r
\r
/**\r
- * Sets the focus to given day of current time. Used when moving in the\r
- * calender with the keyboard.\r
+ * Sets the focus to given date in the current view. Used when moving in the\r
+ * calendar with the keyboard.\r
* \r
* @param date\r
- * The day number from by Date.getDate()\r
+ * A Date representing the day of month to be focused. Must be\r
+ * one of the days currently visible.\r
*/\r
- private void focusDay(Date day) {\r
+ private void focusDay(Date date) {\r
// Only used when calender body is present\r
if (resolution > VDateField.RESOLUTION_MONTH) {\r
if (focusedDay != null) {\r
focusedDay.removeStyleDependentName(CN_FOCUSED);\r
}\r
\r
- if (day != null && focusedDate != null) {\r
- focusedDate.setTime(day.getTime());\r
+ if (date != null && focusedDate != null) {\r
+ focusedDate.setTime(date.getTime());\r
int rowCount = days.getRowCount();\r
for (int i = 0; i < rowCount; i++) {\r
int cellCount = days.getCellCount(i);\r
Widget widget = days.getWidget(i, j);\r
if (widget != null && widget instanceof Day) {\r
Day curday = (Day) widget;\r
- if (curday.getDate().equals(day)) {\r
+ if (curday.getDate().equals(date)) {\r
curday.addStyleDependentName(CN_FOCUSED);\r
focusedDay = curday;\r
focusedRow = i;\r
}\r
\r
/**\r
- * Sets the selection hightlight to a given date of current time\r
+ * Sets the selection highlight to a given day in the current view\r
* \r
* @param date\r
+ * A Date representing the day of month to be selected. Must be\r
+ * one of the days currently visible.\r
+ * \r
*/\r
private void selectDate(Date date) {\r
if (selectedDay != null) {\r
\r
}\r
\r
+ /**\r
+ * A widget representing a single day in the calendar panel.\r
+ */\r
private class Day extends InlineHTML {\r
private static final String BASECLASS = VDateField.CLASSNAME\r
+ "-calendarpanel-day";\r
if (day != null) {\r
Date date = day.getDate();\r
int id = date.getDate();\r
+ // Zero or negative ids map to days of the preceding month,\r
+ // past-the-end-of-month ids to days of the following month\r
if (date.getMonth() < displayedMonth.getMonth()) {\r
id -= DateTimeService.getNumberOfDaysInMonth(date);\r
} else if (date.getMonth() > displayedMonth.getMonth()) {\r
return time.ampm.getElement();\r
}\r
if (subPart.startsWith(SUBPART_DAY)) {\r
- // can be less than 1 or greater than the number of days in the current month\r
- // these map to the "off-month" days\r
+ // Zero or negative ids map to days in the preceding month,\r
+ // past-the-end-of-month ids to days in the following month\r
int dayOfMonth = Integer.parseInt(subPart.substring(SUBPART_DAY\r
.length()));\r
Date date = new Date(displayedMonth.getYear(),\r