Bwidget Source Code
Check-in [0a9de4a94f]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:* scrollframe.tcl (ScrollableFrame::create et al) ScrollableFrame.html Background color of canvas takes the color of the scrolled frame. If themed, canvas takes the themed color of the scrolled themed frame. If themed, parameters -background and -bg are not available(doc + code). [Patch 2822970] by Koen Danckaert
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0a9de4a94f03e409e93090443e6adb930de02a94
User & Date: oehhar 2009-07-17 15:29:51
Context
2009-07-24
16:01
* tree.tcl (Tree::_set_help), Tree.html DynamicHelp -helpcmd added to tree node help * tree.tcl (Tree::_draw_subnodes) a vertical line to a virtual root node above the widget is only drawn when there are multiple child nodes. This reverts the modification dated 2004-04-21 for this case. [Patch 2825354] by Koen Danckaert check-in: 55b962c054 user: oehhar tags: trunk
2009-07-17
15:29
* scrollframe.tcl (ScrollableFrame::create et al) ScrollableFrame.html Background color of canvas takes the color of the scrolled frame. If themed, canvas takes the themed color of the scrolled themed frame. If themed, parameters -background and -bg are not available(doc + code). [Patch 2822970] by Koen Danckaert check-in: 0a9de4a94f user: oehhar tags: trunk
2009-07-15
16:50
* dynhelp.tcl (DynamicHelp) Typo from yesterday corrected [Patch 2820851] by Koen Danckaert check-in: 4ec5be8a22 user: oehhar tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to BWman/ScrollableFrame.html.

10
11
12
13
14
15
16
17
18
19
20
21



22
23
24
25
26
27
28
<DD><A HREF="#descr"><B>ScrollableFrame</B></A> <I>pathName</I> ?<I>option value...</I>?</DD>
</DL>
<DL>
<DT><I>STANDARD OPTIONS</I></DT>
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-background">-background or -bg</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-xscrollcommand">-xscrollcommand</A></TR>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-yscrollcommand">-yscrollcommand</A></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="#-areaheight">-areaheight</A></TR>
<TD>&nbsp;&nbsp;<A HREF="#-areawidth">-areawidth</A></TR>






|


|

>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<DD><A HREF="#descr"><B>ScrollableFrame</B></A> <I>pathName</I> ?<I>option value...</I>?</DD>
</DL>
<DL>
<DT><I>STANDARD OPTIONS</I></DT>
<DD><TABLE CELLSPACING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-background">-background or -bg</A></TD>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-xscrollcommand">-xscrollcommand</A></TD></TR>
</TR>
<TR>
<TD>&nbsp;&nbsp;<A HREF="options.htm#M-yscrollcommand">-yscrollcommand</A></TD></TR>
</TABLE></DD>
<BR>
Themed widget (<B>Widget::theme true</B>): Options <B>-background</B> and <B>-bg</B> are not available.
Modify style <B>TFrame</B> property <B>-background</B> instead.
</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="#-areaheight">-areaheight</A></TR>
<TD>&nbsp;&nbsp;<A HREF="#-areawidth">-areawidth</A></TR>

Changes to ChangeLog.









1
2
3
4
5
6
7







2009-07-15 Harald Oehlmann  <[email protected]>

	* dynhelp.tcl (DynamicHelp) Typo from yesterday corrected
	[Patch 2820851] by Koen Danckaert

2009-07-14 Harald Oehlmann  <[email protected]>

>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2009-07-17 Harald Oehlmann  <[email protected]>

	* scrollframe.tcl (ScrollableFrame::create et al) ScrollableFrame.html
	Background color of canvas takes the color of the scrolled frame.
	If themed, canvas takes the themed color of the scrolled themed frame.
	If themed, parameters -background and -bg are not available(doc + code).
	[Patch 2822970] by Koen Danckaert

2009-07-15 Harald Oehlmann  <[email protected]>

	* dynhelp.tcl (DynamicHelp) Typo from yesterday corrected
	[Patch 2820851] by Koen Danckaert

