Bwidget Source Code
Check-in [3ee805ef99]
Not logged in

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

Overview
Comment:BWidget NoteBook - possibility to add an image at the right of each tab - ticket [15e19fe9ec]
Timelines: family | ancestors | descendants | both | bwidget
Files: files | file ages | folders
SHA3-256: 3ee805ef99853784be3aa5f8ea70c1435444e3205807c3b7be610dabbb6ccb12
User & Date: oehhar 2017-11-03 12:03:37
References
2017-11-03
12:53 Closed ticket [15e19fe9ec]: BWidget NoteBook - add an image at the right of each tab plus 8 other changes artifact: 48aaa8f5b6 user: oehhar
Context
2018-01-09
17:54
Merge fontchooser extensions: hex entry/display, help, title frames, user choice callback. Ticket [75101bf5ce] check-in: 5f374d671e user: oehhar tags: bwidget
2017-11-03
12:03
BWidget NoteBook - possibility to add an image at the right of each tab - ticket [15e19fe9ec] check-in: 3ee805ef99 user: oehhar tags: bwidget
2017-08-25
07:15
Tagged version 1.9.11 check-in: 02881ab4fd user: oehhar tags: bwidget, bwidget-1-9-11
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to BWman/NoteBook.html.

42
43
44
45
46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-arcradius">-arcradius</A></TD>
<TD>&nbsp;&nbsp;<A HREF="#-height">-height</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-homogeneous">-homogeneous</A></TD>
<TD>&nbsp;&nbsp;<A HREF="#-side">-side</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-tabbevelsize">-tabbevelsize</A></TD>
<TD>&nbsp;&nbsp;<A HREF="#-tabpady">-tabpady</A></TD>
</TR>
<TR>

<TD>&nbsp;&nbsp;<A HREF="#-width">-width</A></TD>
</TR>
</TABLE></DD>
</DL>
<DL>
<DT><I><A HREF="#wc">WIDGET COMMAND</A></I></DT>
<DD><I>pathName</I> <A HREF="#bindtabs"><B>bindtabs</B></A>







|


|
|


>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-arcradius">-arcradius</A></TD>
<TD>&nbsp;&nbsp;<A HREF="#-height">-height</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-homogeneous">-homogeneous</A></TD>
<TD>&nbsp;&nbsp;<A HREF="#-internalborderwidth">-internalborderwidth or -ibd</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-side">-side</A></TD>
<TD>&nbsp;&nbsp;<A HREF="#-tabbevelsize">-tabbevelsize</A></TD>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="#-tabpady">-tabpady</A></TD>
<TD>&nbsp;&nbsp;<A HREF="#-width">-width</A></TD>
</TR>
</TABLE></DD>
</DL>
<DL>
<DT><I><A HREF="#wc">WIDGET COMMAND</A></I></DT>
<DD><I>pathName</I> <A HREF="#bindtabs"><B>bindtabs</B></A>
113
114
115
116
117
118
119
120




121
122
123
124
125
126
127
 <I>page</I>
</DD>
</DL>
<BR><HR WIDTH="100%"><BR>
<B><A NAME="descr"></A>DESCRIPTION</B><BR>
<P>

NoteBook widget manage a set of pages and displays one of them.





</P>
<BR><HR WIDTH="50%"><BR>
<B><A NAME="wso">WIDGET-SPECIFIC OPTIONS</A></B><BR>
<DL><DT><A NAME="-arcradius"><B>-arcradius</B></A></DT>
<DD>








|
>
>
>
>







114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
 <I>page</I>
</DD>
</DL>
<BR><HR WIDTH="100%"><BR>
<B><A NAME="descr"></A>DESCRIPTION</B><BR>
<P>

The NoteBook widget manages a set of pages and displays one of them.  A page
is a <B>frame</B> or <B>ttk::frame</B> that is included in the NoteBook by its
<A HREF="#insert"><B>insert</B></A> command.  Each page is associated with a tab;
the tabs are displayed in a band either above or below the pages, depending on
the value of the option <A HREF="#-side">-side</A>.

</P>
<BR><HR WIDTH="50%"><BR>
<B><A NAME="wso">WIDGET-SPECIFIC OPTIONS</A></B><BR>
<DL><DT><A NAME="-arcradius"><B>-arcradius</B></A></DT>
<DD>

138
139
140
141
142
143
144
145








