Tk Library Source Code
Check-in [a6173e19d4]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: [Bug 3458158, 3607261]: Fixed broken bindings of "widget::calendar" which in turn broke "widget::dateentry". Bumped calendar to 1.0.1, dateentry to 0.96.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a6173e19d4cb7f8e695d735598a8aa312637d338
User & Date: aku 2013-03-14 05:57:36
Context
2013-03-26
03:27
Merged release back into the main line. check-in: c1420d949e user: aku tags: trunk
2013-03-14
06:02
Get widget fixes (dateentry & calendar) into release. check-in: 6f613f6445 user: aku tags: tklib-0-6-rc
05:57
[Bug 3458158, 3607261]: Fixed broken bindings of "widget::calendar" which in turn broke "widget::dateentry". Bumped calendar to 1.0.1, dateentry to 0.96. check-in: a6173e19d4 user: aku tags: trunk
2013-02-15
06:44
First set of manpages getting category information, plus extended set of keywords. check-in: f87132aa81 user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/widget/ChangeLog.







1
2
3
4
5
6
7






2011-12-13  Ruediger Haertel <r_haertel@gmx.de>

	* pkgIndex.tcl: Bumped package version to 0.95.
	* widget_dateentry.tcl: 
	* dateentry.tcl: - Bugfix:3458158, Adopt to changes of calendar v1.00
			 - Provide a man page

>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
2013-03-13  Andreas Kupries  <andreas_kupries@users.sourceforge.net>

	* calendar.tcl: [Bug 3458158, 3607261]: Fixed broken bindings of
	* dateentry.tcl: "widget::calendar" which in turn broke "widget::dateentry".
	* pkgIndex.tcl: Bumped calendar to 1.0.1, dateentry to 0.96.

2011-12-13  Ruediger Haertel <r_haertel@gmx.de>

	* pkgIndex.tcl: Bumped package version to 0.95.
	* widget_dateentry.tcl: 
	* dateentry.tcl: - Bugfix:3458158, Adopt to changes of calendar v1.00
			 - Provide a man page

Changes to modules/widget/calendar.tcl.

18
19
20
21
22
23
24

25
26
27
28
29
30
31
..
58
59
60
61
62
63
64

65
66
67
68
69
70
71
...
100
101
102
103
104
105
106



107
108
109
110
111
112
113
...
269
270
271
272
273
274
275

276
277
278
279
280
281
282
...
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
...
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
...
684
685
686
687
688
689
690
691

# -textvariable   -default {}
# -firstday       -default "monday"
# -highlightcolor -default "#FFCC00"
# -shadecolor     -default "#888888"
# -language       -default en   Supported languages: de, en, es, fr, gr,
#                                he, it, ja, sv, pt, zh, fi ,tr, nl, ru,
#                                crk, crx-nak, crx-lhe

#
#  All other options to canvas
#
# Methods
#  $path get <part>   => selected date, part can be
#                              day,month,year, all
#                         default is all
................................................................................
    option -dateformat     -default "%m/%d/%Y"    -configuremethod C-refresh
    option -font           -default {Helvetica 9} -configuremethod C-font
    option -highlightcolor -default "#FFCC00"     -configuremethod C-refresh
    option -shadecolor     -default "#888888"     -configuremethod C-refresh
    option -language       -default en            -configuremethod C-language
    option -showpast       -default 1             -configuremethod C-refresh \
						  -type {snit::boolean}



    variable fullrefresh 1
    variable pending "" ; # pending after id for refresh
    variable data -array {
	day 01 month 01 year 2007
	linespace 0 cellspace 0
................................................................................
	bind $win <Control-Left>    [mymethod adjust  0 -1  0]
	bind $win <Control-Right>   [mymethod adjust  0  1  0]
	# move years
	bind $win <Control-Up>      [mymethod adjust  0  0 -1]
	bind $win <Control-Down>    [mymethod adjust  0  0  1]

	bind $win <Home>            [mymethod adjust today]




	$self configurelist $args

	$self reconfigure
	$self refresh
    }

