gnocl::ruler


A widget that provides horizontal and vertical rulers.

Synopsis

gnocl::ruler [-option value...]

Screenshot


Options

-cursor string (default: 0)

Whether or not the status icon blinks.
-data string
User defined data which can be retrieved via the cget subcommand.
-lower double (default: 0)
Lower limit of ruler.
-maxSize  double (default: 0)
Maximum size of the ruler.
-metric string (default: "pixels")
The metric used for the ruler. Choose from one of pixels, inches or centimeters.
-name string
Name of the widget, can be used to set options in an rc file.
-onShowHelp string (default: "")
Tcl command which is executed in the global scope if the "show-help" signal is received, which is normally the case if the user presses F1 or Ctrl-F1. Before evaluation the following percent strings are substituted:

%w   widget name
%h   help type: either "whatsThis" or "tooltip"
-orientation string (default: "horizontal")
  Ruler orientation, one of horizontal or vertical.
-position double (default: 0)
Position mark of the ruler.
-tooltip string (default: "")

Message that appear next to this widget when the mouse pointer is held over it for a short amount of time.
-upper double (default: 0)
Upper limit of the ruler.
-sensitive boolean (default: 1)
Whether or not the item is sensitive to user input.
-visible boolean (default: 1)
Whether or not the item is visible.

Description

Provide veritcal and horizontal rulers for use primarily in graphics applications.

Commands

id cget option

Returns the value for the specified option. The option may have any of hte values accepted by configure.

id class

Returns the class of the widget, i.e. statusIcon.

id configure [-option value...]

Configures the widget. Option may have any of the values accepted on creation of the widget.
id delete
Deletes the widget and the associated tcl command.

Example

package require Gnocl


set hrul [gnocl::ruler -metric pixels -maxSize 210 ]
set vrul [gnocl::ruler -orientation vertical -metric pixels -maxSize 297]

set tab [gnocl::table -homogeneous 0 -rowSpacing 0 -columnSpacing 0]
set da [gnocl::drawingArea ]


$tab addRow [list "" ""]
$tab addRow [list "" ""]


set box [gnocl::box]

$tab add $box  0 0 -fill {0 0} -expand {0 0} -padding 0
$tab add $hrul 1 0 -fill {1 0} -expand {1 0}
$tab add $vrul 0 1 -fill {0 1} -expand {0 1}
$tab add $da 1 1 -fill {1 1} -expand 1

gnocl::window -child $tab -width 210 -height 297

$da option add -onButtonMotion
$da configure -onButtonMotion {
    puts "%x %y YIPPEEE!!!"
    $hrul configure -position %x
    $vrul configure -position %y
    }


# add options...
$da option add [list \
    -onPointerMotion \
    -onButtonPress \
    -onButtonRelease \
    -onKeyPress \
    -onKeyRelease \
    -onExpose]

# configure them
$da configure \
    -onPointerMotion {
        addPoint %w %x %y
        puts "%x %y"
        $hrul configure -position [expr %x -20]
        $vrul configure -position [expr %y -20]
        } \
    -onButtonPress {
        puts "-- Start Drawing --"
        set draw 1
        %w configure -cursor pencil } \
    -onButtonRelease {
        puts "-- End Drawing --"
        set draw 0
        %w configure -cursor last } \
    -onKeyPress {puts "Press"} \
    -onKeyRelease {puts "Release"} \
    -onExpose { reDraw %w }

set draw 0
set points {}

proc addPoint { w x y } {
    if { $::draw } {
        lappend ::points [list $x $y]
        $w draw point [list $x $y]
    }
}

proc reDraw {w} {
    foreach point $::points {
        $w draw point $point
    }
}


gnocl::mainLoop

Comments