Wednesday, June 27, 2012

gnocl::text -- getSelectionBounds

Just added new command to the text widget functionality to retrieve the bounds of the text buffer selection. If there is no selection, then an empty string is returned, otherwise there is a list of four integers, in the form startRow startCol endRow endCol.

# test-selectionBounds.tcl
exec tclsh "$0" "$@"
package require Gnocl

set txt [gnocl::text -wrapMode word]
$txt configure -onButtonRelease {
    puts [%w getSelectionBounds]

$txt lorem
gnocl::window -child $txt -setSize 0.25

Tuesday, June 12, 2012

gnocl::setStyle -new command

Gtk regards many widget properties as part of a system theme and are called 'style properties' and are not generally accessible via the Gtk+ api. The defaults for the widget can be over-ridden during run time and the loading of a resource file is an example of this. An alternative route, one in which only single changes are intended, can be taken using the new gnocl::setStyle command. This takes three arguments, the specific widget name, the style property name and the value to be assigned.  By default the widget names are NULL strings and, at present, can only be set following widget creation. One useful trick is to name the widget with its own gnocl id. The following script and screenshot show the command at work.

# test-style.tcl
exec tclsh "$0" "$@"

package require Gnocl

set ent(1) [gnocl::entry -name b1 -value "Gnocl"]
set ent(2) [gnocl::entry -name b2 -value "Gnocl"]
set ent(3) [gnocl::entry -name b3 -value "Gnocl"]

# use gnocl id as name
$ent(3) configure -name $ent(3)

puts "1 >>>[$ent(1) cget -name]"
puts "2 >>>[$ent(2) cget -name]"
puts "3 >>>[$ent(3) cget -name]"

gnocl::setStyle b1 {fg[ACTIVE]} "#FF0000"
gnocl::setStyle b1 font_name "Sans Bold 14"
gnocl::setStyle b1 {base[NORMAL]} "#FFFF00"
gnocl::setStyle b1 {text[NORMAL]} "#FF0000"
gnocl::setStyle b1 {bg[SELECTED]} "#FF0000"

gnocl::setStyle b2 font_name "Courier 14"
gnocl::setStyle b2 {text[NORMAL]} "#00FF00"
gnocl::setStyle b2 {base[NORMAL]} "#000000"

gnocl::setStyle $ent(3) {base[NORMAL]} "#0000FF"
gnocl::setStyle $ent(3) {text[NORMAL]} "#FFFFFF"

set box [gnocl::box -orientation vertical]
$box add $ent(1)
$box add $ent(2)
$box add $ent(3)

gnocl::window -child $box

Sunday, June 10, 2012

gnocl::progress -visible * NOW WORKING

In the Gtk2+ Libs the "visible" property in GtkProgress widget is not implemented. In order todo this the commands gtk_widget_show and  gtk_widget_hide have to be called. Hitherto it was possible to set the gnocl::progresssBar -visible option but it would have no effect. This has now been remedied. It will respond as expected.