................................................................................
    #     dyear   - Difference in years
    #   b) when used with mouse button
    #     ""      - empty
    #
    ##
    method adjust { args } {


        switch [llength $args] {
            0 {
                # mouse button select

                catch {focus -force $win} msg

                set item      [$hull find withtag current]
................................................................................
                switch [lindex $args 0] {
                    "today" {
                        set Now [clock seconds]
                        set data(day)   [clock format $Now -format %d]
                        set data(month) [clock format $Now -format %m]
                        set data(year)  [clock format $Now -format %Y]
                    }


                }
            }
            
            3 {
                # keyboard navigation

                # favor foreach approach over lassign to be
                # compatible with Tcl 8.4
                foreach {dday dmonth dyear} $args {break}
                incr data(year)  $dyear
                incr data(month) $dmonth



                set maxday [$self numberofdays $data(month) $data(year)]

                if { ($data(day) + $dday) < 1}  {
                    incr data(month) -1

                    set maxday [$self numberofdays $data(month) $data(year)]
................................................................................
        set data(selday)   $data(day)
        set data(selmonth) $data(month)
        set data(selyear)  $data(year)

        set date    [clock scan   $data(month)/$data(day)/$data(year)]
        set fmtdate [clock format $date -format $options(-dateformat)]

	if {$options(-textvariable) ne {}} {
		set $options(-textvariable) $fmtdate
	}

	if {$options(-command) ne {}} {
		# pass single arg of formatted date chosen
		uplevel \#0 $options(-command) [list $fmtdate]
	}

	$self refresh
    }

    method cbutton {x y w command} {
	# Draw simple arrowbutton using Tk's line arrows
	set wd [expr {abs($w)}]
	set wd2 [expr {$wd/2. - ((abs($w) < 10) ? 1 : 2)}]
	set poly [$hull create line $x $y [expr {$x+$w}] $y -arrow last \
................................................................................
            sierpie\u0144 wrzesie\u0144 pa\u017adziernik listopad grudzie\u0144
        }
        weekdays,pl {Ni Po Wt \u015ar Cz Pi So}
        today,pl {Dzisiaj jest}
    }
}

package provide widget::calendar 1








>







 







>







 







>
>
>







 







>







 







>
>











>
>







 







|
|
|

|
|
|
|

|







 







|
>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
...
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
...
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
...
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
...
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
...
694
695
696
697
698
699
700
701
702
# -textvariable   -default {}
# -firstday       -default "monday"
# -highlightcolor -default "#FFCC00"
# -shadecolor     -default "#888888"
# -language       -default en   Supported languages: de, en, es, fr, gr,
#                                he, it, ja, sv, pt, zh, fi ,tr, nl, ru,
#                                crk, crx-nak, crx-lhe
# -enablecmdonkey -default 1
#
#  All other options to canvas
#
# Methods
#  $path get <part>   => selected date, part can be
#                              day,month,year, all
#                         default is all
................................................................................
    option -dateformat     -default "%m/%d/%Y"    -configuremethod C-refresh
    option -font           -default {Helvetica 9} -configuremethod C-font
    option -highlightcolor -default "#FFCC00"     -configuremethod C-refresh
    option -shadecolor     -default "#888888"     -configuremethod C-refresh
    option -language       -default en            -configuremethod C-language
    option -showpast       -default 1             -configuremethod C-refresh \
						  -type {snit::boolean}
    option -enablecmdonkey -default 1


    variable fullrefresh 1
    variable pending "" ; # pending after id for refresh
    variable data -array {
	day 01 month 01 year 2007
	linespace 0 cellspace 0
................................................................................
	bind $win <Control-Left>    [mymethod adjust  0 -1  0]
	bind $win <Control-Right>   [mymethod adjust  0  1  0]
	# move years
	bind $win <Control-Up>      [mymethod adjust  0  0 -1]
	bind $win <Control-Down>    [mymethod adjust  0  0  1]

	bind $win <Home>            [mymethod adjust today]
	bind $win <space>           [mymethod adjust Return]
	bind $win <Return>          [mymethod adjust Return]
	bind $win <KP_Enter>        [mymethod adjust Return]

	$self configurelist $args

	$self reconfigure
	$self refresh
    }

................................................................................
    #     dyear   - Difference in years
    #   b) when used with mouse button
    #     ""      - empty
    #
    ##
    method adjust { args } {

        set CallCmd 1
        switch [llength $args] {
            0 {
                # mouse button select

                catch {focus -force $win} msg

                set item      [$hull find withtag current]
................................................................................
                switch [lindex $args 0] {
                    "today" {
                        set Now [clock seconds]
                        set data(day)   [clock format $Now -format %d]
                        set data(month) [clock format $Now -format %m]
                        set data(year)  [clock format $Now -format %Y]
                    }
                    "Return" {
                    }
                }
            }
            
            3 {
                # keyboard navigation

                # favor foreach approach over lassign to be
                # compatible with Tcl 8.4
                foreach {dday dmonth dyear} $args {break}
                incr data(year)  $dyear
                incr data(month) $dmonth

                set CallCmd $options(-enablecmdonkey)

                set maxday [$self numberofdays $data(month) $data(year)]

                if { ($data(day) + $dday) < 1}  {
                    incr data(month) -1

                    set maxday [$self numberofdays $data(month) $data(year)]
................................................................................
        set data(selday)   $data(day)
        set data(selmonth) $data(month)
        set data(selyear)  $data(year)

        set date    [clock scan   $data(month)/$data(day)/$data(year)]
        set fmtdate [clock format $date -format $options(-dateformat)]

        if { $CallCmd && $options(-textvariable) ne {}} {
            set $options(-textvariable) $fmtdate
        }

        if { $CallCmd && $options(-command) ne {}} {
            # pass single arg of formatted date chosen
            uplevel \#0 $options(-command) [list $fmtdate]
        }

        $self refresh
    }

    method cbutton {x y w command} {
	# Draw simple arrowbutton using Tk's line arrows
	set wd [expr {abs($w)}]
	set wd2 [expr {$wd/2. - ((abs($w) < 10) ? 1 : 2)}]
	set poly [$hull create line $x $y [expr {$x+$w}] $y -arrow last \
................................................................................
            sierpie\u0144 wrzesie\u0144 pa\u017adziernik listopad grudzie\u0144
        }
        weekdays,pl {Ni Po Wt \u015ar Cz Pi So}
        today,pl {Dzisiaj jest}
    }
}

package provide widget::calendar 1.0.1

Changes to modules/widget/dateentry.tcl.

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
...
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
...
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
	    tk::unsupported::MacWindowStyle style $dropbox \
		help {noActivates hideOnSuspend}
	}
	wm resizable $dropbox 0 0

	# Unpost on Escape or whenever user clicks outside the dropdown
	bind $dropbox <Escape> [list $win unpost]
	bind $dropbox <Return> [list $win DateAccepted]
	bind $dropbox <space>  [list $win DateAccepted]
	bind $dropbox <ButtonPress> [subst -nocommands {
	    if {[string first "$dropbox" [winfo containing %X %Y]] != 0} {
		$win unpost
	    } else {
                $win DateAccepted
            }
	}]
	bindtags $dropbox [linsert [bindtags $dropbox] 1 TDateEntryPopdown]

	set calendar $dropbox.calendar
	widget::calendar $calendar \
	    -textvariable [myvar formattedDate] \
	    -dateformat $options(-dateformat) \
	    -font $options(-font) \
	    -language $options(-language)\
	    -borderwidth 1 -relief solid 
            


	bind $calendar <Map> [list focus -force $calendar]

	pack $calendar -expand 1 -fill both

	return $dropbox
    }
................................................................................
	    right { if {$x <= $sw} { incr x  $bw } { incr x -$mw } }
	}

	return [list $x $y]
    }

    #
    #  DateAccepted --
    #
    #  Called when either Return or space was pressed, or when a date
    #  was selected on mouse click.
    #
    #  Formats the date calls the -command if specified and then
    #  updates the entry.
    #
    ##
    method DateAccepted { args } {
	upvar 0 $options(-textvariable) date

        set waitVar 1
	set date $formattedDate
	set rawDate [clock scan $formattedDate -format $options(-dateformat)]
	if { $options(-command) ne "" } {
	    uplevel \#0 $options(-command) $formattedDate $rawDate
................................................................................
        $self unpost

	$hull configure -state normal
	$hull delete 0 end
	$hull insert end $formattedDate
	$hull configure -state readonly
    }

}

