Bwidget Source Code
Check-in [a98c52b45d]
Not logged in

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

Overview
Comment:Ticket [981605ffff]: Revised calender dialog from attachement file bwidget_calendar_2025-03-13.zip
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | 981605ffff-calender
Files: files | file ages | folders
SHA3-256: a98c52b45d4abe4036581c10c9b025584fa6a287a15cd9650b1847ee9a677d5e
User & Date: oehhar 2025-03-13 17:12:30.311
References
2025-03-13
17:14 Ticket [981605ffff] BWidget Calendar Dialog status still Pending with 4 other changes artifact: e01e1faa54 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
Changes
Unified Diff Ignore Whitespace Patch
Changes to 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>&nbsp;&nbsp;-background or -bg</TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;-parent</TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;-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>&nbsp;&nbsp;<A HREF="#-background">-background</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-backwardimage">-backwardimage</A></TR>

<TR><TD>&nbsp;&nbsp;<A HREF="#-currentdatefont">-currentdatefont</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-datefont">-datefont</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-daybackground">-daybackground</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-dayfont">-dayfont</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-days">-days</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-forwardimage">-forwardimage</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-foreground">-foreground</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-height">-height</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-highlightdaybackground">-highlightdaybackground</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-highlightdaycolor">-highlightdaycolor</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-highlightdaythickness">-highlightdaythickness</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-highlightshowdate">-highlightshowdate</A></TR>

<TR><TD>&nbsp;&nbsp;<A HREF="#-multipleselection">-multipleselection</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-selectdates">-selectdates</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-selectthickness">-selectthickness</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-showdate">-showdate</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-startday">-startday</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-titlefont">-titlefont</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-type">-type</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-weekdaybackground">-weekdaybackground</A></TR>
<TR><TD>&nbsp;&nbsp;<A HREF="#-weekendbackground">-weekendbackground</A></TR>
<TR><TD>&nbsp;&nbsp;<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>
|
|
>
>
>
|
>
>
>
>
>
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
>
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<

|
|
>
>
|
|
|
|
<
|
|
|
|
|
>
>
>
>
>
>
>
|
<
|
|
<
|
|
|
<
|

<
|
|
|
<
|

<
|
|
|
<
|

<
|
|
|
<
|
|
|
>
|
|
|
<
|
|
|
|
|
|
<
|
|
|
|
|
|
<
|

<
|
|
|
<
|

<
|
|
|
<
|

<
|
|
|
<
|

<
|
|
|
<
|
|
|
|
|
>
>
>
>
>
>
>
>
>
|
|
|
|
|
>
>
|
|
|
<
|
|
|
|
|
|
<
|
|
<
<
<
<
<
|
>
>
>
>
|
|
|
|
|
|
|
>
|
|
|
|
|
<
|
|
|
>
>
|
|
|
|
|
>
|
|
>
|
|
|
<
|

<
|
|
|
<
|

<
|
|
|
<
|

<
|
|
|
>
|
<
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

<html>
<head><title>Calendar</title></head>
<body alink="#800080" bgcolor="#ffffff" text="#000000" link="#000080" vlink="#800000">
<!--
CHANGES:
2004 - initial version
2025 - 1. Correct HTML structure, syntax, links etc.
       2. Describe option -type 'embedded' as new possibility
       3. Add Documentation for new options -buttonnames and -months
          for use of other languages
-->
<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>&nbsp;&nbsp;-background or -bg</td>
</tr>
<tr>
<td>&nbsp;&nbsp;-parent</td>
</tr>
<tr>
<td>&nbsp;&nbsp;-title</td>
</tr>
</table></dd>
</dl>
<dl>
<dt><i><a href="#wso">WIDGET-SPECIFIC OPTIONS</a></i></dt>
<dd><table cellspacing="0" cellpadding="0" border="0">