2009-07-14 Harald Oehlmann  <[email protected]ers.sourceforge.net>

Changes to scrollframe.tcl.

1
2
3
4
5
6
7
8
9
10
11
..
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
..
54
55
56
57
58
59
60

61
62
63
64

65


66
67
68
69
70
71
72
...
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# ----------------------------------------------------------------------------
#  scrollframe.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: scrollframe.tcl,v 1.10 2009/06/29 13:28:24 oehhar Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - ScrollableFrame::create
#     - ScrollableFrame::configure
#     - ScrollableFrame::cget
#     - ScrollableFrame::getframe
#     - ScrollableFrame::see
................................................................................
#     - ScrollableFrame::yview
#     - ScrollableFrame::_resize
# ----------------------------------------------------------------------------

namespace eval ScrollableFrame {
    Widget::define ScrollableFrame scrollframe



    Widget::declare ScrollableFrame {













        {-background        TkResource "" 0 frame}
        {-width             Int        0  0 {}}
        {-height            Int        0  0 {}}
        {-areawidth         Int        0  0 {}}
        {-areaheight        Int        0  0 {}}
        {-constrainedwidth  Boolean    0 0}
        {-constrainedheight Boolean    0 0}
        {-xscrollcommand    TkResource "" 0 canvas}
        {-yscrollcommand    TkResource "" 0 canvas}
        {-xscrollincrement  TkResource "" 0 canvas}
        {-yscrollincrement  TkResource "" 0 canvas}
        {-bg                Synonym    -background}
    }


    Widget::addmap ScrollableFrame "" :cmd {
        -background {} -width {} -height {} 
        -xscrollcommand {} -yscrollcommand {}
        -xscrollincrement {} -yscrollincrement {}
    }

    Widget::addmap ScrollableFrame "" .frame {-background {}}


    variable _widget

    bind BwScrollableFrame <Configure> [list ScrollableFrame::_resize %W]
    bind BwScrollableFrame <Destroy>   [list Widget::destroy %W]
}

................................................................................

    set canvas [eval [list canvas $path] [Widget::subcget $path :cmd] \
                    -highlightthickness 0 -borderwidth 0 -relief flat]

    if {[Widget::theme]} {
	set frame [eval [list ttk::frame $path.frame] \
		       [Widget::subcget $path .frame]]

    } else {
	set frame [eval [list frame $path.frame] \
		       [Widget::subcget $path .frame] \
		       -highlightthickness 0 -borderwidth 0 -relief flat]

    }



    $canvas create window 0 0 -anchor nw -window $frame -tags win \
        -width  [Widget::cget $path -areawidth] \
        -height [Widget::cget $path -areaheight]

    bind $frame <Configure> \
        [list ScrollableFrame::_frameConfigure $canvas]
................................................................................
# ----------------------------------------------------------------------------
#  Command ScrollableFrame::_frameConfigure
# ----------------------------------------------------------------------------
proc ScrollableFrame::_max {a b} {return [expr {$a <= $b ? $b : $a}]}
proc ScrollableFrame::_frameConfigure {canvas {unmap 0}} {
    # This ensures that we don't get funny scrollability in the frame
    # when it is smaller than the canvas space
    # when it is smaller than the canvas space.
    # use [winfo] to get height & width of frame

    # [winfo] doesn't work for unmapped frame
    set frameh [expr {$unmap ? 0 : [winfo height $canvas.frame]}]
    set framew [expr {$unmap ? 0 : [winfo width  $canvas.frame]}]

    set height [_max $frameh [winfo height $canvas]]
    set width  [_max $framew [winfo width  $canvas]]

    $canvas:cmd configure -scrollregion [list 0 0 $width $height]
}


|







 







>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>

|



>
|
>







 







>




>

>
>







 







<











1
2
3
4
5
6
7
8
9
10
11
..
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
..
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
...
245
246
247
248
249
250
251