# Bindings for menu portion.
#
# This is a variant of the ttk menubutton.tcl bindings.
# See menubutton.tcl for detailed behavior info.
#

bind TDateEntry <Enter>     { %W state active }
bind TDateEntry <Leave>     { %W state !active }
bind TDateEntry <<Invoke>>  { %W post }
bind TDateEntry <Control-space> { %W post }
bind TDateEntry <Escape>        { %W unpost }
bind TDateEntry <Return>        { %W DateAccepted }
bind TDateEntry <space>         { %W DateAccepted }

bind TDateEntry <ButtonPress-1> { %W state pressed ; %W post }
bind TDateEntry <ButtonRelease-1> { %W state !pressed }

# These are to get around issues on aqua (see ttk::combobox bindings)
bind TDateEntryPopdown <Map> { ttk::globalGrab %W }
bind TDateEntryPopdown <Unmap> { ttk::releaseGrab %W }

package provide widget::dateentry 0.95

##############
# TEST CODE ##
##############

if { [info script] eq $argv0 } {
    set auto_path [linsert $auto_path 0 [file dirname [info script]]]







<
<



<
<










|
<
>







 







|

|
<

|
|


|







 







<













<
<








|







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
...
259
260
261
262
263
264
265
266
267
268

269
270
271
272
273
274
275
276
277
278
279
280
281
...
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
	    tk::unsupported::MacWindowStyle style $dropbox \
		help {noActivates hideOnSuspend}
	}
	wm resizable $dropbox 0 0

	# Unpost on Escape or whenever user clicks outside the dropdown
	bind $dropbox <Escape> [list $win unpost]


	bind $dropbox <ButtonPress> [subst -nocommands {
	    if {[string first "$dropbox" [winfo containing %X %Y]] != 0} {
		$win unpost


            }
	}]
	bindtags $dropbox [linsert [bindtags $dropbox] 1 TDateEntryPopdown]

	set calendar $dropbox.calendar
	widget::calendar $calendar \
	    -textvariable [myvar formattedDate] \
	    -dateformat $options(-dateformat) \
	    -font $options(-font) \
	    -language $options(-language)\
	    -borderwidth 1 -relief solid \

            -enablecmdonkey 0 -command [mymethod DateChosen]

	bind $calendar <Map> [list focus -force $calendar]

	pack $calendar -expand 1 -fill both

	return $dropbox
    }
