Overview
Comment:Added couple more examples
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 74b983c37c0e05d98f27ea0e80ba7c9e22b6faac
User & Date: matt on 2014-02-02 06:14:03
Other Links: manifest | tags
Context
2014-02-02
06:46
Added alternative version check-in: a7dfaea4be user: Administrator tags: trunk
06:14
Added couple more examples check-in: 74b983c37c user: matt tags: trunk
05:53
Everything but canvas-draw brought up to latest check-in: f09bb87b61 user: Administrator tags: trunk
Changes

Added examples/iupwidgetinfo.scm version [c580d04776].































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
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
#! /usr/bin/env csi

(require-library srfi-4 iup)
(import srfi-4 iup iup-pplot iup-glcanvas)

(define (popup dlg . args)
  (apply show dlg #:modal? 'yes args)
  (destroy! dlg))

(define (properties ih)
  (popup (element-properties-dialog ih))
  'default)

(define dlg
  (dialog
    (vbox
      (hbox ; headline
        (fill)
        (frame (label " Inspect control and dialog classes "
                      fontsize: 15))
        (fill)
        margin: '0x0)

      (label "") 
      (label "Dialogs" fontsize: 12)
      (hbox
        (button "dialog"
                action: (lambda (self) (properties (dialog (vbox)))))
        (button "color-dialog"
                action: (lambda (self) (properties (color-dialog))))
        (button "file-dialog"
                action: (lambda (self) (properties (file-dialog))))
        (button "font-dialog"
                action: (lambda (self) (properties (font-dialog))))
        (button "message-dialog"
                action: (lambda (self) (properties (message-dialog))))
        (fill)
        margin: '0x0)
      (hbox
        (button "layout-dialog"
                action: (lambda (self) (properties (layout-dialog))))
        (button "element-properties-dialog"
                action: (lambda (self)
                          (properties
                            (element-properties-dialog (create 'user)))))
        (fill)
        margin: '0x0)

      (label "") 
      (label "Composition widgets" fontsize: 12)
      (hbox
        (button "fill"
                action: (lambda (self) (properties (fill))))
        (button "hbox"
                action: (lambda (self) (properties (hbox))))
        (button "vbox"
                action: (lambda (self) (properties (vbox))))
        (button "zbox"
                action: (lambda (self) (properties (zbox))))
        (button "radio"
                action: (lambda (self) (properties (radio (vbox)))))
        (button "normalizer"
                action: (lambda (self) (properties (normalizer))))
        (button "cbox"
                action: (lambda (self) (properties (cbox))))
        (button "sbox"
                action: (lambda (self) (properties (sbox (vbox)))))
        (button "split"
                action: (lambda (self) (properties (split (vbox) (vbox)))))
        (fill)
        margin: '0x0)

      (label "") 
      (label "Standard widgets" fontsize: 12)
      (hbox
        (button "button"
                action: (lambda (self) (properties (button))))
        (button "canvas"
                action: (lambda (self) (properties (canvas))))
        (button "frame"
                action: (lambda (self) (properties (frame))))
        (button "label"
                action: (lambda (self) (properties (label))))
        (button "listbox"
                action: (lambda (self) (properties (listbox))))
        (button "progress-bar"
                action: (lambda (self) (properties (progress-bar))))
        (button "spin"
                action: (lambda (self) (properties (spin))))
        (fill)
        margin: '0x0)
      (hbox
        (button "tabs"
                action: (lambda (self) (properties (tabs))))
        (button "textbox"
                action: (lambda (self) (properties (textbox))))
        (button "toggle"
                action: (lambda (self) (properties (toggle))))
        (button "treebox"
                action: (lambda (self) (properties (treebox))))
        (button "valuator"
                action: (lambda (self) (properties (valuator ""))))
        (fill)
        margin: '0x0)

      (label "") 
      (label "Additional widgets" fontsize: 12)
      (hbox
        (button "cells"
                action: (lambda (self) (properties (cells))))
        (button "color-bar"
                action: (lambda (self) (properties (color-bar))))
        (button "color-browser"
                action: (lambda (self) (properties (color-browser))))
        (button "dial"
                action: (lambda (self) (properties (dial ""))))
        (button "matrix"
                action: (lambda (self) (properties (matrix))))
        (fill)
        margin: '0x0)
      (hbox
        (button "pplot"
                action: (lambda (self) (properties (pplot))))
        (button "glcanvas"
                action: (lambda (self) (properties (glcanvas))))
        (button "web-browser"
                action: (lambda (self) (properties (web-browser))))
        (fill)
        margin: '0x0)

      (label "") 
      (label "Menu widgets" fontsize: 12)
      (hbox
        (button "menu"
                action: (lambda (self) (properties (menu))))
        (button "menu-item"
                action: (lambda (self) (properties (menu-item))))
        (button "menu-separator"
                action: (lambda (self) (properties (menu-separator))))
        (fill)
        margin: '0x0)

      (label "") 
      (label "Images" fontsize: 12)
      (hbox
        (button "image/palette"
                action: (lambda (self)
                          (properties
                            (image/palette 1 1 (u8vector->blob (u8vector 0))))))
        (button "image/rgb"
                action: (lambda (self)
                          (properties
                            (image/rgb 1 1 (u8vector->blob (u8vector 0))))))
        (button "image/rgba"
                action: (lambda (self)
                          (properties
                            (image/rgba 1 1 (u8vector->blob (u8vector 0))))))
        (button "image/file"
                action: (lambda (self)
                          (properties
                            ;; same attributes as image/palette
                            (image/palette 1 1 (u8vector->blob (u8vector 0))))))
                            ;; needs a file in current directory
                            ;(image/file "chicken.ico")))) ; ok
                            ;(image/file "chicken.png")))) ; doesn't work
        (fill)
        margin: '0x0)

      (label "") 
      (label "Other widgets" fontsize: 12)
      (hbox
        (button "clipboard"
                action: (lambda (self) (properties (clipboard))))
        (button "timer"
                action: (lambda (self) (properties (timer))))
        (button "spinbox"
                action: (lambda (self) (properties (spinbox (vbox)))))
        (fill)
        margin: '0x0)

      (fill)
      (button "E&xit"
              expand: 'horizontal
              action: (lambda (self) 'close))
      )
    margin: '15x15
    title: "Iup inspector"))

(show dlg)
(main-loop)
(exit 0)

Added examples/simple.scm version [547552bbf6].







































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
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
249
250
251
252
253
254
255
256
257
258
259
(require-library iup)
(import (prefix iup iup:))
;; (use canvas-draw canvas-draw-iup)
(use srfi-4)

(define img-bits1 (u8vector->blob (u8vector
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1
 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1
 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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1 1 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2
 2 2 2 2 2 2 3 3 3 3 3 3 3 3 1 1 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2
 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2
 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
)))

(define (iup:item-set-attributes! item . attrlst)
  (for-each (lambda (attrtok)
	      (let ((attrlst (string-split attrtok "=")))
		(iup:attribute-set! item (car attrlst)(cadr attrlst))))
	    attrlst)
  item)

(define (myaction)
  (print "My action called"))

(define (init-dialog)
  (let ((img1    (iup:image/palette 32 32 img-bits1))
	(img2    (iup:image/palette 32 32 img-bits2))
	(mnu     #f)
	(_frm-1  #f)
	(_frm-2  #f)
	(_frm-3  #f)
	(_frm-4  #f)
	(_frm-5  #f)
	(_list-1 #f)
	(_list-2 #f)
	(_list-3 #f)
	(_hbox-1 #f)
	(_vbox-1 #f)
	(_cnv-1  #f)
	(dlg     #f)
	(c1      #f))
    (iup:handle-name-set! img1 "img1")
    (iup:attribute-set! img1 "0" "0 0 0")
    (iup:attribute-set! img1 "1" "BGCOLOR")
    (iup:attribute-set! img1 "2" "255 0 0")

    (iup:handle-name-set! img2 "img2")
    (iup:attribute-set! img2 "0" "0 0 0")
    (iup:attribute-set! img2 "1" "0 255 0")
    (iup:attribute-set! img2 "2" "BGCOLOR")
    (iup:attribute-set! img2 "3" "255 0 0")

    (set! mnu (iup:menu
	       (iup:item-set-attributes!
		(iup:menu-item "IupSubmenu 1" 
			       (iup:menu
				(iup:item-set-attributes! 
				 (iup:menu-item "IupItem 1 Checked" "myaction")
				 "VALUE=ON")
				(iup:menu-separator)
				(iup:item-set-attributes!
				 (iup:menu-item "IupItem 2 Disabled" "myaction")
				 "ACTIVE=NO"))))))
    (iup:handle-name-set! mnu "mnu")

    (set! _frm-1 (iup:frame 
		  (iup:vbox 
		   (iup:button "Button Text" #:action (lambda (x)(print "Blah" x)))
		   (iup:item-set-attributes!
		    (iup:button "" #:action print) "IMAGE=img1")
		   (iup:item-set-attributes! 
		    (iup:button "" #:action print) "IMAGE=img1" "IMPRESS=img2"))))
    (iup:attribute-set! _frm-1 "TITLE" "IupButton")

    (set! _frm-2 (iup:frame
		  (iup:vbox
		   (iup:label "Label Text")
		   (iup:item-set-attributes! 
		    (iup:label "") "SEPARATOR=HORIZONTAL")
		   (iup:item-set-attributes!
		    (iup:label "") "IMAGE=img1"))))
    (iup:attribute-set! _frm-2 "TITLE" "IupLabel")

    (set! _frm-3 (iup:frame
		  (iup:vbox 
		   (iup:item-set-attributes! 
		    (iup:toggle "Toggle Text" "myaction") "VALUE=ON")
		   (iup:item-set-attributes!
		    (iup:toggle "" "myaction") "IMAGE=img1" "IMPRESS=img2")
		   (iup:item-set-attributes!
		    (iup:frame
		     (iup:radio
		      (iup:vbox
		       (iup:toggle "Toggle Text" "myaction")
		       (iup:toggle "Toggle Text" "myaction")))) "TITLE=IupRadio"))))
    (iup:attribute-set! _frm-3 "TITLE" "IupToggle")

    (set! _text-1 (iup:textbox "myaction"))
    (iup:attribute-set! _text-1 "VALUE" "IupText Text")
    (iup:attribute-set! _text-1 "SIZE" "80x")
    
    (set! _m1-1 (iup:textbox "myaction"))
    (iup:attribute-set! _m1-1 "MULTILINE" "YES")
    (iup:attribute-set! _m1-1 "VALUE" "IupMultiline Text\nSecond Line\nThird Line")
    (iup:attribute-set! _m1-1 "EXPAND" "YES")
    (iup:attribute-set! _m1-1 "SIZE" "80x60")

    (set! _frm-4 (iup:frame
		  (iup:vbox
		   _text-1
		   _m1-1)))
    (iup:attribute-set! _frm-4 "TITLE" "IupText/IupMultiline")

    (set! _list-1 
	  (iup:item-set-attributes! 
	   (iup:listbox "myaction")
	   "EXPAND=YES" 
	   "VALUE=1"
	   "1=Item 1 Text"
	   "2=Item 2 Text"
	   "3=Item 3 Text"))
	  
    (set! _list-2
	  (iup:item-set-attributes!
	   (iup:listbox "myaction")
	   "DROPDOWN=YES"
	   "EXPAND=YES"
	   "VALUE=2"
	   "1=Item 1 Text"
	   "2=Item 2 Text"
	   "3=Item 3 Text"))

    (set! _list-3
	  (iup:item-set-attributes!
	   (iup:listbox "myaction")
	   "EDITBOX=YES"
	   "EXPAND=YES"
	   "VALUE=3"
	   "1=Item 1 Text"
	   "2=Item 2 Text"
	   "3=Item 3 Text"))

    (set! _frm-5 (iup:frame
		  (iup:vbox
		   _list-1
		   _list-2
		   _list-3)))
    (iup:attribute-set! _frm-5 "TITLE" "IupList")
	   
    (set! _hbox-1 (iup:hbox
		   _frm-1
		   _frm-2
		   _frm-3
		   _frm-4
		   _frm-5))

  ;;   (set! _cnv-1 
  ;;         ;; (iup:item-set-attributes!
  ;;         ;;(iup:canvas)
  ;;         ;; "BGCOLOR=128 255 0" 
  ;;         ;; "SCROLLBAR=yes"))
  ;;         ;; (iup:handle-name-set! _cnv-1 "cnv1")
  ;; 
  ;;         ;; (use iup canvas-draw canvas-draw-iup)
  ;;         ;; (define dlg
  ;;         ;;   (dialog #:title "Test" #:minsize "320x240"
  ;;         (iup:canvas #:action (make-canvas-action
  ;;       			(lambda (cnv x y)
  ;;       			  (canvas-clear! cnv)
  ;;       			  (canvas-text! cnv 40 40 "Hello world!")
  ;;       			  (canvas-rectangle! cnv 90 120 70 100)))
  ;;       	      #:size "200x100"))
    ;; )
    ;; (show dlg)
    ;; (main-loop)
    (set! _vbox-1 (iup:vbox
		   _hbox-1
		   ;; _cnv-1
		   ))

    (iup:attribute-set! _vbox-1 "MARGIN" "5x5")
    (iup:attribute-set! _vbox-1 "ALIGNMENT" "ARIGHT")
    (iup:attribute-set! _vbox-1 "GAP" "5")
    
    (set! dlg (iup:dialog _vbox-1))
    (iup:handle-name-set! dlg "dlg")
    (iup:attribute-set! dlg "MENU" "mnu")
    (iup:attribute-set! dlg "TITLE" "Iup Sample")

    ;; (set! c1 (make-canvas context:iup "cnv1"))
;; (iup:handle-ref "cnv1")))
;; _cnv-1))
    ;; (canvas-rectangle! c1 10 10 40 40)
    ))
    
(init-dialog)
(iup:show (iup:handle-ref "dlg"))
(iup:main-loop)

Added examples/tree.scm version [49f7155a59].







































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
;; Some tree utilities. (C) 2014 Matt Welland, GPL V2.0
;; Take from Megatest http://www.kiatoa.com/fossils/megatest
;;
(use test)
(require-library iup)
(import (prefix iup iup:))

(define t #f) 

(define tree-dialog
  (iup:dialog
   #:title "Tree Test"
   (let ((t1 (iup:treebox
	      #:selection_cb (lambda (obj id state)
			       (print "selection_db with id=" id " state=" state)
			       (print "USERDATA: " (iup:attribute obj "USERDATA"))
			       (print "SPECIALDATA: " (iup:attribute obj "SPECIALDATA"))
			       (print "Depth: " (iup:attribute obj "DEPTH"))
			       ))))
     (set! t t1)
     t1)))

(iup:show tree-dialog)

(map (lambda (elname el)
       (print "Adding " elname " with value " el)
       (iup:attribute-set! t elname el)
       (iup:attribute-set! t "USERDATA" el))
     '("VALUE" "NAME"    "ADDLEAF" "ADDBRANCH1" "ADDLEAF2"    "VALUE")
     '("0"     "Figures" "Other"   "triangle"   "equilateral" "4")
     )
(map (lambda (attr)
       (print attr " is " (iup:attribute t attr)))
     '("KIND1" "PARENT2" "STATE1"))

(define (tree-find-node obj path)
  ;; start at the base of the tree
  (if (null? path)
      #f ;; or 0 ????
      (let loop ((hed      (car path))
		 (tal      (cdr path))
		 (depth    0)
		 (nodenum  0))
	;; nodes in iup tree are 100% sequential so iterate over nodenum
	(if (iup:attribute obj (conc "DEPTH" nodenum)) ;; end when no more nodes
	    (let ((node-depth (string->number (iup:attribute obj (conc "DEPTH" nodenum))))
		  (node-title (iup:attribute obj (conc "TITLE" nodenum))))
	      ;; (print 0 "hed: " hed ", depth: " depth ", node-depth: " node-depth ", nodenum: " nodenum ", node-title: " node-title)
	      (if (and (equal? depth node-depth)
		       (equal? hed   node-title)) ;; yep, this is the one!
		  (if (null? tal) ;; end of the line
		      nodenum
		      (loop (car tal)(cdr tal)(+ depth 1)(+ 1 nodenum)))
		  ;; this is the case where we found part of the hierarchy but not 
		  ;; all of it, i.e. the node-depth went from deep to less deep
		  (if (> depth node-depth) ;; (+ 1 node-depth))
		      #f
		      (loop hed tal depth (+ nodenum 1)))))
	    #f))))

;; top is the top node name zeroeth node VALUE=0
(define (tree-add-node obj top nodelst)
  (if (not (iup:attribute obj "TITLE0"))
      (iup:attribute-set! obj "ADDBRANCH0" top))
  (cond
   ((not (string=? top (iup:attribute obj "TITLE0")))
    (print "ERROR: top name " top " doesn't match " (iup:attribute obj "TITLE0")))
   ((null? nodelst))
   (else
    (let loop ((hed      (car nodelst))
	       (tal      (cdr nodelst))
	       (depth    1)
	       (pathl    (list top)))
      ;; Because the tree dialog changes node numbers when
      ;; nodes are added or removed we must look up nodes
      ;; each and every time. 0 is the top node so default
      ;; to that.
      (let* ((newpath    (append pathl (list hed)))
	       (parentnode (tree-find-node obj pathl))
	       (nodenum    (tree-find-node obj newpath)))
	  ;; (print "newpath: " newpath ", nodenum " nodenum ", hed: " hed ", depth: " depth ", parentnode: " parentnode ", pathl: " pathl)
	  ;; Add the branch under lastnode if not found
	  (if (not nodenum)
	      (begin
		(iup:attribute-set! obj (conc "ADDBRANCH" parentnode) hed)
		(if (null? tal)
		    #t
		    ;; reset to top
		    (loop (car nodelst)(cdr nodelst) 1 (list top)))) 
	      (if (null? tal) ;; if null here then this path has already been added
		  #t
		  ;; (if nodenum
		  (loop (car tal)(cdr tal)(+ depth 1) newpath)))))))) ;;  (if nodenum nodenum lastnode)))))))
	      ;; 	  (loop hed tal depth pathl lastnode)))))))

(define (tree-node->path obj nodenum)
  ;; (print "\ncurrnode  nodenum  depth  node-depth  node-title   path")
  (let loop ((currnode 0)
	     (depth    0)
	     (path     '()))
    (let ((node-depth (iup:attribute obj (conc "DEPTH" currnode)))
	  (node-title (iup:attribute obj (conc "TITLE" currnode))))
      ;; (display (conc "\n   "currnode "        " nodenum "       " depth "         " node-depth "          " node-title "         " path))
      (if (> currnode nodenum)
	  path
	  (if (not node-depth) ;; #f if we are out of nodes
	      '()
	      (let ((ndepth (string->number node-depth)))
		(if (eq? ndepth depth)
		    ;; This next is the match condition depth == node-depth
		    (if (eq? currnode nodenum)
			(begin
			  ;; (display " <X>")
			  (append path (list node-title)))
			(loop (+ currnode 1)
			      (+ depth 1)
			      (append path (list node-title))))
		    ;; didn't match, reset to base path and keep looking
		    ;; due to more iup odditys we don't reset to base
		    (begin 
		      ;; (display " <L>")
		      (loop (+ 1 currnode)
			    2
			    (append (take path ndepth)(list node-title)))))))))))

(test #f 0  (tree-find-node t '("Figures")))
(test #f 1  (tree-find-node t '("Figures" "Other")))
(test #f #f (tree-find-node t '("Figures" "Other"    "equilateral")))
(test #f 3  (tree-find-node t '("Figures" "triangle" "equilateral")))
(test #f #t (tree-add-node  t "Figures" '()))
(test #f #t (tree-add-node  t "Figures" '("a" "b" "c")))
(test #f 3  (tree-find-node t '("Figures" "a" "b" "c")))
(test #f #t (tree-add-node  t "Figures" '("d" "b" "c")))
(test #f 3  (tree-find-node t '("Figures" "d" "b" "c")))
(test #f 6  (tree-find-node t '("Figures" "a" "b" "c")))
(test #f #t (tree-add-node  t "Figures" '("a" "e" "c")))
(test #f 6  (tree-find-node t '("Figures" "a" "e" "c")))

(test #f '("Figures")             (tree-node->path t 0))
(test #f '("Figures" "d")         (tree-node->path t 1))
(test #f '("Figures" "d" "b" "c") (tree-node->path t 3))
(test #f '("Figures" "a")         (tree-node->path t 4))
(test #f '("Figures" "a" "b" "c")     (tree-node->path t 8)) 
(test #f '()                      (tree-node->path t 40))

(iup:main-loop)