1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
|
<section id="calendar_package">
<title>Calendar Package</title>
<section>
<title>Introduction</title>
<para>
The package is based on the Calendar class, a class capable
of printing an ascii calendar table that closely resembles the output
of the typical Unix <command>cal</command> command. The internal
code is written entirely in Tcl, therefore doesn't rely on the
existance of <command>cal</command> on the system.
XmlCalendar inherits the basic methods and adds XML tagging to the
table. XmlCalendar prints an XML calendar table whose header,
weekdays banner and days rows tags are configurable.
Also specific days or specific weeks can be given arbitrary attributes.
</para>
<para>
Calendar core methods are based on the
<ulink url="http://wiki.tcl.tk/17964">cal</ulink> procedure
written by Richard Suchenwirth and published on the
<ulink url="http://wiki.tcl.tk">Tcl Wiki</ulink>
</para>
<note>
The Calendar package uses Tcl <command>dict</command> command to manage markup
information. Hence either Tcl8.5 or Tcl8.4 with
<ulink url="http://wiki.tcl.tk/5042">package dict</ulink> are required.
</note>
</section>
<refentry id="calendar">
<refnamediv>
<refname>Calendar</refname>
<refpurpose>Utility class the builds and prints a calendar table</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>Calendar</command>
<arg choice="plain"><replaceable>calendar_name</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Calendar object subcommands</title>
<para>
The main public command for a calendar object is
<command>emit</command> that returns a calendar table
</para>
</refsect1>
<refsect1>
<variablelist>
<varlistentry>
<listitem>
<cmdsynopsis>
calendar_obj <command>emit</command>
</cmdsynopsis>
<cmdsynopsis>
calendar_obj <command>emit</command> <arg>month</arg> <arg>year</arg>
</cmdsynopsis>
<cmdsynopsis>
calendar_obj <command>emit</command> <arg><replaceable>month | year</replaceable></arg>
</cmdsynopsis>
<para>
The method 'emit' if invoked without arguments returns an
ASCII formatted calendar of the current month
</para>
<programlisting>
set cal [Calendar #auto]
set current_month [$cal emit]
puts $current_month
Jun 2010
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30</programlisting>
</listitem>
</varlistentry>
<para>
The method <command>emit</command> when invoked with a single argument
takes it as an year number and prints the whole calendar of
that year. When invoked with 2 arguments takes the first as a month, either
expressed in its shortened form ('Jan','Feb',...) or as a number in the
range 1-12. The second argument is a year number.
</para>
</variablelist>
</refsect1>
</refentry>
<refentry id="xml_calendar">
<refnamediv>
<refname>XmlCalendar</refname>
<refpurpose>Prints XML formatted calendar tables</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>XmlCalendar</command>
<arg choice="plain"><replaceable>calendar_name</replaceable></arg>
<arg>-option1 <replaceable>option_list</replaceable></arg>
<arg>-option2 <replaceable>option_list</replaceable></arg>
<arg>...</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<para>
An XmlCalendar object is created and returned. XmlCalendar objects
print XML formatted calendar tables. The markup can be customized
using the configuration options.
</para>
<para>
Configuration options accept odd-length lists as values. An option_list has the following
structure
<para>
<programlisting>tag_name <option>attr11 val1 attr2 val2 ...</option></programlisting>
</para>
The first element of an option list is a tag name, the remaining terms are therefore
an even-length sublist which is interpreted as a sequence of attribute-value pairs that
will in turn become attributes of the tag.
</para>
</refsect1>
<refsect1>
<title>Methods</title>
<variablelist>
<varlistentry>
<listitem>
<cmdsynopsis>
cal_obj <command>emit</command> <option>-opt1 val1 -opt2 val2</option>
</cmdsynopsis>
<cmdsynopsis>
cal_obj <command>emit</command> <arg>month</arg> <arg>year</arg>
<option> -opt1 val1 -opt2 val2</option>
</cmdsynopsis>
<cmdsynopsis>
cal_obj <command>emit</command> <arg>
<replaceable>month | year</replaceable></arg> <option> -opt1 val1
-opt2 val2</option>
</cmdsynopsis>
<para>
The method 'emit' if invoked without arguments returns an
XML calendar table of the current month
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<refsect2>
<title>Options</title>
<variablelist>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-container <group>tag_name
<option>attr11 val1 attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Assigns an options list to the XML element that
will hold the whole table.
</para>
<para>
The default tag for the container is 'calendar', with no attributes.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-header <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Assigns tag name and attributes to the XML header element (default: calheader)
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-body <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Assigns tag name and attributes to the XML body element of the table (default: calbody)
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-banner <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Assigns tag name and attributes to the XML banner element of the table (default: monthyear)
</para>
<para>
The header of a calendar table is made of a banner, showing the Month and Year number, and
of a weekdays bar.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-foot <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Assigns tag name and attributes to the XML foot element
of the table (default: calfoot).
</para>
<note>
This option was added for completeness, but it's not implemented yet
</note>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-banner_month <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Tag name and attributes for the XML element holding the
month name (default:month)
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-banner_year <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Tag name and attributes for the XML element holding the
month name (default: year)
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-weekdays <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Tag name and attributes for the XML element holding the
weekday header (default: weekdays)
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-weekdays_cell <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Tag name and attributes for the XML element holding the
each single weekday (default: wkdays)
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-days_row <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Tag name and attributes for the XML element holding the
each row of the calendar table (default: week)
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-days_cell <group>tag_name <option>attr11 val1
attr2 val2 ...</option></group></command>
</cmdsynopsis>
<para>
Tag name and attributes for the XML element representing
a cell in the calendar table (default: day)
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-cell_function <option>proc</option></command>
</cmdsynopsis>
<para>
If set this option is the name of a procedure that gets
called for every day of the month. The procedure must
accept 4 argument representing day, month, year and weekday
and must return an odd-length list interpreted in the same
way as options lists.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-current_day <option>day</option></command>
</cmdsynopsis>
<para>
This option works as a simple method for pointing out
a specific day of the month. If set with a day number
that day will get the class attribute automatically
set as "current"
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<command>-current_weekday <option>0-6 | today</option></command>
</cmdsynopsis>
<para>
This option works as a simple method for pointing out
a specific weekday of the month. If set with a weekday
index (0: Sunday, 6: Saturday) the corresponding cell in
the weekdays header will get the class attribute automatically
set as "current_wkday"
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
</refentry>
<refentry id="html_calendar">
<refnamediv>
<refname>HtmlCalendar</refname>
<refpurpose>Concrete class derived from XmlCalendar</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>HtmlCalendar</command>
<arg choice="plain"><replaceable>calendar_name</replaceable></arg>
<arg>-option1 <replaceable>option_list</replaceable></arg>
<arg>-option2 <replaceable>option_list</replaceable></arg>
<arg>...</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<para>
Concrete XmlCalendar class for printing html calendar tables. The markup of the class
is xhtml compliant and prints a code fragment for inclusion in a webpage.
The following is the class definition.
</para>
<programlisting>
::itcl::class HtmlCalendar {
inherit XmlCalendar
constructor {args} {XmlCalendar::constructor $args} {
$this configure -container table \
-header thead \
-body tbody \
-banner tr \
-banner_month {th colspan 3 style "text-align: right;"} \
-banner_year {th colspan 4 style "text-align: left;"} \
-weekdays tr \
-weekday_cell th \
-days_row tr \
-days_cell td
}
}</programlisting>
</refsect1>
<refsect1>
<para>
A sample output from HtmlCalendar (with some styling)
</para>
<para>
<graphic fileref="images/calendar.png"/>
</para>
</refsect1>
</refentry>
</section>
|