<tr><td>&nbsp;&nbsp;<a href="#opt_backwardimage">-backwardimage</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_buttonnames">-buttonnames</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_currentdatefont">-currentdatefont</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_datefont">-datefont</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_daybackground">-daybackground</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_dayfont">-dayfont</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_days">-days</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_foreground">-foreground</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_forwardimage">-forwardimage</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_height">-height</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_highlightdaybackground">-highlightdaybackground</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_highlightdaycolor">-highlightdaycolor</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_highlightdaythickness">-highlightdaythickness</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_highlightshowdate">-highlightshowdate</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_months">-months</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_multipleselection">-multipleselection</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_selectdates">-selectdates</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_selectthickness">-selectthickness</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_showdate">-showdate</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_startday">-startday</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_titlefont">-titlefont</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_type">-type</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_weekdaybackground">-weekdaybackground</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_weekendbackground">-weekendbackground</a></td></tr>
<tr><td>&nbsp;&nbsp;<a href="#opt_width">-width</a></td></tr>
</table></dd>
</dl>
<dl>
<dt><i><a name="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 basically a Dialog, and it can be embedded in an
existing frame (returning the variable name for the date selection).
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="opt_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="opt_buttonnames"><b>-buttonnames</b></a></dt>
<dd>
Specifies a list of two strings (label's text) for the both buttons
'OK' and 'Cancel' (in that order) for other languages than English.
Defaults to <b>&quot;OK Cancel&quot;</b>
</dd>
</dl>
<dl><dt><a name="opt_currentdatefont"><b>-currentdatefont</b></a></dt>

<dd>
Specifies a font to use for the <a href="#opt_showdate">-showdate</a>.

</dd>
</dl>
<dl><dt><a name="opt_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="opt_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="opt_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="opt_days"><b>-days</b></a></dt>

<dd>
Specifies a string of whitespace separated abbreviations (list) to
use for the days of the week, starting with Sunday.
Defaults to <b>&quot;Su Mo Tu We Th Fr Sa&quot;</b>
</dd>
</dl>
<dl><dt><a name="opt_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="opt_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="opt_height"><b>-height</b></a></dt>

<dd>
Specifies the height of the Calendar window.

</dd>
</dl>
<dl><dt><a name="opt_highlightdaybackground"><b>-highlightdaybackground</b></a></dt>

<dd>
Specifies the color to highlight the background of a selected day.

</dd>
</dl>
<dl><dt><a name="opt_highlightdaycolor"><b>-highlightdaycolor</b></a></dt>

<dd>
Specifies the color to highlight the edges of a selected day.

</dd>
</dl>
<dl><dt><a name="opt_highlightdaythickness"><b>-highlightdaythickness</b></a></dt>

<dd>
Specifies the thickness of the highlight around a selected day.

</dd>
</dl>
<dl><dt><a name="opt_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="#opt_showdate">-showdate</a>.
</dd>
</dl>
<dl><dt><a name="opt_months"><b>-months</b></a></dt>
<dd>
Specifies a list of 12 strings (text) for the names of the
months of a year, starting with January, for other languages
than English.
Defaults to <b>&quot;January February March April May June July
August September October November December&quot;</b>
</dd>
</dl>
<dl><dt><a name="opt_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="opt_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="opt_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="opt_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="opt_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="opt_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="#opt_backwardimage">-backwardimage</a> or
<a href="#opt_forwardimage">-forwardimage</a>.
</dd>
</dl>
<dl><dt><a name="opt_type"><b>-type</b></a></dt>
<dd>
Type of the widget, either the default <b>dialog</b>, a <b>popup</b> or
<b>embedded</b>.
The <b>popup</b> will return immediately after selecting just one date.
The <b>embedded</b> will also return immediately after creating the widget,
returning the value name for the use of getting the result.
</dd>
</dl>
<dl><dt><a name="opt_weekdaybackground"><b>-weekdaybackground</b></a></dt>

<dd>
Specifies the color to use as the background for the weekdays.

</dd>
</dl>
<dl><dt><a name="opt_weekendbackground"><b>-weekendbackground</b></a></dt>

<dd>
Specifies the color to use as the background for the weekends.

</dd>
</dl>
<dl><dt><a name="opt_width"><b>-width</b></a></dt>

<dd>
Specifies the width of Calendar.

</dd>
</dl>
<small>Copyright &copy; 2004 Chris Maj<br>
Copyright &copy; 2025 Th. Wunderlich</small>
</body></html>

Changes to 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
#==========================================================
# 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}









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>















>












>







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
#==========================================================
# 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)
#
#   Enhanced for other languages by adding 2 options -months
#   and -buttonnames; realize embedding in frame in main window;
#   and corrected some lines (Thomas Wunderlich, 2025-03-13).
#
#   Known problems:
#    1. Old context data still exists after destroy a calendar
#    2. Some combinations of options are not useful
#       (Which order of precedence to overwrite?)
#    3. Embedding in a toplevel other than main don't work yet
#    4. Option -startday has to be in English names (see Enum)!
#    5. BWidget in themed mode using ttk was not checked
#       (options redirecting to -font don't work in version 1.9.8)
#    6. Some data could be centralized for less memory usage
#    7. Unkown: How and when to destroy an embedded calendar?
#==========================================================
# 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}
        {-buttonnames       String      "OK Cancel" 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"}
        {-months            String      "January February March April May June July August September October November December" 0}
        {-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}
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
#
# 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







>
>








>
>
>
>
>
>
>
>
>
>
>
>



















>
>
>
>
>
>
>
>
>
>

<





|
>



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







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
#
# Arguments:
#   path    path to the calendar widget
#   args    args supplied to create the widget
#
# Results:
#   returns a sorted list of all selected dates
#   Using option -type embedded the name of the variable
#   holding the (unsorted) list is returned.
#----------------------------------------------------------
#
proc Calendar::create { path args } {

    variable $path
    upvar 0  $path data

    set data(dotw) "sunday monday tuesday wednesday thursday friday saturday"
    set data(backmonth,0) "January"
    set data(backmonth,1) "February"
    set data(backmonth,2) "March"
    set data(backmonth,3) "April"
    set data(backmonth,4) "May"
    set data(backmonth,5) "June"
    set data(backmonth,6) "July"
    set data(backmonth,7) "August"
    set data(backmonth,8) "September"
    set data(backmonth,9) "October"
    set data(backmonth,10) "November"
    set data(backmonth,11) "December"

    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
    }

    set months [split [Widget::cget "$path#Calendar" -months]]

    set opts [list highlightshowdate selectthickness currentdatefont \
        datefont dayfont daybackground highlightdaybackground \
        highlightdaycolor highlightdaythickness weekdaybackground \
        weekendbackground background titlefont backwardimage \
        forwardimage foreground multipleselection type showdate]
    foreach opt $opts {
        set data($opt) [Widget::cget "$path#Calendar" -$opt]
    }
    # make it easier to know what month/year we are on

    if {$data(showdate)==""} {
        set data(showdate) [clock seconds]
    } else {
        set data(showdate) [clock scan $data(showdate)]
    }
    set data(showmonthnr) [expr {[string trim [clock format $data(showdate) -format %N]]-1}]
    set data(showmonth) [lindex $months $data(showmonthnr)]
    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"]



















    # 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
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
            -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) \







<
<
<
<
<
<
<
<



|



>







161
162
163
164
165
166
167








168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
            -image $data(backwardimage)
    }
    if {[string length $data(forwardimage)] > 0} {
        $fr.rightbtn configure \
            -image $data(forwardimage)
    }









    # lets us pick the month
    ComboBox $fr.monthcombo \
        -font $data(titlefont) \
        -text $data(backmonth,$data(showmonthnr)) \
        -textvariable ::Calendar::[subst {$path}](showmonth) \
        -editable 1 \
        -width 16 \
        -height 12 \
        -values $months \
        -modifycmd [list Calendar::_flipMonth $path 0]

    # lets us pick the year
    SpinBox $fr.yearspin \
        -font $data(titlefont) \
        -text $data(showyear) \
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
        -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 \







