home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / tclMotif-1.4 / examples / tmp < prev    next >
Encoding:
Text File  |  1995-06-29  |  1.5 KB  |  55 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.  
  33. xtAppInitialize
  34.  . setValues -width 100 -height 100
  35.  
  36. topLevelShell .main managed -geometry "=400x200+0+0"
  37.  
  38. xmRowColumn .main.rowcol managed -orientation horizontal
  39. xmFrame .main.rowcol.frame managed
  40. xmLabel .main.rowcol.frame.month managed \
  41.     -alignment alignment_beginning \
  42.     -fontList $fontlist1
  43.  
  44. xmScrolledList .main.rowcol.list managed \
  45.     -itemCount 12 \
  46.     -items $months \
  47.     -fontList $fontlist2
  48. .main.rowcol.list browseSelectionCallback \
  49.     {set_month .main.rowcol.frame.month %item_position}
  50. .main.rowcol.list selectPosition $this_month true
  51.  
  52. . realizeWidget
  53. . mainLoop
  54.  
  55.