A quick update on my progress with the iCalendar class
<a href="http://mattgemmell.com/index.php/dev/mac/icalendar.html">mentioned previously</a>.
The calendar can now have a delegate, which can implement any of the following methods:
- (BOOL)calendar: (iCalendar *)cal shouldSelectDate: (NSCalendarDate *)newDate;
- (void)calendar: (iCalendar *)cal willSelectDate: (NSCalendarDate *)newDate;
- (void)calendar: (iCalendar *)cal didSelectDate: (NSCalendarDate *)newDate;
- (BOOL)calendar: (iCalendar *)cal shouldDrawMarkersForDay: (int)day;
- (NSArray *)calendar: (iCalendar *)cal markerColorsForDay: (int)day;
The date-related methods are self-explanatory (and were requested by Arnold Bocklin, incidentally,
though they're really inevitably required for such a control :));
the last two deserve some additional explanation.
Instances of iCalendar can now display "markers" upon specified days, to visually tag those days.
Multiple colors can be applied to a single day; the <code>calendar:markerColorsForDay:</code> method
should return an NSArray of NSColors, the first of which will be used as the marker color.
If more than one color exists in the array, an additional visual highlight will be applied to the day
in question, to indicate that it was tagged with more than one color (of which more later). The two
basic types of marker are a triangular marker in the top-right of the day's cell, or a circular marker
drawn behind the day-number in the cell. You can see examples of both kinds, with and without drop-shadows,
<a href="http://mattgemmell.com/images/icalendar/icalendar_markers.gif">in this screenshot</a>.
Notice the smaller blue triangle at the top-right of the January 14th cell; this is an indication that more
than one color was supplied as a marker for that day. There are two styles of multiple-marker indicators;
the one shown in the screenshot (a smaller triangle in the extreme upper right of the day's cell, and filled
with the iCalendar's <code>defaultMarkerColor</code>), or simply outlining (stroking) the primary marker (be
it either the triangular tag or circular background types).
In this way, it's very easy for the calendar's delegate to cause days to be marked with color on a
case-by-case basis. If the delegate indicates that a given day should be marked, but does not return
one or more colors for it, it will be marked with the calendar's <code>defaultMarkerColor</code>.
I'm looking into week numbers at the moment, though there are UI issues to consider: (1) where exactly
do I draw them, since space is already tight, and more importantly, (2) since the calendar's weeks can
start on any day, how do you decide which week-number to draw? The week-number of the day which is first
in a given row, maybe? Or the week-number which the majority of the days in a given row are members of?
Haven't decided on that yet.
Any other feature requests should come soon, via the comments system here. I'll be finalising the first
version of the control shortly in order to write documentation. As always, any other kind of feedback
will also be gratefully received.