Had enough of gnocl::wand for the meantime and so I've spent this evening working through the code stubs for printing. The basics were there but nothing really useful. Today I made some useful headway into fully implementing print functionality for disk based text files and for direct printing from a text widget. At the moment only plain text is supported and I'm not yet certain how to handle rich-text formatting.
The way in which Gtk+ prints is by first rendering up to a Cairo canvas and then printing out the graphic content. If the Gnocl side needs to handle the formatting then this could be a lengthy implementation job. Here's the test-script to show how things are progressing.
The way in which Gtk+ prints is by first rendering up to a Cairo canvas and then printing out the graphic content. If the Gnocl side needs to handle the formatting then this could be a lengthy implementation job. Here's the test-script to show how things are progressing.
#---------------
# test-print.tcl
#---------------
# Author: William J Giddings
# Date: 06/01/11
#---------------
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
#---------------
package require Gnocl
proc doPrintFile {} {
puts [upvar level #0]
gnocl::print file test-print.tcl
}
proc doPrintWidget {} {
global txt
puts [upvar level #0]
gnocl::print widget $txt start end
}
proc doWidgetPrint {} {
global txt
puts [upvar level #0]
$txt print start end
}
set tb [gnocl::toolBar]
$tb add item -text "PRINT FILE" -onClicked {doPrintFile}
$tb add item -text "PRINT WIDGET" -onClicked {doPrintWidget}
$tb add item -text "WIDGET PRINT" -onClicked {doWidgetPrint}
set txt [gnocl::text -baseFont {Gentium 12} ]
set box [gnocl::box -orientation vertical]
$box add $tb
$box add $txt -fill {1 1} -expand 1
gnocl::window -child $box -widthRequest 300
# test-print.tcl
#---------------
# Author: William J Giddings
# Date: 06/01/11
#---------------
#!/bin/sh
# the next line restarts using tclsh \
exec tclsh "$0" "$@"
#---------------
package require Gnocl
proc doPrintFile {} {
puts [upvar level #0]
gnocl::print file test-print.tcl
}
proc doPrintWidget {} {
global txt
puts [upvar level #0]
gnocl::print widget $txt start end
}
proc doWidgetPrint {} {
global txt
puts [upvar level #0]
$txt print start end
}
set tb [gnocl::toolBar]
$tb add item -text "PRINT FILE" -onClicked {doPrintFile}
$tb add item -text "PRINT WIDGET" -onClicked {doPrintWidget}
$tb add item -text "WIDGET PRINT" -onClicked {doWidgetPrint}
set txt [gnocl::text -baseFont {Gentium 12} ]
set box [gnocl::box -orientation vertical]
$box add $tb
$box add $txt -fill {1 1} -expand 1
gnocl::window -child $box -widthRequest 300
Comments