home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / tclmotif.1 / tclmotif / tm.1.2 / programs / progDH11.2 < prev    next >
Encoding:
Text File  |  1993-11-15  |  1.4 KB  |  51 lines

  1. # program 11.2 from Dan's book, p368
  2.  
  3. # I'm cheating here. I know how to specify multiple fonts in a fontlist
  4. # <fontname1>=charset1, <fontname2>=charset2
  5. # and I know how to create XmStrings using C code to use these charsets,
  6. # but I don't know how to do it in resource files. So I use 2 fontlists
  7.  
  8. set fontlist1 "-*-courier-bold-r-*--12-*"
  9. set fontlist2 "-*-courier-medium-r-*--12-*"
  10.  
  11. set months "January, February, March, April, May, June, \
  12. July, August, September, October, November, December"
  13.  
  14. # find the current month/year
  15. set this_month [exec date "+%m"]
  16. # this_month is a 2-digit number possibly starting with 0 
  17. # this signals an octal number, so lose any starting 0
  18. if { [regexp {^0} $this_month] } {
  19.   regsub {^0} $this_month "" this_month
  20. }
  21. set year  [exec date "+%y"]
  22. set this_year "19$year"
  23.  
  24. proc set_month {label month} {
  25.     global this_year
  26.  
  27.     set text [exec cal $month $this_year]
  28.     $label setValues -labelString $text
  29. }
  30.  
  31. # now the objects:
  32. xtAppInitialize -class Program
  33.  
  34. xmRowColumn .rowcol managed -orientation horizontal
  35. xmFrame .rowcol.frame managed
  36. xmLabel .rowcol.frame.month managed \
  37.     -alignment alignment_beginning \
  38.     -fontList $fontlist1
  39.  
  40. xmScrolledList .rowcol.list managed \
  41.     -itemCount 12 \
  42.     -items $months \
  43.     -fontList $fontlist2
  44. .rowcol.list browseSelectionCallback \
  45.     {set_month .rowcol.frame.month %item_position}
  46. .rowcol.list selectPosition $this_month true
  47.  
  48. . realizeWidget
  49.  
  50. . mainLoop
  51.