................................................................................
	    right { if {$x <= $sw} { incr x  $bw } { incr x -$mw } }
	}

	return [list $x $y]
    }

    #
    #  DateChosen --
    #
    #  Called from the calendar when a date was selected.

    #
    #  Formats the date, calls the callback -command if specified and
    #  then updates the entry.
    #
    ##
    method DateChosen { args } {
	upvar 0 $options(-textvariable) date

        set waitVar 1
	set date $formattedDate
	set rawDate [clock scan $formattedDate -format $options(-dateformat)]
	if { $options(-command) ne "" } {
	    uplevel \#0 $options(-command) $formattedDate $rawDate
................................................................................
        $self unpost

	$hull configure -state normal
	$hull delete 0 end
	$hull insert end $formattedDate
	$hull configure -state readonly
    }

}

# Bindings for menu portion.
#
# This is a variant of the ttk menubutton.tcl bindings.
# See menubutton.tcl for detailed behavior info.
#

bind TDateEntry <Enter>     { %W state active }
bind TDateEntry <Leave>     { %W state !active }
bind TDateEntry <<Invoke>>  { %W post }
bind TDateEntry <Control-space> { %W post }
bind TDateEntry <Escape>        { %W unpost }



bind TDateEntry <ButtonPress-1> { %W state pressed ; %W post }
bind TDateEntry <ButtonRelease-1> { %W state !pressed }

# These are to get around issues on aqua (see ttk::combobox bindings)
bind TDateEntryPopdown <Map> { ttk::globalGrab %W }
bind TDateEntryPopdown <Unmap> { ttk::releaseGrab %W }

package provide widget::dateentry 0.96

##############
# TEST CODE ##
##############