146
147
148


149
150
151
152
153
154
155
In this case, user may want to call NoteBook::<B>compute_size</B> to make NoteBook larger
enough to contains the largest page.
</DD>
</DL>
<DL><DT><A NAME="-homogeneous"><B>-homogeneous</B></A></DT>
<DD>

Specifies wether or not the label of the pages must have the same width.









</DD>
</DL>


<DL><DT><A NAME="-side"><B>-side</B></A></DT>
<DD>

Specifies the side where to place the label of the pages. Must be one
of <B>top</B> or <B>bottom</B>.

</DD>







|
>
>
>
>
>
>
>
>



>
>







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
In this case, user may want to call NoteBook::<B>compute_size</B> to make NoteBook larger
enough to contains the largest page.
</DD>
</DL>
<DL><DT><A NAME="-homogeneous"><B>-homogeneous</B></A></DT>
<DD>

Specifies whether or not the label of the pages must have the same width.

</DD>
</DL>

<DL><DT><A NAME="-internalborderwidth"><B>-internalborderwidth</B> or <B>-ibd</B></A></DT>
<DD>

Value that is applied to each page in the NoteBook as its <B>-borderwidth</B> or <B>-bd</B>.

</DD>
</DL>


<DL><DT><A NAME="-side"><B>-side</B></A></DT>
<DD>

Specifies the side where to place the label of the pages. Must be one
of <B>top</B> or <B>bottom</B>.

</DD>
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
</DD></DL>
<DL><DT><A NAME="insert"><I>pathName</I> <B>insert</B></A>
 <I>index</I>
 <I>page</I>
 ?<I>option value...</I>?
</DT><DD>

Insert a new page idendified by <I>page</I> at position <I>index</I> in the pages list.
<I>index</I> must be numeric or <B>end</B>. The pathname of the new page is returned.



<P>





















<DL><DT><A NAME="Page-createcmd"><B>-createcmd</B></A></DT>
<DD>

Specifies a command to be called the first time the page is raised.

















































</DD>
</DL>
<DL><DT><A NAME="Page-image"><B>-image</B></A></DT>
<DD>

Specifies an image to display for the page at the left of the label

</DD>
</DL>
<DL><DT><A NAME="Page-leavecmd"><B>-leavecmd</B></A></DT>
<DD>

Specifies a command to be called when a page is about to be leaved.
The command must return 0 if the page can not be leaved, or 1 if it can.








</DD>
</DL>
<DL><DT><A NAME="Page-raisecmd"><B>-raisecmd</B></A></DT>
<DD>

Specifies a command to be called each time the page is raised.

















</DD>
</DL>
<DL><DT><A NAME="Page-state"><B>-state</B></A></DT>
<DD>

Specifies the state of the page. Must be <B>normal</B> or <B>disabled</B>.








|

>
>


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





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















>
>
>
>
>
>
>







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







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
</DD></DL>
<DL><DT><A NAME="insert"><I>pathName</I> <B>insert</B></A>
 <I>index</I>
 <I>page</I>
 ?<I>option value...</I>?
</DT><DD>

Insert a new page identified by <I>page</I> at position <I>index</I> in the pages list.
<I>index</I> must be numeric or <B>end</B>. The pathname of the new page is returned.
Dynamic help, if it is specified by the options, is
displayed when the pointer hovers over the tab that belongs to the page.

<P>
<DL><DT><A NAME="Page-activebackground"><B>-activebackground</B></A></DT>
<DD>

Background color for the tab when it is active.

</DD>
</DL>
<DL><DT><A NAME="Page-activeforeground"><B>-activeforeground</B></A></DT>
<DD>

Color used for the tab's text when the tab is active.

</DD>
</DL>
<DL><DT><A NAME="Page-background"><B>-background</B></A></DT>
<DD>

Background color for the tab when it is not active.

</DD>
</DL>
<DL><DT><A NAME="Page-createcmd"><B>-createcmd</B></A></DT>
<DD>

Specifies a command to be called the first time the page is raised.

</DD>
</DL>
<DL><DT><A NAME="Page-disabledforeground"><B>-disabledforeground</B></A></DT>
<DD>

Color used for the tab's text when the tab is disabled.

</DD>
</DL>

<DL><DT><A NAME="Page-foreground"><B>-foreground</B></A></DT>
<DD>

Color used for the tab's text when the tab is neither active nor disabled.

