Friday, February 19, 2010

New Image Command: turn

Hitherto you could load an image file, resize it and that was it. Basically, the image file did little else. In one of my applications Scandocs which I use to create eBooks of various sorts, I wanted to view my double page scans the right way up. Hence this command. The timing of its creation pretty well coincides with the implementation of a similar command for the gnocl::pixBuf, and for one very good reason -they use the same library calls. Anyway, this is how it works:

set pb4 [gnocl::pixBuf load "wjg.jpg"]
set img1 [gnocl::image -image  "%?$pb4"]

set but1 [gnocl::button \
   -text "Turn" \
   -onClicked { $img1 turn 90 } ]

set box1 [gnocl::box -orientation vertical]
$box1 add $but1
$box1 add $img1 -fill {1 1} -expand 1

set win1 [gnocl::window \
   -child $box1 \
   -widthRequest 200 \
   -heightRequest 200 \
   -allowShrink 0 \
   -alllowGrow 0 ]

No comments: