Penpad - 1.2

a small widget for free-hand drawing.

Table Of Contents

NAME

penpad - a small widget for free-hand drawing.

SYNOPSIS

package require Penpad

penpad pathName ?options?

INTRODUCTION

penpad is a small widget for free-hand drawing.

A Penpad is simply a canvas-widget with some builtin capabilities.

The primary use of penpad is to provide a standard component (widget) for hand-written signatures (autograph), to be inserted/affixed with electonic-signatures on documents.

STANDARD OPTIONS

All canvas options are supported.

They can be managed with the classic cget and configure commands.

Be careful that some standard options could be meaningless in a penpad context. Use them with care ..

PENPAD-SPECIFIC OPTIONS

-penstate state
This option can enable/disable the pen-tracing. Accepted values for state are : normal, disabled, Default value is normal
-pencolor color
This option specifies the pen color. Color may have any of the forms accepted by Tk_GetColor. This option defaults to black
-penthickness thickness
Specifies the thickness of the pen. thickness is a floating-point number optionally followed by c (centimeters), m (millimeters), i (inches), p (printers points (1/72 inch)). If no suffix is present, thickness is in screen-units (pixels). This option defaults to 1.0.

WIDGET COMMANDS

All canvas widget commands are supported, including the standard cget and configure commands. Use them with care ..

EXTENDED COMMANDS

pathName clean
Clean the penpad. Note that only the free-hand scribbles are deleted. If you need to delete everything, use

pathname delete all

If you need to delete the special penpad-background (see import), use the special tag _penpadBg

pathname delete _penpadBg

pathName export filename ?option value(s) ...?
Write the penpad contents to a file named filename. Note that if filename is equal to -clipboard, then the penpad contents is copied to the clipboard (only on Windows; on other platform it has no effect). See the photo command (and Img extension) for valid option.

If the first option is -transparency, then the penpad background color is saved as transparent (this is valid only for those file formats supporting transparency). Be aware of this option; it is very time-consuming, depending on the size of the penpad

NOTE: -transparency option is ignored when copying to the clipboard.

Example:
          # save as JPEG
         $w export myhand.jpeg -format {jpeg -quality 90}
          # save as GIF
         $w export myhand.gif
          # save as GIF, with transparency
         $w export myhand.gif -transparency
          # save to the clipboard
         $w export -clipboard
pathName import filename ?option value(s) ...?
Load an image from filename (it should be a supported file-format) and place it as a special background. By default this image is placed centered in the current penpad-widget. This image is a special floating background, since whenever the widget is resized, the image position is automatically adjusted so that it always appears centered (see -anchor position**).

Note that if filename is equal to -clipboard, then the penpad contents is imported from the clipboard (only on Windows; on other platform it has no effect).

The following options are supported:
-anchor where
Specifies where the image should be placed. Must be one of the values n, ne, e, se, s, sw, w, nw, or center. Default is center

BINDINGS

Penpad-widgets are created with class bindings that give them default behavior:

EXAMPLE

   package require Penpad
   
   penpad .penbox -bg yellow -pencolor blue
   pack .penbox
  
    # now you can start drawing ....
   
    # you can now save your scribbles...
    .penbox export mywork.gif
    
    # you can now clean the penpad ...
   .penbox clean
   

In general, with penpad you are free to use all canvas commands.

NOTES

All your free-hand scribbles are line-items with a tag named _penpadTrace.

Tag _penpadBg is internally used for the special background-image.

Although you are free to manipulate the penpad through all standard canvas commands, do not use these special tags.

CUSTOM CURSORS

Penpad provides two custom cursors, available for Windows and Unix platform (sorry Mac). These cursors can be referenced through two special variables:

and can be set by using the standard configure -cursor command. Default is $penpad::pen_right, but you are free to set any standard cursor or, if you are a left-handed people, you might find useful setting

pathName configure -cursor $penpad::pen_left

TK OPTION DATABASE

A simple command like

    penpad .x

creates a new widget with 'standard' options values.

These options can be of course changed for a specific widget instance

If you want to set different default values for all your next penpads, you should use the standard option database mechanism:

     option add *Canvas.Pencolor     green
     option add *Canvas.Penthickness 2
     option add *Canvas.Background   blue
     penpad .z1
     penpad .z2 -background yellow
     ...

NOTE that

HISTORY