</DD>
</DL>
<DL><DT><A NAME="Page-helpcmd"><B>-helpcmd</B></A></DT>
<DD>

Has no effect.
See also <A HREF="DynamicHelp.html">DynamicHelp</A>.

</DD>
</DL>
<DL><DT><A NAME="Page-helptext"><B>-helptext</B></A></DT>
<DD>

Text for dynamic help. If empty, no help is available for this page.
See also <A HREF="DynamicHelp.html">DynamicHelp</A>.

</DD>
</DL>
<DL><DT><A NAME="Page-helptype"><B>-helptype</B></A></DT>
<DD>

Type of dynamic help. Use <I>balloon</I> (the default for a NoteBook
page) or <I>variable</I>.
See also <A HREF="DynamicHelp.html">DynamicHelp</A>.

</DD>
</DL>
<DL><DT><A NAME="Page-helpvar"><B>-helpvar</B></A></DT>
<DD>

Variable to use when <B>-helptype</B> option is <I>variable</I>.
See also <A HREF="DynamicHelp.html">DynamicHelp</A>.

</DD>
</DL>
<DL><DT><A NAME="Page-image"><B>-image</B></A></DT>
<DD>

Specifies an image to display for the page at the left of the label

</DD>
</DL>
<DL><DT><A NAME="Page-leavecmd"><B>-leavecmd</B></A></DT>
<DD>

Specifies a command to be called when a page is about to be leaved.
The command must return 0 if the page can not be leaved, or 1 if it can.

</DD>
</DL>
<DL><DT><A NAME="Page-ractiveimage"><B>-ractiveimage</B></A></DT>
<DD>

Image to show on the right of the tab when the tab is active.

</DD>
</DL>
<DL><DT><A NAME="Page-raisecmd"><B>-raisecmd</B></A></DT>
<DD>

Specifies a command to be called each time the page is raised.

</DD>
</DL>
<DL><DT><A NAME="Page-rimage"><B>-rimage</B></A></DT>
<DD>

Image to show on the right of the tab when the tab is not active.

</DD>
</DL>
<DL><DT><A NAME="Page-rimagecmd"><B>-rimagecmd</B></A></DT>
<DD>

Specifies a command to be evaluated, with two arguments appended, when the
image shown on the right of the tab is clicked.  The first appended argument
is the Tk window path of the NoteBook, the second is the name of the page.

</DD>
</DL>
<DL><DT><A NAME="Page-state"><B>-state</B></A></DT>
<DD>

Specifies the state of the page. Must be <B>normal</B> or <B>disabled</B>.

Changes to ChangeLog.






1
2
3
4
5
6
7





2017-08-25 Harald Oehlmann <[email protected]>

	**** BWidget 1.9.11 tagged ****

2017-05-08 Harald Oehlmann
	MessageDlg.html: Documented the use of the native widget for
	"MessageDlg -type !user" and the limited set of recognized
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2017-11-03 Harald Oehlmann
	notebook.tcl (+man,demo): Add possibility to NoteBook
	to add an image at the right of each tab.
	Ticket [15e19fe9ec]. Patch by Keith Nash.

2017-08-25 Harald Oehlmann <[email protected]>

	**** BWidget 1.9.11 tagged ****

2017-05-08 Harald Oehlmann
	MessageDlg.html: Documented the use of the native widget for
	"MessageDlg -type !user" and the limited set of recognized

Changes to demo/demo.tcl.

23
24
25
26
27
28
29















30
31
32
33
34
35
36
    foreach script {
	manager.tcl basic.tcl select.tcl dnd.tcl tree.tcl tmpldlg.tcl
    } {
	namespace inscope :: source $DEMODIR/$script
    }
}

















proc Demo::create { } {
    global   tk_patchLevel
    variable _wfont
    variable notebook
    variable mainframe
    variable font







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







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
    foreach script {
	manager.tcl basic.tcl select.tcl dnd.tcl tree.tcl tmpldlg.tcl
    } {
	namespace inscope :: source $DEMODIR/$script
    }
}

image create photo bwidget16 -data {
    R0lGODlhEAAQAOMJABat6IGYffaBCUSku/KCDcCMPomXdgCy//+AANnZ2dnZ2dnZ2dnZ2dnZ2dnZ
    2dnZ2SH5BAEKAA8ALAAAAAAQABAAAAQ58MlJq70U6a0x/9c2iRb5mNmHjmpXuiecIpRA0JWJDEfw
    HIffoWU4AIBBYKuABAoxSGEQ6oxins8IADs=
}

