mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 23:08:40 +02:00
Add ability to change fg/bg colors.
This commit is contained in:
109
scripts/tkremind
109
scripts/tkremind
@@ -168,6 +168,18 @@ set OptDescr(CalboxFont) "Font to use in calendar boxes in Tk font format"
|
|||||||
set Option(HeadingFont) [font actual TkDefaultFont]
|
set Option(HeadingFont) [font actual TkDefaultFont]
|
||||||
set OptDescr(HeadingFont) "Font to use in calendar headings in Tk font format"
|
set OptDescr(HeadingFont) "Font to use in calendar headings in Tk font format"
|
||||||
|
|
||||||
|
set Option(BackgroundColor) "#d9d9d9"
|
||||||
|
set OptDescr(BackgroundColor) "Default background color of calendar boxes"
|
||||||
|
|
||||||
|
set Option(TextColor) "#000000"
|
||||||
|
set OptDescr(TextColor) "Default text color in calendar boxes"
|
||||||
|
|
||||||
|
set Option(LabelColor) "#000000"
|
||||||
|
set OptDescr(LabelColor) "Default label color for headings"
|
||||||
|
|
||||||
|
set Option(WinBackground) "#d9d9d9"
|
||||||
|
set OptDescr(WinBackground) "Background color of calendar window"
|
||||||
|
|
||||||
set TimerUpdateForChanges ""
|
set TimerUpdateForChanges ""
|
||||||
|
|
||||||
# Remind program to execute -- supply full path if you want
|
# Remind program to execute -- supply full path if you want
|
||||||
@@ -465,6 +477,7 @@ proc CalEntryOffset { firstDay } {
|
|||||||
proc CreateCalFrame { w dayNames } {
|
proc CreateCalFrame { w dayNames } {
|
||||||
# Figure out reasonable height for text frames
|
# Figure out reasonable height for text frames
|
||||||
global SetFontsWorked
|
global SetFontsWorked
|
||||||
|
global Option
|
||||||
set h [winfo screenheight .]
|
set h [winfo screenheight .]
|
||||||
if {$h <= 480} {
|
if {$h <= 480} {
|
||||||
if {$SetFontsWorked} {
|
if {$SetFontsWorked} {
|
||||||
@@ -479,7 +492,7 @@ proc CreateCalFrame { w dayNames } {
|
|||||||
}
|
}
|
||||||
|
|
||||||
global MondayFirst
|
global MondayFirst
|
||||||
frame $w
|
frame $w -background $Option(WinBackground)
|
||||||
for {set i 0} {$i < 7} {incr i} {
|
for {set i 0} {$i < 7} {incr i} {
|
||||||
if {$MondayFirst} {
|
if {$MondayFirst} {
|
||||||
set index [expr ($i+1)%7]
|
set index [expr ($i+1)%7]
|
||||||
@@ -487,7 +500,7 @@ proc CreateCalFrame { w dayNames } {
|
|||||||
set index $i
|
set index $i
|
||||||
}
|
}
|
||||||
|
|
||||||
label $w.day$i -border 1 -text [lindex $dayNames $index] -justify center -font HeadingFont
|
label $w.day$i -border 1 -text [lindex $dayNames $index] -justify center -font HeadingFont -foreground $Option(LabelColor) -background $Option(WinBackground)
|
||||||
grid configure $w.day$i -row 0 -column $i -sticky ew
|
grid configure $w.day$i -row 0 -column $i -sticky ew
|
||||||
}
|
}
|
||||||
for {set i 0} {$i < 6} {incr i} {
|
for {set i 0} {$i < 6} {incr i} {
|
||||||
@@ -497,7 +510,7 @@ proc CreateCalFrame { w dayNames } {
|
|||||||
button $w.l$f -text "" -justify center -command "" \
|
button $w.l$f -text "" -justify center -command "" \
|
||||||
-state disabled -relief flat -border 0 -padx 0 -pady 0 -font HeadingFont
|
-state disabled -relief flat -border 0 -padx 0 -pady 0 -font HeadingFont
|
||||||
text $w.t$f -width 12 -height $h -border 1 -spacing3 3 -wrap word -relief flat \
|
text $w.t$f -width 12 -height $h -border 1 -spacing3 3 -wrap word -relief flat \
|
||||||
-state disabled -takefocus 0 -cursor {} -font CalboxFont
|
-state disabled -takefocus 0 -cursor {} -font CalboxFont -foreground $Option(TextColor) -background $Option(BackgroundColor)
|
||||||
$w.t$f tag bind TAGGED <ButtonPress-1> "EditTaggedReminder $w.t$f"
|
$w.t$f tag bind TAGGED <ButtonPress-1> "EditTaggedReminder $w.t$f"
|
||||||
$w.t$f tag bind REM <ButtonPress-3> "FireEditor $w.t$f"
|
$w.t$f tag bind REM <ButtonPress-3> "FireEditor $w.t$f"
|
||||||
|
|
||||||
@@ -527,18 +540,16 @@ proc CreateCalFrame { w dayNames } {
|
|||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
proc ConfigureCalFrame { w firstDay numDays } {
|
proc ConfigureCalFrame { w firstDay numDays } {
|
||||||
global CurMonth CurYear TodayMonth TodayYear TodayDay
|
global CurMonth CurYear TodayMonth TodayYear TodayDay
|
||||||
global tk_version
|
global tk_version Option
|
||||||
set offset [CalEntryOffset $firstDay]
|
set offset [CalEntryOffset $firstDay]
|
||||||
set first [expr $offset+1]
|
set first [expr $offset+1]
|
||||||
set last [expr $offset+$numDays]
|
set last [expr $offset+$numDays]
|
||||||
|
|
||||||
set bg [lindex [. configure -background] 3]
|
|
||||||
|
|
||||||
for {set i 0} {$i < $first} {incr i} {
|
for {set i 0} {$i < $first} {incr i} {
|
||||||
grid $w.l$i $w.t$i
|
grid $w.l$i $w.t$i
|
||||||
$w.l$i configure -text "" -command "" -state disabled -relief flat
|
$w.l$i configure -text "" -command "" -state disabled -relief flat -foreground $Option(LabelColor) -background $Option(WinBackground)
|
||||||
balloon_add_help $w.l$i ""
|
balloon_add_help $w.l$i ""
|
||||||
$w.t$i configure -relief flat -takefocus 0 -state normal
|
$w.t$i configure -relief flat -takefocus 0 -state normal -background $Option(WinBackground)
|
||||||
$w.t$i delete 1.0 end
|
$w.t$i delete 1.0 end
|
||||||
foreach t [$w.t$i tag names] {
|
foreach t [$w.t$i tag names] {
|
||||||
$w.t$i tag delete $t
|
$w.t$i tag delete $t
|
||||||
@@ -546,16 +557,14 @@ proc ConfigureCalFrame { w firstDay numDays } {
|
|||||||
$w.t$i tag bind TAGGED <ButtonPress-1> "EditTaggedReminder $w.t$i"
|
$w.t$i tag bind TAGGED <ButtonPress-1> "EditTaggedReminder $w.t$i"
|
||||||
$w.t$i tag bind REM <ButtonPress-3> "FireEditor $w.t$i"
|
$w.t$i tag bind REM <ButtonPress-3> "FireEditor $w.t$i"
|
||||||
$w.t$i configure -state disabled
|
$w.t$i configure -state disabled
|
||||||
$w.t$i configure -background $bg
|
|
||||||
$w.l$i configure -background $bg
|
|
||||||
}
|
}
|
||||||
for {set i $first} {$i <= $last} {incr i} {
|
for {set i $first} {$i <= $last} {incr i} {
|
||||||
grid $w.l$i $w.t$i
|
grid $w.l$i $w.t$i
|
||||||
set d [expr $i-$first+1]
|
set d [expr $i-$first+1]
|
||||||
$w.l$i configure -text $d -state normal -relief flat \
|
$w.l$i configure -text $d -state normal -relief flat \
|
||||||
-command "ModifyDay $d $firstDay"
|
-command "ModifyDay $d $firstDay" -foreground $Option(LabelColor) -background $Option(WinBackground)
|
||||||
balloon_add_help $w.l$i "Add a reminder..."
|
balloon_add_help $w.l$i "Add a reminder..."
|
||||||
$w.t$i configure -relief sunken -takefocus 1 -state normal
|
$w.t$i configure -relief sunken -takefocus 1 -state normal -foreground $Option(TextColor) -background $Option(BackgroundColor)
|
||||||
$w.t$i delete 1.0 end
|
$w.t$i delete 1.0 end
|
||||||
foreach t [$w.t$i tag names] {
|
foreach t [$w.t$i tag names] {
|
||||||
$w.t$i tag delete $t
|
$w.t$i tag delete $t
|
||||||
@@ -563,8 +572,6 @@ proc ConfigureCalFrame { w firstDay numDays } {
|
|||||||
$w.t$i tag bind TAGGED <ButtonPress-1> "EditTaggedReminder $w.t$i"
|
$w.t$i tag bind TAGGED <ButtonPress-1> "EditTaggedReminder $w.t$i"
|
||||||
$w.t$i tag bind REM <ButtonPress-3> "FireEditor $w.t$i"
|
$w.t$i tag bind REM <ButtonPress-3> "FireEditor $w.t$i"
|
||||||
$w.t$i configure -state disabled
|
$w.t$i configure -state disabled
|
||||||
$w.t$i configure -background $bg
|
|
||||||
$w.l$i configure -background $bg
|
|
||||||
}
|
}
|
||||||
set forgetIt 0
|
set forgetIt 0
|
||||||
for {set i [expr $last+1]} {$i < 42} {incr i} {
|
for {set i [expr $last+1]} {$i < 42} {incr i} {
|
||||||
@@ -579,9 +586,9 @@ proc ConfigureCalFrame { w firstDay numDays } {
|
|||||||
} else {
|
} else {
|
||||||
grid rowconfigure $w [expr $row+1] -weight 1
|
grid rowconfigure $w [expr $row+1] -weight 1
|
||||||
}
|
}
|
||||||
$w.l$i configure -text "" -command "" -state disabled -relief flat
|
$w.l$i configure -text "" -command "" -state disabled -relief flat -foreground $Option(LabelColor) -background $Option(WinBackground)
|
||||||
balloon_add_help $w.l$i ""
|
balloon_add_help $w.l$i ""
|
||||||
$w.t$i configure -relief flat -takefocus 0 -state normal
|
$w.t$i configure -relief flat -takefocus 0 -state normal -background $Option(WinBackground)
|
||||||
$w.t$i delete 1.0 end
|
$w.t$i delete 1.0 end
|
||||||
foreach t [$w.t$i tag names] {
|
foreach t [$w.t$i tag names] {
|
||||||
$w.t$i tag delete $t
|
$w.t$i tag delete $t
|
||||||
@@ -589,8 +596,6 @@ proc ConfigureCalFrame { w firstDay numDays } {
|
|||||||
$w.t$i tag bind TAGGED <ButtonPress-1> "EditTaggedReminder $w.t$i"
|
$w.t$i tag bind TAGGED <ButtonPress-1> "EditTaggedReminder $w.t$i"
|
||||||
$w.t$i tag bind REM <ButtonPress-3> "FireEditor $w.t$i"
|
$w.t$i tag bind REM <ButtonPress-3> "FireEditor $w.t$i"
|
||||||
$w.t$i configure -state disabled
|
$w.t$i configure -state disabled
|
||||||
$w.t$i configure -background $bg
|
|
||||||
$w.l$i configure -background $bg
|
|
||||||
}
|
}
|
||||||
if { $CurMonth == $TodayMonth && $CurYear == $TodayYear } {
|
if { $CurMonth == $TodayMonth && $CurYear == $TodayYear } {
|
||||||
set n [expr $TodayDay + $offset]
|
set n [expr $TodayDay + $offset]
|
||||||
@@ -611,14 +616,14 @@ proc DoQueue {} {
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
proc CreateCalWindow { dayNames } {
|
proc CreateCalWindow { dayNames } {
|
||||||
global Option
|
global Option
|
||||||
frame .h
|
frame .h -background $Option(WinBackground);
|
||||||
label .h.title -text "" -justify center -pady 1 -border 1 -relief raised -font HeadingFont
|
label .h.title -text "" -justify center -pady 1 -border 1 -relief raised -font HeadingFont -background $Option(WinBackground) -foreground $Option(LabelColor)
|
||||||
pack .h.title -side top -fill x
|
pack .h.title -side top -fill x
|
||||||
pack .h -side top -expand 0 -fill x
|
pack .h -side top -expand 0 -fill x
|
||||||
|
|
||||||
CreateCalFrame .cal $dayNames
|
CreateCalFrame .cal $dayNames
|
||||||
|
|
||||||
frame .b
|
frame .b -background $Option(WinBackground);
|
||||||
button .b.prev -image leftarrow -width 24 -command {MoveMonth -1} -border 1
|
button .b.prev -image leftarrow -width 24 -command {MoveMonth -1} -border 1
|
||||||
balloon_add_help .b.prev "Go to previous month"
|
balloon_add_help .b.prev "Go to previous month"
|
||||||
button .b.this -text {Today} -command {ThisMonth} -border 1
|
button .b.this -text {Today} -command {ThisMonth} -border 1
|
||||||
@@ -635,8 +640,8 @@ proc CreateCalWindow { dayNames } {
|
|||||||
balloon_add_help .b.quit "Quit TkRemind"
|
balloon_add_help .b.quit "Quit TkRemind"
|
||||||
button .b.options -text {Options...} -command EditOptions -border 1
|
button .b.options -text {Options...} -command EditOptions -border 1
|
||||||
balloon_add_help .b.options "Set TkRemind options"
|
balloon_add_help .b.options "Set TkRemind options"
|
||||||
label .b.status -text "" -width 25 -relief sunken -border 1
|
label .b.status -text "" -width 25 -relief sunken -border 1 -foreground $Option(LabelColor) -background $Option(WinBackground)
|
||||||
label .b.nqueued -text "" -width 20 -relief sunken -border 1
|
label .b.nqueued -text "" -width 20 -relief sunken -border 1 -foreground $Option(LabelColor) -background $Option(WinBackground)
|
||||||
pack .b.prev .b.this .b.next .b.goto .b.print .b.options .b.queue .b.quit -side left -fill both
|
pack .b.prev .b.this .b.next .b.goto .b.print .b.options .b.queue .b.quit -side left -fill both
|
||||||
pack .b.status -side left -fill x -expand 1
|
pack .b.status -side left -fill x -expand 1
|
||||||
pack .b.nqueued -side left -fill x
|
pack .b.nqueued -side left -fill x
|
||||||
@@ -653,6 +658,7 @@ proc CreateCalWindow { dayNames } {
|
|||||||
bind . <KeyPress-Next> ".b.next flash; .b.next invoke"
|
bind . <KeyPress-Next> ".b.next flash; .b.next invoke"
|
||||||
bind . <KeyPress-Home> ".b.this flash; .b.this invoke"
|
bind . <KeyPress-Home> ".b.this flash; .b.this invoke"
|
||||||
|
|
||||||
|
. configure -background $Option(WinBackground)
|
||||||
if {$Option(StartIconified)} {
|
if {$Option(StartIconified)} {
|
||||||
wm iconify .
|
wm iconify .
|
||||||
}
|
}
|
||||||
@@ -754,11 +760,27 @@ proc EditOptions {} {
|
|||||||
pack $w.extraargs -in $w.eaf -side left -expand 1 -fill x
|
pack $w.extraargs -in $w.eaf -side left -expand 1 -fill x
|
||||||
$w.extraargs insert 0 $tmpOpt(ExtraRemindArgs)
|
$w.extraargs insert 0 $tmpOpt(ExtraRemindArgs)
|
||||||
|
|
||||||
|
# Fonts
|
||||||
frame $w.fframe
|
frame $w.fframe
|
||||||
button $w.font -text "Change entry font..." -command "ChooseCalboxFont"
|
button $w.font -text "Change entry font..." -command "ChooseCalboxFont"
|
||||||
button $w.hfont -text "Change heading font..." -command "ChooseHeadingFont"
|
button $w.hfont -text "Change heading font..." -command "ChooseHeadingFont"
|
||||||
pack $w.font $w.hfont -in $w.fframe -side left -expand 1 -fill x
|
pack $w.font $w.hfont -in $w.fframe -side left -expand 1 -fill x
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
frame $w.colors1
|
||||||
|
label $w.textcolor -text "Text Color:"
|
||||||
|
button $w.btextcolor -background $Option(TextColor) -command [list PickColor TextColor $w.btextcolor]
|
||||||
|
label $w.bgcolor -text " Background color:"
|
||||||
|
button $w.bbgcolor -background $Option(BackgroundColor) -command [list PickColor BackgroundColor $w.bbgcolor]
|
||||||
|
pack $w.textcolor $w.btextcolor $w.bgcolor $w.bbgcolor -in $w.colors1 -side left -expand 1 -fill x
|
||||||
|
|
||||||
|
frame $w.colors2
|
||||||
|
label $w.headcolor -text "Heading Color:"
|
||||||
|
button $w.bheadcolor -background $Option(LabelColor) -command [list PickColor LabelColor $w.bheadcolor]
|
||||||
|
label $w.wincolor -text " Window color:"
|
||||||
|
button $w.bwincolor -background $Option(WinBackground) -command [list PickColor WinBackground $w.bwincolor]
|
||||||
|
pack $w.headcolor $w.bheadcolor $w.wincolor $w.bwincolor -in $w.colors2 -side left -expand 1 -fill x
|
||||||
|
|
||||||
frame $w.sep1 -border 1 -relief sunken
|
frame $w.sep1 -border 1 -relief sunken
|
||||||
frame $w.sep2 -border 1 -relief sunken
|
frame $w.sep2 -border 1 -relief sunken
|
||||||
|
|
||||||
@@ -781,15 +803,23 @@ proc EditOptions {} {
|
|||||||
pack $w.ef -in $w.f -side top -expand 0 -fill x
|
pack $w.ef -in $w.f -side top -expand 0 -fill x
|
||||||
pack $w.eaf -in $w.f -side top -expand 0 -fill x
|
pack $w.eaf -in $w.f -side top -expand 0 -fill x
|
||||||
pack $w.fframe -in $w.f -side top -expand 0 -fill x
|
pack $w.fframe -in $w.f -side top -expand 0 -fill x
|
||||||
|
pack $w.colors1 -in $w.f -side top -expand 0 -fill x
|
||||||
|
pack $w.colors2 -in $w.f -side top -expand 0 -fill x
|
||||||
pack $w.sep2 -in $w.f -side top -expand 0 -fill x -ipady 1
|
pack $w.sep2 -in $w.f -side top -expand 0 -fill x -ipady 1
|
||||||
|
|
||||||
button $w.save -text "Save Options" -command "SaveOptions $w; destroy $w"
|
button $w.save -text "Save Options" -command "SaveOptions $w; destroy $w"
|
||||||
button $w.cancel -text "Cancel" -command "destroy $w"
|
button $w.cancel -text "Cancel" -command "CancelOptions; destroy $w"
|
||||||
|
wm protocol $w WM_DELETE_WINDOW "CancelOptions; destroy $w"
|
||||||
pack $w.save $w.cancel -in $w.b -side left -expand 0 -fill x
|
pack $w.save $w.cancel -in $w.b -side left -expand 0 -fill x
|
||||||
CenterWindow $w .
|
CenterWindow $w .
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc CancelOptions { } {
|
||||||
|
global Option
|
||||||
|
font configure CalboxFont {*}$Option(CalboxFont)
|
||||||
|
font configure HeadingFont {*}$Option(HeadingFont)
|
||||||
|
}
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# %PROCEDURE: ApplyOptions
|
# %PROCEDURE: ApplyOptions
|
||||||
# %ARGUMENTS:
|
# %ARGUMENTS:
|
||||||
@@ -854,6 +884,11 @@ proc SaveOptions { w } {
|
|||||||
}
|
}
|
||||||
puts $f ""
|
puts $f ""
|
||||||
close $f
|
close $f
|
||||||
|
FillCalWindow
|
||||||
|
.h.title configure -background $Option(WinBackground) -foreground $Option(LabelColor)
|
||||||
|
for {set i 0} {$i < 7} {incr i} {
|
||||||
|
.cal.day$i configure -foreground $Option(LabelColor) -background $Option(WinBackground)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
@@ -3089,12 +3124,13 @@ proc TaggedEnter { w } {
|
|||||||
# Removes highlight from an "editable" reminder as mouse leaves it
|
# Removes highlight from an "editable" reminder as mouse leaves it
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
proc TaggedLeave { w } {
|
proc TaggedLeave { w } {
|
||||||
|
global Option
|
||||||
set tag [GetCurrentReminder $w]
|
set tag [GetCurrentReminder $w]
|
||||||
if {$tag != ""} {
|
if {$tag != ""} {
|
||||||
set tags [$w tag names current]
|
set tags [$w tag names current]
|
||||||
set index [lsearch -glob $tags "clr*"]
|
set index [lsearch -glob $tags "clr*"]
|
||||||
if {$index < 0} {
|
if {$index < 0} {
|
||||||
set fg "#000000"
|
set fg $Option(TextColor)
|
||||||
} else {
|
} else {
|
||||||
set fg [string range [lindex $tags $index] 3 end]
|
set fg [string range [lindex $tags $index] 3 end]
|
||||||
set fg "#$fg"
|
set fg "#$fg"
|
||||||
@@ -3736,9 +3772,10 @@ proc ChooseCalboxFont {} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc SetCalboxFont {font} {
|
proc SetCalboxFont {font} {
|
||||||
global Option
|
global tmpOpt
|
||||||
font configure CalboxFont {*}[font actual $font]
|
font configure CalboxFont {*}[font actual $font]
|
||||||
set Option(CalboxFont) [font actual $font]
|
set tmpOpt(CalboxFont) [font actual $font]
|
||||||
|
raise .opt
|
||||||
}
|
}
|
||||||
|
|
||||||
proc ChooseHeadingFont {} {
|
proc ChooseHeadingFont {} {
|
||||||
@@ -3748,8 +3785,20 @@ proc ChooseHeadingFont {} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc SetHeadingFont {font} {
|
proc SetHeadingFont {font} {
|
||||||
global Option
|
global tmpOpt
|
||||||
font configure HeadingFont {*}[font actual $font]
|
font configure HeadingFont {*}[font actual $font]
|
||||||
set Option(HeadingFont) [font actual $font]
|
set tmpOpt(HeadingFont) [font actual $font]
|
||||||
|
raise .opt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc PickColor {index button} {
|
||||||
|
global tmpOpt
|
||||||
|
set x [tk_chooseColor -initialcolor $tmpOpt($index)]
|
||||||
|
if {"$x" != ""} {
|
||||||
|
set tmpOpt($index) $x
|
||||||
|
$button configure -background $x
|
||||||
|
}
|
||||||
|
raise .opt
|
||||||
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|||||||
Reference in New Issue
Block a user