Wednesday, November 03, 2010

gnocl::layout and gnocl::aspectFrame

I've just added the modules for these two widgets. They are pretty obscure. The gnocl::layout object is a sort of mid between a frame and a drawing area and the gnocl::aspectFrame always forces a widget to keep its original aspect ratio. With the inclusion of these two new objects, I think that the bindings to the GTK+ 2.18 release which I'm compiling against is almost done. When all objects have some level of support, then I think it would be possible to notch up an other release - 0.9.96 or thereabouts.

Here's a test code snippet for these new widgets.


set lo [gnocl::layout -width 500 -height 4000]

set but1 [gnocl::button -text "Button"]
set but2 [gnocl::button -text "DEL $but1"]

set x 10

$lo add $but1 -x $x -y 10
$but1 configure -onClicked {$lo move %w -x [incr x 10] -y 10}

$lo add $but2 -x $x -y 50
$but2 configure -onClicked {$lo remove $but1}

gnocl::window -child $lo -title "Layout"

set but3 [gnocl::button -text "BUTTON-3" -onClicked {puts "HELLO [$af cget -xalign]" } ]
set af [gnocl::aspectFrame -child $but3 -xalign 0.5]
gnocl::window -child $af -title "Aspect Frame"

The gnocl::aspectFrame module has been quite interesting, as there are no  get-property functions for this object, I've had to take a peek at the Gtk+ sources. It was interesting, resulted in a long winded hack of the 'get' equivalent, which I promptly abandoned and handled the whole lot through pointers.




No comments: