Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Ticket [981605ffff]: add calendar dialog |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | 981605ffff-calender |
Files: | files | file ages | folders |
SHA3-256: |
c808463f05e6cfa9c9851202b53e7874 |
User & Date: | oehhar 2025-02-28 12:03:31.662 |
References
2025-02-28
| ||
12:39 | • Ticket [981605ffff] BWidget Calendar Dialog status still Pending with 4 other changes artifact: 4b466e0ea4 user: oehhar | |
Context
2025-03-13
| ||
17:12 | Ticket [981605ffff]: Revised calender dialog from attachement file bwidget_calendar_2025-03-13.zip Leaf check-in: a98c52b45d user: oehhar tags: 981605ffff-calender | |
2025-02-28
| ||
12:03 | Ticket [981605ffff]: add calendar dialog check-in: c808463f05 user: oehhar tags: 981605ffff-calender | |
2025-02-25
| ||
06:42 | Update German localization of the password dialog. Thanks to Thomas Wunderlich for the proposal check-in: 14355b0aa3 user: oehhar tags: bwidget | |
Changes
Added BWman/calendar.html.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | <HTML> <HEAD><TITLE>Calendar</TITLE></HEAD> <BODY BGCOLOR=white> <DL><DT><I><A HREF="#descr">NAME</A></I></DT> <DD><B>Calendar</B> - Calendar view by month to return selected date(s) </DD></DL> <DL> <DT><I>CREATION</I></DT> <DD><A HREF="#descr"><B>Calendar</B></A> <I>pathName</I> ?<I>option value...</I>?</DD> </DL> <DL> <DT><I><A HREF="Dialog.html">OPTIONS from <B>Dialog</B></A></I></DT> <DD><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> <TR> <TD> -background or -bg</TD> </TR> <TR> <TD> -parent</TD> </TR> <TR> <TD> -title</TD> </TR> </TABLE></DD> </DL> <DL> <DT><I><A HREF="#wso">WIDGET-SPECIFIC OPTIONS</A></I></DT> <DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0> <TR><TD> <A HREF="#-background">-background</A></TR> <TR><TD> <A HREF="#-backwardimage">-backwardimage</A></TR> <TR><TD> <A HREF="#-currentdatefont">-currentdatefont</A></TR> <TR><TD> <A HREF="#-datefont">-datefont</A></TR> <TR><TD> <A HREF="#-daybackground">-daybackground</A></TR> <TR><TD> <A HREF="#-dayfont">-dayfont</A></TR> <TR><TD> <A HREF="#-days">-days</A></TR> <TR><TD> <A HREF="#-forwardimage">-forwardimage</A></TR> <TR><TD> <A HREF="#-foreground">-foreground</A></TR> <TR><TD> <A HREF="#-height">-height</A></TR> <TR><TD> <A HREF="#-highlightdaybackground">-highlightdaybackground</A></TR> <TR><TD> <A HREF="#-highlightdaycolor">-highlightdaycolor</A></TR> <TR><TD> <A HREF="#-highlightdaythickness">-highlightdaythickness</A></TR> <TR><TD> <A HREF="#-highlightshowdate">-highlightshowdate</A></TR> <TR><TD> <A HREF="#-multipleselection">-multipleselection</A></TR> <TR><TD> <A HREF="#-selectdates">-selectdates</A></TR> <TR><TD> <A HREF="#-selectthickness">-selectthickness</A></TR> <TR><TD> <A HREF="#-showdate">-showdate</A></TR> <TR><TD> <A HREF="#-startday">-startday</A></TR> <TR><TD> <A HREF="#-titlefont">-titlefont</A></TR> <TR><TD> <A HREF="#-type">-type</A></TR> <TR><TD> <A HREF="#-weekdaybackground">-weekdaybackground</A></TR> <TR><TD> <A HREF="#-weekendbackground">-weekendbackground</A></TR> <TR><TD> <A HREF="#-width">-width</A></TR> </TABLE></DD> </DL> <DL> <DT><I><A HREF="#wc">WIDGET COMMAND</A></I></DT> <DD><I>none</I> </DD> </DL> <BR><HR WIDTH="100%"><BR> <B><A NAME="descr"></A>DESCRIPTION</B><BR> <P> Calendar widget enables the user to create a monthly Calendar box. The selected date(s) are returned when the widget is destroyed. The widget is a Dialog, therefore, it cannot be embedded in a frame. It can be operated as a popup to allow for selecting just one date. </P> <BR><HR WIDTH="50%"><BR> <B><A NAME="wso">WIDGET-SPECIFIC OPTIONS</A></B><BR> <DL><DT><A NAME="-backwardimage"><B>-backwardimage</B></A></DT> <DD> Specifies an image name to display instead of a less-than sign for selecting previous months. </DD> </DL> <DL><DT><A NAME="-currentdatefont"><B>-currentdatefont</B></A></DT> <DD> Specifies a font to use for the <A HREF="#-showdate">-showdate</A>. </DD> </DL> <DL><DT><A NAME="-datefont"><B>-datefont</B></A></DT> <DD> Specifies a font to use for days other than the current day. </DD> </DL> <DL><DT><A NAME="-daybackground"><B>-daybackground</B></A></DT> <DD> Specifies a background to use for the colors of the days of the week. </DD> </DL> <DL><DT><A NAME="-dayfont"><B>-dayfont</B></A></DT> <DD> Specifies a font to use for the names of the days of the week. </DD> </DL> <DL><DT><A NAME="-days"><B>-days</B></A></DT> <DD> Specifies a string of whitespace separated abbreviations to use for the days of the week, starting with Sunday. Defaults to <B>"Su Mo Tu We Th Fr Sa"</B> </DD> </DL> <DL><DT><A NAME="-foreground"><B>-foreground</B></A></DT> <DD> Specifies a foreground color to use for the buttons that make up the days of the month. </DD> </DL> <DL><DT><A NAME="-forwardimage"><B>-forwardimage</B></A></DT> <DD> Specifies an image name to display instead of a greater-than sign for selecting previous months. </DD> </DL> <DL><DT><A NAME="-height"><B>-height</B></A></DT> <DD> Specifies the height of the Calendar window. </DD> </DL> <DL><DT><A NAME="-highlightdaybackground"><B>-highlightdaybackground</B></A></DT> <DD> Specifies the color to highlight the background of a selected day. </DD> </DL> <DL><DT><A NAME="-highlightdaycolor"><B>-highlightdaycolor</B></A></DT> <DD> Specifies the color to highlight the edges of a selected day. </DD> </DL> <DL><DT><A NAME="-highlightdaythickness"><B>-highlightdaythickness</B></A></DT> <DD> Specifies the thickness of the highlight around a selected day. </DD> </DL> <DL><DT><A NAME="-highlightshowdate"><B>-highlightshowdate</B></A></DT> <DD> Specifies the color to highlight the edges of a date to show, either today or the date specified by <A HREF="#-showdate">-showdate</A>. </DD> </DL> <DL><DT><A NAME="-multipleselection"><B>-multipleselection</B></A></DT> <DD> Specifies whether or not to allow selecting multiple dates. When the value is 0, mutlipleselection is off and only single selection is allowed. When it is 1, multiple selection is on and allows infinite date selection. Any other value, N, will allow for N selections before returning automatically. Defaults to <B>1</B>. </DD> </DL> <DL><DT><A NAME="-selectdates"><B>-selectdates</B></A></DT> <DD> Specifies a list of pre-selected dates to appear as selected in the Calendar, comma or whitespace separated in any proper Tcl date format. </DD> </DL> <DL><DT><A NAME="-selectthickness"><B>-selectthickness</B></A></DT> <DD> Specifies the border width to use for selected dates. Defaults to <B>3</B>. </DD> </DL> <DL><DT><A NAME="-showdate"><B>-showdate</B></A></DT> <DD> Specifies the date to use as the current date for display. Defaults to today. </DD> </DL> <DL><DT><A NAME="-startday"><B>-startday</B></A></DT> <DD> Specifies the name of the day to place in the first column, in effect, what day to start the week on. Can be <B>sunday, monday, tuesday, wednesday, thursday, friday, saturday</B>. Defaults to <B>sunday</B>. </DD> </DL> <DL><DT><A NAME="-titlefont"><B>-titlefont</B></A></DT> <DD> Specifies font to use for the month, year, and also possibly the previous/next month selectors if no image is defined by <A HREF="#-backwardimage">-backwardimage</A> or <A HREF="#-forwardimage">-forwardimage</A>. </DD> </DL> <DL><DT><A NAME="-type"><B>-type</B></A></DT> <DD> Type of the widget, either the default <B>dialog</B> or a <B>popup</B>. The latter will return immediately after selecting just one date. </DD> </DL> <DL><DT><A NAME="-weekdaybackground"><B>-weekdaybackground</B></A></DT> <DD> Specifies the color to use as the background for the weekdays. </DD> </DL> <DL><DT><A NAME="-weekendbackground"><B>-weekendbackground</B></A></DT> <DD> Specifies the color to use as the background for the weekends. </DD> </DL> <DL><DT><A NAME="-width"><B>-width</B></A></DT> <DD> Specifies the width of Calendar. </DD> </DL> </DD></DL> </BODY></HTML> |
Added calendar.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | #========================================================== # calendar.tcl -- BWidget Calendar # # a widget for playing with time # with an interface based on the iwidget calendar # written by Chris Maj cmaj_hat_freedomcorpse_hot_com # for the PgAccess project www.pgaccess.org # (lots of work needs to be done to get the embedded widget # method working, right now its just a simple dialog) #========================================================== # Index of commands: # Public commands # - Calendar::create # Private commands (internal helper procs) # - Calendar::_flipMonth # - Calendar::_selectDate # - Calendar::_clearDates #========================================================== # namespace eval Calendar { Widget::declare Calendar { {-background TkResource "" 0 "label -background"} {-backwardimage String "" 0} {-currentdatefont TkResource "" 0 "label -font"} {-datefont TkResource "" 0 "label -font"} {-daybackground TkResource "" 0 "label -background"} {-dayfont TkResource "" 0 "label -font"} {-days String "Su Mo Tu We Th Fr Sa" 0} {-foreground TkResource "" 0 "label -foreground"} {-forwardimage String "" 0} {-height Int 165 0 "%d >= 0"} {-highlightdaybackground TkResource "" 0 "label -highlightbackground"} {-highlightdaycolor TkResource "" 0 "label -highlightcolor"} {-highlightdaythickness TkResource "" 0 "label -highlightthickness"} {-highlightshowdate TkResource "" 0 "label -highlightbackground"} {-multipleselection Int 1 0 "%d >= 0"} {-parent String "" 0} {-selectdates String "" 0} {-selectthickness Int 3 0 "%d >= 0"} {-showdate String "" 0 ""} {-startday Enum "sunday" 0 {sunday monday tuesday wednesday thursday friday saturday}} {-title String "Calendar" 0} {-titlefont TkResource "" 0 "label -font"} {-type Enum "dialog" 1 {dialog popup embedded}} {-weekdaybackground TkResource "" 0 "label -background"} {-weekendbackground TkResource "" 0 "label -background"} {-width Int 200 0 "%d >= 0"} } } #---------------------------------------------------------- # Calendar::create -- # # creates the calendar widget # # Arguments: # path path to the calendar widget # args args supplied to create the widget # # Results: # returns a sorted list of all selected dates #---------------------------------------------------------- # proc Calendar::create { path args } { variable $path upvar 0 $path data set data(dotw) "sunday monday tuesday wednesday thursday friday saturday" Widget::init Calendar "$path#Calendar" $args if {[Widget::cget "$path#Calendar" -type]=="embedded"} { set fr [frame $path \ -takefocus 0 \ -class Calendar] } else { if {[winfo exists $path]} {return} eval Dialog::create $path \ -title [Widget::cget "$path#Calendar" -title] \ -background [Widget::cget "$path#Calendar" -background] \ -parent [Widget::cget "$path#Calendar" -parent] set fr [Dialog::getframe $path] $fr configure -width [Widget::cget "$path#Calendar" -width] $fr configure -height [Widget::cget "$path#Calendar" -height] $fr configure -relief flat } # make it easier to know what month/year we are on set data(showdate) [Widget::cget "$path#Calendar" -showdate] if {$data(showdate)==""} { set data(showdate) [clock seconds] } else { set data(showdate) [clock scan $data(showdate)] } set data(showmonth) [clock format $data(showdate) -format %B] set data(showyear) [clock format $data(showdate) -format %Y] set data(showday) [clock format $data(showdate) -format %d] set data(showdate) [clock format $data(showdate) -format "%e-%B-%Y"] set data(highlightshowdate) [Widget::cget "$path#Calendar" -highlightshowdate] set data(selectthickness) [Widget::cget "$path#Calendar" -selectthickness] set data(currentdatafont) [Widget::cget "$path#Calendar" -currentdatefont] set data(datefont) [Widget::cget "$path#Calendar" -datefont] set data(dayfont) [Widget::cget "$path#Calendar" -dayfont] set data(daybackground) [Widget::cget "$path#Calendar" -daybackground] set data(highlightdaybackground) [Widget::cget "$path#Calendar" -highlightdaybackground] set data(highlightdaycolor) [Widget::cget "$path#Calendar" -highlightdaycolor] set data(highlightdaythickness) [Widget::cget "$path#Calendar" -highlightdaythickness] set data(weekdaybackground) [Widget::cget "$path#Calendar" -weekdaybackground] set data(weekendbackground) [Widget::cget "$path#Calendar" -weekendbackground] set data(background) [Widget::cget "$path#Calendar" -background] set data(titlefont) [Widget::cget "$path#Calendar" -titlefont] set data(backwardimage) [Widget::cget "$path#Calendar" -backwardimage] set data(forwardimage) [Widget::cget "$path#Calendar" -forwardimage] set data(foreground) [Widget::cget "$path#Calendar" -foreground] set data(multipleselection) [Widget::cget "$path#Calendar" -multipleselection] set data(type) [Widget::cget "$path#Calendar" -type] # lets us pass in multiple pre-selected dates set data(selectdates) [list] foreach date [split [Widget::cget "$path#Calendar" -selectdates] {, }] { lappend data(selectdates) $date } # two buttons to move up/down a month Button $fr.leftbtn \ -text "<" \ -font $data(titlefont) \ -command [list Calendar::_flipMonth $path -1] Button $fr.rightbtn \ -text ">" \ -font $data(titlefont) \ -command [list Calendar::_flipMonth $path 1] if {[string length $data(backwardimage)] > 0} { $fr.leftbtn configure \ -image $data(backwardimage) } if {[string length $data(forwardimage)] > 0} { $fr.rightbtn configure \ -image $data(forwardimage) } # create a list of full month names set months [list] for {set i 1} {$i <= 12} {incr i} { set yr [clock format [clock seconds] -format %Y] set mo [clock format [clock scan "$yr-$i-1"] -format %B] lappend months $mo } # lets us pick the month ComboBox $fr.monthcombo \ -font $data(titlefont) \ -text $data(showmonth) \ -textvariable ::Calendar::[subst {$path}](showmonth) \ -editable 1 \ -width 16 \ -values $months \ -modifycmd [list Calendar::_flipMonth $path 0] # lets us pick the year SpinBox $fr.yearspin \ -font $data(titlefont) \ -text $data(showyear) \ -textvariable ::Calendar::[subst {$path}](showyear) \ -editable 1 \ -width 8 \ -range [list 1492 2525 1] \ -modifycmd [list Calendar::_flipMonth $path 0] grid $fr.leftbtn \ -row 0 \ -column 0 \ -padx 10 \ -pady 10 \ -sticky news grid $fr.monthcombo \ -row 0 \ -column 1 \ -padx 10 \ -pady 10 \ -columnspan 3 grid $fr.yearspin \ -row 0 \ -column 4 \ -padx 10 \ -pady 10 \ -columnspan 2 grid $fr.rightbtn \ -row 0 \ -column 6 \ -padx 10 \ -pady 10 \ -sticky news # list the days of the week in the format/order supplied set startday [Widget::cget "$path#Calendar" -startday] set data(startdayidx) [lsearch $data(dotw) $startday] set days [split [Widget::cget "$path#Calendar" -days]] for {set i $data(startdayidx)} {$i < [expr {$data(startdayidx) + 7}]} {incr i} { set day [lindex $days [expr {$i % 7}]] set someday "_" append someday $day "_1-" $i Label $fr.$someday \ -font $data(dayfont) \ -text $day \ -background $data(daybackground) grid $fr.$someday \ -row 1 \ -column [expr {$i - $data(startdayidx)}] \ -sticky s \ -pady 2 } # draw all the buttons we will use for days of the month for {set j 2} {$j < 8} {incr j} { for {set i 0} {$i < 7} {incr i} { set btn "_" append btn $i "x" $j Button $fr.$btn \ -relief flat \ -borderwidth $data(selectthickness) \ -foreground $data(foreground) \ -highlightbackground $data(highlightdaybackground) \ -highlightcolor $data(highlightdaycolor) \ -highlightthickness $data(highlightdaythickness) grid $fr.$btn \ -row $j \ -column $i \ -sticky news } } # buttons at the bottom for clearing and/or finishing # the selection of dates, but only when we are a dialog # (not popup or embedded modes) if {[string match $data(type) "dialog"]} { Button $fr.okbtn \ -text "OK" \ -font $data(titlefont) \ -command [list destroy $path] Button $fr.cancelbtn \ -text "Cancel" \ -font $data(titlefont) \ -command [list Calendar::_clearDates $path 1] grid $fr.okbtn \ -row [expr {$j+1}] \ -column 1 \ -columnspan 3 \ -padx 10 \ -pady 10 \ -sticky news grid $fr.cancelbtn \ -row [expr {$j+1}] \ -column 4 \ -columnspan 2 \ -padx 10 \ -pady 10 \ -sticky news } # space the columns evenly # modified with tips from comp.lang.tcl posting by Donald Arseneau # BUT '-uniform' only works with newer versions of Tk if {$::tk_version>=8.4} { grid columnconfigure $fr {0 1 2 3 4 5 6} \ -weight 1 \ -uniform $fr } else { grid columnconfigure $fr {0 1 2 3 4 5 6} \ -weight 1 } # gets us to the right month _flipMonth $path $data(showdate) if {[string match $data(type) "popup"] \ || [string match $data(type) "dialog"]} { # draws the calendar and waits for it to be destroyed Dialog::draw $path return [lsort -dictionary $data(selectdates)] } }; # end proc Calendar::create #---------------------------------------------------------- # Calendar::configure # # not yet used #---------------------------------------------------------- # proc Calendar::configure { path args } { return [Widget::configure "$path#Calendar" $args] }; #end proc Calendar::configure #---------------------------------------------------------- # Calendar::cget # # not yet used #---------------------------------------------------------- # proc Calendar::cget { path option } { return [Widget::cget "$path#Calendar" $option] }; # end proc Calendar::cget #---------------------------------------------------------- # Calendar::_flipMonth -- # # handles display of new month/year; places days of the # month in the proper places # # Arguments: # path path of the calendar # flipday_ what date we are flipping to # OR if 1, go forward a month # if -1, go back a month # if 0, use the combobox selected month/year # # Results: # none returned # # Modifies: # current days of the month to reflect the newly selected # date #---------------------------------------------------------- # proc Calendar::_flipMonth { path flipday_ } { variable $path upvar 0 $path data if {[string match $data(type) "popup"] \ || [string match $data(type) "dialog"]} { set fr [Dialog::getframe $path] } else { set fr $path } if {$flipday_ == -1} { set flipday_ "1-$data(showmonth)-$data(showyear)" set flipday_ [clock format [clock scan "last month" \ -base [clock scan $flipday_]] -format "%D"] } elseif {$flipday_ == 1} { set flipday_ "1-$data(showmonth)-$data(showyear)" set flipday_ [clock format [clock scan "next month" \ -base [clock scan $flipday_]] -format "%D"] } elseif {$flipday_ == 0} { set flipday_ "1-$data(showmonth)-$data(showyear)" } # crunching on some dates to make placement easier below set firstday [clock format [clock scan $flipday_] -format "%m/1/%y"] set firstdayow [expr {([clock format [clock scan $firstday] -format "%w"]-$data(startdayidx)) % 7}] set lastday [clock format [clock scan "yesterday" -base [clock scan [clock format [clock scan "next month" -base [clock scan $firstday]] -format "%m/1/%y"]]] -format "%D"] set lastdayom [clock format [clock scan $lastday] -format "%e"] set data(showmonth) [clock format [clock scan $firstday] -format "%B"] set data(showyear) [clock format [clock scan $firstday] -format "%Y"] set placeday 0 set todayis [clock format [clock seconds] -format "%e-%B-%Y"] for {set j 2} {$j < 8} {incr j} { for {set i 0} {$i < 7} {incr i} { set btn "_" append btn $i "x" $j if {!$placeday && $firstdayow == $i} { set placeday 1 } if {$placeday && $placeday <= $lastdayom} { set curday "$placeday-$data(showmonth)-$data(showyear)" # if this is today, use the right font if {[string match [string trim $curday] [string trim $todayis]]} { $fr.$btn configure \ -font $data(currentdatafont) } else { $fr.$btn configure \ -font $data(datefont) } # if this was a show date, highlight it if {[string match [string trim $curday] [string trim $data(showdate)]] \ && [string length $data(highlightshowdate)]>0} { $fr.$btn configure \ -highlightbackground $data(highlightshowdate) } else { $fr.$btn configure \ -highlightbackground $data(highlightdaybackground) } # different backgrounds for weekdays and weekends if {[lindex $data(dotw) [expr {($data(startdayidx) + $i) % 7}]] \ == "saturday" || [lindex $data(dotw) [expr {($data(startdayidx) + $i) % 7}]] \ == "sunday"} { $fr.$btn configure \ -background $data(weekendbackground) } else { $fr.$btn configure \ -background $data(weekdaybackground) } $fr.$btn configure \ -text $placeday \ -command [list Calendar::_selectDate $fr.$btn $curday 0] # check to see if the date we just drew was # previously selected, maybe they went back # and forth a month or two a couple of times _selectDate $fr.$btn $curday 1 incr placeday } elseif {!$placeday} { # click on day from previous month goes there $fr.$btn configure \ -text "" \ -relief flat \ -background $data(background) \ -highlightbackground $data(highlightdaybackground) \ -command [list Calendar::_flipMonth $path -1] } else { # click on day from next month goes there $fr.$btn configure \ -text "" \ -relief flat \ -background $data(background) \ -highlightbackground $data(highlightdaybackground) \ -command [list Calendar::_flipMonth $path 1] } } } }; # end proc Calendar::_flipMonth #---------------------------------------------------------- # Calendar::_selectDate -- # # handles selection and display of dates, by both # adding/deleting them from the list of selectdates and/or # updating the visual display. if we are in popup mode, # the window will be destroyed after the first date is # selected. # # Arguments: # btnpath path of the calendar widget button # clkd_ what date was selected # refresh_ whether to add/delete or just update the # display, 1 if just updating the display # # Results: # none returned # # Modifies: # the highlight of selected dates for the current month, # and the data(selectdates) list if not refreshing them #---------------------------------------------------------- # proc Calendar::_selectDate { btnpath clkd_ refresh_ } { set path [winfo toplevel $btnpath] variable $path upvar 0 $path data # this format is good for sorting set clkd_ [clock format [clock scan $clkd_] -format "%Y-%m-%d"] set clkpos [lsearch $data(selectdates) $clkd_] if {$clkpos == -1} { if {!$refresh_} { if {$data(multipleselection)} { # just keep adding dates $btnpath configure \ -relief sunken lappend data(selectdates) $clkd_ } else { # ooh make sure that we only have one date # selected at a time so turn off the others set data(selectdates) [list] lappend data(selectdates) $clkd_ # this makes things a little sluggish # another list (or an array) to hold the # button paths we need to change would speed # it up, but it works so wtf _flipMonth [winfo toplevel $btnpath] $clkd_ } } else { # just a refresh, no biggie, we weren't selected $btnpath configure \ -relief flat } } else { if {!$refresh_} { # we deselected a date $btnpath configure \ -relief flat set data(selectdates) [lreplace $data(selectdates) $clkpos $clkpos] } else { # refreshing a previously selected date $btnpath configure \ -relief sunken } } # should we disappear ? if {!$refresh_} { if {$data(multipleselection)>1} { if {[string match $data(type) "dialog"]} { if {[llength $data(selectdates)]==$data(multipleselection)} { destroy [winfo toplevel $btnpath] } } } elseif {[string match $data(type) "popup"]} { destroy [winfo toplevel $btnpath] } } }; # end proc Calendar::_selectDate #---------------------------------------------------------- # Calendar::_clearDates -- # # clears the selected dates list # # Parameters: # path_ of the button firing this proc # destroy_ optional, can destroy the window # # Modifies: # data(selectdates) internal list #---------------------------------------------------------- # proc Calendar::_clearDates { path {destroy_ 0} } { variable $path upvar 0 $path data set data(selectdates) [list] if {$destroy_} { destroy $path } else { _flipMonth [winfo toplevel $path] 0 } }; # end proc Calendar::_clearDates |
Added demo/calendar.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | namespace eval DemoCalendar { variable singleDate } proc DemoCalendar::pickSingleDate { path_ } { variable singleDate set singleDate [Calendar::create $path_ \ -type popup \ -datefont "Times 12" \ -dayfont "Times 12" \ -currentdatefont "Times 14 bold" \ -titlefont "Times 16"] } proc DemoCalendar::pickMultipleDates { path_ {lbpath_ ""} } { set dates [Calendar::create $path_ \ -multipleselection 1 \ -datefont "Arial 12" \ -dayfont "Arial 12" \ -currentdatefont "Arial 14 bold" \ -titlefont "Arial 16"] if {[string length $lbpath_]>0} { $lbpath_ delete [$lbpath_ items] foreach day $dates { $lbpath_ insert end [string map {- {}} $day] \ -text $day } } } proc DemoCalendar::pickColorfulDate { path_ } { variable colorfulDate set colorfulDate [Calendar::create $path_ \ -background navyblue \ -foreground blue \ -daybackground yellow \ -highlightdaybackground navyblue \ -highlightdaythickness 2 \ -weekdaybackground white \ -weekendbackground green \ -multipleselection 0 \ -selectthickness 5 \ -showdate $colorfulDate \ -highlightshowdate red \ -selectdates $colorfulDate] } proc DemoCalendar::create { nb } { set frame [$nb insert end demoCalendar \ -text "Calendar"] # single dates set titf1 [TitleFrame $frame.titf1 \ -text "Single Date"] set subf [$titf1 getframe] set btn [Button $subf.btn \ -text "Pick" \ -command [list DemoCalendar::pickSingleDate $titf1.cal]] set ent [Entry $subf.ent \ -editable 0 \ -textvariable DemoCalendar::singleDate] pack $btn $ent \ -side top \ -pady 4 \ -fill x # multiple dates set titf2 [TitleFrame $frame.titf2 \ -text "Multiple Dates"] set subf [$titf2 getframe] set btn [Button $subf.btn \ -text "Pick" \ -command [list DemoCalendar::pickMultipleDates $titf2.cal $subf.lb]] set lb [ListBox $subf.lb \ -height 5] pack $btn $lb \ -side top \ -pady 4 \ -fill x # lots of colors set titf3 [TitleFrame $frame.titf3 \ -text "Easy on the eyes"] set subf [$titf3 getframe] set btn [Button $subf.btn \ -text "Pick" \ -command [list DemoCalendar::pickColorfulDate $titf3.cal]] set ent [Entry $subf.ent \ -editable 0 \ -textvariable DemoCalendar::colorfulDate] pack $btn $ent \ -side top \ -pady 4 \ -fill x # pack the title frames nicely pack $titf1 $titf2 $titf3 \ -pady 4 return $frame } |
Changes to demo/demo.tcl.
︙ | ︙ | |||
18 19 20 21 22 23 24 | set pwd [pwd] cd [file dirname [info script]] variable DEMODIR [pwd] cd $pwd foreach script { | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | set pwd [pwd] cd [file dirname [info script]] variable DEMODIR [pwd] cd $pwd foreach script { manager.tcl basic.tcl select.tcl dnd.tcl tree.tcl tmpldlg.tcl calendar.tcl } { namespace inscope :: source $DEMODIR/$script } } image create photo bwidget16 -data { R0lGODlhEAAQAOMJABat6IGYffaBCUSku/KCDcCMPomXdgCy//+AANnZ2dnZ2dnZ2dnZ2dnZ2dnZ |
︙ | ︙ | |||
145 146 147 148 149 150 151 152 153 154 155 156 157 158 | set f3b [DemoDlg::create $notebook] set prgtext "Creating Drag and Drop..." incr prgindic set f4 [DemoDnd::create $notebook] set prgtext "Creating Tree..." incr prgindic set f5 [DemoTree::create $notebook] foreach page [$notebook pages] { $notebook itemconfigure $page \ -image bwidget16 \ -rimage faded16 \ -ractiveimage stop16 \ -rimagecmd {::Demo::_close_tab} | > > > | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | set f3b [DemoDlg::create $notebook] set prgtext "Creating Drag and Drop..." incr prgindic set f4 [DemoDnd::create $notebook] set prgtext "Creating Tree..." incr prgindic set f5 [DemoTree::create $notebook] set prgtext "Creating Calendar..." incr prgindic set f6 [DemoCalendar::create $notebook] foreach page [$notebook pages] { $notebook itemconfigure $page \ -image bwidget16 \ -rimage faded16 \ -ractiveimage stop16 \ -rimagecmd {::Demo::_close_tab} |
︙ | ︙ |
Changes to demo/tmpldlg.tcl.
︙ | ︙ | |||
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 | proc DemoDlg::create { nb } { set frame [$nb insert end demoDlg -text "Dialog"] set titf1 [TitleFrame $frame.titf1 -text "Resources"] set titf2 [TitleFrame $frame.titf2 -text "Template Dialog"] set titf3 [TitleFrame $frame.titf3 -text "Message Dialog"] set titf4 [TitleFrame $frame.titf4 -text "Other dialog"] set subf [$titf1 getframe] set cmd {option read [file join $::BWIDGET::LIBRARY "lang" $DemoDlg::resources.rc]} set rad1 [radiobutton $subf.rad1 -text "English" \ -variable DemoDlg::resources -value en \ -command $cmd] set rad2 [radiobutton $subf.rad2 -text "French" \ -variable DemoDlg::resources -value fr \ -command $cmd] set rad3 [radiobutton $subf.rad3 -text "German" \ -variable DemoDlg::resources -value de \ -command $cmd] pack $rad1 $rad2 $rad3 -side left _tmpldlg [$titf2 getframe] _msgdlg [$titf3 getframe] _stddlg [$titf4 getframe] pack $titf1 -fill x -pady 2 -padx 2 | > > | | 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 | proc DemoDlg::create { nb } { set frame [$nb insert end demoDlg -text "Dialog"] set titf1 [TitleFrame $frame.titf1 -text "Resources"] set titf2 [TitleFrame $frame.titf2 -text "Template Dialog"] set titf3 [TitleFrame $frame.titf3 -text "Message Dialog"] set titf4 [TitleFrame $frame.titf4 -text "Other dialog"] set titf5 [TitleFrame $frame.titf5 -text "Calendars"] set subf [$titf1 getframe] set cmd {option read [file join $::BWIDGET::LIBRARY "lang" $DemoDlg::resources.rc]} set rad1 [radiobutton $subf.rad1 -text "English" \ -variable DemoDlg::resources -value en \ -command $cmd] set rad2 [radiobutton $subf.rad2 -text "French" \ -variable DemoDlg::resources -value fr \ -command $cmd] set rad3 [radiobutton $subf.rad3 -text "German" \ -variable DemoDlg::resources -value de \ -command $cmd] pack $rad1 $rad2 $rad3 -side left _tmpldlg [$titf2 getframe] _msgdlg [$titf3 getframe] _stddlg [$titf4 getframe] _caldlg [$titf5 getframe] pack $titf1 -fill x -pady 2 -padx 2 pack $titf4 $titf5 -side bottom -fill x -pady 2 -padx 2 pack $titf2 $titf3 -side left -padx 2 -fill both -expand yes } proc DemoDlg::_tmpldlg { parent } { variable tmpl |
︙ | ︙ | |||
209 210 211 212 213 214 215 | } } proc DemoDlg::_show_passdlg { } { PasswdDlg .passwd -parent . } | > > > > > > > > > > > > > > > | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | } } proc DemoDlg::_show_passdlg { } { PasswdDlg .passwd -parent . } proc DemoDlg::_caldlg { parent } { set but0 [button $parent.but0 \ -text "Single date" \ -command "DemoCalendar::pickSingleDate $parent.but0cal"] set but1 [button $parent.but1 \ -text "Multiple dates" \ -command "DemoCalendar::pickMultipleDates $parent.but1cal"] set but2 [button $parent.but2 \ -text "Colorful date" \ -command "DemoCalendar::pickColorfulDate $parent.but2cal"] pack $but0 $but1 $but2 -side left -padx 5 -anchor w } |
Changes to pkgIndex.tcl.
︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | {tree.tcl source {Tree ::Tree::create ::Tree::use}} {color.tcl source {SelectColor ::SelectColor::menu ::SelectColor::dialog ::SelectColor::setcolor ::SelectColor::setbasecolor}} {dynhelp.tcl source {::DynamicHelp::configure ::DynamicHelp::use ::DynamicHelp::register ::DynamicHelp::include ::DynamicHelp::add ::DynamicHelp::delete}} {dialog.tcl source {Dialog ::Dialog::create ::Dialog::use}} {messagedlg.tcl source {MessageDlg ::MessageDlg::create ::MessageDlg::use}} {font.tcl source {SelectFont ::SelectFont::create ::SelectFont::use ::SelectFont::loadfont}} {wizard.tcl source {Wizard ::Wizard::create ::Wizard::use SimpleWizard ClassicWizard}} {xpm2image.tcl source {xpm-to-image}} }]; \ [list namespace eval ::BWIDGET {}]; \ [list set ::BWIDGET::LIBRARY $dir]; \ [list source [file join $dir widget.tcl]]; \ [list source [file join $dir init.tcl]]; \ [list source [file join $dir utils.tcl]]; \ | > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | {tree.tcl source {Tree ::Tree::create ::Tree::use}} {color.tcl source {SelectColor ::SelectColor::menu ::SelectColor::dialog ::SelectColor::setcolor ::SelectColor::setbasecolor}} {dynhelp.tcl source {::DynamicHelp::configure ::DynamicHelp::use ::DynamicHelp::register ::DynamicHelp::include ::DynamicHelp::add ::DynamicHelp::delete}} {dialog.tcl source {Dialog ::Dialog::create ::Dialog::use}} {messagedlg.tcl source {MessageDlg ::MessageDlg::create ::MessageDlg::use}} {font.tcl source {SelectFont ::SelectFont::create ::SelectFont::use ::SelectFont::loadfont}} {wizard.tcl source {Wizard ::Wizard::create ::Wizard::use SimpleWizard ClassicWizard}} {calendar.tcl source {Calendar Calendar::create Calendar::use}} {xpm2image.tcl source {xpm-to-image}} }]; \ [list namespace eval ::BWIDGET {}]; \ [list set ::BWIDGET::LIBRARY $dir]; \ [list source [file join $dir widget.tcl]]; \ [list source [file join $dir init.tcl]]; \ [list source [file join $dir utils.tcl]]; \ |
︙ | ︙ |