SR Technology WTK Repo
Check-in [0b61c414a1]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Further fixes for the canvas Added different shapes to the sketch demo
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0b61c414a1c37d8df683b9d18d6cdf1bba1cb56b
User & Date: seandeelywoods 2013-02-12 20:55:20
Context
2013-03-05
00:01
De-snitted a lot of the event handlers Added a new "options_dict" method for introspecting options. The odie way of handling properties collapsed horribly if there happened to be an option named -options (as we see in the combobox...) Added "my variable" to methods that were relying on the "variable" keyword in the class definition magically working Developed a TclOO implementation of traced variable event linking Updated to the latest ODIE, which adds mutexes, fixes a few bugs with properties, etc. (See odie fossil timeline) check-in: 9a05a8cffa user: seandeelywoods tags: trunk
2013-02-12
20:55
Further fixes for the canvas Added different shapes to the sketch demo check-in: 0b61c414a1 user: seandeelywoods tags: trunk
20:29
Added oval, circle, and arc types to the canvas/wtk.js Modified the "graft" keyword such that calling the method of a graft with no arguments returns the object The wtk widget classes now fall back to the traditional unknown handler if the first argument does not look like a tkpath check-in: bb947dbc82 user: seandeelywoods tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to sketch.tcl.

3
4
5
6
7
8
9
10
11
12
13
14
15












::wtk::bind .c <1> "set x %x; set y %y"
::wtk::bind .c <B1-Motion> { 
   .c create line $x $y %x %y -fill $color
   set x %x; set y %y
}

set colors "black blue red green yellow orange brown"
::wtk::grid [::wtk::canvas .palette -background #cccccc -width 400 -height 30] -column 0 -row 2
set x 25
foreach i $colors {
    .palette bind [.palette create rectangle $x 5 [expr {$x+25}] 25 -fill $i] <1> "set color $i"
    incr x 28
}



















|





>
>
>
>
>
>
>
>
>
>
>
>
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
::wtk::bind .c <1> "set x %x; set y %y"
::wtk::bind .c <B1-Motion> { 
   .c create line $x $y %x %y -fill $color
   set x %x; set y %y
}

set colors "black blue red green yellow orange brown"
::wtk::grid [::wtk::canvas .palette -background #cccccc -width 400 -height 30] -column 0 -row 1
set x 25
foreach i $colors {
    .palette bind [.palette create rectangle $x 5 [expr {$x+25}] 25 -fill $i] <1> "set color $i"
    incr x 28
}
::wtk::grid [::wtk::canvas .shapes -background #cccccc -width 400 -height 30] -column 0 -row 2
set x 25
.shapes create rectangle $x 5 [expr {$x+25}] 25
incr x 28
.shapes create line      $x 5 [expr {$x+25}] 25
incr x 28
.shapes create oval      $x 5 [expr {$x+20}] 25
incr x 28
.shapes create oval      [list $x 5 [expr {$x+30}] 25]
incr x 33
.shapes create circle    [expr {$x+10}] 15 10 -fill green -width 0
incr x 33

Changes to widgets/canvas.tcl.

32
33
34
35
36
37
38

39
40
41


42
43



44
45
46
47
48
49
50
    my variable nextid
    set itemtypes [my property itemtypes]
    if {![dict exists $itemtypes $itemtype]} {
      error "bad item type: $itemtype. Valid: [dict keys $itemtypes]"
    }
    if [catch {
    set optmap [dict get $itemtypes $itemtype]

    set cid [incr nextid]
    if {[llength $coords]==1} {
      set idx -1


      while {[string is double [lindex $args [incr idx]]]} {
        lappend coords [lindex $args $idx]



      }
      set args [lrange $args $idx end]
    }
    foreach {var val} $args {
      if {![dict exists $optmap $var]} {error "bad option $var"}
      lappend opts "[dict get $optmap $var]:\"$val\""
    }







>



>
>
|
|
>
>
>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    my variable nextid
    set itemtypes [my property itemtypes]
    if {![dict exists $itemtypes $itemtype]} {
      error "bad item type: $itemtype. Valid: [dict keys $itemtypes]"
    }
    if [catch {
    set optmap [dict get $itemtypes $itemtype]
    set opts {}
    set cid [incr nextid]
    if {[llength $coords]==1} {
      set idx -1
      set n [llength $args]
      for {set idx 0} {$idx < $n} {incr idx} {
        if {[string is double [lindex $args $idx]]} {
          lappend coords [lindex $args $idx]
        } else {
          break
        }
      }
      set args [lrange $args $idx end]
    }
    foreach {var val} $args {
      if {![dict exists $optmap $var]} {error "bad option $var"}
      lappend opts "[dict get $optmap $var]:\"$val\""
    }