home *** CD-ROM | disk | FTP | other *** search
- # program 11.2 from Dan's book, p368
-
- # I'm cheating here. I know how to specify multiple fonts in a fontlist
- # <fontname1>=charset1, <fontname2>=charset2
- # and I know how to create XmStrings using C code to use these charsets,
- # but I don't know how to do it in resource files. So I use 2 fontlists
-
- set fontlist1 "-*-courier-bold-r-*--12-*"
- set fontlist2 "-*-courier-medium-r-*--12-*"
-
- set months "January February March April May June \
- July August September October November December"
-
- # find the current month/year
- set this_month [exec date "+%m"]
- # this_month is a 2-digit number possibly starting with 0
- # this signals an octal number, so lose any starting 0
- if { [regexp {^0} $this_month] } {
- regsub {^0} $this_month "" this_month
- }
- set year [exec date "+%y"]
- set this_year "19$year"
-
- proc set_month {label month} {
- global this_year
-
- # quote the text to preserve formatting in it
- # when it gets converted to XmString
- set text \{[exec cal $month $this_year]\}
- $label setValues -labelString "$text"
- }
-
- # now the objects:
- xtAppInitialize -class Program
-
- xmRowColumn .rowcol managed -orientation horizontal
- xmFrame .rowcol.frame managed
- xmLabel .rowcol.frame.month managed \
- -alignment alignment_beginning \
- -fontList $fontlist1
-
- xmScrolledList .rowcol.list managed \
- -itemCount 12 \
- -items $months \
- -fontList $fontlist2
- .rowcol.list browseSelectionCallback \
- {set_month .rowcol.frame.month %item_position}
- .rowcol.list selectPosition $this_month true
-
- . realizeWidget
-
- . mainLoop
-