|

|
<














|
<


















>

|



|







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
        -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<($data(startdayidx)+7)} {incr i} {
        set day [lindex $days [expr {$i % 7}]]
        set 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 "_${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"]} {
        set buttonnames [Widget::cget "$path#Calendar" -buttonnames]
        Button $fr.okbtn \
            -text [lindex $buttonnames 0] \
            -font $data(titlefont) \
            -command [list destroy $path]
        Button $fr.cancelbtn \
            -text [lindex $buttonnames 1] \
            -font $data(titlefont) \
            -command [list Calendar::_clearDates $path 1]
        grid $fr.okbtn \
            -row [expr {$j+1}] \
            -column 1 \
            -columnspan 3 \
            -padx 10 \
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

    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
#----------------------------------------------------------







>
>
>
>
>
>
>
>












|







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

    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)]
    }
    # We don't know the manager for embedding!
    # Supported are only pack and grid.
    if {[catch {pack $path -in [winfo parent $path]}]} {
        grid $path -in [winfo parent $path]
    }
    update idletasks
    # We deliver the qualified variable name holding the changes
    return "::Calendar::${path}(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
#----------------------------------------------------------
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
     || [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} {







|



|



>
|


>
>

|

|

|
>






|
<




|



|







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
     || [string match $data(type) "dialog"]} {
        set fr [Dialog::getframe $path]
    } else {
        set fr $path
    }

    if {$flipday_ == -1} {
        set flipday_ "1-$data(backmonth,$data(showmonthnr))-$data(showyear)"
        set flipday_ [clock format [clock scan "last month" \
            -base [clock scan $flipday_]] -format "%D"]
    } elseif {$flipday_ == 1} {
        set flipday_ "1-$data(backmonth,$data(showmonthnr))-$data(showyear)"
        set flipday_ [clock format [clock scan "next month" \
            -base [clock scan $flipday_]] -format "%D"]
    } elseif {$flipday_ == 0} {
        set months [split [Widget::cget "$path#Calendar" -months]]
        set flipday_ "1-$data(backmonth,[lsearch -nocase -exact $months $data(showmonth)])-$data(showyear)"
    }

    set months [split [Widget::cget "$path#Calendar" -months]]

    # 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(showmonthnr) [expr {[string trim [clock format [clock scan $firstday] -format "%N"]]-1}]
    set data(showmonth) [lindex $months $data(showmonthnr)]
    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 "_${i}x$j"

            if {!$placeday && $firstdayow == $i} {
                set placeday 1
            }
            if {$placeday && $placeday <= $lastdayom} {
                set curday "$placeday-$data(backmonth,$data(showmonthnr))-$data(showyear)"
                # if this is today, use the right font
                if {[string match [string trim $curday] [string trim $todayis]]} {
                    $fr.$btn configure \
                        -font $data(currentdatefont)
                } 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} {
454
455
456
457
458
459
460





461
462
463
464
465
466
467
#   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_]







>
>
>
>
>







479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
#   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]
    # Check for Embedding,
    # Embedding in toplevels NOT supported yet!
    if {$path=="."} {
        set path [winfo parent $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_]
Changes to demo/calendar.tcl.
95
96
97
98
99
100
101


    # pack the title frames nicely
    pack $titf1 $titf2 $titf3 \
        -pady 4

    return $frame
}








>
95
96
97
98
99
100
101
102

    # pack the title frames nicely
    pack $titf1 $titf2 $titf3 \
        -pady 4

    return $frame
}

