1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
|
# Copyright (c) 1993 by Sanjay Ghemawat
###############################################################################
# User Preferences
# Autload support
proc pref {type} {
# Dispatch to appropriate method
return [pref_$type]
}
proc pref_load_common {} {
option add *fontFamily times startupFile
option add *fixedFontFamily courier startupFile
option add *Font fixed startupFile
option add *fontSize normal startupFile
option add *saveSeconds 30 startupFile
option add *pollSeconds 120 startupFile
option add *itemPad 2 startupFile
option add *Reminder.geometry +400+0 startupFile
option add *Listing.geometry +400+0 startupFile
option add *Dayview*takeFocus 0 startupFile
option add *ApptList.Canvas.Relief raised startupFile
option add *ApptList.Canvas.highlightThickness 0 startupFile
option add *NoteList.Canvas.Relief raised startupFile
option add *NoteList.Canvas.highlightThickness 0 startupFile
}
proc pref_load_color {} {
set fg [pref_findcolor black]
set bg [pref_findcolor gray80 white]
set wday [pref_findcolor black $fg]
set wend [pref_findcolor red $fg]
set int [pref_findcolor blue $fg]
set wendint [pref_findcolor purple $fg]
set line $fg
set ifg $fg
set ibg [pref_findcolor gray75 $bg white]
set isfg $fg
set isbg [pref_findcolor LightSkyBlue $bg white]
set over [pref_findcolor DeepSkyBlue $bg white]
set csbg [pref_findcolor khaki $fg]
if [catch {set disabled [pref_findcolor gray60]}] {
set disabled ""
}
option add *weekdayColor $wday startupFile
option add *weekendColor $wend startupFile
option add *interestColor $int startupFile
option add *weekendInterestColor $wendint startupFile
option add *apptLineColor $line startupFile
option add *itemFg $ifg startupFile
option add *itemBg $ibg startupFile
option add *itemSelectFg $isfg startupFile
option add *itemSelectBg $isbg startupFile
option add *itemSelectWidth 0 startupFile
option add *itemOverflowColor $over startupFile
option add *itemOverflowStipple {} startupFile
option add *Canvas*selectBackground $csbg startupFile
option add *ApptList.Canvas.BorderWidth 1 startupFile
option add *NoteList.Canvas.BorderWidth 1 startupFile
}
proc pref_load_mono {} {
option add *Foreground black startupFile
option add *Background white startupFile
option add *weekdayColor black startupFile
option add *weekendColor black startupFile
option add *interestColor black startupFile
option add *weekendInterestColor black startupFile
option add *apptLineColor black startupFile
option add *itemFg black startupFile
option add *itemBg white startupFile
option add *itemSelectFg black startupFile
option add *itemSelectBg white startupFile
option add *itemSelectWidth 4 startupFile
option add *itemOverflowColor black startupFile
option add *itemOverflowStipple gray50 startupFile
option add *ApptList.Canvas.BorderWidth 2 startupFile
option add *NoteList.Canvas.BorderWidth 2 startupFile
}
proc pref_init {} {
global preference
option clear
tcllib_load_options
# Load default options
pref_load_common
if [string match *color* [winfo screenvisual .]] {
pref_load_color
} else {
pref_load_mono
}
pref_fixfonts
# Cache various entries
set preference(itemPad) [winfo pixels . [option get . itemPad Size]]
# Use command-line geometry specification (if any)
global geometry
if ![catch {set geometry}] {
# Specified on command line
option add Ical.Dayview.geometry $geometry
}
# XXX People do not seem to like the motif-style popup behavior
global tk_strictMotif
if {!$tk_strictMotif} {
bind Menubutton <Any-ButtonRelease-1> {tkMenuUnpost {}}
}
# Handle command line preferences
global ical
foreach pref $ical(prefs) {eval $pref}
}
# Fix fonts in option database
proc pref_fixfonts {} {
global preference
set ff [option get . fontFamily String]
set preference(norm_fontfamilies) [concat [list $ff] {
times
charter
{new century schoolbook}
courier
helvetica
}]
set ff [option get . fixedFontFamily String]
set preference(fixed_fontfamilies) [concat [list $ff] {
courier
fixed
terminal
lucidatypewriter
}]
switch -exact -- [option get . fontSize String] {
small {
set size1 120
set size2 120
set size3 140
set size4 180
}
default {
set size1 120
set size2 140
set size3 180
set size4 240
}
}
# Normal fonts
set ff norm_fontfamilies
set norm120 [pref_findfont medium r $size1 $ff]
set norm140 [pref_findfont medium r $size2 $ff]
set ital140 [pref_findfont medium i $size2 $ff]
set bold140 [pref_findfont bold r $size2 $ff]
set blit140 [pref_findfont bold i $size2 $ff]
set norm180 [pref_findfont medium r $size3 $ff]
set bold180 [pref_findfont bold r $size3 $ff]
set norm240 [pref_findfont medium r $size4 $ff]
# Fixed fonts
set ff fixed_fontfamilies
set norm140fixed [pref_findfont medium r $size2 $ff]
set bold140fixed [pref_findfont medium r $size2 $ff]
# Set option database
option add *weekdayFont $norm140 startupFile
option add *weekendFont $ital140 startupFile
option add *interestFont $bold140 startupFile
option add *weekendInterestFont $blit140 startupFile
option add *itemFont $norm140 startupFile
option add *normFont $norm140 startupFile
option add *boldFont $bold140 startupFile
option add *italFont $ital140 startupFile
option add *smallHeadingFont $bold140 startupFile
option add *largeHeadingFont $bold180 startupFile
option add *normFixedFont $norm140fixed startupFile
option add *boldFixedFont $bold140fixed startupFile
# General preferences
option add *Dialog*font $norm180 startupFile
option add *Dialog*Message*font $norm140 startupFile
option add *Button*font $bold180 startupFile
option add *Dayview*Button*font $bold140 startupFile
option add *Label*font $norm180 startupFile
option add *Menubutton*font $norm140 startupFile
option add *Menu*font $norm140 startupFile
option add *Listbox*font $norm140 startupFile
option add *Text*font $norm140 startupFile
option add *Scale*font $norm140 startupFile
option add *editkeys*Entry*font $norm120 startupFile
# Dialogs with lots of stuff
option add *Bigdialog*font $norm140 startupFile
option add *Bigdialog*Button*font $bold180 startupFile
# Date editor preferences
option add *Dayview*Dateeditor*Label*font $norm240 startupFile
option add *Dialog*Dateeditor*Label*font $norm180 startupFile
option add *Dialog*Dateeditor*Button*font $norm180 startupFile
}
# effects - Find font matching given specification
proc pref_findfont {weight style size ff} {
global preference
# Try a whole bunch of sizes
foreach sdelta {0 10 -10 20 -20 30 -30 40 -40} {
# Search for this size in families
set s [expr $size + $sdelta]
foreach family $preference($ff) {
set f "-*-$family-$weight-$style-normal-*-*-$s-*"
if [font_exists $f] {
return $f
}
}
}
# Return default font
return fixed
}
# effects - Find first legal color in named list and return it.
proc pref_findcolor {args} {
foreach c $args {
if [color_exists $c] {return $c}
}
error "could not find any of the following colors: \"[join $args]\""
}
# Methods for obtaining various preferences.
# Return the specified font if it exists, else return fixed.
proc pref_cf {f} {
if ![font_exists $f] {
return fixed
} else {
return $f
}
}
proc pref_weekdayFont {} {
return [pref_cf [option get . weekdayFont Font]]
}
proc pref_weekendFont {} {
return [pref_cf [option get . weekendFont Font]]
}
proc pref_interestFont {} {
return [pref_cf [option get . interestFont Font]]
}
proc pref_weekendInterestFont {} {
return [pref_cf [option get . weekendInterestFont Font]]
}
proc pref_itemFont {} {
return [pref_cf [option get . itemFont Font]]
}
proc pref_normFont {} {return [pref_cf [option get . normFont Font]]}
proc pref_boldFont {} {return [pref_cf [option get . boldFont Font]]}
proc pref_italFont {} {return [pref_cf [option get . italFont Font]]}
proc pref_smallHeadingFont {} {
return [pref_cf [option get . smallHeadingFont Font]]
}
proc pref_largeHeadingFont {} {
return [pref_cf [option get . largeHeadingFont Font]]
}
proc pref_weekdayColor {} {
return [option get . weekdayColor Foreground]
}
proc pref_weekendColor {} {
return [option get . weekendColor Foreground]
}
proc pref_interestColor {} {
return [option get . interestColor Foreground]
}
proc pref_weekendInterestColor {} {
return [option get . weekendInterestColor Foreground]
}
proc pref_itemFg {} {
return [option get . itemFg Foreground]
}
proc pref_itemBg {} {
return [option get . itemBg Background]
}
proc pref_itemSelectFg {} {
return [option get . itemSelectFg Background]
}
proc pref_itemSelectBg {} {
return [option get . itemSelectBg Foreground]
}
proc pref_itemSelectWidth {} {
return [option get . itemSelectWidth Size]
}
proc pref_itemOverflowColor {} {
return [option get . itemOverflowColor Foreground]
}
proc pref_itemOverflowStipple {} {
return [option get . itemOverflowStipple Bitmap]
}
proc pref_apptLineColor {} {
return [option get . apptLineColor Foreground]
}
proc pref_itemPad {} {
global preference
return $preference(itemPad)
}
proc pref_pollSeconds {} {
return [option get . pollSeconds Time]
}
proc pref_saveSeconds {} {
return [option get . saveSeconds Time]
}
|