252
253
254
255
256
257
258
259
260
261
262
# ----------------------------------------------------------------------------
#  scrollframe.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: scrollframe.tcl,v 1.11 2009/07/17 15:29:51 oehhar Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - ScrollableFrame::create
#     - ScrollableFrame::configure
#     - ScrollableFrame::cget
#     - ScrollableFrame::getframe
#     - ScrollableFrame::see
................................................................................
#     - ScrollableFrame::yview
#     - ScrollableFrame::_resize
# ----------------------------------------------------------------------------

namespace eval ScrollableFrame {
    Widget::define ScrollableFrame scrollframe

    # If themed, there is no background and -bg option
    if {[Widget::theme]} {
        Widget::declare ScrollableFrame {
            {-width             Int        0  0 {}}
            {-height            Int        0  0 {}}
            {-areawidth         Int        0  0 {}}
            {-areaheight        Int        0  0 {}}
            {-constrainedwidth  Boolean    0 0}
            {-constrainedheight Boolean    0 0}
            {-xscrollcommand    TkResource "" 0 canvas}
            {-yscrollcommand    TkResource "" 0 canvas}
            {-xscrollincrement  TkResource "" 0 canvas}
            {-yscrollincrement  TkResource "" 0 canvas}
        }
    } else {
        Widget::declare ScrollableFrame {
            {-background        TkResource "" 0 frame}
            {-width             Int        0  0 {}}
            {-height            Int        0  0 {}}
            {-areawidth         Int        0  0 {}}
            {-areaheight        Int        0  0 {}}
            {-constrainedwidth  Boolean    0 0}
            {-constrainedheight Boolean    0 0}
            {-xscrollcommand    TkResource "" 0 canvas}
            {-yscrollcommand    TkResource "" 0 canvas}
            {-xscrollincrement  TkResource "" 0 canvas}
            {-yscrollincrement  TkResource "" 0 canvas}
            {-bg                Synonym    -background}
        }
    }

    Widget::addmap ScrollableFrame "" :cmd {
        -width {} -height {} 
        -xscrollcommand {} -yscrollcommand {}
        -xscrollincrement {} -yscrollincrement {}
    }
    if { ! [Widget::theme]} {
        Widget::addmap ScrollableFrame "" .frame {-background {}}
    }

    variable _widget

    bind BwScrollableFrame <Configure> [list ScrollableFrame::_resize %W]
    bind BwScrollableFrame <Destroy>   [list Widget::destroy %W]
}

................................................................................

    set canvas [eval [list canvas $path] [Widget::subcget $path :cmd] \
                    -highlightthickness 0 -borderwidth 0 -relief flat]

    if {[Widget::theme]} {
	set frame [eval [list ttk::frame $path.frame] \
		       [Widget::subcget $path .frame]]
	set bg [ttk::style lookup TFrame -background]
    } else {
	set frame [eval [list frame $path.frame] \
		       [Widget::subcget $path .frame] \
		       -highlightthickness 0 -borderwidth 0 -relief flat]
	set bg [$frame cget -background]
    }
    # Give canvas frame (or theme) background
    $canvas configure -background $bg

    $canvas create window 0 0 -anchor nw -window $frame -tags win \
        -width  [Widget::cget $path -areawidth] \
        -height [Widget::cget $path -areaheight]

    bind $frame <Configure> \
        [list ScrollableFrame::_frameConfigure $canvas]
................................................................................
# ----------------------------------------------------------------------------
#  Command ScrollableFrame::_frameConfigure
# ----------------------------------------------------------------------------
proc ScrollableFrame::_max {a b} {return [expr {$a <= $b ? $b : $a}]}
proc ScrollableFrame::_frameConfigure {canvas {unmap 0}} {
    # This ensures that we don't get funny scrollability in the frame
    # when it is smaller than the canvas space

    # use [winfo] to get height & width of frame

    # [winfo] doesn't work for unmapped frame
    set frameh [expr {$unmap ? 0 : [winfo height $canvas.frame]}]
    set framew [expr {$unmap ? 0 : [winfo width  $canvas.frame]}]

    set height [_max $frameh [winfo height $canvas]]
    set width  [_max $framew [winfo width  $canvas]]

    $canvas:cmd configure -scrollregion [list 0 0 $width $height]
}