image create photo faded16 -data {
    R0lGODlhEAAQAKEDAAAAAICAgKCgoP///yH5BAEKAAMALAAAAAAQABAAAAIjnI+py+1vQEABsDoH
    blUI+XyAAImk033Zsmng8hoVRNd2XQAAOw==
}

image create photo stop16 -data {
    R0lGODlhEAAQAMIFAAAAAC8DA3gKCpYMDPAUFP///////////yH5BAEKAAcALAAAAAAQABAAAAMm
    SLrc/jDKqYBgAsB8CY/ZMFjTGAzUEACoFI7d83nkUysZpe/8ngAAOw==
}

proc Demo::create { } {
    global   tk_patchLevel
    variable _wfont
    variable notebook
    variable mainframe
    variable font
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
    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   "Done"
    incr prgindic
    $notebook compute_size
    pack $notebook -fill both -expand yes -padx 4 -pady 4
    $notebook raise [$notebook page 0]

    pack $mainframe -fill both -expand yes
    update idletasks
    destroy .intro
}



























proc Demo::update_font { newfont } {
    variable _wfont
    variable notebook
    variable font
    variable font_name







>
>
>
>
>
>
>
>











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







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

    set prgtext   "Done"
    incr prgindic
    $notebook compute_size
    pack $notebook -fill both -expand yes -padx 4 -pady 4
    $notebook raise [$notebook page 0]

    pack $mainframe -fill both -expand yes
    update idletasks
    destroy .intro
}

proc Demo::_close_tab { tabSet tabName } {
    after idle [list $tabSet delete $tabName]

    set tabIndex [$tabSet index $tabName]
    set tabList  [$tabSet pages]
    set tabTot   [llength $tabList]

    # Pick another tab to raise.
    if {$tabTot == 1} {
        # No other tabs.
        exit
    } elseif {$tabIndex < $tabTot - 1} {
        # Raise the tab to the right.
        set raiseTabName [lindex $tabList [expr {$tabIndex + 1}]]
    } else {
        # This tab is furthest to the right. Raise the tab to the left.
        set raiseTabName [lindex $tabList [expr {$tabIndex - 1}]]
    }

    $tabSet raise $raiseTabName
    $tabSet see   $raiseTabName
    return
}



proc Demo::update_font { newfont } {
    variable _wfont
    variable notebook
    variable font
    variable font_name

Changes to notebook.tcl.

39
40
41
42
43
44
45



46
47
48
49
50
51
52
    namespace eval Page {
        Widget::declare NoteBook::Page {
            {-state      Enum       normal 0 {normal disabled}}
            {-createcmd  String     ""     0}
            {-raisecmd   String     ""     0}
            {-leavecmd   String     ""     0}
            {-image      TkResource ""     0 label}



            {-text       String     ""     0}
            {-foreground         String     ""     0}
            {-background         String     ""     0}
            {-activeforeground   String     ""     0}
            {-activebackground   String     ""     0}
            {-disabledforeground String     ""     0}
        }







>
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    namespace eval Page {
        Widget::declare NoteBook::Page {
            {-state      Enum       normal 0 {normal disabled}}
            {-createcmd  String     ""     0}
            {-raisecmd   String     ""     0}
            {-leavecmd   String     ""     0}
            {-image      TkResource ""     0 label}
            {-rimage     String     ""     0}
            {-ractiveimage String   ""     0}
            {-rimagecmd  String     ""     0}
            {-text       String     ""     0}
            {-foreground         String     ""     0}
            {-background         String     ""     0}
            {-activeforeground   String     ""     0}
            {-activebackground   String     ""     0}
            {-disabledforeground String     ""     0}
        }
270
271
272
273
274
275
276

277
278
279
280
281
282
283
        } else {
            frame $f \
                -relief      flat \
                -background  [Widget::cget $path -background] \
                -borderwidth [Widget::cget $path -internalborderwidth]
        }
        set data($page,realized) 0

    } else {
        if { ! $::Widget::_theme} {
            $f configure -background  [Widget::cget $path -background]
        }
        $f configure -borderwidth [Widget::cget $path -internalborderwidth]
    }
    _compute_height $path







>







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
        } else {
            frame $f \
                -relief      flat \
                -background  [Widget::cget $path -background] \
                -borderwidth [Widget::cget $path -internalborderwidth]
        }
        set data($page,realized) 0
        set data($page,rimage)   0
    } else {
        if { ! $::Widget::_theme} {
            $f configure -background  [Widget::cget $path -background]
        }
        $f configure -borderwidth [Widget::cget $path -internalborderwidth]
    }
    _compute_height $path
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
        set data(select) ""
    }
    if { $pos < $data(base) } {
        incr data(base) -1
    }
    if { $destroyframe } {
        destroy $path.f$page
        unset data($page,width) data($page,realized)
    }
    _redraw $path
}


