SR Technology WTK Repo
Check-in [9a05a8cffa]
Not logged in

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

Overview
Comment: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)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9a05a8cffabe0b07d3622c7a631485dccb50584f
User & Date: seandeelywoods 2013-03-05 00:01:52
Context
2013-03-07
04:11
Start of private SAPUI5 branch edits. Leaf check-in: d092328cde user: gerald tags: trunk
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/wtk-base.tcl.

62
63
64
65
66
67
68


69
70
71
72
73
74
75
76
77
78
79
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
...
144
145
146
147
148
149
150
151
152

153
154
155
156
157
158
159
...
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180




181

182
183
184

185

186
187
188
189
190
191
192
193
194
195






















196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
        variable id
        variable tkpath
        variable created
        variable wobj
        variable postcreatemsgs
        variable propertiesDict
        variable options



        constructor {new_tkpath args} {
          #puts [list WIDGET [info object class [self]] $new_tkpath $args]
          my variable id tkpath postcreatemsgs created options
          set created 0
          set postcreatemsgs {}
          set tkpath $new_tkpath
          if { $tkpath eq "." } {
            # used for root window only
            dict set propertiesDict class Toplevel
          }
................................................................................
          set id obj[incr ::wtk::_nextid]
          set wobj [self]
          oo::objdefine [self] forward tkpath $tkpath
          #my graft tkpath $tkpath

          dict set ::wtk::widgets($tkpath) id $id
          set ::wtk::wobj($id) [self]
          foreach {var info} [my property options] {
            set options(-$var) [dictGet $info -default]
          }
          
          my configurelist {*}$args
          return $new_tkpath
        }
        

        class_method unknown {objname args} {
          if {[string index $objname 0] eq "."} {
................................................................................
          } else {
            my configurelist {*}$args
          }
        }

        method configurelist args {
          my variable options
          set dat [my info options]
          

          foreach {var val} $args {
            set field  [string trimleft $var -]
            if {![dict exists $dat $field]} {
              error "Invalid option $var. Valid: [dict keys $dat]"
            }
            set info [dict get $dat $field]
            set options($var) $val
................................................................................
        }

        method cget field {
          my variable options
          set field [string trimleft $field -]

          if {![info exists options(-$field)]} {
            set dat [my info options]
            if {![dict exists $dat $field]} {
              error "Invalid option -$field. Valid: [dict keys $dat]"
            }
            set info [dict get $dat $field]
            set options(-$field) [dictGet $info -default]
          }
          return $options(-$field)
        }







        method id {} {return $id}
        method jqobj {} {return "\$('#[my id]')"}
        method jsobj {} {return "wtk.widgets\['[my id]'\]"}

        method event_focus {} {toclient "[my jsobj].focus();"}




        # TODO - variable handling; only relevant if -variable option is delegated to us


        # bindings
        variable bindings
        method action_bind {ev script} {set bindings($ev) $script}
        method event_fire {ev subs} {if {[info exists bindings($ev)]} {uplevel #0 [string map $subs $bindings($ev)]}}






















    }

    ::odie::class ::wtk::LabelWidget {
      superclass ::wtk::Widget
      
      
      # text variable handling; only relevant if the main types delegate these options to us
      option -text -configuremethod event_textchanged
      option -textvariable -configuremethod event_textvarset
      
      method event_textchanged {opt txt {fromwidget 0}} {
        my variable created options
        set options($opt) $txt
        if {$created && !$fromwidget} {
          ::wtk::toclient [my _textchangejs $txt]
        }
        
        if {$options(-textvariable)!=""} {
          uplevel #0 set $options(-textvariable) [list $txt]
        }
      }
      method event_textvariablechanged {args} {
        my variable options
        if {$options(-text) ne [uplevel #0 set $options(-textvariable)]} {
            my event_textchanged -text [uplevel #0 set $options(-textvariable)]
................................................................................
                [format {bad window path name "%1$s"} $window]
        }
        return;
    }

    proc focus {w} {$w event_focus; return ""}
    proc bind {w ev script} {return [$w action_bind $ev $script]}

    # Macro that can be used to simplify the definition of any widget
    ::odie::macro _wtkwidget {args} {
        component W; delegate method * to W; set extrainits ""
        if {"-usetextvar" in $args} {delegate option -textvariable to W; delegate option -text to W; set extrainits {$W event_setuptextvar}}
        constructor {args} "install W using Widget \$\{selfns\}::W \$self; \$self configurelist \$args; $extrainits"
    }


    # Macro used to define options which set their value and then send some Javascript command to the widget
    ::odie::macro _wtkoption {opt default msg} {
        option $opt -default $default -configuremethod _wtkoption$opt
        method _wtkoption$opt {opt val} "
        my variable options
        set opt [string trimleft $opt -]
        set options(\$opt) \$val
        set JS \[my jsobj\]
        set V \$val
        my action_sendWhenCreated \[subst [list $msg]\]
        "
    }

}


foreach file [glob -- commands/*.tcl] {
    source $file
}
foreach file [glob -- geomanagers/*.tcl] {
    source $file
}
source widgets/wtk-widgets.tcl







>
>



|







 







|
<
<
<







 







<

>







 







|









>
>
>
>
|
>



>
|
>










>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









|







|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
..
82
83
84
85
86
87
88
89



90
91
92
93
94
95
96
...
143
144
145
146
147
148
149

150
151
152
153
154
155
156
157
158
...
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
...
279
280
281
282
283
284
285






















286
287
288
289
290
291
292
293
294
295
        variable id
        variable tkpath
        variable created
        variable wobj
        variable postcreatemsgs
        variable propertiesDict
        variable options

        

        constructor {new_tkpath args} {
          #puts [list WIDGET [info object class [self]] $new_tkpath $args]
          my variable id tkpath postcreatemsgs created
          set created 0
          set postcreatemsgs {}
          set tkpath $new_tkpath
          if { $tkpath eq "." } {
            # used for root window only
            dict set propertiesDict class Toplevel
          }
................................................................................
          set id obj[incr ::wtk::_nextid]
          set wobj [self]
          oo::objdefine [self] forward tkpath $tkpath
          #my graft tkpath $tkpath

          dict set ::wtk::widgets($tkpath) id $id
          set ::wtk::wobj($id) [self]
          my init_options



          my configurelist {*}$args
          return $new_tkpath
        }
        

        class_method unknown {objname args} {
          if {[string index $objname 0] eq "."} {
................................................................................
          } else {
            my configurelist {*}$args
          }
        }

        method configurelist args {
          my variable options

          
          set dat [my option_dict]
          foreach {var val} $args {
            set field  [string trimleft $var -]
            if {![dict exists $dat $field]} {
              error "Invalid option $var. Valid: [dict keys $dat]"
            }
            set info [dict get $dat $field]
            set options($var) $val
................................................................................
        }

        method cget field {
          my variable options
          set field [string trimleft $field -]

          if {![info exists options(-$field)]} {
            set dat [my option_dict]
            if {![dict exists $dat $field]} {
              error "Invalid option -$field. Valid: [dict keys $dat]"
            }
            set info [dict get $dat $field]
            set options(-$field) [dictGet $info -default]
          }
          return $options(-$field)
        }

        method init_options args {
          my variable options
          foreach {var info} [my option_dict] {
            set options(-$var) [dictGet $info -default]
          }
        }
        method id {} {return $id}
        method jqobj {} {return "\$('#[my id]')"}
        method jsobj {} {return "wtk.widgets\['[my id]'\]"}
        method event_focus {} {
          ::wtk::toclient "[my jsobj].focus();"
        }



        # TODO - variable handling; only relevant if -variable option is delegated to us


        # bindings
        variable bindings
        method action_bind {ev script} {set bindings($ev) $script}
        method event_fire {ev subs} {if {[info exists bindings($ev)]} {uplevel #0 [string map $subs $bindings($ev)]}}
    

      # Macro that can be used to simplify the definition of any widget
      ::odie::macro _wtkwidget {args} {
          component W; delegate method * to W; set extrainits ""
          if {"-usetextvar" in $args} {delegate option -textvariable to W; delegate option -text to W; set extrainits {$W event_setuptextvar}}
          constructor {args} "install W using Widget \$\{selfns\}::W \$self; \$self init_options \;\$self configurelist \$args; $extrainits"
      }
  
  
      # Macro used to define options which set their value and then send some Javascript command to the widget
      ::odie::macro _wtkoption {opt default msg} {
          option $opt -default $default -configuremethod _wtkoption$opt
          method _wtkoption$opt {opt val} "
          my variable options
          set opt [string trimleft $opt -]
          set options(\$opt) \$val
          set JS \[my jsobj\]
          set V \$val
          my action_sendWhenCreated \[subst [list $msg]\]
          "
      }
    }

    ::odie::class ::wtk::LabelWidget {
      superclass ::wtk::Widget
      
      
      # text variable handling; only relevant if the main types delegate these options to us
      option -text -configuremethod event_textchanged
      option -textvariable -configuremethod event_textvarset

      method event_textchanged {opt txt {fromwidget 0}} {
        my variable created options
        set options($opt) $txt
        if {$created && !$fromwidget} {
          ::wtk::toclient [my _textchangejs $txt]
        }
        
        if {[get options(-textvariable)]!=""} {
          uplevel #0 set $options(-textvariable) [list $txt]
        }
      }
      method event_textvariablechanged {args} {
        my variable options
        if {$options(-text) ne [uplevel #0 set $options(-textvariable)]} {
            my event_textchanged -text [uplevel #0 set $options(-textvariable)]
................................................................................
                [format {bad window path name "%1$s"} $window]
        }
        return;
    }

    proc focus {w} {$w event_focus; return ""}
    proc bind {w ev script} {return [$w action_bind $ev $script]}






















}


foreach file [glob -- commands/*.tcl] {
    source $file
}
foreach file [glob -- geomanagers/*.tcl] {
    source $file
}
source widgets/wtk-widgets.tcl

Changes to odie/moac.tcl.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
...
242
243
244
245
246
247
248



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266

267
268
269
270
271
272
273
...
275
276
277
278
279
280
281
282




























283
284

285
286
287
288
289
290
291

292

293


294
295
296
297
298
299
300
...
307
308
309
310
311
312
313
314
315
316
317
318







319




















# topic: 5539066c-3e90-2cbd-b008-77a2eb4e7acd
# title: Mother of all Classes
# description:
#    Base class used to define a global
#    template of expected behaviors
###
odie::class moac {
  variable objectInfo
  

  ###
  # topic: 3c54cd52-e671-de60-2102-ebf9d5562a2d
  ###
  method debugOut string {}

  ###
  # topic: dfd570ca-bd5e-28af-f080-8fc28d36b54d
................................................................................
    oo::objdefine [self] forward $method {*}$args
  }

  ###
  # topic: 92971042-7138-47f7-88b0-7704312df200
  ###
  method get {{field {}}} {
    my variable objectInfo
    if { $field == {} } {
      set result {}
      foreach f [::info object vars [self]] {
        my variable $f
        if {[array exists $f]} {
          dict set result @$f [::array get $f]
        } else {
................................................................................
  }

  ###
  # topic: e1c1cccb-5201-997d-e0c5-4e04394b61e2
  ###
  method graft args {
    my variable organs



    foreach {stub object} $args {
      set stub [string trimleft $stub /]
      logicset add organs $stub
      ###
      # For backward compadibility
      ###
      my put [list $stub $object]
      set body [string map [list %OBJECT% $object] {
        if {[llength $args]==0} {
          return %OBJECT%
        }
        return [%OBJECT% {*}$args]
      }]
      oo::objdefine [self] method $stub args $body 
      #my forward ${stub} $object
      # Provide a more standard "/->object" stub
      #my forward /${stub} $object
    }

  }

  ###
  # topic: df00845e-dcbf-6f93-65b9-ee824513102a
  ###
  method morph newclass {
    set class [string trimleft [info object class [self]]]
................................................................................
    if {[info command $newclass] eq {}} {
      error "Class $newclass does not exist"
    }
    if { $class ne $newclass } {
      oo::objdefine [self] class ::${newclass}
    }
  }





























  ###
  # topic: 3826d482-8446-2b39-4590-1d02d1ba67e2

  ###
  method organsExport {} {
    my variable organs
    set result {}
    if {![info exists organs]} return
    foreach organ $organs {
      lappend result $organ [my get $organ]

    }

    return $result


  }

  ###
  # topic: 886b734b-f9a9-8aa7-82e8-f77b9a42c344
  ###
  method put args {
    if { [llength $args] == 1 } {
................................................................................
    }
  }

  ###
  # topic: 5b9a51d5-e327-84f0-8cb7-973e8f4115f0
  ###
  method sensai object {
    foreach {stub obj} [$object organsExport] {
      my graft $stub $obj
    }
  }
}



































<
<
<







 







<







 







>
>
>


<
<
<
<
|
<
<
<
<
<
<
<
|
<
<

>







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

<
>

|

<
|
<
<
>

>
|
>
>







 







|



|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
2
3
4
5
6
7
8



9
10
11
12
13
14
15
...
204
205
206
207
208
209
210

211
212
213
214
215
216
217
...
238
239
240
241
242
243
244
245
246
247
248
249




250







251


252
253
254
255
256
257
258
259
260
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298

299
300
301
302

303


304
305
306
307
308
309
310
311
312
313
314
315
316
...
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# topic: 5539066c-3e90-2cbd-b008-77a2eb4e7acd
# title: Mother of all Classes
# description:
#    Base class used to define a global
#    template of expected behaviors
###
odie::class moac {



  ###
  # topic: 3c54cd52-e671-de60-2102-ebf9d5562a2d
  ###
  method debugOut string {}

  ###
  # topic: dfd570ca-bd5e-28af-f080-8fc28d36b54d
................................................................................
    oo::objdefine [self] forward $method {*}$args
  }

  ###
  # topic: 92971042-7138-47f7-88b0-7704312df200
  ###
  method get {{field {}}} {

    if { $field == {} } {
      set result {}
      foreach f [::info object vars [self]] {
        my variable $f
        if {[array exists $f]} {
          dict set result @$f [::array get $f]
        } else {
................................................................................
  }

  ###
  # topic: e1c1cccb-5201-997d-e0c5-4e04394b61e2
  ###
  method graft args {
    my variable organs
    if {[llength $args] == 1} {
      error "Need two arguments"
    }
    foreach {stub object} $args {
      set stub [string trimleft $stub /]




      dict set organs $stub $object







      my forward ${stub} $object


    }
    return $object
  }

  ###
  # topic: df00845e-dcbf-6f93-65b9-ee824513102a
  ###
  method morph newclass {
    set class [string trimleft [info object class [self]]]
................................................................................
    if {[info command $newclass] eq {}} {
      error "Class $newclass does not exist"
    }
    if { $class ne $newclass } {
      oo::objdefine [self] class ::${newclass}
    }
  }

  method mutex {method flag} {
    switch $method {
      peek {
        my variable $flag
        if {![info exists $flag]} {
          set $flag 0
        }
        return [set $flag]
      }
      up {
        my variable $flag
        if {![info exists $flag]} {
          set $flag 0
        }
        set $flag 1
        return [set $flag]
      }
      down {
        my variable $flag
        set $flag 0
        return 0
      }
      default {
        error "Unknown method $method. Valid: up, down, peek"
      }
    }
  }

  ###

  # topic: 3f0b7f48-ed3b-d2d9-bf96-f7c8ca506146
  ###
  method organ {{stub all}} {
    my variable organs

    if {![info exists organs]} {


      return {}
    }
    if { $stub eq "all" } {
      return $organs
    }
    return [dictGet $organs $stub]
  }

  ###
  # topic: 886b734b-f9a9-8aa7-82e8-f77b9a42c344
  ###
  method put args {
    if { [llength $args] == 1 } {
................................................................................
    }
  }

  ###
  # topic: 5b9a51d5-e327-84f0-8cb7-973e8f4115f0
  ###
  method sensai object {
    foreach {stub obj} [$object organ all] {
      my graft $stub $obj
    }
  }

  ###
  # topic: acd18cd5-2335-dc26-7a3d-90f0bb8f8ef1
  ###
  method setting {field args} {
    my variable $field
    if {[llength $args]} {
      set $field [lindex $args 0]
    }
    return [if_null [::get $field] 0]
  }

  ###
  # topic: bda8baec-9227-ee0f-745c-7d3253d94b9c
  ###
  method trace {{onoff {}}} {
    my variable trace
    if { $onoff == {} } {
      return $trace
    }
    set trace $onoff
    if { $trace } {
      oo::objdefine [self] method debugOut string {puts [list [my simTime] [self] $string]}
    } else {
      oo::objdefine [self] method debugOut string {}
    }
  }
}

Changes to odie/ootools.tcl.

2
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
28
..
57
58
59
60
61
62
63



64
65
66
67
68
69
70
...
292
293
294
295
296
297
298

299

300
301
302
303


304
305
306
307
308
309
310
...
318
319
320
321
322
323
324



325
326
327
328
329
330
331

::namespace eval ::classDefine {}

::namespace eval ::odie {}

::namespace eval ::viewobj {}


###
# topic: 14474616-1674-47d6-673c-5059adc6bbb0

###
proc ::classDefine::class_method {name arglist body} {  
  method $name $arglist $body
  dict set ::class_property([peek]) class_methods $name [list arglist $arglist body $body]
}




proc ::classDefine::component args {
  
}




proc ::classDefine::delegate {keyword object args} {
  switch $keyword {
    method {}
    option {}
    typemethod -
    class_method {} 
  }
................................................................................
  if {[string first : $rawmethod] < 0} {
    ::oo::define $class method $rawmethod {*}$args
    return
  }
  dict set ::class_ensemble($class) $rawmethod [lindex $args end]
}




proc ::classDefine::option {name args} {
  ::global class_property
  set class [peek]
  dict set class_property($class) [string trimleft $name -] [list option $args]
}

###
................................................................................
        append body \n " [list $var [list return $val]]"
      }
    }
  }
  ###
  # Build options
  ###

  append body \n "  [list options [list return $optiondict]]"

  append body \n "\}"
  append body \n {return [my get $field]}
  oo::define $class method info field $body
  oo::define $class method property field $body



  set cmethods {}
  foreach {method methodinfo} [dictGet $info class_methods] {
    dict with methodinfo {
      logicset add cmethods $method
      ::oo::objdefine $class method $method [get arglist] [get body]
    }
................................................................................
        logicset add cmethods $method
        ::oo::objdefine $class method $method [get arglist] [get body]
      }
    }
  }
}




proc ::odie::macro {name arglist body} {
  proc ::classDefine::$name $arglist $body
}

###
# topic: bcb549b7-ddbc-16e1-aafe-14cf30ed039a
# description: Work space for the IRM class parser







<

<
>






>
>
>




>
>
>







 







>
>
>







 







>

>




>
>







 







>
>
>







2
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
28
29
30
31
32
33
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
...
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
...
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346

::namespace eval ::classDefine {}

::namespace eval ::odie {}

::namespace eval ::viewobj {}


###

# topic: 56ba79b6-8470-1768-5b00-5164127b4ceb
###
proc ::classDefine::class_method {name arglist body} {  
  method $name $arglist $body
  dict set ::class_property([peek]) class_methods $name [list arglist $arglist body $body]
}

###
# topic: 9fee82d2-ae53-7c1d-76c6-f581b7523165
###
proc ::classDefine::component args {
  
}

###
# topic: 2bc6c677-0bda-1995-4549-51349463a4ff
###
proc ::classDefine::delegate {keyword object args} {
  switch $keyword {
    method {}
    option {}
    typemethod -
    class_method {} 
  }
................................................................................
  if {[string first : $rawmethod] < 0} {
    ::oo::define $class method $rawmethod {*}$args
    return
  }
  dict set ::class_ensemble($class) $rawmethod [lindex $args end]
}

###
# topic: fd968700-a47f-5827-49f1-8d131fedd178
###
proc ::classDefine::option {name args} {
  ::global class_property
  set class [peek]
  dict set class_property($class) [string trimleft $name -] [list option $args]
}

###
................................................................................
        append body \n " [list $var [list return $val]]"
      }
    }
  }
  ###
  # Build options
  ###

  append body \n "  [list options [list return $optiondict]]"
  append body \n "  [list option_dict [list return $optiondict]]"
  append body \n "\}"
  append body \n {return [my get $field]}
  oo::define $class method info field $body
  oo::define $class method property field $body
  oo::define $class method option_dict {} [list return $optiondict]


  set cmethods {}
  foreach {method methodinfo} [dictGet $info class_methods] {
    dict with methodinfo {
      logicset add cmethods $method
      ::oo::objdefine $class method $method [get arglist] [get body]
    }
................................................................................
        logicset add cmethods $method
        ::oo::objdefine $class method $method [get arglist] [get body]
      }
    }
  }
}

###
# topic: 65511c4b-21db-02f9-135f-c8fc4f66f59f
###
proc ::odie::macro {name arglist body} {
  proc ::classDefine::$name $arglist $body
}

###
# topic: bcb549b7-ddbc-16e1-aafe-14cf30ed039a
# description: Work space for the IRM class parser

Changes to odie/yggdrasil.tcl.

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
...
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
...
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
...
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
...
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
...
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
...
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
...
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
    $alias function uuid_generate [list [self] uuid_generate]
  }

  ###
  # topic: 4c04478b-06d5-9bd5-8ae1-a6df2170d2e9
  ###
  method enum_dump class {
    return [my eval {select id,name from idset where class=:class order by id}]
  }

  ###
  # topic: a1250c93-e5cd-53c1-93df-d7832c47357c
  ###
  method enum_id {class name} {
    set arr ::irm::${class}_name_to_idx
................................................................................
  }

  ###
  # topic: f9685bcf-fb03-9e78-3938-4898c01a59c5
  ###
  method link_detect_address args {
    if {[my node_exists $args entryid]} {
      return [my eval {select entryid from entry where entryid=$entryid}]
    }
    ###
    # If the link contains a / we know it is a hard
    # path
    ###
    if {[my node_exists $args entryid]} {
      return $entryid
    }
    if {[llength $args] > 1} {
      set rootentries [my eval {select name from entry where class='section'}]
      
      if {[lindex $args 0] in $rootentries} {
        set type [lindex $args 0]
        set name [my canonical $type [lindex $args 1]]
        if {[my node_exists [list $type $name] entryid]} {
          return $entryid
        }
................................................................................
        set name [my canonical $type [lindex $args 0]]
        if {[my node_exists [list $type $name] entryid]} {
          return $entryid
        }
      }
    }
    set addr [lindex $args 0]
    set cnames [my eval {select class,cname from aliases where alias=$addr}]
  
    if {[llength $cnames] == 2} {
      if {[my node_exists $cnames entryid]} {
        return $entryid
      }
    }
    #if {[string first / $addr] > 0 } {
    #  return $addr
    #}
    set candidates [my eval {select entryid,name from entry where name like '%$addr%'}]
    foreach address $candidates {
      if {[regexp simnode $address]} {
        return $address
      }
    }
    #puts [list CAN'T RESOLVE $args]
    return $args
  }

  ###
  # topic: 612a2335-0b20-ae08-c159-97a025d11390
  ###
  method node_alloc_child {parent entry {class {}}} {
    if { $parent eq $class } {
      set row [my one {select entryid from entry where parent is null and class=$class and name=$entry}]
    } elseif { $class ne {} } {
      set row [my one {select entryid from entry where parent=$parent and class=$class and name=$entry}]    
    } else {
      set row [my one {select entryid from entry where parent=$parent and name=$entry}]    
    }
    if { [llength $row] && $row != $parent } {
      return $row
    }
    set row [my uuid_generate $parent $class $entry]
    if { $class eq $parent } {
      set row $parent/$entry
      my db eval {insert into entry (entryid,class,name) VALUES ($row,$parent,$entry)}
    } elseif { $class ne {} } {
      my db eval {insert into entry (entryid,parent,class,name) VALUES ($row,$parent,$class,$entry)}
    } else {
      my db eval {insert into entry (entryid,parent,name) VALUES ($row,$parent,$entry)}
    }
    return $row
  }

  ###
  # topic: 522463d0-c361-0c5e-1e00-06469359750b
  # description:
  #    Return a list of all children of node,
  #    Filter is a key/value list that understands
  #    the following:
  #    type - Limit children to type
  #    dump - Output the contents of the child node, not their id
  ###
  method node_children {nodeid class} {
    set dump 1
    set entryid [my node_id $nodeid]
    if { $class eq {} } {
      set nodes [my eval {select name,entryid from entry where parent=$entryid}]
    } else {
      set nodes [my eval {select name,entryid from entry where parent=$entryid and class=$class}]
    }
    if {!$dump} {
      return $nodes
    }
    set result {}
    foreach {cname cid} $nodes {
      dict set result $cname [my eval {select field,value from property where entryid=$cid order by field}]
    }
    return $result
  }

  ###
  # topic: b4954836-f396-6f2c-92cc-4c8251572bd8
  ###
................................................................................
        set nodeid [helpdoc node_id [list $class $name] 1]
        foreach {var val} [my node_empty $class] {
          my node_property_set $nodeid $var $val        
        }
      }
    } elseif {![my node_exists $nodeid]} {
      my canonical_set $class $name $name
      my eval {insert into entry (entryid,class,name) VALUES (:nodeid,:class,:name)}
      foreach {var val} [my node_empty $class] {
        my node_property_set $nodeid $var $val        
      }
    }
  
    foreach {var val} $info {
      my node_property_set $nodeid $var $val
................................................................................
      set nodeid {}
  
      if {[dict exists $info topic]} {
        set topicid [dict get $info topic]
        dict unset info topic
        if {![my db exists {select entryid from entry where entryid=:topicid}]} {
          # If we are recycling an unused UUID re-create the entry in the table
          my eval {insert into entry (entryid,parent,class,name) VALUES (:topicid,:parent,:class,:name)}
          set nodeid $topicid
        }
      }
      if { $nodeid eq {} } {
        set nodeid [my uuid_generate $parent $class $name]
      }
      if {[my db exists {select entryid from entry where entryid=:nodeid and class=:class and name=:name}]} {
        ###
        # Correct a misfiled node
        ###
        my db eval {update entry set parent=:parent where entryid=:nodeid}
      } else {
        my eval {insert into entry (entryid,parent,class,name) VALUES (:nodeid,:parent,:class,:name)}
      }
      foreach {var val} [my node_empty $class] {
        if {![dict exists $info $var]} {
          dict set info $var $val
        }
      }
    }
................................................................................
      if { $row eq {} } {
        if { $create } {
          if { $ename in $classes } {
            set eclass $token
            continue            
          } else {
            set eclass {}
            set row [my node_alloc_child $parent $ename $eclass]
          }          
        } else {
          error "Node $node does not exist"
        }
      }
      set parent $row
    }
................................................................................
    return $row
  }

  ###
  # topic: eb137c42-eacd-7016-7a91-7056ba96ed70
  ###
  method node_properties entryid {
    return [my eval {select field,value from property where entryid=$entryid}]
  }

  ###
  # topic: 8d72229b-f33b-acd0-cd41-b4584fa240eb
  ###
  method node_property_append {nodeid field text} {
    set buffer [my one {select value from property where entryid=:nodeid and field=:field}]
................................................................................

  ###
  # topic: c4e91fb2-44d0-aee6-8454-1effc7012081
  # description: nodeid is any value acceptable to {[my node_alloc]}
  ###
  method node_property_lappend {entryid field args} {
    if {![llength $args]} return
    set dbvalue [my eval {select value from property where entryid=$entryid and field=$field}]
    foreach value $args {
      if { $value eq {} } continue
      logicset add dbvalue $value
    }
    my db eval {update property set value=$dbvalue where entryid=$entryid and field=$field}
  }








|







 







|









|







 







|









|









<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<













|

|






|







 







|







 







|












|







 







|







 







|







 







|







191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
...
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
...
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406


























407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
...
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
...
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
...
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
...
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
...
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
    $alias function uuid_generate [list [self] uuid_generate]
  }

  ###
  # topic: 4c04478b-06d5-9bd5-8ae1-a6df2170d2e9
  ###
  method enum_dump class {
    return [my db eval {select id,name from idset where class=:class order by id}]
  }

  ###
  # topic: a1250c93-e5cd-53c1-93df-d7832c47357c
  ###
  method enum_id {class name} {
    set arr ::irm::${class}_name_to_idx
................................................................................
  }

  ###
  # topic: f9685bcf-fb03-9e78-3938-4898c01a59c5
  ###
  method link_detect_address args {
    if {[my node_exists $args entryid]} {
      return [my db eval {select entryid from entry where entryid=$entryid}]
    }
    ###
    # If the link contains a / we know it is a hard
    # path
    ###
    if {[my node_exists $args entryid]} {
      return $entryid
    }
    if {[llength $args] > 1} {
      set rootentries [my db eval {select name from entry where class='section'}]
      
      if {[lindex $args 0] in $rootentries} {
        set type [lindex $args 0]
        set name [my canonical $type [lindex $args 1]]
        if {[my node_exists [list $type $name] entryid]} {
          return $entryid
        }
................................................................................
        set name [my canonical $type [lindex $args 0]]
        if {[my node_exists [list $type $name] entryid]} {
          return $entryid
        }
      }
    }
    set addr [lindex $args 0]
    set cnames [my db eval {select class,cname from aliases where alias=$addr}]
  
    if {[llength $cnames] == 2} {
      if {[my node_exists $cnames entryid]} {
        return $entryid
      }
    }
    #if {[string first / $addr] > 0 } {
    #  return $addr
    #}
    set candidates [my db eval {select entryid,name from entry where name like '%$addr%'}]
    foreach address $candidates {
      if {[regexp simnode $address]} {
        return $address
      }
    }
    #puts [list CAN'T RESOLVE $args]
    return $args
  }



























  ###
  # topic: 522463d0-c361-0c5e-1e00-06469359750b
  # description:
  #    Return a list of all children of node,
  #    Filter is a key/value list that understands
  #    the following:
  #    type - Limit children to type
  #    dump - Output the contents of the child node, not their id
  ###
  method node_children {nodeid class} {
    set dump 1
    set entryid [my node_id $nodeid]
    if { $class eq {} } {
      set nodes [my db eval {select name,entryid from entry where parent=$entryid}]
    } else {
      set nodes [my db eval {select name,entryid from entry where parent=$entryid and class=$class}]
    }
    if {!$dump} {
      return $nodes
    }
    set result {}
    foreach {cname cid} $nodes {
      dict set result $cname [my db eval {select field,value from property where entryid=$cid order by field}]
    }
    return $result
  }

  ###
  # topic: b4954836-f396-6f2c-92cc-4c8251572bd8
  ###
................................................................................
        set nodeid [helpdoc node_id [list $class $name] 1]
        foreach {var val} [my node_empty $class] {
          my node_property_set $nodeid $var $val        
        }
      }
    } elseif {![my node_exists $nodeid]} {
      my canonical_set $class $name $name
      my db eval {insert into entry (entryid,class,name) VALUES (:nodeid,:class,:name)}
      foreach {var val} [my node_empty $class] {
        my node_property_set $nodeid $var $val        
      }
    }
  
    foreach {var val} $info {
      my node_property_set $nodeid $var $val
................................................................................
      set nodeid {}
  
      if {[dict exists $info topic]} {
        set topicid [dict get $info topic]
        dict unset info topic
        if {![my db exists {select entryid from entry where entryid=:topicid}]} {
          # If we are recycling an unused UUID re-create the entry in the table
          my db eval {insert or replace into entry (entryid,parent,class,name) VALUES (:topicid,:parent,:class,:name)}
          set nodeid $topicid
        }
      }
      if { $nodeid eq {} } {
        set nodeid [my uuid_generate $parent $class $name]
      }
      if {[my db exists {select entryid from entry where entryid=:nodeid and class=:class and name=:name}]} {
        ###
        # Correct a misfiled node
        ###
        my db eval {update entry set parent=:parent where entryid=:nodeid}
      } else {
        my db eval {insert or replace into entry (entryid,parent,class,name) VALUES (:nodeid,:parent,:class,:name)}
      }
      foreach {var val} [my node_empty $class] {
        if {![dict exists $info $var]} {
          dict set info $var $val
        }
      }
    }
................................................................................
      if { $row eq {} } {
        if { $create } {
          if { $ename in $classes } {
            set eclass $token
            continue            
          } else {
            set eclass {}
            my node_define_child $parent $eclass $ename {} row
          }          
        } else {
          error "Node $node does not exist"
        }
      }
      set parent $row
    }
................................................................................
    return $row
  }

  ###
  # topic: eb137c42-eacd-7016-7a91-7056ba96ed70
  ###
  method node_properties entryid {
    return [my db eval {select field,value from property where entryid=$entryid}]
  }

  ###
  # topic: 8d72229b-f33b-acd0-cd41-b4584fa240eb
  ###
  method node_property_append {nodeid field text} {
    set buffer [my one {select value from property where entryid=:nodeid and field=:field}]
................................................................................

  ###
  # topic: c4e91fb2-44d0-aee6-8454-1effc7012081
  # description: nodeid is any value acceptable to {[my node_alloc]}
  ###
  method node_property_lappend {entryid field args} {
    if {![llength $args]} return
    set dbvalue [my db eval {select value from property where entryid=$entryid and field=$field}]
    foreach value $args {
      if { $value eq {} } continue
      logicset add dbvalue $value
    }
    my db eval {update property set value=$dbvalue where entryid=$entryid and field=$field}
  }

Changes to widgets/button.tcl.

13
14
15
16
17
18
19
20
21
22
23
24
  
  method do_createjs {} {return "wtk.createButton('[my id]','[my cget -text]');"}
  
  method _textchangejs {txt} {return "[my jqobj].html('$txt');"}
  
  method wtk_event {which} {
    if {$which eq "pressed"} {
      variable options
      uplevel #0 $options(-command)
    }
  }
}







|




13
14
15
16
17
18
19
20
21
22
23
24
  
  method do_createjs {} {return "wtk.createButton('[my id]','[my cget -text]');"}
  
  method _textchangejs {txt} {return "[my jqobj].html('$txt');"}
  
  method wtk_event {which} {
    if {$which eq "pressed"} {
      my variable options
      uplevel #0 $options(-command)
    }
  }
}

Changes to widgets/checkbutton.tcl.

6
7
8
9
10
11
12
13






14


15






16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41















42

43
44
45
46
47
48
49
50
51


52
53
54
  _wtkoption -bg "" {$JS.style.background='$V';}
  _wtkoption -fg "" {$JS.style.color='$V';}
  variable currentvalue 0
  option -command
  option -onvalue -default 1 -configuremethod _onoffchanged
  option -offvalue -default 0 -configuremethod _onoffchanged
  option -variable -configuremethod _varnameset







  # TODO : move -variable handling into generic widget base


  method do_createjs {} {set r "wtk.createCheckButton('[my id]','[my cget -text]');"; if {$currentvalue==$options(-onvalue)} {append r "[my jsobj].childNodes\[0\].checked=true;"}; return $r}






  method _textchangejs {txt} {return "[my jqobj].children(':last').html('$txt');"}

  method wtk_event {which} {
    if {$which in "checked unchecked"} {
      variable options
      if {$which=="checked"} {
        set val $options(-onvalue)
      } else {
        set val $options(-offvalue)
      }
      my _changevalue $val 1; uplevel #0 $options(-command)
    }
  }
  method _varnameset {opt var} {
    my variable options
    set options($opt) $var;
    if {$var!=""} {
      if {![uplevel #0 info exists $var]} {
        uplevel #0 set $var $currentvalue
      } else {
        set currentvalue [uplevel #0 set $var]
      }
      uplevel #0 trace add variable $var write [list [list $self _varchanged]]
    }
  }
  method _onoffchanged {opt val} {if {$currentvalue==$options($opt)} {set options($opt) $val; $self _changevalue $val} else {set options($opt) $val}}
  method _varchanged {args} {if {$currentvalue ne [uplevel #0 set $options(-variable)]} {$self _changevalue [uplevel #0 set $options(-variable)]}}; # trace callback















  method _changevalue {newval {fromwidget 0}} {

    if {[my was_created] && !$fromwidget} {
      if {$newval eq $options(-onvalue) && $options(-onvalue) ne $currentvalue} {
        ::wtk::toclient "[my jsobj].childNodes\[0\].checked=true;"
      } elseif {$newval ne $options(-onvalue) && $options(-onvalue) eq $currentvalue} {
        ::wtk::toclient "[my jsobj].childNodes\[0\].checked=false;"
      }
    }
    set currentvalue $newval
    if {$options(-variable) ne ""} {uplevel #0 set $options(-variable) [list $newval]}


  }

}








>
>
>
>
>
>

>
>
|
>
>
>
>
>
>
|
>


|













|



|


|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>








|
>
>



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
  _wtkoption -bg "" {$JS.style.background='$V';}
  _wtkoption -fg "" {$JS.style.color='$V';}
  variable currentvalue 0
  option -command
  option -onvalue -default 1 -configuremethod _onoffchanged
  option -offvalue -default 0 -configuremethod _onoffchanged
  option -variable -configuremethod _varnameset

  method init_options {} {
    my variable currentvalue
    set currentvalue 0
    next
  }

  # TODO : move -variable handling into generic widget base
  method do_createjs {} {
    my variable options
    set r "wtk.createCheckButton('[my id]','[my cget -text]');"
    if {$currentvalue==$options(-onvalue)} {
      append r "[my jsobj].childNodes\[0\].checked=true;"
    }
    return $r
  }
  method _textchangejs {txt} {
    return "[my jqobj].children(':last').html('$txt');"
  }
  method wtk_event {which} {
    if {$which in "checked unchecked"} {
      my variable options
      if {$which=="checked"} {
        set val $options(-onvalue)
      } else {
        set val $options(-offvalue)
      }
      my _changevalue $val 1; uplevel #0 $options(-command)
    }
  }
  method _varnameset {opt var} {
    my variable options
    set options($opt) $var;
    if {$var!=""} {
      if {![uplevel #0 info exists $var]} {
        uplevel #0 [list set $var $currentvalue]
      } else {
        set currentvalue [uplevel #0 set $var]
      }
      uplevel #0 trace add variable $var write [list [namespace code {my _varchanged}]]
    }
  }
  method _onoffchanged {opt val} {
    my variable currentvalue options
    if {$currentvalue==$options($opt)} {
      set options($opt) $val
      my _changevalue $val
    } else {
      set options($opt) $val
    }
  }
  method _varchanged {args} {
    my variable currentvalue options
    upvar #0 $options(-variable) globalValue
    if {$currentvalue ne $globalValue} {
      my _changevalue $globalValue
    }
  }
    
  method _changevalue {newval {fromwidget 0}} {
    my variable options currentvalue
    if {[my was_created] && !$fromwidget} {
      if {$newval eq $options(-onvalue) && $options(-onvalue) ne $currentvalue} {
        ::wtk::toclient "[my jsobj].childNodes\[0\].checked=true;"
      } elseif {$newval ne $options(-onvalue) && $options(-onvalue) eq $currentvalue} {
        ::wtk::toclient "[my jsobj].childNodes\[0\].checked=false;"
      }
    }
    set currentvalue $newval
    if {$options(-variable) ne ""} {
      uplevel #0 [list set $options(-variable) [list $newval]]
    }
  }

}

Changes to widgets/combobox.tcl.

1
2
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
28
29

30
31
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
57
58
59
60
61


62
63
64
65
66
67
68

# Combobox widgets
::odie::class ::wtk::combobox {
  superclass wtk::Widget
  
  _wtkoption -bg "" {$JS.style.background='$V';}
  _wtkoption -fg "" {$JS.style.color='$V';}
  _wtkoption -width "" {$JS.style.width=$V;}
  _wtkoption -height "" {$JS.style.height=$V;}
  _wtkoption -radius "" {$JS.style.borderRadius=$V;}

  variable optionsvalue ""
  variable currentvalue ""
  
  option -text -configuremethod event_textchanged
  option -options  -configuremethod _setoptions 
  option -variable -configuremethod _varnameset
  option -command
  







  method do_createjs {} {
    my variable optionsvalue
    set r "wtk.createCombobox('[my id]','[my cget -text]');"
    foreach e [get optionsvalue] {
      append r "[my jsobj].innerHTML+='<option>$e</option>';"
    }
    return $r
  }
  method _textchangejs {txt} {return "[my jqobj].html('$txt');"}
  method wtk_event {which value} {
              if {$which eq "value"} {

                       $self _changevalue $value 1;
                       uplevel #0 $options(-command)
              }
  }    
  method _varnameset {opt var} {set options($opt) $var;


      if {$var!=""} {



          if {![uplevel #0 info exists $var]} {uplevel #0 set $var $currentvalue} else {set currentvalue [uplevel #0 set $var]}

          uplevel #0 trace add variable $var write [list [list $self _varchanged]]
      }
  }

  method _varchanged {args} {


    if {$currentvalue ne [uplevel #0 set $options(-variable)]} {
      my _changevalue [uplevel #0 set $options(-variable)]
    }
  }
  
  method _changevalue {newval {fromwidget 0}} {

    if {[my was_created] } {
      if {$newval ne $currentvalue} {
        ::wtk::toclient "[my jsobj].value = '$newval';"
      }
    }
    set currentvalue $newval
    if {$options(-variable) ne ""} {
      uplevel #0 set $options(-variable) [list $newval]
    }
  }

  method _setoptions {op values} {
    my variable optionsvalue
    set optionsvalue $values
    if {$options(-options) ne ""} {uplevel #0 set $options(-options) [list $values]}


    if {[my was_created]} {
      foreach e $values {
        ::wtk::toclient "[my jsobj].innerHTML+='<option>$e</option>';"
      }
    }
  }
}



|
|





>






|

>
>
>
>
>
>
>










|
>
|
|
|

|
>
>
|
>
>
>
|
>
|
|

>

>
>
|
|


|

>







|




|

|
>
>







1
2
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
28
29
30
31
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

# Combobox widgets
::odie::class ::wtk::combobox {
  superclass ::wtk::button

  _wtkoption -bg "" {$JS.style.background='$V';}
  _wtkoption -fg "" {$JS.style.color='$V';}
  _wtkoption -width "" {$JS.style.width=$V;}
  _wtkoption -height "" {$JS.style.height=$V;}
  _wtkoption -radius "" {$JS.style.borderRadius=$V;}
  
  variable optionsvalue ""
  variable currentvalue ""
  
  option -text -configuremethod event_textchanged
  option -options  -configuremethod _setoptions 
  option -variable -configuremethod _varnameset
  option -command -default {}
  
  method init_options {} {
    my variable optionsvalue currentvalue
    set currentvalue {}
    set optionsvalue {}
    next
  }

  method do_createjs {} {
    my variable optionsvalue
    set r "wtk.createCombobox('[my id]','[my cget -text]');"
    foreach e [get optionsvalue] {
      append r "[my jsobj].innerHTML+='<option>$e</option>';"
    }
    return $r
  }
  method _textchangejs {txt} {return "[my jqobj].html('$txt');"}
  method wtk_event {which value} {
    if {$which eq "value"} {
      my variable options
      my _changevalue $value 1;
      uplevel #0 $options(-command)
    }
  }    
  method _varnameset {opt var} {
    my variable currentvalue
    set options($opt) $var;
    if {$var!=""} {
      if {![uplevel #0 info exists $var]} {
        uplevel #0 [list set $var $currentvalue]
      } else {
        set currentvalue [uplevel #0 set $var]
      }
      uplevel #0 trace add variable $var write [list [namespace code {my _varchanged}]]
    }
  }

  method _varchanged {args} {
    my variable currentvalue options
    upvar #0 $options(-variable) globalValue
    if {$currentvalue ne $globalValue} {
      my _changevalue $globalValue
    }
  }

  method _changevalue {newval {fromwidget 0}} {
    my variable currentvalue options
    if {[my was_created] } {
      if {$newval ne $currentvalue} {
        ::wtk::toclient "[my jsobj].value = '$newval';"
      }
    }
    set currentvalue $newval
    if {$options(-variable) ne ""} {
      uplevel #0 [list set $options(-variable) [list $newval]]
    }
  }

  method _setoptions {op values} {
    my variable optionsvalue options
    set optionsvalue $values
    if {$options(-options) ne ""} {
      set $options(-options) $values
    }
    if {[my was_created]} {
      foreach e $values {
        ::wtk::toclient "[my jsobj].innerHTML+='<option>$e</option>';"
      }
    }
  }
}

Changes to widgets/misc.tcl.

9
10
11
12
13
14
15
16









17
18
19
20
21
22
23
..
29
30
31
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
57

58
59
60
61
62
63
64
65
66
67
  variable attrvalue ""
  variable currentvalue ""

  option -type  -configuremethod _setoption
  option -attr  -configuremethod _setoption
  option -variable -configuremethod _varnameset
  option -command
  









  method do_createjs {} {
      set r "wtk.createMisc('[my id]','[my cget -type]','[my cget -text]','[my cget -attr]');"
      return $r
  }
  method _textchangejs {txt} {return "[my jqobj].html('$txt');"}   
  
  method _setoption {opt var} {
................................................................................
        set typevalue [uplevel #0 set $options($opt)]
      }
      #uplevel #0 trace add variable $options($opt) write [list [list $self _varchanged]]
    }
  }
  
  method wtk_event {which args} {

    uplevel #0 $options(-command) $args
  }
  
  method _varnameset {opt var} {
    set options($opt) $var
    if {$var!=""} {
      if {![uplevel #0 info exists $var]} {
        uplevel #0 set $var $currentvalue
      } else {
        set currentvalue [uplevel #0 set $var]
      }
      uplevel #0 trace add variable $var write [list [list $self _varchanged]]
    }
  }
  
  method _varchanged {args} {
    if {$currentvalue ne [uplevel #0 set $options(-variable)]} {
            $self _changevalue [uplevel #0 set $options(-variable)]


    }
  }
              
  method _changevalue {newval {fromwidget 0}} {

    if {[my was_created] } {
      if {$newval ne $currentvalue} {
          ::wtk::toclient "[my jsobj].value = '$newval';"
      }
    }
    set currentvalue $newval
    if {$options(-variable) ne ""} {uplevel #0 set $options(-variable) [list $newval]}
  }

}







|
>
>
>
>
>
>
>
>
>







 







>







|



|


|

|
|
>
>




>










9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  variable attrvalue ""
  variable currentvalue ""

  option -type  -configuremethod _setoption
  option -attr  -configuremethod _setoption
  option -variable -configuremethod _varnameset
  option -command

  method init_options {} {
    my variable typevalue attrvalue currentvalue 
    set typevalue {}
    set attrvalue {}
    set currentvalue {}
    next
  }


  method do_createjs {} {
      set r "wtk.createMisc('[my id]','[my cget -type]','[my cget -text]','[my cget -attr]');"
      return $r
  }
  method _textchangejs {txt} {return "[my jqobj].html('$txt');"}   
  
  method _setoption {opt var} {
................................................................................
        set typevalue [uplevel #0 set $options($opt)]
      }
      #uplevel #0 trace add variable $options($opt) write [list [list $self _varchanged]]
    }
  }
  
  method wtk_event {which args} {
    my variable options
    uplevel #0 $options(-command) $args
  }
  
  method _varnameset {opt var} {
    set options($opt) $var
    if {$var!=""} {
      if {![uplevel #0 info exists $var]} {
        uplevel #0 [list set $var $currentvalue]
      } else {
        set currentvalue [uplevel #0 set $var]
      }
      uplevel #0 trace add variable $var write [list [namespace code {my _varchanged}]]
    }
  }

  method _varchanged {args} {
    my variable currentvalue options
    upvar #0 $options(-variable) globalValue
    if {$currentvalue ne $globalValue} {
      my _changevalue $globalValue
    }
  }
              
  method _changevalue {newval {fromwidget 0}} {
    my variable currentvalue options
    if {[my was_created] } {
      if {$newval ne $currentvalue} {
          ::wtk::toclient "[my jsobj].value = '$newval';"
      }
    }
    set currentvalue $newval
    if {$options(-variable) ne ""} {uplevel #0 set $options(-variable) [list $newval]}
  }

}