Class Canvaseditor

Class canvaseditor deals with objects dot, line, fill, group. Constructor takes canvas window as argument. Contextmenu only. Pointer coords are store on right mouse-key.

Common data: instances to calculate ID for XML processing.

Private data: settings, selection, undoStack, redoStack, undonePtr, destroyAction to be iinvoked by destructor, memory for different purposes.

Constructor parameters: canvas window and optional action to be done on destroy.

obj class canvaseditor -common "
  instances {}
  garbage [obj new group]
obj constructor canvaseditor {canvas {destroyAction {}}} {
  ::destroy $canvas.x $canvas.y
  $canvas configure\
    -xscrollcommand "[scrollbar $canvas.x\
      -orient horizontal\
      -command "$canvas xview"] set"\
    -yscrollcommand "[scrollbar $canvas.y\
      -orient vertical\
      -command "$canvas yview"] set"
  variable level
  incr level($canvas)
  if {$self ni [our instances]} then {
    our instances [list {*}[our instances] $self]
  my destroyAction $destroyAction
  my zoom [obj inscope dot set zoom]
  my canvas $canvas
  my defaultmessage Ready
  my memory {
    before {}
    after {}
    transformation {}
  my settings [dict create filename ""\
    width [winfo reqwidth $canvas]\
    height [winfo reqheight $canvas]\
    background gray95\
    svgtool eog\
    pstool evince]
  my undoStack {}
  my redoStack {}
  my undonePtr 0
  my lastFillColor white
  my lastLineColor black
  my selection {}
  if {![winfo exists $canvas]} then {
    ::canvas $canvas
  $canvas configure -highlightthickness 0\
    -background [$self setting background]\
    -width [$self setting width]\
    -height [$self setting height]\
    -scrollregion "0 0\
      [* [my zoom] [$self setting width]]\
      [* [my zoom] [$self setting height]]"
  $self buildMenu
  $self basicBindings
obj destructor canvaseditor {
  variable level
  incr level([my canvas]) -1
  set index [lsearch [our instances] $self]
  our instances [lreplace [our instances] $index $index]
  $self basicBindings off
  apply [list self [my destroyAction]] $self

© Wolf-Dieter Busch | Home | Sitemap | Urheber | A-Z