use maximum allocation width to process table ordering
authorgc <gc>
Fri, 1 Apr 2005 20:17:57 +0000 (20:17 +0000)
committergc <gc>
Fri, 1 Apr 2005 20:17:57 +0000 (20:17 +0000)
lib/booh/GtkAutoTable.rb

index 5c9c2136fc8efa80dc6b64817580fde2f10a8c49..962a224a77a4ecd1f5ffe30018e5bdfdd02f10a4 100644 (file)
@@ -3,6 +3,12 @@ require 'gtk2'
 require 'booh/booh-lib'
 include Booh
 
+class Gtk::Allocation
+    def to_s
+        "width:#{width} heigth:#{height}"
+    end
+end
+
 class Gtk::AutoTable < Gtk::VBox
 
     def initialize(row_spacings)
@@ -289,12 +295,13 @@ class Gtk::AutoTable < Gtk::VBox
                 return
 
             else
-                maxwidth = allocation.width
-                xpix = 5 + @children[0][:allocation][:width] + 5
+                totalwidth = allocation.width
+                maxwidth = @children.collect { |chld| chld[:allocation][:width] }.max
+                xpix = 5 + maxwidth + 5
                 x = 1
                 y = 0
                 @children[1..-1].each { |e|
-                    if xpix + 5 + e[:allocation][:width] + 5 > maxwidth - 1
+                    if xpix + 5 + maxwidth + 5 > totalwidth - 1
                         x = 0
                         y += 1
                         xpix = 0
@@ -302,7 +309,7 @@ class Gtk::AutoTable < Gtk::VBox
                     e[:xnew] = x
                     e[:ynew] = y
                     x += 1
-                    xpix += 5 + e[:allocation][:width] + 5
+                    xpix += 5 + maxwidth + 5
                 }
                 if @children[1..-1].find { |e| e[:xnew] != e[:x] || e[:ynew] != e[:y] } || force
                     msg 3, "I can proceed with #{allocation}"