# ---------------------------------------------------------------------------
#  Command NoteBook::itemconfigure







|







309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
        set data(select) ""
    }
    if { $pos < $data(base) } {
        incr data(base) -1
    }
    if { $destroyframe } {
        destroy $path.f$page
        unset data($page,width) data($page,realized) data($page,rimage)
    }
    _redraw $path
}


# ---------------------------------------------------------------------------
#  Command NoteBook::itemconfigure
502
503
504
505
506
507
508



509
510
511
512
513
514
515

    set res [Widget::configure $path.f$page $lres]
    if { [Widget::hasChanged $path.f$page -text foo] } {
        _compute_width $path
    } elseif  { [Widget::hasChanged $path.f$page -image foo] } {
        _compute_height $path
        _compute_width  $path



    }
    if { [Widget::hasChanged $path.f$page -state state] &&
         $state == "disabled" && $data(select) == $page } {
        set data(select) ""
    }
    _set_help $path $page
    return $res







>
>
>







506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522

    set res [Widget::configure $path.f$page $lres]
    if { [Widget::hasChanged $path.f$page -text foo] } {
        _compute_width $path
    } elseif  { [Widget::hasChanged $path.f$page -image foo] } {
        _compute_height $path
        _compute_width  $path
    } elseif  { [Widget::hasChanged $path.f$page -rimage foo] } {
        _compute_height $path
        _compute_width  $path
    }
    if { [Widget::hasChanged $path.f$page -state state] &&
         $state == "disabled" && $data(select) == $page } {
        set data(select) ""
    }
    _set_help $path $page
    return $res
542
543
544
545
546
547
548