if { [info script] eq $argv0 } {
    set auto_path [linsert $auto_path 0 [file dirname [info script]]]

Changes to modules/widget/pkgIndex.tcl.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
	    lappend allpkgs [list package provide $bundle $bundlev]
	    package ifneeded $bundle $bundlev [join $allpkgs \n]
	}
	return
    }
}
if {![package vsatisfies [package provide Tcl] 8.4]} {return}
::tcl::pkgindex $dir widget::all 1.2.3 {
    widget			3.1	widget.tcl
    widget::arrowbutton	        1.0	arrowb.tcl
    widget::calendar		1.00	calendar.tcl
    widget::dateentry		0.95	dateentry.tcl
    widget::dialog		1.3.1	dialog.tcl
    widget::menuentry		1.0.1	mentry.tcl
    widget::panelframe		1.1	panelframe.tcl
    widget::ruler		1.1	ruler.tcl
    widget::screenruler		1.2	ruler.tcl
    widget::scrolledtext	1.0	stext.tcl
    widget::scrolledwindow	1.2.1	scrollw.tcl
    widget::statusbar		1.2.1	statusbar.tcl
    widget::superframe		1.0.1	superframe.tcl
    widget::toolbar		1.2.1	toolbar.tcl
}







|


|
|











10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
	    lappend allpkgs [list package provide $bundle $bundlev]
	    package ifneeded $bundle $bundlev [join $allpkgs \n]
	}
	return
    }
}
if {![package vsatisfies [package provide Tcl] 8.4]} {return}
::tcl::pkgindex $dir widget::all 1.2.4 {
    widget			3.1	widget.tcl
    widget::arrowbutton	        1.0	arrowb.tcl
    widget::calendar		1.0.1	calendar.tcl
    widget::dateentry		0.96	dateentry.tcl
    widget::dialog		1.3.1	dialog.tcl
    widget::menuentry		1.0.1	mentry.tcl
    widget::panelframe		1.1	panelframe.tcl
    widget::ruler		1.1	ruler.tcl
    widget::screenruler		1.2	ruler.tcl
    widget::scrolledtext	1.0	stext.tcl
    widget::scrolledwindow	1.2.1	scrollw.tcl
    widget::statusbar		1.2.1	statusbar.tcl
    widget::superframe		1.0.1	superframe.tcl
    widget::toolbar		1.2.1	toolbar.tcl
}

Changes to modules/widget/widget_calendar.man.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin widget_calendar n 1.00]
[moddesc   {Various megawidgets}]
[titledesc {Calendar Megawidget}]
[category Widget]
[keywords megawidget snit widget calendar date]
[require Tcl 8.4]
[require Tk 8.4]
[require widget [opt 3.0]]
[require widget::calendar [opt 1.00]]
[description]

This package provides a calendar megawidget (snidget).

[para]

[list_begin definitions]

|







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin widget_calendar n 1.0.1]
[moddesc   {Various megawidgets}]
[titledesc {Calendar Megawidget}]
[category Widget]
[keywords megawidget snit widget calendar date]
[require Tcl 8.4]
[require Tk 8.4]
[require widget [opt 3.0]]
[require widget::calendar [opt 1.0.1]]
[description]

This package provides a calendar megawidget (snidget).

[para]

[list_begin definitions]

Changes to modules/widget/widget_dateentry.man.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin widget_dateentry n 0.95]
[moddesc   {Various megawidgets}]
[titledesc {Date Entry Megawidget}]
[category Widget]
[keywords megawidget snit widget dateentry date]
[require Tcl 8.4]
[require Tk 8.4]
[require widget [opt 3.0]]
[require widget::dateentry [opt 0.95]]
[description]

This package provides a dateentry megawidget (snidget).
It is based on an ttk::entry. All widget commands of the ttk::entry
are available for the dateentry.

[para]

|







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[comment {-*- tcl -*- doctools manpage}]
[manpage_begin widget_dateentry n 0.96]
[moddesc   {Various megawidgets}]
[titledesc {Date Entry Megawidget}]
[category Widget]
[keywords megawidget snit widget dateentry date]
[require Tcl 8.4]
[require Tk 8.4]
[require widget [opt 3.0]]
[require widget::dateentry [opt 0.96]]
[description]

This package provides a dateentry megawidget (snidget).
It is based on an ttk::entry. All widget commands of the ttk::entry
are available for the dateentry.

[para]