Added demo/calendar_enhanced_example.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
# Example showing the enhanced and new features of BWidget::clendar
# Copyright (C) 2025 Th. Wunderlich
# File is in WIN-1252 (ANSI) encoding (because of Umlaut U and a) and with Unix (LF)

package require Tk
package require BWidget

cd [file dirname [info script]]

source "../calendar.tcl"

set date ""
ttk::label .l1 -text "Result of calendar in German:"
ttk::label .l2 -textvariable date
ttk::label .l3 -text "Result from embedded calendar:"
ttk::frame .embedFrame
ttk::label .l4 \
    -width 66 \
    -textvariable \
        [Calendar::create .embedFrame.cal \
            -type embedded]
grid .l1         -row 0 -column 0
grid .l2         -row 0 -column 1
grid .l3         -row 1 -column 0
grid .l4         -row 1 -column 1
grid .embedFrame -row 2 -column 0 -columnspan 2
grid columnconfigure . 2 -weight 1
grid rowconfigure    . 2 -weight 1
set date [Calendar::create .cal\
    -title "Kalender" \
    -multipleselection 0 \
    -buttonnames "\u00dcbernehmen Abbrechen" \
    -months "Januar Februar M\u00e4rz April Mai Juni Juli August September Oktober November Dezember" \
    -days "So Mo Di Mi Do Fr Sa" \
    -startday "monday"]