549
550
551
552
553
554
555
        set wtext [expr {$x2 - $x1 + 20}]
        if { [set img [Widget::cget $path.f$page -image]] != "" } {
            set wtext [expr {$wtext + [image width $img] + 4}]
            set himg  [expr {[image height $img] + 6}]
            if { $himg > $hmax } {
                set hmax $himg
            }







        }
        set  wmax  [expr {$wtext > $wmax ? $wtext : $wmax}]
        incr wtot  $wtext
        set  data($page,width) $wtext
    }
    if { [Widget::cget $path -homogeneous] } {
        foreach page $data(pages) {







>
>
>
>
>
>
>







549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
        set wtext [expr {$x2 - $x1 + 20}]
        if { [set img [Widget::cget $path.f$page -image]] != "" } {
            set wtext [expr {$wtext + [image width $img] + 4}]
            set himg  [expr {[image height $img] + 6}]
            if { $himg > $hmax } {
                set hmax $himg
            }
        }
        if { [set jmg [Widget::cget $path.f$page -rimage]] != "" } {
            set wtext [expr {$wtext + [image width $jmg] + 4}]
            set hjmg  [expr {[image height $jmg] + 6}]
            if { $hjmg > $hmax } {
                set hmax $hjmg
            }
        }
        set  wmax  [expr {$wtext > $wmax ? $wtext : $wmax}]
        incr wtot  $wtext
        set  data($page,width) $wtext
    }
    if { [Widget::cget $path -homogeneous] } {
        foreach page $data(pages) {
570
571
572
573
574
575
576

577
578
579

580
581
582
583
584
585
586




587
588
589

590
591
592
593
594
595
596
    upvar 0  $path data

    set font    [Widget::cget $path -font]
    set pady0   [Widget::_get_padding $path -tabpady 0]
    set pady1   [Widget::_get_padding $path -tabpady 1]
    set metrics [font metrics $font -linespace]
    set imgh    0

    set lines   1
    foreach page $data(pages) {
        set img  [Widget::cget $path.f$page -image]

        set text [Widget::cget $path.f$page -text]
        set len [llength [split $text \n]]
        if {$len > $lines} { set lines $len}
        if {$img != ""} {
            set h [image height $img]
            if {$h > $imgh} { set imgh $h }
        }




    }
    set height [expr {$metrics * $lines}]
    if {$imgh > $height} { set height $imgh }

    set data(hpage) [expr {$height + $pady0 + $pady1}]
}


# ---------------------------------------------------------------------------
#  Command NoteBook::_get_x_page
# ---------------------------------------------------------------------------







>



>







>
>
>
>



>







584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
    upvar 0  $path data

    set font    [Widget::cget $path -font]
    set pady0   [Widget::_get_padding $path -tabpady 0]
    set pady1   [Widget::_get_padding $path -tabpady 1]
    set metrics [font metrics $font -linespace]
    set imgh    0
    set jmgh    0
    set lines   1
    foreach page $data(pages) {
        set img  [Widget::cget $path.f$page -image]
        set jmg  [Widget::cget $path.f$page -rimage]
        set text [Widget::cget $path.f$page -text]
        set len [llength [split $text \n]]
        if {$len > $lines} { set lines $len}
        if {$img != ""} {
            set h [image height $img]
            if {$h > $imgh} { set imgh $h }
        }
        if {$jmg != ""} {
            set h [image height $jmg]
            if {$h > $jmgh} { set jmgh $h }
        }
    }
    set height [expr {$metrics * $lines}]
    if {$imgh > $height} { set height $imgh }
    if {$jmgh > $height} { set height $jmgh }
    set data(hpage) [expr {$height + $pady0 + $pady1}]
}


# ---------------------------------------------------------------------------
#  Command NoteBook::_get_x_page
# ---------------------------------------------------------------------------
662
663
664
665
666
667
668




















































669
670
671
672
673
674
675
		    -fill [_getoption $path $page -background]
            $path.c itemconfigure "$page:text" \
		    -fill [_getoption $path $page -foreground]
        }
    }
}






















































# ---------------------------------------------------------------------------
#  Command NoteBook::_select
# ---------------------------------------------------------------------------
proc NoteBook::_select { path page } {
    variable $path
    upvar 0  $path data







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







683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
		    -fill [_getoption $path $page -background]
            $path.c itemconfigure "$page:text" \
		    -fill [_getoption $path $page -foreground]
        }
    }
}


