Bwidget Source Code
View Ticket
Not logged in
Ticket UUID: 2fa44401d59c79916cc9d395fb6bae36ba9740a6
Title: ScrolledFrame incorrect sizes when both -constrainedwidth and -constrainedheight are true
Type: Bug Version: 1.9.7
Submitter: anonymous Created on: 2013-12-08 16:56:52
Subsystem: bwidget Assigned To: oehhar
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2014-01-21 13:12:33
Resolution: Accepted Closed By: oehhar
    Closed on: 2014-01-21 13:12:33
Description:
If for a ScrollableFrame both -constrainedwidth and -constrainedheight are set to true, the scrollable area is shrinked to its minimum size instead of being expanded to take all available space. As soon as the widget gets a "resize" event, the size of the area gets adjusted to what you'd expect. 
The following code snipped illustates the issue best (meant to be copied into a console step by step):

  # "Setup" - the label and backgroud color are merely to visualize the issue
  package require BWidget
  ScrollableFrame .sf
  grid .sf
  .sf.frame configure -bg blue 
  label .sf.frame.l -text "Hello"

  grid .sf
  grid .sf.frame.l

  # The problem...
  .sf configure -constrainedwidth 1
    # Everything's fine so far
  .sf configure -constrainedheight 1 
    # At this point the frame is shrunk th its original size!
    # resize the toplevel window at this point: the frame will change to the desired size

The following patch should fix the issue: 

diff -u bwidget-1.9.7-orig/scrollframe.tcl bwidget-1.9.7/scrollframe.tcl
--- bwidget-1.9.7-orig/scrollframe.tcl	2013-12-08 17:23:21.810759369 +0100
+++ bwidget-1.9.7/scrollframe.tcl	2013-12-08 17:34:28.310445852 +0100
@@ -116,20 +116,20 @@
     set modcw [Widget::hasChanged $path -constrainedwidth cw]
     set modw  [Widget::hasChanged $path -areawidth w]
     if { $modcw || (!$cw && $modw) } {
-        if { $cw } {
-            set w [winfo width $path]
-        }
         set upd 1
     }
+    if { $cw } {
+        set w [winfo width $path]
+    }
 
     set modch [Widget::hasChanged $path -constrainedheight ch]
     set modh  [Widget::hasChanged $path -areaheight h]
     if { $modch || (!$ch && $modh) } {
-        if { $ch } {
-            set h [winfo height $path]
-        }
         set upd 1
     }
+    if { $ch } {
+        set h [winfo height $path]
+    }
 
     if { $upd } {
         $path:cmd itemconfigure win -width $w -height $h
User Comments: oehhar added on 2014-01-21 13:12:33: (text/x-fossil-wiki)
Accepted, checkin [89e6f27a6a]
Thank you,
Harald

Attachments: