Files
remind/scripts/tkremind
2004-08-11 01:55:20 +00:00

3696 lines
131 KiB
Tcl
Executable File

#!/bin/sh
# -*-Mode: TCL;-*-
#--------------------------------------------------------------
# TKREMIND
#
# A cheesy graphical front/back end for Remind using Tcl/Tk
#
# This file is part of REMIND.
# Copyright (C) 1992-1998 David F. Skoll
# Copyright (C) 1999-2000 Roaring Penguin Software Inc.
#
#--------------------------------------------------------------
# $Id: tkremind,v 1.32 2004-08-11 01:55:20 dfs Exp $
# the next line restarts using wish \
exec wish "$0" "$@"
wm withdraw .
# Check that we have the right version of wish
if {$tcl_version < 8.0} {
tk_dialog .error Error "You need wish version 8.0 or higher to run TkRemind; you have $tcl_version" error 0 OK
exit 1
}
if {$tcl_platform(platform) == "windows"} {
tk_dialog .error Error "Please do not port Remind to Windows" error 0 OK
exit 1
}
#---------------------------------------------------------------------------
# GLOBAL VARIABLES
#---------------------------------------------------------------------------
set Option(ConfirmQuit) 0
set OptDescr(ConfirmQuit) "(0/1) If 1, TkRemind prompts you to confirm 'Quit' operation"
set Option(AutoClose) 1
set OptDescr(AutoClose) "(0/1) If 1, TkRemind automatically closes pop-up reminders after a minute"
set Option(RingBell) 0
set OptDescr(RingBell) "(0/1) If 1, TkRemind beeps the terminal when a pop-up reminder appears"
set Option(StartIconified) 0
set OptDescr(StartIconified) "(0/1) If 1, TkRemind starts up in the iconified state"
set Option(Deiconify) 0
set OptDescr(Deiconify) "(0/1) If 1, TkRemind deiconifies the calendar window when a reminder pops up"
set Option(ShowTodaysReminders) 1
set OptDescr(ShowTodaysReminders) "(0/1) If 1, TkRemind shows all of today's non-timed reminders in a window at startup and when the date changes"
set Option(RunCmd) ""
set OptDescr(RunCmd) "(String) If non-blank, run specified command when a pop-up reminder appears"
set Option(FeedReminder) 0
set OptDescr(FeedReminder) "(0/1) If 1, feed the reminder to RunCmd on standard input (see RunCmd option)"
# Remind program to execute -- supply full path if you want
set Remind "remind"
#set Remind "/home/dfs/Remind/src/remind"
# Rem2PS program to execute -- supply full path if you want
set Rem2PS "rem2ps"
# Reminder file to source -- default
set ReminderFile {NOSUCHFILE}
set ReminderFile [file nativename "~/.reminders"]
# Reminder file to append to -- default
set AppendFile {NOSUCHFILE}
catch {set AppendFile $ReminderFile}
#---------------- DON'T CHANGE STUFF BELOW HERE ------------------
# Is Monday in first column?
set MondayFirst 0
# Month names in English
set MonthNames {January February March April May June July August September October November December}
# Day names in Remind's pre-selected language
set DayNames {}
# Day name in English
set EnglishDayNames {Sunday Monday Tuesday Wednesday Thursday Friday Saturday}
# Current month and year -- will be set by Initialize procedure
set CurMonth -1
set CurYear -1
# Background reminder counter
set BgCounter 0
# Absolutely today -- unlike the CurMonth and CurYear, these won't change
set TodayMonth -1
set TodayYear -1
set TodayDay -1
# Reminder option types and skip types
set OptionType 1
set SkipType 1
# Remind command line
set CommandLine {}
set PSCmd {}
# Print options -- destination file; letter-size; landscape; fill page; default
# encoding; 36pt margins; print small calendars
set PrintDest file
set PrintSize letter
set PrintOrient landscape
set PrintFill 1
set PrintEncoding 0
set PrintMargins 36pt
set PrintSmallCalendars 1
# Highest tag seen so far. Array of tags is stored in ReminderTags()
set HighestTagSoFar 0
#***********************************************************************
# %PROCEDURE: Initialize
# %ARGUMENTS:
# None
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Initializes TkRemind -- sets day names, Remind command line,
# MondayFirst flag, current date, etc.
#***********************************************************************
proc Initialize {} {
global DayNames argc argv CommandLine ReminderFile AppendFile Remind PSCmd
global MondayFirst
set CommandLine "|$Remind -itkremind=1 -p"
set PSCmd "$Remind -p"
set i 0
while {$i < $argc} {
if {[regexp -- {-[bgxim].*} [lindex $argv $i]]} {
append CommandLine " [lindex $argv $i]"
append PSCmd " [lindex $argv $i]"
if {[regexp -- {m} [lindex $argv $i]]} {
set MondayFirst 1
}
} else {
break
}
incr i
}
if {$i < $argc} {
set ReminderFile [lindex $argv $i]
set AppendFile $ReminderFile
incr i
if {$i < $argc} {
set AppendFile [lindex $argv $i]
incr i
}
}
# Check system sanity
if {! [file readable $ReminderFile]} {
set ans [tk_dialog .error "TkRemind: Warning" "Can't read reminder file `$ReminderFile'" warning 0 "Create it and continue" "Exit"]
if {$ans != 0} {
exit 1
}
catch {close [open "$ReminderFile" w]}
}
if {! [file readable $ReminderFile]} {
tk_dialog .error "TkRemind: Error" "Could not create reminder file `$ReminderFile'" error 0 "Exit"
exit 1
}
if {! [file writable $AppendFile]} {
tk_dialog .error Error "Can't write reminder file `$AppendFile'" error 0 Ok
exit 1
}
append CommandLine " $ReminderFile"
append PSCmd " $ReminderFile"
set DayNames [GetWeekdayNames]
# puts "CommandLine: $CommandLine"
}
#---------------------------------------------------------------------------
# GetWeekdayNames - Spawn a remind process and get the names of the weekdays
# Also sets CurMonth and CurYear.
#---------------------------------------------------------------------------
proc GetWeekdayNames {} {
global CurMonth CurYear TodayYear TodayMonth TodayDay Remind
set f [open "|$Remind - 2>/dev/null" r+]
puts $f "banner %"
set i 0
while { $i < 7 } {
puts $f "msg \[wkday($i)\]%"
incr i
}
# Get current month and year as long as we're running Remind
puts $f "msg %n%"
puts $f "msg %y%"
puts $f "msg %d%"
puts $f "FLUSH"
flush $f
set ans {}
set i 0
while { $i < 7 } {
lappend ans [gets $f]
incr i
}
set CurMonth [expr [gets $f] - 1]
set CurYear [gets $f]
set TodayDay [gets $f]
set TodayMonth $CurMonth
set TodayYear $CurYear
close $f
return $ans
}
#***********************************************************************
# %PROCEDURE: CalEntryOffset
# %ARGUMENTS:
# firstDay -- first day of month (0=Sunday, 6=Saturday)
# %RETURNS:
# Offset mapping day numbers (1-31) to window numbers (0-41)
# %DESCRIPTION:
# Computes offset from day number to window number
#***********************************************************************
proc CalEntryOffset { firstDay } {
global MondayFirst
if {$MondayFirst} {
incr firstDay -1
if {$firstDay < 0} {
set firstDay 6
}
}
return [expr $firstDay-1]
}
#***********************************************************************
# %PROCEDURE: CreateCalFrame
# %ARGUMENTS:
# w -- name of frame window
# dayNames -- names of weekdays
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Creates a frame holding a grid of labels and a grid of text entries
#***********************************************************************
proc CreateCalFrame { w dayNames } {
# Figure out reasonable height for text frames
set h [winfo screenheight .]
if {$h <= 480} {
set h 2
} elseif {$h <= 600} {
set h 4
} else {
set h 5
}
global MondayFirst
frame $w
for {set i 0} {$i < 7} {incr i} {
if {$MondayFirst} {
set index [expr ($i+1)%7]
} else {
set index $i
}
label $w.day$i -text [lindex $dayNames $index] -justify center
grid configure $w.day$i -row 0 -column $i -sticky ew
}
for {set i 0} {$i < 6} {incr i} {
set n [expr $i*7]
for {set j 0} {$j < 7} {incr j} {
set f [expr $n+$j]
button $w.l$f -text "" -justify center -command "" \
-state disabled -relief flat
text $w.t$f -width 12 -height $h -wrap word -relief flat \
-state disabled -takefocus 0 -cursor {}
$w.t$f tag bind TAGGED <Enter> "TaggedEnter $w.t$f"
$w.t$f tag bind TAGGED <Leave> "TaggedLeave $w.t$f"
$w.t$f tag bind TAGGED <ButtonPress-1> "EditTaggedReminder $w.t$f"
grid configure $w.l$f -row [expr $i*2+1] -column $j -sticky ew
grid configure $w.t$f -row [expr $i*2+2] -column $j -sticky nsew
}
}
for {set i 0} {$i < 7} {incr i} {
grid columnconfigure $w $i -weight 1
}
for {set i 2} {$i < 14} {incr i 2} {
grid rowconfigure $w $i -weight 1
}
}
#***********************************************************************
# %PROCEDURE: ConfigureCalFrame
# %ARGUMENTS:
# w -- window name of calendar frame
# firstDay -- first weekday of month
# numDays -- number of days in month
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Sets up button labels; configures text justification
#***********************************************************************
proc ConfigureCalFrame { w firstDay numDays } {
global CurMonth CurYear TodayMonth TodayYear TodayDay
set offset [CalEntryOffset $firstDay]
set first [expr $offset+1]
set last [expr $offset+$numDays]
for {set i 0} {$i < $first} {incr i} {
grid $w.l$i $w.t$i
$w.l$i configure -text "" -command "" -state disabled -relief flat
$w.t$i configure -relief flat -takefocus 0 -state normal
$w.t$i delete 1.0 end
$w.t$i configure -state disabled
$w.t$i configure -background [lindex [$w.t$i configure -background] 3]
$w.l$i configure -background [lindex [$w.l$i configure -background] 3]
}
for {set i $first} {$i <= $last} {incr i} {
grid $w.l$i $w.t$i
set d [expr $i-$first+1]
$w.l$i configure -text $d -state normal -relief flat \
-command "ModifyDay $d $firstDay"
$w.t$i configure -relief sunken -takefocus 1 -state normal
$w.t$i delete 1.0 end
$w.t$i configure -state disabled
$w.t$i configure -background [lindex [$w.t$i configure -background] 3]
$w.l$i configure -background [lindex [$w.l$i configure -background] 3]
}
set forgetIt 0
for {set i [expr $last+1]} {$i < 42} {incr i} {
if {$i%7 == 0} {
set forgetIt 1
}
set row [expr ($i/7)*2+1]
if {$forgetIt} {
grid remove $w.l$i $w.t$i
grid rowconfigure $w $row -weight 0
grid rowconfigure $w [expr $row+1] -weight 0
} else {
grid rowconfigure $w [expr $row+1] -weight 1
}
$w.l$i configure -text "" -command "" -state disabled -relief flat
$w.t$i configure -relief flat -takefocus 0 -state normal
$w.t$i delete 1.0 end
$w.t$i configure -state disabled
$w.t$i configure -background [lindex [$w.t$i configure -background] 3]
$w.l$i configure -background [lindex [$w.l$i configure -background] 3]
}
if { $CurMonth == $TodayMonth && $CurYear == $TodayYear } {
set n [expr $TodayDay + $offset]
$w.l$n configure -background "#00c0c0"
}
}
#---------------------------------------------------------------------------
# CreateCalWindow -- create the calendar window.
# Arguments:
# dayNames -- names of weekdays in current language {Sun .. Sat}
#---------------------------------------------------------------------------
proc CreateCalWindow { dayNames } {
global Option
frame .h
label .h.title -text "" -justify center -pady 2 -relief raised
pack .h.title -side top -fill x
pack .h -side top -expand 0 -fill x
CreateCalFrame .cal $dayNames
frame .b
button .b.prev -text {<-} -command {MoveMonth -1}
button .b.this -text {Today} -command {ThisMonth}
button .b.next -text {->} -command {MoveMonth 1}
button .b.goto -text {Go To Date...} -command {GotoDialog}
button .b.print -text {Print...} -command {DoPrint}
button .b.quit -text {Quit} -command {Quit}
button .b.options -text {Options...} -command EditOptions
label .b.status -text "" -width 25 -relief sunken
label .b.nqueued -text "" -width 20 -relief sunken
pack .b.prev .b.this .b.next .b.goto .b.print .b.options .b.quit -side left -fill x
pack .b.status -side left -fill x -expand 1
pack .b.nqueued -side left -fill x
pack .b -side bottom -fill x -expand 0
pack .cal -side top -fill both -expand 1
wm title . "TkRemind"
wm iconname . ""
wm protocol . WM_DELETE_WINDOW Quit
wm deiconify .
if {$Option(StartIconified)} {
wm iconify .
}
update
grid propagate .cal 0
}
#***********************************************************************
# %PROCEDURE: EditOptions
# %ARGUMENTS:
# None
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Lets user edit options
#***********************************************************************
proc EditOptions {} {
global Option tmpOpt
# Make a working copy of current option set
foreach name [array names Option] {
set tmpOpt($name) $Option($name)
}
set w .opt
catch { destroy $w }
toplevel $w
wm title $w "TkRemind Options"
wm iconname $w "Options"
frame $w.f
frame $w.b
pack $w.f -side top -expand 1 -fill both
pack $w.b -side top -expand 0 -fill x
# Start iconified
checkbutton $w.startIconified -text "Start up Iconified" \
-anchor w -justify left \
-variable tmpOpt(StartIconified)
# Show today's reminders on startup
checkbutton $w.showTodays -text "Show Today's Reminders on Startup" \
-anchor w -justify left \
-variable tmpOpt(ShowTodaysReminders)
# Confirm quit
checkbutton $w.confirmQuit -text "Confirm Quit" -anchor w -justify left \
-variable tmpOpt(ConfirmQuit)
# Bring down reminder windows after one minute
checkbutton $w.bringDown \
-text "Automatically close pop-up reminders after a minute" \
-anchor w -justify left -variable tmpOpt(AutoClose)
# Ring bell when popping up reminder
checkbutton $w.ring -text "Beep terminal when popping up a reminder" \
-anchor w -justify left -variable tmpOpt(RingBell)
checkbutton $w.deic -text "Deiconify calendar window when popping up a reminder" \
-anchor w -justify left -variable tmpOpt(Deiconify)
# Run command when popping up reminder
frame $w.rf
label $w.rl -text "Run command when popping up reminder:" -anchor w \
-justify left
entry $w.cmd -width 30
pack $w.rl -in $w.rf -side left -expand 0 -fill none
pack $w.cmd -in $w.rf -side left -expand 1 -fill x
$w.cmd insert 0 $tmpOpt(RunCmd)
frame $w.sep1 -border 1 -relief sunken
frame $w.sep2 -border 1 -relief sunken
checkbutton $w.feed \
-text "Feed popped-up reminder to command's standard input" \
-variable tmpOpt(FeedReminder) -anchor w -justify left
pack $w.startIconified -in $w.f -side top -expand 0 -fill x
pack $w.showTodays -in $w.f -side top -expand 0 -fill x
pack $w.confirmQuit -in $w.f -side top -expand 0 -fill x
pack $w.bringDown -in $w.f -side top -expand 0 -fill x
pack $w.ring -in $w.f -side top -expand 0 -fill x
pack $w.deic -in $w.f -side top -expand 0 -fill x
pack $w.sep1 -in $w.f -side top -expand 0 -fill x -ipady 1
pack $w.rf -in $w.f -side top -expand 0 -fill x
pack $w.feed -in $w.f -side top -expand 0 -fill x
pack $w.sep2 -in $w.f -side top -expand 0 -fill x -ipady 1
button $w.apply -text "Apply Options" -command "ApplyOptions $w; destroy $w"
button $w.save -text "Save Options" -command "SaveOptions $w; destroy $w"
button $w.cancel -text "Cancel" -command "destroy $w"
pack $w.apply $w.save $w.cancel -in $w.b -side left -expand 0 -fill x
CenterWindow $w
}
#***********************************************************************
# %PROCEDURE: ApplyOptions
# %ARGUMENTS:
# w -- edit options window path
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Applies options set in the edit options box.
#***********************************************************************
proc ApplyOptions { w } {
global Option tmpOpt
set tmpOpt(RunCmd) [$w.cmd get]
# Copy working copy to real option set
foreach name [array names tmpOpt] {
set Option($name) $tmpOpt($name)
}
}
#***********************************************************************
# %PROCEDURE: SaveOptions
# %ARGUMENTS:
# w -- edit options window path
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Saves options in $HOME/.tkremindrc
#***********************************************************************
proc SaveOptions { w } {
global Option OptDescr
ApplyOptions $w
set problem [catch {set f [open ~/.tkremindrc "w"]} err]
if {$problem} {
tk_dialog .error Error "Can't write ~/.tkremindrc: $err" 0 OK
return
}
puts $f "# TkRemind option file -- created automatically"
puts $f "# [clock format [clock seconds]]"
puts $f "# Format of each line is 'key value' where 'key'"
puts $f "# specifies the option name, and 'value' is a"
puts $f "# *legal Tcl list element* specifying the option value."
foreach name [lsort [array names Option]] {
puts $f ""
puts $f "# $OptDescr($name)"
puts $f [list $name $Option($name)]
}
puts $f ""
close $f
}
#***********************************************************************
# %PROCEDURE: LoadOptions
# %ARGUMENTS:
# None
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Loads options from ~/.tkremindrc
#***********************************************************************
proc LoadOptions {} {
global Option
set problem [catch {set f [open "~/.tkremindrc" "r"]}]
if {$problem} {
return
}
while {[gets $f line] >= 0} {
if {[string match "#*" $line]} { continue }
if {$line == ""} { continue }
foreach {key val} $line {}
if {![info exists Option($key)]} {
puts "Unknown option in ~/.tkremindrc: $key"
continue
}
set Option($key) $val
}
close $f
}
#***********************************************************************
# %PROCEDURE: ConfigureCalWindow
# %ARGUMENTS:
# month -- month name
# year -- the year
# firstDay -- first day in month
# numDays -- number of days in month
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Configures the calendar window for a month and year
# %PRECONDITIONS:
# Any preconditions
# %POSTCONDITIONS:
# Any postconditions
# %SIDE EFFECTS:
# Any side effects
#***********************************************************************
proc ConfigureCalWindow { month year firstDay numDays } {
.h.title configure -text "$month $year"
wm title . "TkRemind - $month $year"
wm iconname . "$month $year"
ConfigureCalFrame .cal $firstDay $numDays
}
#---------------------------------------------------------------------------
# FillCalWindow -- Fill in the calendar for global CurMonth and CurYear.
#---------------------------------------------------------------------------
proc FillCalWindow {} {
global DayNames CurYear CurMonth MonthNames CommandLine
Status "Firing off Remind..."
set month [lindex $MonthNames $CurMonth]
set file [open "$CommandLine $month $CurYear" r]
# Look for # rem2ps begin line
while { [gets $file line] >= 0 } {
if { [string compare "$line" "# rem2ps begin"] == 0 } { break }
}
if { [string compare "$line" "# rem2ps begin"] != 0 } {
Status "Problem reading results from Remind!"
after 5000 DisplayTime
catch { close $file }
return 0
}
# Read month name, year, number of days in month, first weekday, Mon flag
gets $file line
regexp {^([^ ]*) ([0-9][0-9][0-9][0-9]) ([0-9][0-9]?) ([0-9]) ([0-9])} $line dummy monthName year daysInMonth firstWkday mondayFirst
# Skip day names -- we already have them
gets $file line
ConfigureCalWindow $monthName $year $firstWkday $daysInMonth
set offset [CalEntryOffset $firstWkday]
for {set i 1} {$i <= 31} {incr i} {
set didSomething($i) 0
}
while { [gets $file line] >= 0 } {
if { [regexp {^([0-9][0-9][0-9][0-9])/([0-9][0-9])/([0-9][0-9]) +([^ ]+) +([^ ]+) +[^ ]+ +[^ ]+(.*)} $line all year month day type tag stuff] == 0 } {
continue
}
set day [string trimleft $day 0]
set n [expr $day+$offset]
set month [string trimleft $month 0]
set extratags ""
switch -exact -- $type {
"SHADE" {
DoShadeSpecial $n $stuff
continue
}
"MOON" {
DoMoonSpecial $n $stuff
continue
}
"COLOR" {
if {[regexp {^ *([0-9]+) +([0-9]+) +([0-9]+) +(.*)$} $stuff all r g b rest]} {
if {$r > 255} {
set r 255
} elseif {$r < 0} {
set r 0
}
if {$g > 255} {
set g 255
} elseif {$g < 0} {
set g 0
}
if {$b > 255} {
set b 255
} elseif {$b < 0} {
set b 0
}
set color [format "%02X%02X%02X" $r $g $b]
set extratags "clr$color"
.cal.t$n configure -state normal
.cal.t$n tag configure $extratags -foreground "#$color"
.cal.t$n configure -state disabled
set stuff $rest
}
}
}
if { $type != "*" && $type != "COLOR"} {
continue
}
.cal.t$n configure -state normal
if { $didSomething($day) } {
.cal.t$n insert end " .....\n"
}
set didSomething($day) 1
if {[regexp {TKTAG([0-9]+)} $tag all tagno]} {
.cal.t$n insert end [string trim $stuff] [list TAGGED "TKTAG$tagno" $extratags]
} else {
.cal.t$n insert end [string trim $stuff]
}
.cal.t$n insert end "\n"
.cal.t$n configure -state disabled
}
set problem [catch { close $file } errmsg]
if {$problem} {
tk_dialog .error Error "There was a problem running Remind: $errmsg" error 0 OK
}
DisplayTime
}
#---------------------------------------------------------------------------
# MoveMonth -- move by +1 or -1 months
# Arguments:
# delta -- +1 or -1 -- months to move.
#---------------------------------------------------------------------------
proc MoveMonth {delta} {
global CurMonth CurYear
set CurMonth [expr $CurMonth + $delta]
if {$CurMonth < 0} {
set CurMonth 11
set CurYear [expr $CurYear-1]
}
if {$CurMonth > 11} {
set CurMonth 0
incr CurYear
}
FillCalWindow
}
#---------------------------------------------------------------------------
# ThisMonth -- move to current month
#---------------------------------------------------------------------------
proc ThisMonth {} {
global CurMonth CurYear TodayMonth TodayYear
# Do nothing if already there
if { $CurMonth == $TodayMonth && $CurYear == $TodayYear } {
return 0;
}
set CurMonth $TodayMonth
set CurYear $TodayYear
FillCalWindow
}
#---------------------------------------------------------------------------
# Status -- set status string
# Arguments:
# stuff -- what to set string to.
#---------------------------------------------------------------------------
proc Status { stuff } {
catch { .b.status configure -text $stuff }
update idletasks
}
#---------------------------------------------------------------------------
# DoPrint -- print a calendar
# Arguments:
# None
#---------------------------------------------------------------------------
proc DoPrint {} {
global PrintDest PrintSize PrintMargins PrintOrient PrintFill PrintEncoding PrintSmallCalendars PrintStatus Rem2PS PSCmd
global CurMonth CurYear MonthNames
catch {destroy .p}
toplevel .p
wm title .p "TkRemind Print..."
wm iconname .p "Print..."
frame .p.f1 -relief sunken -border 2
frame .p.f11
frame .p.f12
frame .p.f2 -relief sunken -border 2
frame .p.f2a -relief sunken -border 2
frame .p.f3 -relief sunken -border 2
frame .p.f3a -relief sunken -border 2
frame .p.f4
radiobutton .p.tofile -text "To file: " -variable PrintDest -value file
entry .p.filename
button .p.browse -text "Browse..." -command PrintFileBrowse
radiobutton .p.tocmd -text "To command: " -variable PrintDest -value command
entry .p.command
.p.command insert end "lpr"
label .p.size -text "Paper Size:"
radiobutton .p.letter -text "Letter" -variable PrintSize -value letter
radiobutton .p.a4 -text "A4" -variable PrintSize -value a4
label .p.margin -text "Margins:"
radiobutton .p.24pt -text "24pt margins" -variable PrintMargins -value 24pt
radiobutton .p.36pt -text "36pt margins" -variable PrintMargins -value 36pt
radiobutton .p.48pt -text "48pt margins" -variable PrintMargins -value 48pt
label .p.orient -text "Orientation:"
radiobutton .p.landscape -text "Landscape" -variable PrintOrient -value landscape
radiobutton .p.portrait -text "Portrait" -variable PrintOrient -value portrait
checkbutton .p.fill -text "Fill page" -variable PrintFill
checkbutton .p.encoding -text "ISO 8859-1 PostScript encoding" -variable PrintEncoding
checkbutton .p.calendars -text "Print small calendars" -variable PrintSmallCalendars
button .p.print -text "Print" -command {set PrintStatus print}
button .p.cancel -text "Cancel" -command {set PrintStatus cancel}
pack .p.f1 .p.f2 .p.f2a .p.f3 .p.f3a \
-side top -fill both -expand 1 -anchor w
pack .p.fill .p.encoding .p.calendars -in .p.f3a \
-side top -anchor w -fill none -expand 0
pack .p.f4 -side top -fill both -expand 1 -anchor w
pack .p.f11 .p.f12 -in .p.f1 -side top -fill none -expand 0 -anchor w
pack .p.tofile .p.filename .p.browse -in .p.f11 -side left -fill none -expand 0 -anchor w
pack .p.tocmd .p.command -in .p.f12 -side left -fill none -expand 0 -anchor w
pack .p.size .p.letter .p.a4 -in .p.f2 -side top -fill none -expand 0 -anchor w
pack .p.margin .p.24pt .p.36pt .p.48pt -in .p.f2a -side top -anchor w -fill none -expand 0
pack .p.orient .p.landscape .p.portrait -in .p.f3 -side top -fill none -expand 0 -anchor w
pack .p.print .p.cancel -in .p.f4 -side left -fill none -expand 0
bind .p <KeyPress-Escape> ".p.cancel flash; .p.cancel invoke"
bind .p <KeyPress-Return> ".p.print flash; .p.print invoke"
set PrintStatus 2
CenterWindow .p
tkwait visibility .p
set oldFocus [focus]
focus .p.filename
grab .p
tkwait variable PrintStatus
catch {focus $oldFocus}
set fname [.p.filename get]
set cmd [.p.command get]
destroy .p
if {$PrintStatus == "cancel"} {
return
}
if {$PrintDest == "file"} {
if {$fname == ""} {
tk_dialog .error Error "No filename specified" error 0 Ok
return
}
if {[file isdirectory $fname]} {
tk_dialog .error Error "$fname is a directory" error 0 Ok
return
}
if {[file readable $fname]} {
set ans [tk_dialog .error Overwrite? "Overwrite $fname?" question 0 No Yes]
if {$ans == 0} {
return
}
}
set fname "> $fname"
} else {
set fname "| $cmd"
}
# Build the command line
set cmd "$PSCmd 1 [lindex $MonthNames $CurMonth] $CurYear | $Rem2PS"
if {$PrintSize == "letter"} {
append cmd " -m Letter"
} else {
append cmd " -m A4"
}
if {$PrintMargins == "24pt"} {
append cmd " -or 24 -ol 24 -ot 24 -ob 24"
} elseif {$PrintMargins == "36pt"} {
append cmd " -or 36 -ol 36 -ot 36 -ob 36"
} else {
append cmd " -or 48 -ol 48 -ot 48 -ob 48"
}
if {$PrintOrient == "landscape"} {
append cmd " -l"
}
if {$PrintFill} {
append cmd " -e"
}
if {$PrintEncoding} {
append cmd " -i"
}
if {$PrintSmallCalendars} {
append cmd " -c3"
} else {
append cmd " -c0"
}
append cmd " $fname"
Status "Printing..."
if {[catch {eval "exec $cmd"} err]} {
tk_dialog .error Error "Error during printing: $err" error 0 Ok
}
DisplayTime
}
#---------------------------------------------------------------------------
# PrintFileBrowse -- browse for a filename for Print dialog
# Arguments: none
#---------------------------------------------------------------------------
proc PrintFileBrowse {} {
set ans [BrowseForFile .filebrowse "Print to file..." "Ok" 0 "*.ps"]
if {$ans != ""} {
.p.filename delete 0 end
.p.filename insert end $ans
.p.filename icursor end
.p.filename xview end
}
}
#---------------------------------------------------------------------------
# GotoDialog -- Do the "Goto..." dialog
#---------------------------------------------------------------------------
proc GotoDialog {} {
global CurMonth MonthNames CurYear
catch { destroy .g }
set month [lindex $MonthNames $CurMonth]
toplevel .g
wm title .g "Go To Date"
menubutton .g.mon -text "$month" -menu .g.mon.menu -relief raised
menu .g.mon.menu -tearoff 0
foreach m $MonthNames {
.g.mon.menu add command -label $m -command ".g.mon configure -text $m"
}
frame .g.y
label .g.y.lab -text "Year: "
entry .g.y.e -width 4
.g.y.e insert end $CurYear
bind .g.y.e <Return> ".g.b.go flash; .g.b.go invoke"
frame .g.b
button .g.b.go -text "Go" -command {DoGoto}
button .g.b.cancel -text "Cancel" -command { destroy .g }
pack .g.b.go .g.b.cancel -expand 1 -fill x -side left
pack .g.mon -fill x -expand 1
pack .g.y.lab -side left
pack .g.y.e -side left -fill x -expand 1
pack .g.y -expand 1 -fill x
pack .g.b -expand 1 -fill x
bind .g <KeyPress-Escape> ".g.b.cancel flash; .g.b.cancel invoke"
CenterWindow .g
set oldFocus [focus]
grab .g
focus .g.y.e
tkwait window .g
catch {focus $oldFocus}
}
#---------------------------------------------------------------------------
# DoGoto -- go to specified date
#---------------------------------------------------------------------------
proc DoGoto {} {
global CurYear CurMonth MonthNames
set year [.g.y.e get]
if { ! [regexp {^[0-9]+$} $year] } {
tk_dialog .error Error {Illegal year specified (1990-2078)} error 0 Ok
return
}
if { $year < 1990 || $year > 2078 } {
tk_dialog .error Error {Illegal year specified (1990-2078)} error 0 Ok
return
}
set month [lsearch -exact $MonthNames [.g.mon cget -text]]
set CurMonth $month
set CurYear $year
destroy .g
FillCalWindow
}
#---------------------------------------------------------------------------
# Quit -- handle the Quit button
#---------------------------------------------------------------------------
proc Quit {} {
global Option
if { !$Option(ConfirmQuit) } {
destroy .
StopBackgroundRemindDaemon
exit
}
if { [tk_dialog .question "Confirm..." {Really quit?} question 0 No Yes] } {
destroy .
StopBackgroundRemindDaemon
exit
}
}
#---------------------------------------------------------------------------
# CreateModifyDialog -- create dialog for adding a reminder
# Arguments:
# w -- path of parent window
# day -- day number of month
# firstDay -- day number of first day of month
# args -- buttons to add to bottom frame. First sets result to 1, next
# to 2, and so on. FIRST BUTTON MUST BE "Cancel"
#---------------------------------------------------------------------------
proc CreateModifyDialog {w day firstDay args} {
# Set up: Year, Month, Day, WeekdayName
global CurYear CurMonth EnglishDayNames MonthNames OptionType SkipType
global ModifyDialogResult
set OptionType 1
set SkipType 1
set year $CurYear
set month [lindex $MonthNames $CurMonth]
set wkday [lindex $EnglishDayNames [expr ($day+$firstDay-1) % 7]]
frame $w.o -border 4 -relief ridge
frame $w.o1 -border 4
frame $w.o2 -border 4
frame $w.o3 -border 4
frame $w.exp -border 4
frame $w.adv -border 4
frame $w.weekend -border 4
frame $w.time -border 4
frame $w.hol -border 4
frame $w.msg
frame $w.buttons
pack $w.o1 $w.o2 $w.o3 -side top -anchor w -in $w.o
pack $w.o $w.exp $w.adv $w.weekend $w.time $w.hol $w.msg -side top -anchor w -pady 4 -expand 1 -fill both
pack $w.buttons -side top -anchor w -pady 4 -expand 1 -fill x
# TYPE 1 REMINDER
radiobutton $w.type1 -variable OptionType -value 1
menubutton $w.day1 -text $day -relief raised -menu $w.day1.menu
CreateDayMenu $w.day1
menubutton $w.mon1 -text $month -relief raised -menu $w.mon1.menu
CreateMonthMenu $w.mon1
menubutton $w.year1 -text $year -relief raised -menu $w.year1.menu
CreateYearMenu $w.year1
checkbutton $w.repbut -text "and repeating every"
$w.repbut deselect
menubutton $w.repdays -text 1 -relief raised -menu $w.repdays.menu
CreateDayMenu $w.repdays 1 28 0
label $w.label1a -text "day(s) thereafter"
pack $w.type1 $w.day1 $w.mon1 $w.year1 $w.repbut $w.repbut $w.repdays $w.label1a -side left -anchor w -in $w.o1
# TYPE 2 REMINDER
radiobutton $w.type2 -variable OptionType -value 2
label $w.label2a -text First
menubutton $w.wkday2 -text $wkday -relief raised -menu $w.wkday2.menu
CreateWeekdayMenu $w.wkday2
label $w.label2b -text "on or after"
menubutton $w.day2 -text $day -relief raised -menu $w.day2.menu
CreateDayMenu $w.day2 1 31 0
menubutton $w.mon2 -text $month -relief raised -menu $w.mon2.menu
CreateMonthMenu $w.mon2
menubutton $w.year2 -text $year -relief raised -menu $w.year2.menu
CreateYearMenu $w.year2
pack $w.type2 $w.label2a $w.wkday2 $w.label2b $w.day2 $w.mon2 $w.year2 -side left -anchor w -in $w.o2
# TYPE 3 REMINDER
if { $day <= 7 } {
set which "First"
} elseif {$day <= 14} {
set which "Second"
} elseif {$day <= 21} {
set which "Third"
} elseif {$day <= 28} {
set which "Fourth"
} else {
set which "Last"
}
radiobutton $w.type3 -variable OptionType -value 3
menubutton $w.ordinal -text $which -relief raised -menu $w.ordinal.menu
menu $w.ordinal.menu -tearoff 0
$w.ordinal.menu add command -label "First" -command "$w.ordinal configure -text First"
$w.ordinal.menu add command -label "Second" -command "$w.ordinal configure -text Second"
$w.ordinal.menu add command -label "Third" -command "$w.ordinal configure -text Third"
$w.ordinal.menu add command -label "Fourth" -command "$w.ordinal configure -text Fourth"
$w.ordinal.menu add command -label "Last" -command "$w.ordinal configure -text Last"
$w.ordinal.menu add command -label "Every" -command "$w.ordinal configure -text Every"
menubutton $w.wkday3 -text $wkday -relief raised -menu $w.wkday3.menu
CreateWeekdayMenu $w.wkday3
label $w.label3 -text "in"
menubutton $w.mon3 -text $month -relief raised -menu $w.mon3.menu
CreateMonthMenu $w.mon3
menubutton $w.year3 -text $year -relief raised -menu $w.year3.menu
CreateYearMenu $w.year3
pack $w.type3 $w.ordinal $w.wkday3 $w.label3 $w.mon3 $w.year3 -side left -anchor w -in $w.o3
# EXPIRY DATE
checkbutton $w.expbut -text "Expire after"
$w.expbut deselect
menubutton $w.expday -text $day -relief raised -menu $w.expday.menu
CreateDayMenu $w.expday 1 31 0
menubutton $w.expmon -text $month -relief raised -menu $w.expmon.menu
CreateMonthMenu $w.expmon 0
menubutton $w.expyear -text $year -relief raised -menu $w.expyear.menu
CreateYearMenu $w.expyear 0
pack $w.expbut $w.expday $w.expmon $w.expyear -side left -anchor w -in $w.exp
# ADVANCE NOTICE
checkbutton $w.advbut -text "Issue"
$w.advbut deselect
menubutton $w.advdays -text 3 -menu $w.advdays.menu -relief raised
CreateDayMenu $w.advdays 1 10 0
label $w.advlab -text "day(s) in advance"
checkbutton $w.advcount -text "not counting holidays/weekend"
$w.advcount select
pack $w.advbut $w.advdays $w.advlab $w.advcount -side left -anchor w -in $w.adv
# WEEKEND
label $w.weeklab -text "Weekend is: "
pack $w.weeklab -side left -anchor w -in $w.weekend
foreach d $EnglishDayNames {
checkbutton $w.d$d -text $d
$w.d$d deselect
pack $w.d$d -side left -anchor w -in $w.weekend
}
$w.dSaturday select
$w.dSunday select
# TIMED REMINDER
checkbutton $w.timebut -text "Timed reminder at"
$w.timebut deselect
menubutton $w.timehour -text "12" -menu $w.timehour.menu -relief raised
CreateDayMenu $w.timehour 1 12 0
menubutton $w.timemin -text "00" -menu $w.timemin.menu -relief raised
menu $w.timemin.menu -tearoff 0
foreach i {00 05 10 15 20 25 30 35 40 45 50 55} {
$w.timemin.menu add command -label $i \
-command "$w.timemin configure -text $i"
}
menubutton $w.ampm -text "PM" -menu $w.ampm.menu -relief raised
menu $w.ampm.menu -tearoff 0
$w.ampm.menu add command -label "AM" -command "$w.ampm configure -text {AM}"
$w.ampm.menu add command -label "PM" -command "$w.ampm configure -text {PM}"
checkbutton $w.timeadvbut -text "with"
$w.timeadvbut deselect
menubutton $w.timeadv -text "15" -menu $w.timeadv.menu -relief raised
menu $w.timeadv.menu -tearoff 0
foreach i {5 10 15 30 45 60} {
$w.timeadv.menu add command -label $i -command "$w.timeadv configure -text $i"
}
label $w.timelab1 -text "minutes advance notice"
checkbutton $w.timerepbut -text "repeated every"
$w.timerepbut deselect
menubutton $w.timerep -text "5" -menu $w.timerep.menu -relief raised
menu $w.timerep.menu -tearoff 0
foreach i {3 5 10 15 30} {
$w.timerep.menu add command -label $i -command "$w.timerep configure -text $i"
}
label $w.timelab2 -text "minutes"
pack $w.timebut $w.timehour $w.timemin $w.ampm $w.timeadvbut $w.timeadv $w.timelab1 $w.timerepbut $w.timerep $w.timelab2 -side left -anchor w -in $w.time
# SKIP TYPE
label $w.labhol -text "On holidays or weekends:"
radiobutton $w.issue -variable SkipType -value 1 -text "Issue reminder as usual"
radiobutton $w.skip -variable SkipType -value 2 -text "Skip reminder"
radiobutton $w.before -variable SkipType -value 3 -text "Move reminder before holiday or weekend"
radiobutton $w.after -variable SkipType -value 4 -text "Move reminder after holiday or weekend"
pack $w.labhol $w.issue $w.skip $w.before $w.after -side top -anchor w -in $w.hol
# TEXT ENTRY
label $w.msglab -text "Body:"
entry $w.entry
pack $w.msglab -side left -anchor w -in $w.msg
pack $w.entry -side left -anchor w -expand 1 -fill x -in $w.msg
# BUTTONS
set nbut 0
foreach but $args {
incr nbut
button $w.but$nbut -text $but -command "set ModifyDialogResult $nbut"
pack $w.but$nbut -side left -anchor w -in $w.buttons -expand 1 -fill x
}
bind $w <KeyPress-Escape> "$w.but1 invoke"
set ModifyDialogResult 0
# Center the window on the root
CenterWindow $w
}
#***********************************************************************
# %PROCEDURE: RemindDialogToOptions
# %ARGUMENTS:
# w -- dialog window
# %RETURNS:
# A list of flag/value pairs representing the current state of
# the "create reminder" dialog.
#***********************************************************************
proc RemindDialogToOptions { w } {
global OptionType SkipType repbut expbut advbut advcount
global timebut timeadvbut timerepbut
global dSaturday dSunday dMonday dTuesday dWednesday dThursday dFriday
set ans {}
lappend ans "-global-OptionType" $OptionType
lappend ans "-global-SkipType" $SkipType
foreach win [winfo children $w] {
set winstem [winfo name $win]
switch -exact -- [winfo class $win] {
"Menubutton" {
lappend ans "-text-$winstem" [$win cget -text]
}
"Checkbutton" {
lappend ans "-global-$winstem" [eval set $winstem]
}
"Entry" {
lappend ans "-entry-$winstem" [$win get]
}
}
}
return $ans
}
#***********************************************************************
# %PROCEDURE: OptionsToRemindDialog
# %ARGUMENTS:
# w -- Remind dialog window
# opts -- option list set by RemindDialogToOptions
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Sets parameters in the dialog box according to saved options.
#***********************************************************************
proc OptionsToRemindDialog { w opts } {
global OptionType SkipType repbut expbut advbut advcount
global timebut timeadvbut timerepbut
global dSaturday dSunday dMonday dTuesday dWednesday dThursday dFriday
foreach {flag value} $opts {
switch -glob -- $flag {
"-text-*" {
set win [string range $flag 6 end]
$w.$win configure -text $value
}
"-global-*" {
set win [string range $flag 8 end]
set $win $value
}
"-entry-*" {
set win [string range $flag 7 end]
$w.$win delete 0 end
$w.$win insert end $value
}
}
}
}
#---------------------------------------------------------------------------
# CreateMonthMenu -- create a menu with all the months of the year
# Arguments:
# w -- menu button -- becomes parent of menu
# every -- if true, include an "every month" entry
#---------------------------------------------------------------------------
proc CreateMonthMenu {w {every 1}} {
global MonthNames
menu $w.menu -tearoff 0
if {$every} {
$w.menu add command -label "every month" -command "$w configure -text {every month}"
}
foreach month $MonthNames {
$w.menu add command -label $month -command "$w configure -text $month"
}
}
#---------------------------------------------------------------------------
# CreateWeekdayMenu -- create a menu with all the weekdays
# Arguments:
# w -- menu button -- becomes parent of menu
#---------------------------------------------------------------------------
proc CreateWeekdayMenu {w} {
global EnglishDayNames
menu $w.menu -tearoff 0
foreach d $EnglishDayNames {
$w.menu add command -label $d -command "$w configure -text $d"
}
$w.menu add command -label "weekday" -command "$w configure -text weekday"
}
#---------------------------------------------------------------------------
# CreateDayMenu -- create a menu with entries 1-31 and possibly "every day"
# Arguments:
# w -- menu button -- becomes parent of menu
# min -- minimum day to start from.
# max -- maximum day to go up to
# every -- if true, include an "every day" entry
#---------------------------------------------------------------------------
proc CreateDayMenu {w {min 1} {max 31} {every 1}} {
menu $w.menu -tearoff 0
if {$every} {
$w.menu add command -label "every day" -command "$w configure -text {every day}"
}
set d $min
while { $d <= $max } {
$w.menu add command -label $d -command "$w configure -text $d"
incr d
}
}
#---------------------------------------------------------------------------
# CreateYearMenu -- create a menu with entries from this year to this year+10
# and possibly "every year"
# Arguments:
# w -- menu button -- becomes parent of menu
# every -- if true, include an "every year" entry
#---------------------------------------------------------------------------
proc CreateYearMenu {w {every 1}} {
menu $w.menu -tearoff 0
if {$every} {
$w.menu add command -label "every year" -command "$w configure -text {every year}"
}
global CurYear
set d $CurYear
while { $d < [expr $CurYear + 11] } {
$w.menu add command -label $d -command "$w configure -text $d"
incr d
}
}
#---------------------------------------------------------------------------
# ModifyDay -- bring up dialog for adding reminder.
# Arguments:
# d -- which day to modify
# firstDay -- first weekday in month (0-6)
#---------------------------------------------------------------------------
proc ModifyDay {d firstDay} {
global ModifyDialogResult AppendFile HighestTagSoFar ReminderTags
catch {destroy .mod}
toplevel .mod
CreateModifyDialog .mod $d $firstDay "Cancel" "Add to reminder file" "Preview reminder"
wm title .mod "TkRemind Add Reminder..."
wm iconname .mod "Add Reminder"
tkwait visibility .mod
set oldFocus [focus]
while {1} {
grab .mod
focus .mod.entry
set ModifyDialogResult -1
tkwait variable ModifyDialogResult
if {$ModifyDialogResult == 1} {
catch {focus $oldFocus}
destroy .mod
return 0
}
set problem [catch {set rem [CreateReminder .mod]} err]
if {$problem} {
tk_dialog .error Error "$err" error 0 Ok
} else {
if {$ModifyDialogResult == 3} {
set rem [EditReminder $rem Cancel "Add reminder"]
if {$ModifyDialogResult == 1} {
continue
}
}
set opts [RemindDialogToOptions .mod]
catch {focus $oldFocus}
destroy .mod
Status "Writing reminder..."
set f [open $AppendFile a]
incr HighestTagSoFar
set ReminderTags($HighestTagSoFar) 1
WriteReminder $f TKTAG$HighestTagSoFar $rem $opts
close $f
FillCalWindow
RestartBackgroundRemindDaemon
return 0
}
}
}
#---------------------------------------------------------------------------
# CenterWindow -- center a window on the screen. Stolen from tk_dialog code
# Arguments:
# w -- window to center
#---------------------------------------------------------------------------
proc CenterWindow {w} {
wm withdraw $w
update idletasks
set x [expr [winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 \
- [winfo vrootx [winfo parent $w]]]
set y [expr [winfo screenheight $w]/2 - [winfo reqheight $w]/2 \
- [winfo vrooty [winfo parent $w]]]
wm geom $w +$x+$y
wm deiconify $w
}
#---------------------------------------------------------------------------
# CreateReminder -- create the reminder
# Arguments:
# w -- the window containing the add reminder dialog box.
# Returns:
# The reminder as a string.
#---------------------------------------------------------------------------
proc CreateReminder {w} {
global DidOmit
set body [string trim [$w.entry get]]
if {"$body" == ""} {
error "Blank body in reminder"
}
set DidOmit 0
set needOmit 0
# Delegate the first part to CreateReminder1, CreateReminder2, or
# CreateReminder3
global OptionType SkipType repbut expbut advbut advcount
global timebut timeadvbut timerepbut
set rem [CreateReminder$OptionType $w]
# Do the "until" part
if {$expbut} {
append rem " UNTIL [$w.expday cget -text] [$w.expmon cget -text] [$w.expyear cget -text]"
}
# Advance warning
if {$advbut} {
append rem " +"
if {!$advcount} {
append rem "+"
} else {
set needOmit 1
}
append rem [$w.advdays cget -text]
}
# Timed reminder
if {$timebut} {
set hour [$w.timehour cget -text]
set min [$w.timemin cget -text]
if {[$w.ampm cget -text] == "PM"} {
if {$hour < 12} {
incr hour 12
}
} else {
if {$hour == 12} {
set hour 0
}
}
append rem " AT $hour:$min"
if {$timeadvbut} {
append rem " +[$w.timeadv cget -text]"
}
if {$timerepbut} {
append rem " *[$w.timerep cget -text]"
}
}
global SkipType
if {$SkipType == 2} {
append rem " SKIP"
set needOmit 1
} elseif {$SkipType == 3} {
append rem " BEFORE"
set needOmit 1
} elseif {$SkipType == 4} {
append rem " AFTER"
set needOmit 1
}
if {$needOmit && !$DidOmit} {
append rem " OMIT [GetWeekend $w 1]"
}
# Check it out!
global Remind
set f [open "|$Remind -arq -e -" r+]
puts $f "BANNER %"
puts $f "$rem MSG %"
puts $f "MSG %_%_%_%_"
puts $f "FLUSH"
flush $f
set err {}
catch {set err [gets $f]}
catch {close $f}
if {"$err" != ""} {
# Clean up the message a bit
regsub -- {^-stdin-\([0-9]*\): } $err {} err
error "Error from Remind: $err"
}
append rem " MSG $body"
return $rem
}
#---------------------------------------------------------------------------
# CreateReminder1 -- Create the first part of a type-1 reminder
# Arguments:
# w -- add reminder dialog window
# Returns: first part of reminder
#---------------------------------------------------------------------------
proc CreateReminder1 {w} {
global repbut
set rem "REM"
set gotDay 0
set gotMon 0
set gotYear 0
set d [$w.day1 cget -text]
if {"$d" != "every day"} {
append rem " $d"
set gotDay 1
}
set m [$w.mon1 cget -text]
if {"$m" != "every month"} {
append rem " $m"
set gotMon 1
}
set y [$w.year1 cget -text]
if {"$y" != "every year"} {
append rem " $y"
set gotYear 1
}
# Check for repetition
if {$repbut} {
if {!$gotDay || !$gotMon || !$gotYear} {
error "All components of a date must be specified if you wish to use the repeat feature."
}
append rem " *[$w.repdays cget -text]"
}
return $rem
}
#---------------------------------------------------------------------------
# CreateReminder2 -- Create the first part of a type-2 reminder
# Arguments:
# w -- add reminder dialog window
# Returns: first part of reminder
#---------------------------------------------------------------------------
proc CreateReminder2 {w} {
set wkday [$w.wkday2 cget -text]
if {"$wkday" == "weekday"} {
set wkday [GetWeekend $w 0]
}
set day [$w.day2 cget -text]
set mon [$w.mon2 cget -text]
set year [$w.year2 cget -text]
set rem "REM $wkday $day"
if {$mon != "every month"} {
append rem " $mon"
}
if {$year != "every year"} {
append rem " $year"
}
return $rem
}
#---------------------------------------------------------------------------
# CreateReminder3 -- Create the first part of a type-3 reminder
# Arguments:
# w -- add reminder dialog window
# Returns: first part of reminder
#---------------------------------------------------------------------------
proc CreateReminder3 {w} {
global MonthNames DidOmit
set which [$w.ordinal cget -text]
set day [$w.wkday3 cget -text]
set mon [$w.mon3 cget -text]
set year [$w.year3 cget -text]
set rem "REM"
if {$which != "Last"} {
if {$which == "First"} {
append rem " 1"
} elseif {$which == "Second"} {
append rem " 8"
} elseif {$which == "Third"} {
append rem " 15"
} elseif {$which == "Fourth"} {
append rem " 22"
}
if {$day != "weekday"} {
append rem " $day"
} else {
append rem " [GetWeekend $w 0]"
}
if {$mon != "every month"} {
append rem " $mon"
}
if {$year != "every year"} {
append rem " $year"
}
} else {
if {$day != "weekday"} {
append rem " $day 1 --7"
} else {
append rem " 1 -1 OMIT [GetWeekend $w 1]"
set DidOmit 1
}
if {$mon != "every month"} {
set i [lsearch -exact $MonthNames $mon]
if {$i == 11} {
set i 0
} else {
incr i
}
append rem " [lindex $MonthNames $i]"
}
if {$year != "every year"} {
if {$mon == "December"} {
incr year
}
append rem " $year"
}
}
return $rem
}
#---------------------------------------------------------------------------
# GetWeekend -- returns a list of weekdays or weekend days
# Arguments:
# w -- add reminder dialog window
# wkend -- if 1, we want weekend. If 0, we want weekdays.
# Returns:
# list of weekdays or weekend-days
#---------------------------------------------------------------------------
proc GetWeekend {w wkend} {
global dSaturday dSunday dMonday dTuesday dWednesday dThursday dFriday
global EnglishDayNames
set ret {}
foreach d $EnglishDayNames {
set v [set d$d]
if {$v == $wkend} {
lappend ret $d
}
}
return $ret
}
#---------------------------------------------------------------------------
# EditReminder -- allow user to edit what gets put in reminder file
# Arguments:
# rem -- current reminder
# args -- buttons to add to bottom
# Returns:
# edited version of rem
#---------------------------------------------------------------------------
proc EditReminder {rem args} {
catch {destroy .edit}
global ModifyDialogResult
toplevel .edit
wm title .edit "TkRemind Preview reminder"
wm iconname .edit "Preview reminder"
text .edit.t -width 80 -height 5 -relief sunken
.edit.t insert end $rem
frame .edit.f
set n 0
foreach but $args {
incr n
button .edit.but$n -text $but -command "set ModifyDialogResult $n"
pack .edit.but$n -in .edit.f -side left -fill x -expand 1
}
pack .edit.t -side top -fill both -expand 1
pack .edit.f -side top -fill x -expand 1
bind .edit <KeyPress-Escape> ".edit.but1 invoke"
set ModifyDialogResult 0
CenterWindow .edit
tkwait visibility .edit
set oldFocus [focus]
focus .edit.t
grab .edit
tkwait variable ModifyDialogResult
catch {focus $oldFocus}
set rem [.edit.t get 1.0 end]
catch {destroy .edit}
return $rem
}
#---------------------------------------------------------------------------
# SetWinAttr -- sets an attribute for a window
# Arguments:
# w -- window name
# attr -- attribute name
# val -- value to set it to
# Returns:
# $val
#---------------------------------------------------------------------------
proc SetWinAttr {w attr val} {
global attrPriv
set attrPriv($w-$attr) $val
}
#---------------------------------------------------------------------------
# GetWinAttr -- gets an attribute for a window
# Arguments:
# w -- window name
# attr -- attribute name
# Returns:
# Value of attribute
#---------------------------------------------------------------------------
proc GetWinAttr {w attr} {
global attrPriv
return $attrPriv($w-$attr)
}
#---------------------------------------------------------------------------
# WaitWinAttr -- wait for a window attribute to change
# Arguments:
# w -- window name
# attr -- attribute name
# Returns:
# Value of attribute
#---------------------------------------------------------------------------
proc WaitWinAttr {w attr} {
global attrPriv
tkwait variable attrPriv($w-$attr)
return $attrPriv($w-$attr)
}
#---------------------------------------------------------------------------
# BrowseForFile -- creates and operates a file browser dialog.
# Arguments:
# w -- dialog window.
# title -- dialog title
# oktext -- text for "OK" button
# showdots -- if non-zero, shows "dot" files as well.
# Returns:
# complete path of filename chosen, or "" if Cancel pressed.
#---------------------------------------------------------------------------
proc BrowseForFile {w title {oktext "OK"} {showdots 0} {filter "*"}} {
catch {destroy $w}
toplevel $w
wm title $w $title
# Global array to hold window attributes
global a${w}
SetWinAttr $w status busy
SetWinAttr $w showdots $showdots
frame $w.fileframe
frame $w.butframe
label $w.cwd -text [pwd]
entry $w.entry
label $w.masklab -text "Match: "
listbox $w.list -yscrollcommand "$w.scroll set"
scrollbar $w.scroll -command "$w.list yview"
button $w.ok -text $oktext -command "BrowseForFileOK $w"
button $w.cancel -text "Cancel" -command "BrowseForFileCancel $w"
entry $w.filter -width 7
$w.filter insert end $filter
pack $w.cwd $w.entry -side top -expand 0 -fill x
pack $w.fileframe -side top -expand 1 -fill both
pack $w.butframe -side top -expand 0 -fill x
pack $w.list -in $w.fileframe -side left -expand 1 -fill both
pack $w.scroll -in $w.fileframe -side left -expand 0 -fill y
pack $w.ok -in $w.butframe -side left -expand 1 -fill x
pack $w.cancel -in $w.butframe -side left -expand 1 -fill x
pack $w.masklab -in $w.butframe -side left -expand 0
pack $w.filter -in $w.butframe -side left -expand 1 -fill x
# Fill in the box and wait for status to change
BrowseForFileRead $w [pwd]
bind $w <KeyPress-Escape> "$w.cancel flash; $w.cancel invoke"
bind $w.list <Button-1> "$w.entry delete 0 end; $w.entry insert 0 \[selection get\]"
bind $w.list <Double-Button-1> "$w.ok flash; $w.ok invoke"
bind $w.list <Return> "$w.entry delete 0 end; $w.entry insert 0 \[selection get\]; $w.ok flash; $w.ok invoke"
bind $w.entry <Return> "$w.ok flash; $w.ok invoke"
bind $w.filter <Return> "BrowseForFileRead $w"
bind $w.entry <KeyPress> "CompleteFile $w"
bind $w.entry <KeyPress-space> "ExpandFile $w"
bindtags $w.entry "Entry $w.entry $w all"
bindtags $w.list "Listbox $w.list $w all"
CenterWindow $w
set oldFocus [focus]
tkwait visibility $w
focus $w.entry
set oldGrab [grab current $w]
grab set $w
WaitWinAttr $w status
catch {focus $oldFocus}
catch {grab set $oldGrab}
set ans [GetWinAttr $w status]
destroy $w
return $ans
}
proc CompleteFile {w} {
set index [lsearch [$w.list get 0 end] [$w.entry get]* ]
if {$index > -1} {
$w.list see $index
$w.list selection clear 0 end
$w.list selection set $index
}
}
proc ExpandFile {w} {
set stuff [$w.list curselection]
if {[string compare $stuff ""]} {
$w.entry delete 0 end
$w.entry insert end [$w.list get $stuff]
}
}
proc BrowseForFileCancel {w} {
SetWinAttr $w status {}
}
proc BrowseForFileOK {w} {
set fname [$w.entry get]
if {[string compare $fname ""]} {
# If it starts with a slash, handle it specially.
if {[string match "/*" $fname]} {
if {[file isdirectory $fname]} {
BrowseForFileRead $w $fname
return
} else {
SetWinAttr $w status $fname
return
}
}
if {[string match */ $fname]} {
set fname [string trimright $fname /]
}
if {[$w.cwd cget -text] == "/"} {
set fname "/$fname"
} else {
set fname "[$w.cwd cget -text]/$fname"
}
# If it's a directory, change directories
if {[file isdirectory $fname]} {
BrowseForFileRead $w $fname
} else {
SetWinAttr $w status $fname
}
}
}
#---------------------------------------------------------------------------
# BrowseForFileRead -- read the current directory into the file browser
# Arguments:
# w -- window name
# dir -- directory
# Returns:
# nothing
#---------------------------------------------------------------------------
proc BrowseForFileRead {w {dir ""}} {
# Save working dir
set cwd [pwd]
if {$dir == ""} {
set dir [$w.cwd cget -text]
}
if {[catch "cd $dir" err]} {
tk_dialog .error Error "$err" error 0 Ok
return
}
$w.cwd configure -text [pwd]
if {[GetWinAttr $w showdots]} {
set flist [glob -nocomplain .* *]
} else {
set flist [glob -nocomplain *]
}
set flist [lsort $flist]
set filter [$w.filter get]
if {$filter == ""} {
set filter "*"
}
$w.list delete 0 end
foreach item $flist {
if {$item != "." && $item != ".."} {
if {[file isdirectory $item]} {
$w.list insert end "$item/"
} else {
if {[string match $filter $item]} {
$w.list insert end $item
}
}
}
}
if {[pwd] != "/"} {
$w.list insert 0 "../"
}
cd $cwd
$w.entry delete 0 end
}
#---------------------------------------------------------------------------
# StartBackgroundRemindDaemon
# Arguments:
# none
# Returns:
# nothing
# Description:
# Starts a background Remind daemon to handle timed reminders
#---------------------------------------------------------------------------
proc StartBackgroundRemindDaemon {} {
global Remind DaemonFile ReminderFile
set problem [catch { set DaemonFile [open "|$Remind -z0 $ReminderFile" "r+"] } err]
if {$problem} {
tk_dialog .error Error "Can't start Remind daemon in background: $err" error 0 OK
} else {
fileevent $DaemonFile readable "DaemonReadable $DaemonFile"
puts $DaemonFile "STATUS"
flush $DaemonFile
}
}
#---------------------------------------------------------------------------
# StopBackgroundRemindDaemon
# Arguments:
# none
# Returns:
# nothing
# Description:
# Stops the background Remind daemon
#---------------------------------------------------------------------------
proc StopBackgroundRemindDaemon {} {
global DaemonFile
catch {
puts $DaemonFile "EXIT"
flush $DaemonFile
close $DaemonFile
}
}
#---------------------------------------------------------------------------
# RestartBackgroundRemindDaemon
# Arguments:
# none
# Returns:
# nothing
# Description:
# Restarts the background Remind daemon
#---------------------------------------------------------------------------
proc RestartBackgroundRemindDaemon {} {
global DaemonFile
catch {
puts $DaemonFile "REREAD"
flush $DaemonFile
}
}
#---------------------------------------------------------------------------
# DaemonReadable
# Arguments:
# file -- file channel that is readable
# Returns:
# nothing
# Description:
# Reads data from the Remind daemon and handles it appropriately
#---------------------------------------------------------------------------
proc DaemonReadable { file } {
global Ignore
set line ""
catch { set num [gets $file line] }
if {$num < 0} {
catch { close $file }
return
}
switch -glob -- $line {
"NOTE reminder*" {
scan $line "NOTE reminder %s %s %s" time now tag
IssueBackgroundReminder $file $time $now $tag
}
"NOTE newdate" {
# Date has rolled over -- clear "ignore" list
catch { unset Ignore}
Initialize
FillCalWindow
ShowTodaysReminders
}
"NOTE reread" {
puts $file "STATUS"
flush $file
}
"NOTE queued*" {
scan $line "NOTE queued %d" n
if {$n == 1} {
.b.nqueued configure -text "1 reminder queued"
} else {
.b.nqueued configure -text "$n reminders queued"
}
}
default {
puts "Unknown message from daemon: $line\n"
}
}
}
#---------------------------------------------------------------------------
# IssueBackgroundReminder
# Arguments:
# file -- file channel that is readable
# time -- time of reminder
# now -- current time according to Remind daemon
# tag -- tag for reminder, or "*" if no tag
# Returns:
# nothing
# Description:
# Reads a background reminder from daemon and pops up window.
#---------------------------------------------------------------------------
proc IssueBackgroundReminder { file time now tag } {
global BgCounter Option Ignore
if {$Option(Deiconify)} {
wm deiconify .
}
set msg ""
set line ""
while (1) {
gets $file line
if {$line == "NOTE endreminder"} {
break
}
if {$msg != ""} {
append msg "\n";
}
append msg $line
}
# Do nothing if it's blank -- was probably a RUN-type reminder.
if {$msg == ""} {
return
}
# Do nothing if user told us to ignore this reminder
if {[info exists Ignore($tag)]} {
return
}
incr BgCounter
set w .bg$BgCounter
toplevel $w
wm iconname $w "Reminder"
wm title $w "Timed reminder ($time)"
label $w.l -text "Reminder for $time issued at $now"
message $w.msg -width 6i -text $msg
frame $w.b
button $w.ok -text "OK" -command "destroy $w"
if {$tag != "*"} {
button $w.nomore -text "Don't remind me again today" -command \
"destroy $w; set Ignore($tag) 1"
button $w.kill -text "Delete this reminder completely" -command \
"destroy $w; InteractiveDeleteReminder $tag"
}
pack $w.l -side top
pack $w.msg -side top -expand 1 -fill both
pack $w.b -side top
pack $w.ok -in $w.b -side left
if {$tag != "*"} {
pack $w.nomore $w.kill -in $w.b -side left
}
CenterWindow $w
# Automatically shut down window after a minute if option says so
if {$Option(AutoClose)} {
after 60000 "catch { destroy $w }"
}
update
if {$Option(RingBell)} {
bell
}
if {$Option(RunCmd) != ""} {
if {$Option(FeedReminder)} {
FeedReminderToCommand $Option(RunCmd) $msg
} else {
exec "/bin/sh" "-c" $Option(RunCmd) "&"
}
}
# reread status
if {$file != "stdin"} {
puts $file "STATUS"
flush $file
}
}
#***********************************************************************
# %PROCEDURE: FeedReminderToCommand
# %ARGUMENTS:
# cmd -- command to execute
# msg -- what to feed it
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Feeds "$msg" to a command.
#***********************************************************************
proc FeedReminderToCommand { cmd msg } {
catch {
set f [open "|$cmd" "w"]
fconfigure $f -blocking 0
fileevent $f writable [list CommandWritable $f $msg]
}
}
#***********************************************************************
# %PROCEDURE: CommandWritable
# %ARGUMENTS:
# f -- file which is writable
# msg -- message to write
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Writes $msg to $f; closes $f.
#***********************************************************************
proc CommandWritable { f msg } {
puts $f $msg
flush $f
close $f
}
proc main {} {
# If no ~/.tkremindrc file, do the penguin logo!
if {![file exists ~/.tkremindrc]} {
doLogo
catch {
set f [open ~/.tkremindrc "w"]
close $f
}
}
# Free the memory used by the logo procedures
rename doLogo {}
rename drawLogo {}
global AppendFile HighestTagSoFar DayNames
puts "\nTkRemind Copyright (C) 1996-1998 David F. Skoll"
puts "Copyright (C) 1999-2000 Roaring Penguin Software Inc."
LoadOptions
CreateMoonImages
Initialize
ShowTodaysReminders
ScanForTags $AppendFile
CreateCalWindow $DayNames
FillCalWindow
StartBackgroundRemindDaemon
DisplayTimeContinuously
}
#***********************************************************************
# %PROCEDURE: ScanForTags
# %ARGUMENTS:
# fname -- name of file to scan
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Scans the file for all tags of the form "TKTAGnnnn" and builds
# the tag array. Also adjusts HighestTagSoFar
#***********************************************************************
proc ScanForTags { fname } {
global HighestTagSoFar ReminderTags
if {[catch { set f [open $fname "r"]}]} {
return
}
while {[gets $f line] >= 0} {
switch -regexp -- $line {
{^# TKTAG[0-9]+} {
regexp {^# TKTAG([0-9]+)} $line dummy tagno
if {$tagno > $HighestTagSoFar} {
set HighestTagSoFar $tagno
}
set ReminderTags($tagno) 1
}
}
}
close $f
}
#***********************************************************************
# %PROCEDURE: ReadTaggedOptions
# %ARGUMENTS:
# tag -- tag to match
# %RETURNS:
# A list of options for the dialog box for the tagged reminder
# %DESCRIPTION:
# Scans the file for specified tag and returns the "options" list for the
# reminder.
#***********************************************************************
proc ReadTaggedOptions { tag } {
global AppendFile
if {[catch { set f [open $AppendFile "r"]}]} {
return ""
}
while {[gets $f line] >= 0} {
if {[string match "# $tag *" $line]} {
gets $f line
close $f
return [string range $line 2 end]
}
}
close $f
return ""
}
#***********************************************************************
# %PROCEDURE: GetCurrentReminder
# %ARGUMENTS:
# w -- text window
# %RETURNS:
# The tag (TKTAGnnnn) for current editable reminder, or "" if no
# current editable reminder.
#***********************************************************************
proc GetCurrentReminder { w } {
set tags [$w tag names current]
set index [lsearch -glob $tags "TKTAG*"]
if {$index < 0} {
return ""
}
set tag [lindex $tags $index]
return $tag
}
#***********************************************************************
# %PROCEDURE: TaggedEnter
# %ARGUMENTS:
# w -- text window
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Highlights an "editable" reminder as mouse moves into it
#***********************************************************************
proc TaggedEnter { w } {
set tag [GetCurrentReminder $w]
if {$tag != ""} {
$w tag configure $tag -foreground #FF0000
}
}
#***********************************************************************
# %PROCEDURE: TaggedLeave
# %ARGUMENTS:
# w -- text window
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Removes highlight from an "editable" reminder as mouse leaves it
#***********************************************************************
proc TaggedLeave { w } {
set tag [GetCurrentReminder $w]
if {$tag != ""} {
set tags [$w tag names current]
set index [lsearch -glob $tags "clr*"]
if {$index < 0} {
set fg "#000000"
} else {
set fg [string range [lindex $tags $index] 3 end]
set fg "#$fg"
}
$w tag configure $tag -foreground $fg
}
}
#***********************************************************************
# %PROCEDURE: EditTaggedReminder
# %ARGUMENTS:
# w -- text window
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Opens a dialog box to edit the current editable reminder
#***********************************************************************
proc EditTaggedReminder { w } {
global ModifyDialogResult
set tag [GetCurrentReminder $w]
if {$tag == ""} {
return
}
# Read in options
set opts [ReadTaggedOptions $tag]
if {$opts == ""} {
return
}
toplevel .mod
CreateModifyDialog .mod 1 0 "Cancel" "Replace reminder" "Delete reminder" "Preview reminder"
wm title .mod "TkRemind Edit Reminder..."
wm iconname .mod "Edit Reminder"
OptionsToRemindDialog .mod $opts
tkwait visibility .mod
set oldFocus [focus]
while {1} {
grab .mod
focus .mod.entry
set ModifyDialogResult -1
tkwait variable ModifyDialogResult
if {$ModifyDialogResult == 1} {
catch {focus $oldFocus}
destroy .mod
return 0
}
set problem [catch {set rem [CreateReminder .mod]} err]
if {$problem} {
tk_dialog .error Error "$err" error 0 Ok
continue
}
if {$ModifyDialogResult == 4} {
set rem [EditReminder $rem "Cancel" "Replace reminder"]
if {$ModifyDialogResult == 1} {
continue
}
}
set opts [RemindDialogToOptions .mod]
catch {focus $oldFocus}
destroy .mod
set problem [catch {
if {$ModifyDialogResult == 2} {
ReplaceTaggedReminder $tag $rem $opts
} else {
DeleteTaggedReminder $tag
}
} err]
if {$problem} {
tk_dialog .error Error "Error: $err" error 0 Ok
return 1
}
FillCalWindow
RestartBackgroundRemindDaemon
return 0
}
}
#***********************************************************************
# %PROCEDURE: UniqueFileName
# %ARGUMENTS:
# stem -- base name of file
# %RETURNS:
# A filename of the form "stem.xxx" which does not exist
#***********************************************************************
proc UniqueFileName { stem } {
set n 1
while {[file exists $stem.$n]} {
incr n
}
return $stem.$n
}
#***********************************************************************
# %PROCEDURE: DeleteTaggedReminder
# %ARGUMENTS:
# tag -- tag of reminder to delete
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Deletes tagged reminder from reminder file
#***********************************************************************
proc DeleteTaggedReminder { tag } {
global AppendFile
set tmpfile [UniqueFileName $AppendFile]
set out [open $tmpfile "w"]
set in [open $AppendFile "r"]
set foundStart 0
set foundEnd 0
while {[gets $in line] >= 0} {
if {[string match "# $tag *" $line]} {
set foundStart 1
break
}
puts $out $line
}
if {! $foundStart} {
close $in
close $out
file delete $tmpfile
error "Did not find start of reminder with tag $tag"
}
while {[gets $in line] >= 0} {
if { $line == "# TKEND"} {
set foundEnd 1
break
}
}
if {! $foundEnd} {
close $in
close $out
file delete $tmpfile
error "Did not find end of reminder with tag $tag"
}
while {[gets $in line] >= 0} {
puts $out $line
}
close $in
close $out
file rename -force -- $tmpfile $AppendFile
}
#***********************************************************************
# %PROCEDURE: ReplaceTaggedReminder
# %ARGUMENTS:
# tag -- tag of reminder to replace
# rem -- text to replace it with
# opts -- edit options
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Replaces a tagged reminder in the reminder file
#***********************************************************************
proc ReplaceTaggedReminder { tag rem opts } {
global AppendFile
set tmpfile [UniqueFileName $AppendFile]
set out [open $tmpfile "w"]
set in [open $AppendFile "r"]
set foundStart 0
set foundEnd 0
while {[gets $in line] >= 0} {
if {[string match "# $tag *" $line]} {
set foundStart 1
break
}
puts $out $line
}
if {! $foundStart} {
close $in
close $out
file delete $tmpfile
error "Did not find start of reminder with tag $tag"
}
# Consume the old reminder
while {[gets $in line] >= 0} {
if { $line == "# TKEND"} {
set foundEnd 1
break
}
}
if {! $foundEnd} {
close $in
close $out
file delete $tmpfile
error "Did not find end of reminder with tag $tag"
}
# Write the new reminder
WriteReminder $out $tag $rem $opts
# Copy rest of file over
while {[gets $in line] >= 0} {
puts $out $line
}
close $in
close $out
file rename -force -- $tmpfile $AppendFile
}
#***********************************************************************
# %PROCEDURE: WriteReminder
# %ARGUMENTS:
# out -- file to write to
# tag -- reminder tag
# rem -- reminder body
# opts -- edit options
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Writes a reminder to a file
#***********************************************************************
proc WriteReminder { out tag rem opts } {
puts $out "# $tag Next reminder was created with TkRemind. DO NOT EDIT"
puts $out "# $opts"
if {[string range $rem 0 3] == "REM "} {
puts $out "REM TAG $tag [string range $rem 4 end]"
} else {
puts $out $rem
}
puts $out "# TKEND"
}
#***********************************************************************
# %PROCEDURE: DoShadeSpecial
# %ARGUMENTS:
# n -- calendar box to shade
# stuff -- Remind command line
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Handles the "SHADE" special -- shades a box.
#***********************************************************************
proc DoShadeSpecial { n stuff } {
set num [scan $stuff "%d %d %d" r g b]
if {$num == 1} {
set g $r
set b $r
} elseif {$num != 3} {
return
}
if {$r < 0 || $r > 255 || $g < 0 || $g > 255 || $b < 0 || $b > 255} {
return
}
set bg [format "#%02x%02x%02x" $r $g $b]
.cal.t$n configure -background $bg
}
#***********************************************************************
# %PROCEDURE: DoMoonSpecial
# %ARGUMENTS:
# n -- calendar box for moon
# stuff -- Remind command line
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Handles the "MOON" special -- draws a moon symbol
#***********************************************************************
proc DoMoonSpecial { n stuff } {
set msg ""
set num [scan $stuff "%d %d %d %s" phase junk1 junk2 msg]
if {$num < 1} {
return
}
if {$phase < 0 || $phase > 3} {
return
}
switch -exact -- $phase {
0 { set image new }
1 { set image first }
2 { set image full }
3 { set image last }
}
.cal.t$n configure -state normal
.cal.t$n image create end -image $image
if {$msg != ""} {
.cal.t$n insert end " $msg"
}
.cal.t$n insert end "\n"
.cal.t$n configure -state disabled
}
#***********************************************************************
# %PROCEDURE: DisplayTime
# %ARGUMENTS:
# None
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Displays current date and time in status window
#***********************************************************************
proc DisplayTime {} {
set msg [clock format [clock seconds] -format "%e %b %Y %I:%M%p"]
Status $msg
}
#***********************************************************************
# %PROCEDURE: CreateMoonImages
# %ARGUMENTS:
# None
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Creates the moon images "new", "first", "full" and "last"
#***********************************************************************
proc CreateMoonImages {} {
image create bitmap full -foreground black \
-data "#define newmoon_width 16\n#define newmoon_height 16\nstatic unsigned char newmoon_bits[] = {\n0x00, 0x00, 0xc0, 0x01, 0x30, 0x06, 0x0c, 0x18, 0x04, 0x10, 0x02, 0x20,\n0x02, 0x20, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x02, 0x20, 0x02, 0x20,\n0x04, 0x10, 0x0c, 0x18, 0x30, 0x06, 0xc0, 0x01};"
image create bitmap first -foreground black \
-data "#define firstquarter_width 16\n#define firstquarter_height 16\nstatic unsigned char firstquarter_bits[] = {\n0x00, 0x00, 0xc0, 0x01, 0xf0, 0x06, 0xfc, 0x18, 0xfc, 0x10, 0xfe, 0x20,\n0xfe, 0x20, 0xff, 0x40, 0xff, 0x40, 0xff, 0x40, 0xfe, 0x20, 0xfe, 0x20,\n0xfc, 0x10, 0xfc, 0x18, 0xf0, 0x06, 0xc0, 0x01};"
image create bitmap new -foreground black \
-data "#define fullmoon_width 16\n#define fullmoon_height 16\nstatic unsigned char fullmoon_bits[] = {\n0x00, 0x00, 0xc0, 0x01, 0xf0, 0x07, 0xfc, 0x1f, 0xfc, 0x1f, 0xfe, 0x3f,\n0xfe, 0x3f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xfe, 0x3f, 0xfe, 0x3f,\n0xfc, 0x1f, 0xfc, 0x1f, 0xf0, 0x07, 0xc0, 0x01};"
image create bitmap last -foreground black \
-data "#define lastquarter_width 16\n#define lastquarter_height 16\nstatic unsigned char lastquarter_bits[] = {\n0x00, 0x00, 0xc0, 0x01, 0xb0, 0x07, 0x8c, 0x1f, 0x84, 0x1f, 0x82, 0x3f,\n0x82, 0x3f, 0x81, 0x7f, 0x81, 0x7f, 0x81, 0x7f, 0x82, 0x3f, 0x82, 0x3f,\n0x84, 0x1f, 0x8c, 0x1f, 0xb0, 0x07, 0xc0, 0x01};"
}
#***********************************************************************
# %PROCEDURE: DisplayTimeContinuously
# %ARGUMENTS:
# None
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Continuously displays current date and time in status window,
# updating once a minute
#***********************************************************************
proc DisplayTimeContinuously {} {
DisplayTime
set secs [clock format [clock seconds] -format "%S"]
# Doh -- don't interpret as an octal number if leading zero
scan $secs "%d" decSecs
set decSecs [expr 60 - $decSecs]
after [expr $decSecs * 1000] DisplayTimeContinuously
}
#***********************************************************************
# %PROCEDURE: drawLogo
# %ARGUMENTS:
# c -- canvas to draw logo in
# bg -- background color of canvas
# pencolor -- color of the word "Penguin"
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Draws Roaring Penguin logo in a Tcl canvas
#***********************************************************************
proc drawLogo { c bg {pengcolor #6699cc} } {
$c create polygon 372.249 5.182 361.23 5.519 \
346.164 8.892 316.482 20.023 305.463 17.774 296.468 \
19.573 288.935 24.97 282.864 33.177 267.348 55.102 \
254.531 77.814 236.204 125.26 225.635 174.844 \
221.026 226.113 213.605 228.025 208.658 232.634 \
225.523 240.28 250.708 243.316 282.752 242.416 \
320.079 238.818 330.985 193.17 338.181 146.735 \
338.743 99.963 335.483 76.577 329.524 53.191 345.602 \
48.131 353.135 45.995 359.768 41.048 342.679 43.184 \
324.689 40.036 334.583 28.905 348.3 18.674 372.249 \
5.182 -fill #000000 -outline {} -width 1 -tags logo
$c create line 372.249 5.182 361.23 5.519 \
346.164 8.892 316.482 20.023 305.463 17.774 296.468 \
19.573 288.935 24.97 282.864 33.177 267.348 55.102 \
254.531 77.814 236.204 125.26 225.635 174.844 \
221.026 226.113 213.605 228.025 208.658 232.634 \
225.523 240.28 250.708 243.316 282.752 242.416 \
320.079 238.818 330.985 193.17 338.181 146.735 \
338.743 99.963 335.483 76.577 329.524 53.191 345.602 \
48.131 353.135 45.995 359.768 41.048 342.679 43.184 \
324.689 40.036 334.583 28.905 348.3 18.674 372.249 \
5.182 -tags logo
$c create polygon 298.605 109.632 290.734 \
159.328 282.752 182.939 271.958 205.65 262.851 \
171.133 263.75 138.752 264.537 164.5 271.958 192.833 \
286.687 157.192 298.605 109.632 -fill #ffffff \
-outline {} -width 1 -tags logo
$c create line 298.605 109.632 290.734 159.328 \
282.752 182.939 271.958 205.65 262.851 171.133 \
263.75 138.752 264.537 164.5 271.958 192.833 286.687 \
157.192 298.605 109.632 -tags logo
$c create polygon 312.546 30.592 315.132 35.876 \
310.747 39.586 308.161 34.414 312.546 30.592 -fill \
#ffffff -outline {} -width 1 -tags logo
$c create line 312.546 30.592 315.132 35.876 \
310.747 39.586 308.161 34.414 312.546 30.592 -tags logo
$c create polygon 328.624 54.427 322.665 58.7 \
314.458 61.286 289.16 59.15 284.55 74.665 285.338 \
90.181 303.214 98.951 308.499 106.259 310.523 \
116.378 305.913 130.208 312.771 141.563 308.049 \
167.76 299.729 192.158 279.041 238.593 313.558 \
233.871 327.388 185.75 335.033 139.989 335.82 96.253 \
328.624 54.427 -fill #ffffff -outline {} -width 1 -tags logo
$c create line 328.624 54.427 322.665 58.7 \
314.458 61.286 289.16 59.15 284.55 74.665 285.338 \
90.181 303.214 98.951 308.499 106.259 310.523 \
116.378 305.913 130.208 312.771 141.563 308.049 \
167.76 299.729 192.158 279.041 238.593 313.558 \
233.871 327.388 185.75 335.033 139.989 335.82 96.253 \
328.624 54.427 -tags logo
$c create polygon 53.837 185.412 54.399 185.862 \
53.837 188.223 54.399 188.673 53.837 188.673 53.837 \
189.572 53.837 190.472 53.387 191.034 52.938 192.833 \
50.577 195.644 49.677 196.656 49.677 197.105 48.215 \
198.455 47.316 198.904 46.866 198.904 44.505 200.816 \
43.606 200.366 42.594 201.265 42.144 201.715 41.245 \
202.277 40.795 202.727 40.345 202.277 39.783 202.277 \
36.972 203.177 36.522 203.177 36.073 203.177 35.623 \
203.627 34.723 203.627 34.161 203.627 34.161 204.076 \
30.901 204.526 28.54 205.538 26.291 205.088 25.729 \
205.088 24.829 205.088 24.38 204.526 23.93 204.526 \
23.48 204.526 22.918 205.088 22.918 206.437 22.918 \
206.887 22.918 207.337 22.468 207.337 22.468 208.798 \
22.018 209.248 22.018 211.16 22.018 211.609 21.569 \
213.521 21.119 215.769 21.569 216.781 20.669 218.13 \
20.669 219.592 20.669 220.042 20.107 220.941 20.107 \
221.953 20.107 223.752 19.657 225.664 19.208 226.113 \
19.657 227.013 18.308 230.835 17.858 240.167 17.296 \
248.15 17.296 249.05 16.846 250.062 15.947 250.062 \
15.048 250.062 15.048 250.511 12.686 251.86 12.237 \
251.86 11.675 251.411 11.675 250.511 11.675 246.689 \
11.225 245.339 11.225 243.878 10.775 240.617 11.225 \
239.268 11.225 238.818 10.775 238.256 10.325 237.357 \
10.325 236.007 9.876 232.634 9.876 231.735 9.876 \
231.285 9.876 230.835 9.876 230.386 9.876 229.824 \
9.426 229.374 9.426 226.113 9.876 226.113 9.876 \
225.664 9.426 224.202 9.426 223.752 9.426 223.302 \
10.325 221.953 9.426 220.941 9.426 219.592 9.426 \
219.142 9.426 218.58 9.426 217.681 9.426 217.231 \
9.426 216.781 8.864 216.332 8.864 214.42 8.864 \
213.97 8.414 213.521 8.414 210.148 8.414 209.248 \
7.964 207.899 8.414 205.988 8.414 204.526 7.065 \
201.265 7.515 200.816 9.426 201.715 10.325 201.265 \
10.775 200.816 10.775 198.904 11.225 198.005 11.225 \
197.555 10.775 197.555 9.876 196.094 9.426 194.744 \
7.515 194.295 6.615 193.845 6.053 193.845 5.153 \
193.283 3.804 191.484 3.804 190.022 3.804 189.572 \
3.804 189.123 3.242 188.673 3.242 186.762 3.804 \
185.412 4.254 184.85 4.704 184.4 7.964 180.24 10.325 \
178.779 11.225 178.779 12.237 177.879 14.036 176.98 \
15.497 175.968 21.569 173.607 22.918 173.157 23.48 \
173.157 24.38 172.707 24.829 172.707 29.102 171.808 \
29.551 171.808 30.001 171.358 31.35 170.796 31.913 \
171.358 32.362 170.796 39.783 171.358 40.345 170.796 \
42.144 171.358 47.766 174.619 48.778 176.418 49.227 \
176.418 49.677 176.98 50.127 176.98 51.588 178.329 \
52.038 179.228 52.488 180.69 52.038 181.14 52.038 \
181.59 52.488 182.039 52.938 182.039 53.387 182.601 \
53.837 183.051 53.837 183.501 53.837 185.412 -fill \
$pengcolor -outline {} -width 1 -tags logo
$c create polygon 42.594 222.853 43.156 221.953 \
41.694 222.403 39.783 224.202 39.783 224.764 39.783 \
225.214 40.345 225.214 41.245 224.202 41.694 223.752 \
42.594 222.853 -fill $pengcolor -outline {} -width 1 -tags logo
$c create polygon 58.559 234.096 59.009 234.096 \
59.009 234.546 58.559 234.995 58.559 235.445 57.21 \
236.907 56.648 237.806 52.938 241.067 52.038 241.629 \
52.038 242.079 51.026 242.529 50.577 242.978 50.127 \
242.978 49.227 244.44 45.405 246.239 44.055 246.689 \
43.606 246.689 43.606 247.251 42.144 247.251 41.694 \
247.7 40.795 247.7 38.434 248.15 36.522 248.15 \
35.173 247.7 34.161 246.689 33.711 246.239 32.812 \
244.44 32.362 241.629 32.812 239.718 32.812 239.268 \
33.711 234.995 36.522 229.824 35.623 228.474 35.623 \
227.013 36.522 225.664 37.534 224.202 38.883 222.853 \
41.694 220.492 42.594 219.592 43.156 219.592 43.606 \
219.142 45.405 217.681 45.967 217.681 46.416 217.231 \
48.778 215.769 52.038 214.87 53.387 214.42 54.849 \
214.87 55.299 214.87 56.198 215.769 56.198 217.681 \
56.198 218.58 54.399 221.953 53.837 222.853 53.837 \
223.302 53.387 223.752 50.577 226.113 49.677 226.563 \
47.316 228.474 43.156 230.386 41.245 230.835 40.795 \
230.835 40.345 230.835 39.333 230.835 38.883 230.835 \
38.883 229.824 39.783 229.374 40.795 228.474 41.694 \
228.025 42.594 227.575 45.967 227.013 46.866 226.563 \
50.127 224.764 51.588 223.302 52.488 221.953 52.488 \
220.492 52.488 219.142 51.026 218.13 49.677 218.13 \
48.778 218.13 47.766 219.142 47.316 219.142 47.316 \
219.592 46.866 219.592 45.967 220.941 44.505 221.953 \
44.055 222.403 43.606 222.853 42.594 223.752 41.694 \
225.664 41.245 225.664 41.245 226.113 40.345 226.563 \
39.333 227.575 39.333 228.474 38.434 229.374 36.522 \
233.197 35.623 236.457 35.623 237.357 35.623 238.256 \
35.173 241.067 35.623 242.079 36.522 243.428 37.534 \
243.878 37.984 244.44 38.434 244.89 38.883 244.89 \
39.783 245.339 43.156 245.339 45.967 244.44 49.227 \
242.529 50.127 241.629 50.577 241.067 54.399 238.818 \
54.399 238.256 54.399 237.806 56.198 236.907 58.559 \
234.096 -fill $pengcolor -outline {} -width 1 -tags logo
$c create polygon 92.289 248.6 92.739 249.05 \
92.289 249.05 91.84 249.05 90.94 248.6 90.378 248.6 \
89.478 247.7 89.029 247.251 88.129 246.689 87.117 \
245.789 85.768 244.89 85.318 244.44 85.768 244.44 \
85.318 242.529 84.756 242.079 84.756 240.617 84.756 \
240.167 84.756 239.718 84.756 239.268 83.857 236.457 \
83.407 234.096 83.407 233.197 83.407 231.735 83.407 \
223.302 83.407 221.391 82.957 220.941 82.508 221.953 \
80.596 226.113 80.146 226.563 80.146 227.013 79.697 \
228.025 79.135 228.474 79.697 228.474 76.324 234.096 \
75.874 234.995 75.424 236.457 74.975 236.457 74.975 \
236.907 74.975 237.357 74.075 239.268 73.513 239.718 \
73.063 240.167 72.613 241.067 72.164 242.529 71.714 \
242.529 71.714 243.878 70.252 245.789 69.803 246.689 \
68.903 246.689 68.903 247.251 67.891 247.7 66.542 \
247.7 66.092 247.7 65.643 247.7 65.08 247.251 65.08 \
246.689 65.08 245.789 64.631 242.079 65.08 242.079 \
64.631 241.629 65.08 241.067 65.08 238.818 64.631 \
237.806 64.631 236.457 64.631 234.546 64.631 233.197 \
64.631 232.634 64.631 232.185 64.631 231.735 64.631 \
228.924 64.631 227.575 64.631 225.664 64.631 225.214 \
64.631 224.764 64.631 223.302 64.631 217.231 65.08 \
216.332 65.643 215.769 69.803 214.87 70.252 215.32 \
70.252 216.332 70.252 217.681 70.252 218.58 69.803 \
219.142 69.803 220.492 69.353 220.941 69.353 221.391 \
68.903 221.953 68.903 225.664 68.453 226.563 68.453 \
228.025 68.453 228.474 67.891 228.924 67.891 230.835 \
68.453 236.457 68.453 237.806 68.453 238.818 68.453 \
240.617 68.453 241.067 68.903 241.067 68.903 241.629 \
69.353 241.629 70.702 241.067 70.702 240.617 71.264 \
240.167 71.264 239.268 72.164 238.256 73.063 236.457 \
74.525 234.546 74.975 233.197 76.324 230.835 77.336 \
229.824 78.235 227.575 78.235 227.013 78.685 226.563 \
78.685 225.664 79.135 225.214 79.697 224.764 79.697 \
224.202 80.146 222.403 81.046 220.941 81.945 217.681 \
82.957 215.769 85.318 214.87 85.768 214.87 87.567 \
214.42 87.567 215.769 87.117 216.332 87.567 216.781 \
88.129 219.592 87.567 219.592 87.567 220.492 87.567 \
221.391 87.567 224.764 87.567 225.664 87.567 226.113 \
87.117 226.113 87.117 227.575 87.567 229.374 88.579 \
235.445 89.029 239.268 89.029 239.718 89.029 241.067 \
89.478 242.529 89.478 242.978 89.928 243.878 89.928 \
244.44 90.378 244.89 90.94 246.239 92.289 248.6 \
-fill $pengcolor -outline {} -width 1 -tags logo
$c create polygon 117.587 220.492 118.037 \
222.403 117.587 222.853 117.587 224.764 116.687 \
226.113 116.687 227.013 116.238 228.025 114.776 \
229.374 113.877 231.285 112.865 231.735 109.154 \
234.995 106.343 236.457 105.444 237.357 103.982 \
237.806 103.083 238.256 102.633 238.818 102.183 \
238.818 101.172 239.268 99.822 239.718 98.361 \
239.268 97.461 239.718 96.562 239.268 96.0 238.818 \
95.55 238.818 94.201 236.907 94.201 235.445 94.201 \
233.646 94.65 233.197 94.65 232.634 95.1 232.185 \
95.1 231.735 95.55 231.735 96.0 230.386 97.461 \
228.025 97.461 227.575 98.361 226.563 99.822 224.764 \
101.172 223.302 101.172 222.853 102.633 221.391 \
103.083 220.941 104.432 219.592 103.982 218.58 \
103.982 217.231 103.982 216.781 103.982 215.32 \
104.432 214.42 103.982 210.148 103.982 209.698 \
103.982 209.248 104.432 208.798 104.432 207.899 \
104.432 205.988 104.432 205.538 104.994 203.177 \
104.994 202.277 104.994 201.265 104.994 200.816 \
104.994 200.366 104.994 199.916 105.894 199.467 \
106.343 198.904 106.793 198.455 107.243 198.904 \
108.255 198.904 108.255 199.467 108.705 199.467 \
108.705 202.727 108.255 204.076 108.255 205.538 \
108.255 205.988 107.805 205.988 107.805 206.887 \
107.805 209.698 107.243 210.71 106.793 212.059 \
106.343 214.87 106.343 215.32 106.343 215.769 \
105.894 217.681 106.343 217.681 106.793 217.681 \
107.243 217.231 108.705 215.32 109.604 215.32 \
110.054 214.42 110.054 213.97 110.616 213.97 110.616 \
214.42 111.965 214.87 112.415 214.87 112.865 215.32 \
114.326 216.332 116.238 217.681 116.687 218.58 \
117.137 219.592 117.587 220.042 117.587 220.492 \
-fill $pengcolor -outline {} -width 1 -tags logo
$c create polygon 123.658 258.944 123.658 \
259.394 123.658 260.293 123.658 261.755 123.658 \
262.654 123.658 263.104 123.209 266.364 123.209 \
267.376 122.759 269.175 122.309 269.737 121.859 \
271.087 121.859 271.536 121.859 271.986 121.297 \
271.986 121.297 272.548 120.847 273.448 120.398 \
273.448 120.398 273.897 118.486 276.259 118.037 \
276.708 117.587 277.608 117.137 278.17 116.687 \
278.17 115.675 278.62 115.675 279.069 113.427 \
280.419 112.865 280.981 112.415 280.981 111.965 \
281.43 110.054 282.33 109.154 282.33 108.705 282.78 \
108.255 282.78 107.805 283.229 104.994 283.792 \
104.432 283.792 103.982 283.792 103.533 283.792 \
103.083 283.792 102.633 283.792 102.183 283.792 \
101.172 283.792 100.722 283.792 99.822 283.792 98.81 \
283.792 96.562 282.33 96.0 282.78 95.1 281.88 94.201 \
281.43 91.84 279.969 92.289 279.519 92.289 278.62 \
93.751 279.069 93.751 279.519 94.201 279.519 94.65 \
279.969 95.1 279.969 96.0 280.981 98.81 281.88 \
101.172 281.88 101.621 281.88 102.633 281.88 103.083 \
281.88 103.533 281.88 104.432 281.43 104.994 281.88 \
105.444 281.43 106.793 281.43 107.805 280.981 \
108.705 280.419 109.154 280.419 109.604 279.969 \
110.054 279.969 110.616 279.969 111.066 279.519 \
112.865 278.17 113.427 277.608 113.877 277.608 \
113.877 277.158 114.326 277.158 114.326 276.708 \
114.776 276.259 115.226 276.259 116.238 274.347 \
116.687 274.347 116.687 273.897 117.587 272.998 \
117.587 272.548 118.037 271.986 119.498 267.826 \
120.398 265.015 120.398 262.204 119.948 259.843 \
119.948 259.394 119.948 258.944 119.498 257.482 \
118.486 254.222 118.037 253.772 117.587 251.86 \
115.675 249.05 115.226 248.6 114.776 248.15 113.877 \
247.251 111.965 246.239 111.515 246.239 110.616 \
246.239 110.054 246.239 109.154 246.239 107.243 \
247.251 106.343 247.251 105.444 247.7 104.994 247.7 \
103.083 248.15 102.183 248.6 101.621 248.6 101.172 \
249.05 100.722 249.499 99.822 250.062 98.361 250.062 \
97.461 249.499 97.012 249.499 96.562 249.05 96.562 \
248.6 97.012 248.15 99.822 245.789 100.272 245.339 \
101.621 244.44 101.621 243.878 102.183 243.428 \
102.633 243.428 102.633 242.978 103.982 241.629 \
103.982 241.067 103.982 240.617 103.982 240.167 \
105.444 239.268 108.705 236.907 108.705 236.457 \
109.154 236.457 110.054 235.445 111.066 234.546 \
112.415 234.096 112.865 233.646 113.427 233.646 \
113.877 233.646 113.877 234.096 114.326 234.995 \
114.776 235.445 114.776 236.457 114.326 237.357 \
113.427 238.818 112.415 239.268 112.415 240.167 \
111.965 240.167 111.515 240.617 110.054 241.629 \
110.054 242.079 109.604 242.529 108.705 242.978 \
110.054 242.978 113.427 242.079 114.326 242.529 \
115.226 242.978 116.687 244.44 119.048 246.689 \
119.498 247.7 119.498 248.15 119.948 248.6 119.948 \
249.05 120.398 249.05 120.398 249.499 120.847 \
249.499 120.847 250.062 121.297 250.511 121.297 \
251.411 121.859 252.31 122.759 252.872 122.759 \
254.222 122.759 254.671 123.658 258.494 123.658 \
258.944 -fill $pengcolor -outline {} -width 1 -tags logo
$c create polygon 147.607 215.769 148.506 215.32 \
148.506 217.231 148.506 217.681 148.506 218.13 \
148.956 218.58 148.506 220.492 148.506 220.941 \
148.506 222.853 148.956 224.764 148.956 226.113 \
148.506 226.563 148.956 226.563 148.506 228.924 \
148.956 229.824 148.956 231.285 148.506 232.185 \
148.956 232.634 148.956 233.646 149.405 234.995 \
148.956 234.995 149.405 235.445 149.405 236.907 \
149.405 237.357 149.968 238.818 150.867 240.167 \
150.867 240.617 151.317 242.079 152.216 243.428 \
153.228 245.339 154.128 245.789 155.027 246.239 \
156.939 245.789 157.388 246.239 156.489 246.689 \
155.027 247.7 154.128 247.7 153.228 247.7 152.216 \
247.7 151.767 247.7 150.867 247.251 150.417 246.239 \
149.405 246.239 148.056 245.339 147.607 244.44 \
147.157 243.428 145.695 241.629 145.695 240.617 \
145.245 240.167 145.245 239.718 144.796 238.256 \
144.346 236.907 144.346 235.445 143.784 234.546 \
143.784 233.197 143.784 232.185 143.784 230.835 \
143.334 229.824 143.784 229.374 143.334 229.374 \
143.334 228.474 142.884 230.386 141.985 231.735 \
140.973 233.197 140.523 234.096 140.523 234.546 \
140.523 234.995 139.624 236.457 139.174 237.806 \
138.162 239.718 137.263 241.067 136.813 242.079 \
135.913 242.978 134.452 244.89 134.002 245.789 \
133.552 245.789 132.091 246.689 131.191 247.251 \
129.73 248.15 129.28 248.15 128.38 247.7 128.38 \
248.15 126.919 247.7 126.019 247.251 125.12 246.239 \
125.12 245.339 124.67 244.89 124.67 244.44 124.67 \
243.428 124.67 242.529 124.67 241.067 124.67 239.718 \
125.12 239.268 124.67 239.268 124.67 238.256 125.12 \
237.806 125.12 237.357 125.12 236.907 125.12 236.007 \
125.12 234.096 125.57 233.197 125.57 232.185 126.019 \
232.185 126.019 231.285 126.019 230.386 126.019 \
229.374 126.469 228.474 126.469 227.013 126.469 \
225.214 126.019 225.214 126.469 225.214 126.019 \
223.302 126.019 221.953 126.019 220.492 125.57 \
220.042 125.12 219.592 124.108 219.142 123.209 \
219.142 121.859 220.042 121.297 220.042 120.398 \
220.941 119.498 221.391 119.048 221.391 118.486 \
221.953 118.037 221.953 118.037 221.391 118.486 \
220.941 119.498 220.042 120.847 219.142 122.759 \
217.681 124.108 216.781 125.12 215.769 126.469 \
214.87 126.919 214.87 127.481 214.87 128.38 214.87 \
128.83 214.87 129.73 214.87 129.73 215.769 130.292 \
215.769 130.742 216.781 130.742 217.681 130.292 \
219.142 130.292 221.953 130.292 223.302 130.292 \
224.202 129.73 225.214 129.28 227.013 128.83 227.575 \
129.28 227.575 129.28 228.474 128.83 229.374 129.28 \
229.824 129.28 230.386 128.83 231.735 128.38 234.096 \
128.38 234.995 127.931 236.457 127.931 239.268 \
127.931 240.167 127.931 241.629 128.83 242.978 \
129.28 243.878 129.73 244.44 130.742 244.44 131.191 \
244.44 132.091 244.44 133.103 243.878 134.002 \
242.978 134.902 242.079 135.351 241.067 135.913 \
240.167 136.363 239.268 136.813 238.818 137.263 \
237.806 137.712 236.907 138.162 235.445 138.724 \
234.546 139.174 233.646 139.624 232.634 140.523 \
230.835 140.973 228.924 141.535 227.013 142.435 \
225.664 142.884 223.302 143.334 221.391 143.334 \
220.941 143.334 219.142 144.346 217.681 144.796 \
216.781 145.695 216.332 146.595 216.332 147.607 \
215.769 -fill $pengcolor -outline {} -width 1 -tags logo
$c create polygon 165.371 241.067 165.371 \
241.067 164.921 243.878 164.921 246.239 163.46 \
246.689 161.211 247.251 160.649 247.251 160.199 \
244.44 160.199 243.878 160.199 243.428 160.199 \
242.079 160.199 240.167 160.199 239.718 159.749 \
239.268 160.199 237.806 159.749 237.357 159.749 \
236.007 159.749 230.835 159.749 229.824 159.749 \
228.924 159.749 226.113 159.749 225.664 159.749 \
223.752 159.749 222.853 159.749 218.58 159.749 \
218.13 159.749 217.681 160.199 217.231 161.661 \
216.781 162.11 216.781 162.56 216.781 163.46 216.781 \
164.022 219.142 163.46 222.403 163.46 222.853 163.46 \
224.202 163.46 225.664 163.46 226.563 163.46 227.013 \
163.46 228.924 163.01 230.835 163.01 232.634 163.46 \
233.197 164.022 232.634 164.472 232.634 164.921 \
232.185 164.921 231.735 165.371 231.735 165.821 \
232.185 165.371 233.646 165.821 236.007 165.371 \
238.256 165.371 238.818 165.371 240.617 165.371 \
241.067 -fill $pengcolor -outline {} -width 1 -tags logo
$c create polygon 165.821 214.42 166.833 215.32 \
166.271 215.32 165.821 216.332 165.371 216.332 \
165.371 216.781 165.821 217.681 165.821 218.13 \
165.371 219.142 165.371 220.042 164.921 222.853 \
165.371 224.764 164.921 225.664 165.371 227.575 \
165.371 228.474 164.921 228.474 164.472 227.575 \
164.472 226.113 164.022 224.764 164.472 224.202 \
164.472 223.752 164.472 222.403 164.921 214.87 \
164.472 213.521 164.472 212.959 164.472 212.509 \
164.022 212.509 163.46 212.509 163.01 212.959 162.56 \
212.959 161.661 212.959 161.211 212.059 161.211 \
211.609 160.649 211.609 160.199 209.698 160.649 \
208.349 163.46 206.437 164.472 206.437 165.821 \
207.899 165.821 208.349 166.833 210.148 166.833 \
210.71 165.821 211.609 165.371 212.059 165.371 \
212.959 165.821 213.97 165.821 214.42 -fill $pengcolor \
-outline {} -width 1 -tags logo
$c create polygon 201.462 248.6 201.462 249.05 \
201.012 249.05 200.563 249.05 200.001 248.6 199.551 \
248.6 198.651 247.7 197.752 247.251 196.74 246.689 \
196.29 245.789 194.379 244.89 194.379 244.44 194.379 \
242.529 193.929 242.079 193.479 240.617 193.479 \
240.167 193.929 239.718 193.479 239.268 193.03 \
236.457 192.58 234.096 192.58 233.197 192.58 231.735 \
192.58 223.302 192.58 221.391 192.13 220.941 191.568 \
221.953 189.769 226.113 189.319 226.563 189.319 \
227.013 188.757 228.025 188.307 228.474 188.757 \
228.474 185.497 234.096 185.047 234.995 184.597 \
236.457 184.147 236.457 184.147 236.907 184.147 \
237.357 183.136 239.268 182.686 239.268 182.686 \
239.718 182.236 240.167 181.786 241.067 181.337 \
242.529 180.887 242.529 180.887 243.878 179.425 \
245.789 178.975 246.689 178.076 246.689 178.076 \
247.251 177.064 247.7 175.715 247.7 175.265 247.7 \
174.703 247.7 174.253 247.251 174.253 246.689 \
174.253 245.789 173.804 242.079 174.253 242.079 \
173.804 241.629 173.804 241.067 173.804 238.818 \
173.804 237.806 173.804 236.457 173.354 234.546 \
173.354 233.197 173.804 232.634 173.804 232.185 \
173.804 231.735 173.804 228.924 173.354 227.575 \
173.804 227.575 173.804 225.664 173.804 225.214 \
173.804 224.764 173.804 223.302 173.804 217.231 \
174.253 216.332 174.703 215.769 178.526 214.87 \
179.425 215.32 179.425 216.332 179.425 217.681 \
179.425 218.58 178.975 219.142 178.526 220.492 \
178.526 220.941 178.076 221.391 178.076 221.953 \
178.076 225.664 177.514 226.563 177.514 228.025 \
177.064 228.474 177.064 228.924 177.064 230.835 \
177.514 236.457 177.064 237.806 177.514 237.806 \
177.514 238.818 177.514 240.617 177.514 241.067 \
178.076 241.629 178.526 241.629 179.425 241.067 \
179.875 240.617 179.875 240.167 180.325 239.268 \
181.337 238.256 182.236 236.457 183.698 234.546 \
184.147 233.197 185.497 230.835 186.509 229.824 \
187.408 227.575 187.408 227.013 187.408 226.563 \
187.858 225.664 188.307 225.214 188.757 224.764 \
188.757 224.202 189.319 222.403 190.219 220.941 \
191.118 217.681 192.13 215.769 194.379 214.87 \
194.941 214.87 196.74 214.42 196.74 215.769 196.29 \
215.769 196.29 216.332 196.29 216.781 196.74 219.592 \
196.74 220.492 196.29 221.391 196.74 224.764 196.29 \
225.664 196.29 226.113 196.29 227.575 196.74 229.374 \
197.19 235.445 198.202 239.268 198.202 239.718 \
198.202 241.067 198.202 242.529 198.651 242.978 \
199.101 243.878 199.101 244.44 199.551 244.89 \
200.001 246.239 201.462 248.6 -fill $pengcolor -outline \
{} -width 1 -tags logo
$c create polygon 71.714 185.412 71.714 110.869 \
81.496 110.869 82.845 110.981 83.969 111.431 85.094 \
112.106 86.105 113.118 86.893 114.467 87.567 116.041 \
88.017 117.39 88.242 118.065 88.467 118.852 88.579 \
119.639 88.804 120.538 88.916 121.438 89.029 122.337 \
89.141 123.349 89.254 124.361 89.366 125.485 89.366 \
126.61 89.478 127.734 89.478 128.971 89.478 130.208 \
89.478 131.444 89.478 132.456 89.478 133.468 89.478 \
134.48 89.366 135.492 89.254 136.391 89.254 137.291 \
89.141 138.19 89.029 139.09 88.916 139.877 88.804 \
140.664 88.691 141.451 88.579 142.238 88.354 143.362 \
88.129 144.374 87.904 145.386 87.567 146.398 87.342 \
147.297 87.005 148.197 86.668 148.984 86.218 149.771 \
87.005 151.233 87.342 152.02 87.68 152.919 87.904 \
153.931 88.129 154.943 88.129 155.505 88.354 156.854 \
88.354 157.641 88.354 158.428 88.467 159.328 88.467 \
160.34 88.467 161.352 88.467 162.476 88.579 163.6 \
88.579 164.837 88.579 166.186 88.579 166.973 88.691 \
167.873 88.804 168.885 88.916 169.897 89.029 171.021 \
89.029 172.258 89.029 173.719 89.029 175.068 89.029 \
176.305 89.029 177.542 89.141 178.554 89.141 179.566 \
89.141 180.353 89.141 181.14 89.254 181.814 89.366 \
182.714 89.478 183.051 89.478 185.412 83.857 185.412 \
83.857 184.738 83.744 183.951 83.744 183.276 83.744 \
182.489 83.744 180.803 83.857 179.791 83.857 178.891 \
83.857 177.879 83.857 176.867 83.857 175.743 83.857 \
174.619 83.857 173.27 83.857 172.033 83.744 170.908 \
83.744 170.009 83.632 169.109 83.632 168.322 83.52 \
166.973 83.407 166.524 83.407 166.186 83.407 165.062 \
83.407 164.05 83.295 163.151 83.295 162.251 83.295 \
161.464 83.182 160.789 82.957 159.553 81.945 158.203 \
80.596 157.754 76.886 157.754 76.886 185.412 71.714 \
185.412 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 92.289 148.309 92.289 147.185 \
92.289 146.061 92.289 145.049 92.402 143.924 92.402 \
142.8 92.402 141.788 92.402 140.664 92.514 139.652 \
92.514 138.64 92.627 137.628 92.627 136.616 92.739 \
135.717 92.739 134.705 92.851 133.805 92.964 132.793 \
92.964 131.894 93.076 130.995 93.301 129.196 93.414 \
128.409 93.526 127.509 93.639 126.722 93.751 125.935 \
93.863 125.148 93.976 124.361 94.313 122.787 94.426 \
122.112 94.65 121.325 94.763 120.651 95.1 119.301 \
95.55 117.615 96.112 116.041 96.674 114.692 97.236 \
113.455 97.799 112.443 98.361 111.544 99.035 110.757 \
99.71 110.082 100.385 109.632 101.059 109.295 \
101.846 109.07 102.633 108.958 104.207 109.295 \
104.882 109.632 105.556 110.082 106.231 110.757 \
106.906 111.544 107.468 112.443 108.03 113.455 \
108.592 114.692 109.154 116.041 109.604 117.615 \
110.054 119.301 110.279 119.976 110.616 121.325 \
110.841 122.112 110.953 122.787 111.178 123.574 \
111.403 125.148 111.628 125.935 111.74 126.722 \
111.853 127.622 111.965 128.409 112.078 129.308 \
112.19 130.208 112.302 130.995 112.415 132.006 \
112.64 133.805 112.752 134.817 112.865 135.717 \
112.977 136.729 112.977 137.741 113.089 138.752 \
113.089 139.764 113.202 140.776 113.202 141.788 \
113.314 142.912 113.314 143.924 113.314 145.049 \
113.427 146.061 113.427 147.185 113.427 148.309 \
113.427 149.546 113.314 150.783 113.314 151.907 \
113.314 153.032 113.314 154.156 113.202 155.28 \
113.202 156.405 113.089 157.529 113.089 158.541 \
112.977 159.553 112.865 160.565 112.752 161.576 \
112.64 162.588 112.527 163.6 112.415 164.5 112.302 \
165.512 112.19 166.411 112.078 167.311 111.965 \
168.21 111.853 169.109 111.628 169.897 111.515 \
170.796 111.403 171.583 111.178 172.37 111.066 \
173.157 110.616 174.731 110.504 175.518 110.279 \
176.193 110.054 176.98 109.604 178.666 109.154 \
180.128 108.592 181.59 108.03 182.826 107.468 \
183.951 106.906 184.963 106.231 185.75 105.556 \
186.424 104.882 186.986 104.207 187.436 103.42 \
187.661 102.633 187.661 101.846 187.661 101.059 \
187.436 100.385 186.986 99.71 186.424 99.035 185.75 \
98.361 184.963 97.799 183.951 97.236 182.826 96.674 \
181.59 96.112 180.128 95.55 178.666 95.1 176.98 \
94.988 176.193 94.763 175.518 94.538 174.731 94.426 \
173.944 94.088 172.37 93.976 171.583 93.863 170.796 \
93.639 169.897 93.526 169.109 93.414 168.21 93.301 \
167.311 93.189 166.411 93.076 165.512 92.964 164.5 \
92.964 163.6 92.851 162.588 92.739 161.576 92.627 \
160.565 92.627 159.553 92.514 158.541 92.514 157.529 \
92.514 156.405 92.402 155.28 92.402 154.156 92.402 \
153.032 92.289 151.907 92.289 150.783 92.289 149.546 \
92.289 148.309 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 121.859 110.869 127.481 \
110.869 134.902 185.412 129.28 185.412 127.931 \
171.808 120.847 171.808 119.948 185.412 114.326 \
185.412 121.859 110.869 -fill #000000 -outline {} \
-width 1 -tags logo
$c create polygon 137.263 185.412 137.263 \
110.869 147.157 110.869 148.394 110.981 149.518 \
111.431 150.417 112.106 151.317 113.118 152.104 \
114.467 152.778 116.041 153.228 117.39 153.341 \
118.065 153.566 118.852 153.903 120.538 154.015 \
121.438 154.128 122.337 154.24 123.349 154.353 \
124.361 154.465 125.485 154.465 126.61 154.577 \
127.734 154.577 128.971 154.577 130.208 154.577 \
131.444 154.577 132.456 154.577 133.468 154.577 \
134.48 154.577 135.492 154.577 136.391 154.577 \
137.291 154.577 138.19 154.465 139.09 154.465 \
139.877 154.353 140.664 154.24 141.451 154.128 \
142.238 153.903 143.362 153.678 144.374 153.341 \
145.386 153.003 146.398 152.554 147.297 152.216 \
148.197 151.767 148.984 151.317 149.771 152.104 \
151.233 152.441 152.02 152.778 152.919 153.003 \
153.931 153.228 154.943 153.341 155.505 153.453 \
156.854 153.566 157.641 153.678 158.428 153.79 \
159.328 153.903 160.34 154.015 161.352 154.015 \
162.476 154.128 163.6 154.128 164.837 154.128 \
166.186 154.128 166.973 154.128 167.873 154.128 \
168.885 154.128 169.897 154.128 171.021 154.128 \
172.258 154.128 173.719 154.24 175.068 154.24 \
176.305 154.353 177.542 154.353 178.554 154.465 \
179.566 154.577 180.353 154.69 181.14 154.69 181.814 \
154.915 182.714 155.027 183.051 155.027 185.412 \
149.405 185.412 149.405 184.738 149.293 183.951 \
149.293 183.276 149.181 182.489 149.181 180.803 \
149.068 179.791 149.068 178.891 149.068 177.879 \
149.068 176.867 148.956 175.743 148.956 174.619 \
148.956 173.27 148.956 172.033 148.956 170.908 \
148.956 170.009 148.956 169.109 148.956 168.322 \
148.956 166.973 148.956 166.524 148.956 166.186 \
148.956 165.062 148.843 164.05 148.731 163.151 \
148.618 162.251 148.506 161.464 148.394 160.789 \
148.056 159.553 147.269 158.203 146.145 157.754 \
142.435 157.754 142.435 185.412 137.263 185.412 \
-fill #000000 -outline {} -width 1 -tags logo
$c create polygon 158.4 185.412 158.4 110.869 \
164.022 110.869 164.022 185.412 158.4 185.412 -fill \
#000000 -outline {} -width 1 -tags logo
$c create polygon 168.182 185.412 168.182 \
110.869 173.804 110.869 177.514 135.267 177.739 \
136.054 177.851 136.954 177.964 137.853 178.076 \
138.752 178.301 139.539 178.413 140.439 178.526 \
141.338 178.751 143.137 178.975 144.037 179.088 \
144.824 179.2 145.723 179.313 146.623 179.425 147.41 \
179.538 148.422 179.763 149.321 179.875 150.333 \
180.1 151.233 180.212 152.132 180.437 153.032 180.55 \
154.043 180.774 154.943 180.887 155.842 180.999 \
156.742 181.224 157.754 181.337 158.653 181.337 \
157.641 181.224 156.629 181.224 155.617 181.224 \
154.606 181.224 153.594 181.112 152.582 181.112 \
151.682 181.112 150.67 180.999 149.771 180.999 \
148.759 180.999 147.86 180.887 146.96 180.887 \
145.948 180.887 145.049 180.887 144.149 180.887 \
143.25 180.887 142.125 180.887 141.114 180.887 \
140.102 180.887 139.09 180.887 138.078 180.887 \
137.178 180.887 136.166 180.887 135.267 180.887 \
134.368 180.887 133.468 180.887 132.569 180.887 \
131.669 180.887 130.882 180.887 130.095 180.887 \
110.869 185.946 110.869 185.946 185.412 180.325 \
185.412 176.165 160.565 176.052 159.778 175.94 \
158.99 175.827 158.203 175.602 156.517 175.49 \
155.617 175.378 154.718 175.265 153.931 175.153 \
153.032 175.04 152.02 174.928 151.12 174.703 150.221 \
174.591 149.321 174.478 148.422 174.366 147.41 \
174.141 146.51 174.028 145.611 173.804 144.599 \
173.691 143.587 173.579 142.575 173.354 141.676 \
173.241 140.551 173.017 139.539 172.904 138.528 \
172.904 139.539 172.904 140.551 173.017 141.563 \
173.017 142.575 173.017 143.587 173.129 144.599 \
173.129 145.498 173.129 146.51 173.241 147.41 \
173.241 148.422 173.241 149.321 173.354 150.221 \
173.354 151.233 173.354 152.132 173.354 153.144 \
173.354 154.156 173.354 155.055 173.354 156.067 \
173.354 156.967 173.354 157.866 173.354 158.766 \
173.354 159.553 173.354 160.452 173.354 161.239 \
173.354 162.026 173.354 162.926 173.354 185.412 \
168.182 185.412 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 206.184 185.412 205.622 \
175.968 205.397 177.092 205.172 178.217 204.948 \
179.228 204.61 180.128 204.385 181.027 204.048 \
181.814 203.823 182.489 203.486 183.164 203.149 \
183.838 202.811 184.4 202.024 185.75 201.125 186.762 \
200.113 187.436 199.101 187.661 198.089 187.549 \
197.19 186.986 196.29 186.087 195.391 184.85 194.941 \
184.176 194.491 183.389 194.042 182.489 193.592 \
181.477 193.255 180.465 192.805 179.341 192.467 \
178.217 192.13 176.98 191.905 176.193 191.68 175.406 \
191.568 174.619 191.456 173.832 191.231 172.932 \
191.118 172.145 191.006 171.246 190.781 169.559 \
190.669 168.66 190.556 167.648 190.444 166.748 \
190.331 165.736 190.219 164.725 190.106 163.825 \
189.994 162.926 189.994 162.026 189.882 161.127 \
189.769 160.227 189.769 159.215 189.657 158.316 \
189.544 157.304 189.544 156.405 189.432 155.393 \
189.432 154.381 189.319 153.369 189.319 152.357 \
189.319 151.345 189.319 150.333 189.319 149.321 \
189.319 148.197 189.319 146.96 189.319 145.948 \
189.319 144.824 189.319 143.7 189.319 142.688 \
189.432 141.563 189.432 140.551 189.544 139.539 \
189.544 138.528 189.544 137.516 189.657 136.504 \
189.769 135.492 189.769 134.592 189.882 133.581 \
189.994 132.681 189.994 131.782 190.106 130.882 \
190.219 129.983 190.331 129.083 190.556 127.397 \
190.669 126.61 190.781 125.823 191.006 124.923 \
191.118 124.136 191.231 123.462 191.568 121.887 \
191.793 121.213 191.905 120.426 192.13 119.751 \
192.58 117.952 193.142 116.378 193.704 114.917 \
194.266 113.567 194.941 112.443 195.616 111.431 \
196.29 110.532 196.965 109.857 197.752 109.295 \
198.426 108.845 199.214 108.62 200.001 108.508 \
201.799 108.958 202.699 109.407 203.374 110.194 \
204.161 111.094 204.835 112.218 205.51 113.567 \
206.184 115.141 206.634 116.491 206.859 117.165 \
206.971 117.952 207.421 119.526 207.534 120.426 \
207.758 121.325 207.871 122.225 207.983 123.124 \
208.096 124.136 208.208 125.036 208.321 126.047 \
208.433 127.172 208.545 128.184 208.658 129.308 \
208.77 130.32 208.77 131.557 208.883 132.681 208.995 \
133.805 204.273 133.805 204.161 132.681 203.936 \
131.557 203.711 130.432 203.486 129.533 203.261 \
128.633 202.924 127.734 202.699 126.947 202.362 \
126.385 201.35 124.586 200.001 124.024 199.438 \
124.136 198.989 124.361 198.426 124.923 197.977 \
125.598 197.527 126.497 197.077 127.622 196.628 \
128.971 196.29 130.545 196.178 131.219 195.953 \
132.681 195.84 133.356 195.728 134.143 195.616 \
134.93 195.503 135.829 195.278 137.516 195.278 \
138.303 195.166 139.315 195.166 140.214 195.053 \
141.114 195.053 142.125 194.941 143.137 194.941 \
144.149 194.941 145.161 194.941 146.173 194.941 \
147.297 194.941 148.309 194.941 149.546 194.941 \
150.67 194.941 151.907 194.941 152.919 195.053 \
154.043 195.053 155.168 195.166 156.18 195.166 \
157.192 195.278 158.091 195.391 159.103 195.391 \
160.002 195.503 160.902 195.616 161.801 195.728 \
162.588 195.84 163.375 196.065 164.162 196.178 \
164.949 196.29 165.736 196.628 167.198 197.077 \
168.547 197.527 169.672 197.977 170.571 198.426 \
171.246 198.989 171.808 199.438 172.145 200.001 \
172.258 200.9 171.92 201.575 171.246 202.249 170.009 \
202.811 168.547 203.149 167.76 203.374 166.973 \
203.598 166.186 203.823 165.399 204.048 164.5 \
204.273 163.488 204.385 162.476 204.498 161.464 \
204.61 160.34 204.723 159.103 200.001 159.103 \
200.001 145.049 209.445 145.049 209.445 185.412 \
206.184 185.412 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 148.506 261.305 148.506 \
263.554 143.784 263.554 143.784 261.305 143.671 \
260.068 143.334 259.394 142.772 259.056 141.985 \
258.944 141.085 259.056 140.523 259.394 140.074 \
261.755 140.074 263.104 140.523 264.678 141.085 \
265.465 141.985 266.364 146.145 270.637 147.607 \
271.874 148.506 272.998 148.843 274.01 148.956 \
275.359 148.956 277.158 148.843 278.507 148.506 \
279.632 147.944 280.643 147.157 281.43 146.482 \
281.88 145.695 282.218 144.796 282.442 143.784 \
282.667 142.659 282.78 141.535 282.78 140.298 282.78 \
139.286 282.78 138.387 282.667 137.6 282.442 136.925 \
282.218 136.363 281.88 135.576 281.093 135.014 \
280.194 134.564 278.957 134.452 277.608 134.452 \
275.359 139.624 275.359 139.624 277.608 139.736 \
279.069 140.074 279.969 141.535 280.419 142.659 \
280.081 143.334 279.519 143.671 278.62 143.784 \
277.158 143.784 275.809 143.671 275.022 143.334 \
274.235 142.772 273.448 141.985 272.548 137.263 \
267.376 136.251 266.364 135.351 265.465 135.014 \
264.565 134.902 263.554 134.902 261.755 135.014 \
260.518 135.464 259.506 136.026 258.719 136.813 \
257.932 137.488 257.595 138.275 257.145 139.174 \
256.92 140.186 256.695 141.31 256.583 142.435 \
256.583 143.447 256.583 144.458 256.583 145.245 \
256.695 145.92 256.92 147.157 257.482 147.719 \
258.157 148.169 258.944 148.394 260.068 148.506 \
261.305 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 165.821 270.187 165.821 \
276.708 165.821 277.833 165.708 278.957 165.483 \
279.856 165.259 280.643 164.921 281.318 164.472 \
281.88 163.909 282.218 163.235 282.555 162.448 \
282.667 161.548 282.78 160.536 282.78 159.3 282.78 \
158.175 282.78 157.051 282.78 156.151 282.667 \
155.364 282.555 154.69 282.218 154.128 281.88 \
153.678 281.318 153.341 280.643 153.116 279.856 \
152.891 278.845 152.778 277.833 152.778 276.708 \
152.778 270.187 152.778 269.063 152.891 268.051 \
153.116 267.264 153.341 266.589 154.128 265.465 \
155.364 264.678 156.151 264.453 157.051 264.228 \
158.063 264.116 159.3 264.116 160.424 264.116 \
161.548 264.228 162.448 264.453 163.235 264.678 \
163.909 265.015 164.472 265.465 164.921 265.915 \
165.483 267.264 165.708 268.051 165.821 269.063 \
165.821 270.187 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 177.514 256.583 177.514 \
258.494 177.064 258.494 176.165 258.606 175.715 \
258.944 175.378 259.281 175.265 259.843 175.265 \
264.565 177.514 264.565 177.514 266.927 175.265 \
266.927 175.265 282.78 170.543 282.78 170.543 \
266.927 168.632 266.927 168.632 264.565 170.543 \
264.565 170.543 261.305 170.655 259.843 170.993 \
258.606 171.442 257.707 171.892 257.032 173.579 \
256.358 174.703 256.133 176.165 256.133 176.727 \
256.133 177.064 256.133 177.514 256.583 -fill \
#000000 -outline {} -width 1 -tags logo
$c create polygon 185.946 259.843 185.946 \
264.565 188.757 264.565 188.757 266.927 185.946 \
266.927 185.946 278.62 186.171 279.407 186.509 \
279.969 187.071 280.306 187.858 280.419 188.307 \
280.419 188.757 280.419 188.757 282.78 188.645 \
282.78 188.307 282.78 187.183 282.78 186.509 282.78 \
185.159 282.78 183.923 282.555 182.911 282.33 \
182.236 281.88 181.786 281.206 181.561 280.419 \
181.337 279.407 181.337 278.17 181.337 266.927 \
179.425 266.927 179.425 264.565 181.337 264.565 \
181.337 261.305 185.946 259.843 -fill #000000 \
-outline {} -width 1 -tags logo
$c create polygon 190.219 264.565 194.379 \
264.565 196.29 279.519 196.74 279.519 199.101 \
264.565 204.723 264.565 207.084 279.519 207.534 \
279.519 209.895 264.565 213.605 264.565 209.895 \
282.78 204.723 282.78 201.912 267.376 201.462 \
267.376 199.101 282.78 193.479 282.78 190.219 \
264.565 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 229.121 269.175 229.121 282.78 \
224.848 282.78 224.848 280.981 224.061 281.768 \
223.049 282.33 221.925 282.667 220.688 282.78 \
219.564 282.78 218.44 282.555 217.54 282.33 216.866 \
281.88 216.528 281.318 216.191 280.531 216.079 \
279.632 215.966 278.62 215.966 275.359 216.079 \
274.347 216.978 272.998 217.877 272.548 218.44 \
272.211 219.114 271.986 219.789 271.761 220.688 \
271.536 221.588 271.424 222.6 271.311 223.724 \
271.199 224.848 271.087 224.848 269.175 224.736 \
267.826 224.399 266.927 223.612 266.477 222.487 \
266.364 221.7 266.477 221.138 266.927 220.688 \
268.726 220.688 269.175 216.416 269.175 216.528 \
267.938 216.753 266.702 217.203 265.69 217.877 \
265.015 218.44 264.678 219.114 264.453 219.901 \
264.228 220.801 264.116 221.925 264.116 223.049 \
264.116 224.061 264.116 225.073 264.116 225.86 \
264.228 226.535 264.453 227.659 265.015 228.334 \
265.69 228.783 266.702 229.008 267.938 229.121 \
269.175 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 243.175 264.565 243.175 \
266.927 242.725 266.927 241.601 266.927 240.701 \
267.151 239.914 267.489 239.352 267.826 239.015 \
268.276 238.678 268.95 238.565 269.737 238.453 \
270.637 238.453 282.78 233.731 282.78 233.731 \
264.565 238.453 264.565 238.453 265.915 239.352 \
265.128 240.364 264.565 242.163 264.116 242.725 \
264.565 243.175 264.565 -fill #000000 -outline {} \
-width 1 -tags logo
$c create polygon 258.129 270.187 258.129 \
274.347 249.696 274.347 249.696 278.17 249.809 \
279.294 250.146 279.969 250.708 280.643 251.607 \
280.981 252.732 280.643 253.406 279.969 253.744 \
279.294 253.969 278.17 253.969 276.708 258.129 \
276.708 258.129 277.608 258.129 278.957 257.904 \
280.081 257.454 281.093 256.779 281.88 256.217 \
282.218 254.643 282.667 253.744 282.78 252.732 \
282.78 251.607 282.78 250.371 282.78 249.359 282.78 \
248.459 282.667 247.672 282.442 246.436 281.88 \
245.986 281.318 245.649 280.643 245.424 279.856 \
245.199 278.957 245.086 277.833 244.974 276.708 \
244.974 270.187 245.086 269.063 245.199 268.051 \
245.311 267.264 245.649 266.589 245.986 265.915 \
246.436 265.465 246.998 265.015 247.672 264.678 \
248.459 264.453 249.359 264.228 250.371 264.116 \
251.607 264.116 252.732 264.116 253.744 264.228 \
254.756 264.453 255.543 264.678 256.217 265.015 \
256.779 265.465 257.229 265.915 257.566 266.589 \
257.791 267.264 258.016 268.051 258.129 269.063 \
258.129 270.187 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 272.183 256.583 277.355 \
256.583 277.355 282.78 272.183 282.78 272.183 \
256.583 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 295.569 268.726 295.569 282.78 \
290.959 282.78 290.959 269.175 290.847 268.051 \
290.509 267.376 289.947 266.702 289.048 266.364 \
287.923 266.702 287.136 267.376 287.024 268.051 \
287.136 269.175 287.136 282.78 282.527 282.78 \
282.527 264.565 286.687 264.565 287.136 265.915 \
288.036 265.128 289.048 264.565 290.172 264.228 \
291.409 264.116 292.533 264.116 293.433 264.341 \
294.107 264.565 294.669 265.015 295.344 266.477 \
295.569 267.489 295.569 268.726 -fill #000000 \
-outline {} -width 1 -tags logo
$c create polygon 312.434 269.737 312.434 \
270.637 308.274 270.637 308.274 269.175 308.161 \
267.826 307.824 266.927 307.262 266.477 306.363 \
266.364 305.576 266.477 305.013 266.927 304.676 \
267.826 304.564 269.175 304.564 278.17 304.676 \
279.294 305.013 279.969 306.363 280.981 307.262 \
280.643 307.824 279.969 307.937 279.294 307.824 \
278.17 307.824 276.259 312.434 276.259 312.434 \
277.608 312.434 278.957 312.209 280.081 311.759 \
281.093 311.085 281.88 310.523 282.218 309.173 \
282.667 308.386 282.78 307.374 282.78 306.363 282.78 \
305.238 282.78 304.226 282.78 303.327 282.667 \
302.427 282.442 301.753 282.218 301.191 281.88 \
300.853 281.318 300.516 280.643 300.179 279.856 \
299.954 278.957 299.841 277.833 299.841 276.708 \
299.841 270.187 299.841 269.063 299.954 268.051 \
300.179 267.264 300.404 266.589 301.191 265.465 \
302.427 264.678 303.327 264.453 304.226 264.228 \
305.238 264.116 306.363 264.116 307.374 264.116 \
308.386 264.228 309.173 264.453 309.96 264.678 \
310.523 265.015 311.085 265.465 311.759 266.252 \
312.209 267.264 312.434 268.388 312.434 269.737 \
-fill #000000 -outline {} -width 1 -tags logo
$c create polygon 316.706 279.069 320.866 \
279.069 320.866 282.78 316.706 282.78 316.706 \
279.069 -fill #000000 -outline {} -width 1 -tags logo
$c create polygon 48.215 186.312 48.215 185.412 \
47.766 184.4 47.766 183.501 47.316 183.501 47.316 \
182.601 46.416 181.59 46.416 181.14 45.967 180.24 \
45.405 179.791 44.955 179.228 44.055 178.329 43.606 \
177.879 43.156 177.43 42.144 176.98 41.694 176.418 \
41.245 175.968 38.883 175.068 36.972 174.169 36.522 \
174.169 35.173 173.607 34.723 174.169 31.913 173.607 \
31.913 174.169 29.551 173.607 29.551 174.169 28.54 \
174.169 28.09 174.619 27.19 174.169 27.19 174.619 \
26.741 174.619 25.729 175.068 23.93 175.518 22.918 \
175.068 22.468 175.518 20.669 176.418 19.657 176.418 \
15.048 178.779 14.036 179.228 12.686 180.24 12.237 \
180.69 11.225 181.59 10.775 182.039 10.325 182.601 \
10.775 182.601 10.325 184.4 10.775 184.85 11.225 \
186.312 14.036 188.223 14.485 188.673 16.846 190.022 \
17.296 190.472 17.296 191.034 15.947 191.933 15.048 \
192.383 14.485 192.833 14.036 193.283 13.136 193.845 \
12.237 194.295 12.686 195.644 12.686 196.094 12.237 \
197.555 12.237 198.005 11.675 198.904 12.237 200.816 \
12.237 202.277 12.237 204.526 11.675 205.988 12.237 \
205.988 12.237 206.437 12.237 207.337 12.686 208.349 \
12.686 209.248 13.136 209.698 12.686 211.16 13.136 \
212.509 13.136 213.521 13.586 215.32 13.586 216.781 \
13.586 217.681 14.036 220.492 14.485 222.403 15.048 \
222.853 15.947 222.853 15.947 222.403 16.397 221.953 \
16.846 216.781 17.296 215.32 17.858 211.609 18.308 \
210.71 18.308 210.148 18.308 209.248 17.858 208.798 \
17.858 207.899 18.308 206.437 18.308 205.538 18.308 \
205.088 18.308 203.627 16.846 203.627 15.947 203.177 \
15.947 202.727 15.947 202.277 16.397 201.715 16.846 \
201.715 17.858 201.715 18.308 201.715 18.758 201.265 \
18.308 200.816 17.858 199.916 18.308 198.455 17.858 \
198.455 17.858 193.283 19.208 192.383 20.107 191.933 \
21.569 191.484 22.018 191.484 22.918 192.383 22.918 \
192.833 23.48 192.833 23.93 198.005 23.48 199.467 \
23.93 202.277 25.279 202.277 29.551 202.727 30.001 \
202.277 30.901 202.277 31.913 202.277 35.623 201.265 \
36.522 201.265 36.972 200.816 37.984 200.816 38.883 \
200.816 39.333 200.366 40.345 199.916 40.795 199.916 \
42.594 198.455 44.055 198.005 44.055 197.555 44.505 \
197.105 46.416 195.644 46.416 194.744 46.866 194.295 \
47.316 193.845 47.766 193.283 47.316 192.833 48.215 \
190.472 48.215 190.022 48.215 189.572 48.215 188.673 \
48.215 187.211 48.215 186.762 48.215 186.312 -fill \
$bg -outline {} -width 1 -tags logo
$c create polygon 76.886 142.688 81.046 142.688 \
82.508 142.35 83.407 140.889 83.632 140.327 83.969 \
138.865 84.082 137.965 84.194 137.066 84.307 136.054 \
84.307 134.93 84.307 133.805 84.307 132.456 84.194 \
131.332 84.082 130.208 83.857 129.308 83.632 128.409 \
83.407 127.734 82.395 126.272 81.046 125.823 76.886 \
125.823 76.886 142.688 -fill $bg -outline {} -width \
1 -tags logo
$c create polygon 97.461 148.309 97.461 149.546 \
97.461 150.783 97.461 152.02 97.574 153.144 97.574 \
154.268 97.686 155.28 97.686 156.405 97.799 157.416 \
97.799 158.316 97.911 159.328 98.023 160.227 98.136 \
161.127 98.361 162.701 98.473 163.488 98.586 164.275 \
98.698 164.949 98.81 165.736 99.373 167.535 99.822 \
169.109 100.497 170.234 101.059 171.133 101.846 \
171.583 102.633 171.808 104.095 171.133 104.769 \
170.234 105.332 169.109 105.894 167.535 106.343 \
165.736 106.456 164.949 106.681 164.275 106.793 \
163.488 106.906 162.701 107.018 161.914 107.243 \
160.227 107.355 159.328 107.355 158.316 107.468 \
157.416 107.58 156.405 107.58 155.28 107.693 154.268 \
107.693 153.144 107.693 152.02 107.693 150.783 \
107.805 149.546 107.805 148.309 107.805 147.073 \
107.693 145.836 107.693 144.711 107.693 143.587 \
107.693 142.463 107.58 141.338 107.58 140.327 \
107.468 139.315 107.355 138.303 107.355 137.403 \
107.243 136.504 107.131 135.604 106.906 133.918 \
106.793 133.131 106.681 132.456 106.456 131.669 \
106.343 130.995 105.894 129.196 105.332 127.622 \
104.769 126.497 104.095 125.598 103.42 125.148 \
102.633 124.923 101.846 125.148 101.059 125.598 \
100.497 126.497 99.822 127.622 99.373 129.196 98.81 \
130.995 98.698 131.669 98.586 132.456 98.473 133.131 \
98.361 133.918 98.248 134.817 98.023 136.504 97.911 \
137.403 97.799 138.303 97.799 139.315 97.686 140.327 \
97.686 141.338 97.574 142.463 97.574 143.587 97.461 \
144.711 97.461 145.836 97.461 147.073 97.461 148.309 \
-fill $bg -outline {} -width 1 -tags logo
$c create polygon 122.309 156.292 126.919 \
156.292 124.67 130.545 122.309 156.292 -fill $bg \
-outline {} -width 1 -tags logo
$c create polygon 142.435 142.688 146.145 \
142.688 147.607 142.35 148.506 140.889 148.731 \
140.327 149.068 138.865 149.181 137.965 149.293 \
137.066 149.405 136.054 149.405 134.93 149.405 \
133.805 149.405 132.456 149.405 131.332 149.405 \
130.208 149.293 129.308 149.181 128.409 148.956 \
127.734 148.056 126.272 146.595 125.823 142.435 \
125.823 142.435 142.688 -fill $bg -outline {} -width \
1 -tags logo
$c create polygon 111.515 228.924 111.515 \
227.575 111.066 225.664 108.705 221.391 108.255 \
220.042 108.255 219.142 108.255 218.58 108.255 \
218.13 107.805 217.681 106.793 218.58 104.994 \
220.941 104.432 221.953 102.633 224.202 102.183 \
224.764 101.621 225.214 99.822 228.474 97.461 \
233.197 97.461 234.096 97.461 234.995 97.911 235.445 \
98.361 236.007 99.822 236.457 102.633 236.457 \
104.432 235.445 105.894 234.995 106.343 234.546 \
106.793 234.546 107.805 233.646 110.616 230.835 \
111.515 229.824 111.515 229.374 111.515 228.924 \
-fill $bg -outline {} -width 1 -tags logo
$c create polygon 161.211 269.175 160.986 \
267.826 160.649 266.927 160.199 266.477 159.3 \
266.364 158.4 266.477 157.838 266.927 157.613 \
267.826 157.388 269.175 157.388 278.17 157.613 \
279.294 157.838 279.969 159.3 280.981 160.199 \
280.643 160.649 279.969 160.986 279.294 161.211 \
278.17 161.211 269.175 -fill $bg -outline {} -width \
1 -tags logo
$c create polygon 224.848 273.448 223.836 \
273.448 222.825 273.56 222.15 273.673 221.588 \
273.897 220.913 274.684 220.688 275.809 220.688 \
278.17 220.801 279.294 221.138 279.969 221.7 280.643 \
222.487 280.981 223.612 280.643 224.399 279.969 \
224.736 279.294 224.848 278.17 224.848 273.448 -fill \
$bg -outline {} -width 1 -tags logo
$c create polygon 253.969 269.175 253.744 \
267.826 253.406 266.927 252.732 266.477 251.607 \
266.364 250.708 266.477 250.146 266.927 249.696 \
269.175 249.696 272.548 253.969 272.548 253.969 \
269.175 -fill $bg -outline {} -width 1 -tags logo
}
#***********************************************************************
# %PROCEDURE: doLogo
# %ARGUMENTS:
# None
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Does the logo thing
#***********************************************************************
proc doLogo {} {
wm deiconify .
canvas .c -width 374 -height 286 -bg #FFFFCC
pack .c
update idletasks
drawLogo .c #FFFFCC
# Funky effect
.c create text 4 4 -anchor nw -text "Welcome to Remind" \
-fill red -font {-family times -size -24 -weight bold} -tags remind
.c lower remind
.c move logo -300 0
update idletasks
for {set i 0} {$i < 15} {incr i} {
.c move logo 20 0
update idletasks
after 25
}
.c create text 4 28 -anchor nw -text "http://www.roaringpenguin.com" \
-fill red -font {-family courier -size -14 -weight bold}
.c create text 4 46 -anchor nw -text "(This splash screen only appears once)" -fill red -font {-family courier -size 12}
update idletasks
after 2500
destroy .c
}
#***********************************************************************
# %PROCEDURE: ShowTodaysReminders
# %ARGUMENTS:
# None
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Shows all of today's non-timed reminders in a window
#***********************************************************************
proc ShowTodaysReminders {} {
global Option
global Remind
global ReminderFile
if {!$Option(ShowTodaysReminders)} {
return
}
set w .today
catch { destroy $w }
toplevel $w
wm title $w "Today's Reminders"
wm iconname $w "Reminders"
text $w.text -width 80 -height 20 -wrap word -yscrollcommand "$w.sb set"
scrollbar $w.sb -orient vertical -command "$w.text yview"
button $w.ok -text "OK" -command "destroy $w"
grid $w.text -row 0 -column 0 -sticky nsew
grid $w.sb -row 0 -column 1 -sticky ns
grid $w.ok -row 1 -column 0 -sticky w
CenterWindow $w
# Grab the reminders
set stuff [exec -keepnewline $Remind -q -a -r $ReminderFile 2>/dev/null]
$w.text insert end $stuff
$w.text configure -state disabled
}
#***********************************************************************
# %PROCEDURE: InteractiveDeleteReminder
# %ARGUMENTS:
# tag -- tag of reminder to delete
# %RETURNS:
# Nothing
# %DESCRIPTION:
# Prompts for confirmation; then deletes reminder
#***********************************************************************
proc InteractiveDeleteReminder { tag } {
set ans [tk_dialog .error "Really Delete" "Really delete reminder?" warning 0 No Yes]
if {$ans == 1} {
DeleteTaggedReminder $tag
FillCalWindow
RestartBackgroundRemindDaemon
}
}
main