int x = pos - (y * columns);
if (x == 0 && daysCount > 7) {
// Add week to weekToolbar for navigation
weekToolbar.addWeek(week, d.getYear());
}
final SimpleDayCell cell = new SimpleDayCell(this, y, x);
cell.setMonthGrid(monthGrid);
cell.setDate(d);
cell.addDomHandler(new ContextMenuHandler() {
public void onContextMenu(ContextMenuEvent event) {
if (mouseEventListener != null) {
event.preventDefault();
event.stopPropagation();
mouseEventListener.contextMenu(event, cell);
}
}
}, ContextMenuEvent.getType());
if (!firstDayFound) {
cell.addStyleDependentName("prev-month");
} else if (lastDayFound) {
cell.addStyleDependentName("next-month");
}
if (dayOfMonth >= 1 && !monthNameDrawn) {
cell.setMonthNameVisible(true);
monthNameDrawn = true;
}
if (today.getDate() == dayOfMonth && today.getYear() == d.getYear()
&& today.getMonth() == d.getMonth()) {
cell.setToday(true);
}
monthGrid.setWidget(y, x, cell);
pos++;
}