# ---------------------------------------------------------------------------
#  Command NoteBook::_rightImage
# ---------------------------------------------------------------------------
proc NoteBook::_rightImage { type path page } {
    variable $path
    upvar 0  $path data

    if { [string equal [Widget::cget $path.f$page -state] "disabled"] } {
        return
    }

    switch -- $type {
        on {
            set data($page,rimage) 1
            set jmg  [Widget::cget $path.f$page -rimage]
            set jamg [Widget::cget $path.f$page -ractiveimage]
            if {    ($jmg  ne {})
                 && ($jamg ne {})
                 && ([image height $jmg] == [image height $jamg])
                 && ([image width  $jmg] == [image width  $jamg])
            } {
            $path.c itemconfigure "$page:jmg" \
		    -image $jamg
            } else {
                # Don't replace the -rimage with the -raimage if they are
                # different sizes.
            }
        }
        off {
            set data($page,rimage) 0
            $path.c itemconfigure "$page:jmg" \
		    -image [Widget::cget $path.f$page -rimage]
        }
        command {
	    set cmd [Widget::cget $path.f$page -rimagecmd]
	    if {$cmd ne {}} {
		after idle [list uplevel #0 [list NoteBook::_rightImage execute $path $page]]
		# Call after idle so that, if the pointer has left the -rimage,
		# the <Leave> event fires and resets data($page,rimage) before
		# NoteBook::_rightImage execute is evaluated.
	    }
        }
        execute {
	    set cmd [Widget::cget $path.f$page -rimagecmd]
	    if {$cmd ne {} && $data($page,rimage)} {
		uplevel #0 [concat $cmd [list $path $page]]
	    }
        }
    }
}


# ---------------------------------------------------------------------------
#  Command NoteBook::_select
# ---------------------------------------------------------------------------
proc NoteBook::_select { path page } {
    variable $path
    upvar 0  $path data
834
835
836
837
838
839
840

841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859









860
861
862
863
864
865
866
		[expr {$xf + 1 - $xBevel}] 		[expr {$top + 1}] \
		[expr {$rightPlusRadius - $xBevel}]	$topPlusRadius \
		$rightPlusRadius			$h \
		]
    }

    set img [Widget::cget $path.f$page -image]


    set ytext $top
    if { $tabsOnBottom } {
	# The "+ 2" below moves the text closer to the bottom of the tab,
	# so it doesn't look so cramped.  I should be able to achieve the
	# same goal by changing the anchor of the text and using this formula:
	# ytext = $top + $h1 - $textOffsetY
	# but that doesn't quite work (I think the linespace from the text
	# gets in the way)
	incr ytext [expr {$h1 - $h + 2}]
    }
    incr ytext $textOffsetY

    set xtext [expr {$xd + $textOffsetX}]
    if { $img != "" } {
	# if there's an image, put it on the left and move the text right
	set ximg $xtext
	incr xtext [expr {[image width $img] + 2}]
    }









	
    if { $data(select) == $page } {
        set bd    [Widget::cget $path -borderwidth]
	if {$bd < 1} { set bd 1 }
        set fg    [_getoption $path $page -foreground]
    } else {
        set bd    1







>



















>
>
>
>
>
>
>
>
>







907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
		[expr {$xf + 1 - $xBevel}] 		[expr {$top + 1}] \
		[expr {$rightPlusRadius - $xBevel}]	$topPlusRadius \
		$rightPlusRadius			$h \
		]
    }

    set img [Widget::cget $path.f$page -image]
    set jmg [Widget::cget $path.f$page -rimage]

    set ytext $top
    if { $tabsOnBottom } {
	# The "+ 2" below moves the text closer to the bottom of the tab,
	# so it doesn't look so cramped.  I should be able to achieve the
	# same goal by changing the anchor of the text and using this formula:
	# ytext = $top + $h1 - $textOffsetY
	# but that doesn't quite work (I think the linespace from the text
	# gets in the way)
	incr ytext [expr {$h1 - $h + 2}]
    }
    incr ytext $textOffsetY

    set xtext [expr {$xd + $textOffsetX}]
    if { $img != "" } {
	# if there's an image, put it on the left and move the text right
	set ximg $xtext
	incr xtext [expr {[image width $img] + 2}]
    }

    if { $jmg != "" } {
	# if there's an image, put it on the right and leave the text
	set xjmg $xtext
	if { $img != "" } {
	    set xjmg $ximg
	}
	incr xjmg [expr {$data($page,width) - [image width $jmg] - 10}]
    }
	
    if { $data(select) == $page } {
        set bd    [Widget::cget $path -borderwidth]
	if {$bd < 1} { set bd 1 }
        set fg    [_getoption $path $page -foreground]
    } else {
        set bd    1
924
925
926
927
928
929
930




















931
932
933
934
935
936
937
        }
        $path.c coords $id $ximg $ytext
        $path.c itemconfigure $id -image $img
        # Sven end
    } else {
        $path.c delete $page:img
    }





















    if { $data(select) == $page } {
        $path.c raise p:$page
    } elseif { $pos == 0 } {
        if { $data(select) == "" } {
            $path.c raise p:$page
        } else {







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







1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
        }
        $path.c coords $id $ximg $ytext
        $path.c itemconfigure $id -image $img
        # Sven end
    } else {
        $path.c delete $page:img
    }

    if { $jmg != "" } {
	set id [$path.c find withtag $page:jmg]
	if { [string equal $id ""] } {
	    set id [$path.c create image $xjmg $ytext \
		    -anchor nw    \
		    -tags   [list page p:$page $page:jmg]]
        }
        $path.c coords $id $xjmg $ytext
        $path.c itemconfigure $id -image $jmg

        $path.c bind $page:jmg <Enter> \
		[list NoteBook::_rightImage on  $path $page]
        $path.c bind $page:jmg <Leave> \
		[list NoteBook::_rightImage off $path $page]
        $path.c bind $page:jmg <ButtonRelease-1> \
		[list NoteBook::_rightImage command $path $page]
    } else {
        $path.c delete $page:jmg
    }

    if { $data(select) == $page } {
        $path.c raise p:$page
    } elseif { $pos == 0 } {
        if { $data(select) == "" } {
            $path.c raise p:$page
        } else {