ruby-iup 0.1.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/CHANGES +3 -0
  2. data/MANIFEST +8 -0
  3. data/MIT-LICENSE +18 -0
  4. data/README +12 -0
  5. data/Rakefile +85 -0
  6. data/doc/README +10 -0
  7. data/doc/build_install.txt +74 -0
  8. data/examples/README +16 -0
  9. data/examples/ctrl/cbox.rb +220 -0
  10. data/examples/ctrl/checkboard.rb +33 -0
  11. data/examples/ctrl/degrade.rb +76 -0
  12. data/examples/ctrl/example1.rb +53 -0
  13. data/examples/ctrl/example2.rb +39 -0
  14. data/examples/ctrl/iupcolorbar.rb +95 -0
  15. data/examples/ctrl/iupcolorbrowser.rb +45 -0
  16. data/examples/ctrl/iupdial.rb +117 -0
  17. data/examples/ctrl/iupgauge.rb +242 -0
  18. data/examples/ctrl/iupgetcolor.rb +8 -0
  19. data/examples/ctrl/iupgetparam.rb +62 -0
  20. data/examples/ctrl/iupglcanvas.rb +172 -0
  21. data/examples/ctrl/iupmask.rb +13 -0
  22. data/examples/ctrl/iupmatrix.rb +39 -0
  23. data/examples/ctrl/iupplot2.rb +601 -0
  24. data/examples/ctrl/iuptabs.rb +22 -0
  25. data/examples/ctrl/iuptree.rb +190 -0
  26. data/examples/ctrl/iupval.rb +71 -0
  27. data/examples/ctrl/numbering.rb +46 -0
  28. data/examples/ctrl/sample.rb +166 -0
  29. data/examples/dlg/iupalarm.rb +16 -0
  30. data/examples/dlg/iupfiledlg.rb +19 -0
  31. data/examples/dlg/iupgetfile.rb +19 -0
  32. data/examples/dlg/iuplistdialog.rb +26 -0
  33. data/examples/dlg/iupmessage.rb +5 -0
  34. data/examples/dlg/iupscanf.rb +17 -0
  35. data/examples/elem/iupbutton.rb +180 -0
  36. data/examples/elem/iupcanvas.rb +29 -0
  37. data/examples/elem/iupcanvas2.rb +114 -0
  38. data/examples/elem/iupcanvas3.rb +52 -0
  39. data/examples/elem/iupdialog.rb +67 -0
  40. data/examples/elem/iupdialog2.rb +25 -0
  41. data/examples/elem/iupfill.rb +51 -0
  42. data/examples/elem/iupframe.rb +25 -0
  43. data/examples/elem/iuphbox.rb +68 -0
  44. data/examples/elem/iupimage.rb +113 -0
  45. data/examples/elem/iupitem.rb +60 -0
  46. data/examples/elem/iuplabel.rb +57 -0
  47. data/examples/elem/iuplist.rb +41 -0
  48. data/examples/elem/iuplist2.rb +125 -0
  49. data/examples/elem/iupmenu.rb +32 -0
  50. data/examples/elem/iupmultiline.rb +24 -0
  51. data/examples/elem/iupmultiline2.rb +156 -0
  52. data/examples/elem/iupradio.rb +32 -0
  53. data/examples/elem/iupseparator.rb +81 -0
  54. data/examples/elem/iupsubmenu.rb +85 -0
  55. data/examples/elem/iuptimer.rb +36 -0
  56. data/examples/elem/iuptoggle.rb +110 -0
  57. data/examples/elem/iupvbox.rb +87 -0
  58. data/examples/elem/iupzbox.rb +60 -0
  59. data/examples/elem/mdisample.rb +377 -0
  60. data/examples/elem/progressbar.rb +280 -0
  61. data/examples/elem/scrollbar.rb +66 -0
  62. data/examples/elem/tray.rb +90 -0
  63. data/examples/func/iupgetattribute.rb +32 -0
  64. data/examples/func/iupidle.rb +48 -0
  65. data/lib/iup.so +0 -0
  66. data/ruby-iup.gemspec +26 -0
  67. data/test/test_ruby_iup.rb +25 -0
  68. metadata +132 -0
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'iup'
3
+
4
+ text = Iup.Text()
5
+ text.mask = "/d*"
6
+ text.size = "100x"
7
+ text.expand = "HORIZONTAL"
8
+
9
+ dg = Iup.Dialog(text,:title=> "IupMask")
10
+
11
+ dg.Show()
12
+ Iup.MainLoop()
13
+ dg.Destroy()
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'iup'
3
+
4
+
5
+ def create_mat()
6
+
7
+ mat = Iup.Matrix(nil)
8
+
9
+ mat.numcol_visible = 2
10
+ mat.numlin_visible = 3
11
+ mat.resizematrix = "YES"
12
+
13
+ mat.numlin = 3
14
+ mat.numcol = 2
15
+
16
+ mat["0:0"] = "Inflation"
17
+ mat["1:0"] = "Medicine "
18
+ mat["2:0"] = "Food"
19
+ mat["3:0"] = "Energy"
20
+ mat["0:1"] = "January 2000"
21
+ mat["0:2"] = "February 2000"
22
+ mat["1:1"] = 5.6
23
+ mat["2:1"] = 2.2
24
+ mat["3:1"] = 7.2
25
+ mat["1:2"] = 4.5
26
+ mat["2:2"] = 8.1
27
+ mat["3:2"] = 3.4
28
+ mat.widthdef = 34
29
+
30
+ mat
31
+ end
32
+
33
+
34
+
35
+ dlg = Iup.Dialog(create_mat)
36
+ dlg.ShowXY(Iup::CENTER,Iup::CENTER)
37
+ Iup.MainLoop
38
+ dlg.Destroy
39
+
@@ -0,0 +1,601 @@
1
+ require 'rubygems'
2
+ require 'iup'
3
+
4
+ MAXPLOT = 6 # room for examples
5
+
6
+ class IupPlotTest
7
+
8
+ def InitPlots()
9
+
10
+ delete_cb = lambda do |ih, index, sample_index, x, y|
11
+ puts("DELETE_CB(#{index}, #{sample_index}, #{x}, #{y})")
12
+ Iup::DEFAULT
13
+ end
14
+
15
+ select_cb = lambda do |ih, index, sample_index, x, y, select|
16
+ puts("SELECT_CB(#{index}, #{sample_index}, #{x}, #{y}, #{select})")
17
+ Iup::DEFAULT
18
+ end
19
+
20
+ edit_cb = lambda do |ih, index, sample_index, x, y,new_x,new_y|
21
+ puts("EDIT_CB(#{index}, #{sample_index}, #{x}, #{y}, #{new_x}, #{new_y})")
22
+ Iup::DEFAULT
23
+ end
24
+
25
+ postdraw_cb = lambda do |ih,cnv|
26
+ ix,iy = ih.PPlotTransform(0.003, 0.02)
27
+ cnv.CanvasFont(nil, Cd::BOLD, 10)
28
+ cnv.CanvasTextAlignment(Cd::SOUTH)
29
+ cnv.CanvasText(ix, iy, "My Inline Legend")
30
+ puts("POSTDRAW_CB()")
31
+ Iup::DEFAULT
32
+ end
33
+
34
+ predraw_cb = lambda do |ih, cnv|
35
+ puts("PREDRAW_CB()")
36
+ Iup::DEFAULT
37
+ end
38
+
39
+ # PLOT 0 - MakeExamplePlot1
40
+ @plot[0].title = "AutoScale"
41
+ @plot[0].margintop = 40
42
+ @plot[0].marginleft = 40
43
+ @plot[0].marginbottom = 50
44
+ @plot[0].titlefontsize = 16
45
+ @plot[0].axs_xlabel = "gnu (Foo)"
46
+ @plot[0].axs_ylabel = "Space (m^3)"
47
+ @plot[0].axs_yfontsize = 7
48
+ @plot[0].axs_ytickfontsize = 7
49
+ @plot[0].legendshow = "YES"
50
+ @plot[0].axs_xfontsize = 10
51
+ @plot[0].axs_yfontsize = 10
52
+ @plot[0].axs_xlabelcentered = "NO"
53
+ @plot[0].axs_ylabelcentered = "NO"
54
+
55
+ # @plot[0].use_imagergb = "YES"
56
+ # @plot[0].use_gdi = "YES"
57
+
58
+ theFac = 1.0/(100*100*100)
59
+ @plot[0].PPlotBegin(0)
60
+ for theI in -100..100
61
+ x = theI+50.0
62
+ y = theFac*theI*theI*theI
63
+ @plot[0].PPlotAdd(x, y)
64
+ end
65
+ @plot[0].PPlotEnd()
66
+ @plot[0].ds_linewidth = 3
67
+ @plot[0].ds_legend = "Line"
68
+
69
+ theFac = 2.0/100
70
+ @plot[0].PPlotBegin(0)
71
+ for theI in -100..100
72
+ x = 1.0*theI
73
+ y = -theFac*theI
74
+ @plot[0].PPlotAdd(x, y)
75
+ end
76
+ @plot[0].PPlotEnd()
77
+ @plot[0].ds_legend = "Curve 1"
78
+
79
+ @plot[0].PPlotBegin(0)
80
+ for theI in -100..100
81
+ x = 0.01*theI*theI-30
82
+ y = 0.01*theI;
83
+ @plot[0].PPlotAdd(x, y)
84
+ end
85
+ @plot[0].PPlotEnd()
86
+ @plot[0].ds_legend = "Curve 2"
87
+
88
+ # PLOT 1 - MakeExamplePlot2
89
+ @plot[1].title = "No Autoscale+No CrossOrigin"
90
+ @plot[1].titlefontsize = 16
91
+ @plot[1].margintop = 40
92
+ @plot[1].marginleft = 55
93
+ @plot[1].marginbottom = 50
94
+ @plot[1].bgcolor = "0 192 192"
95
+ @plot[1].axs_xlabel = "Tg (X)"
96
+ @plot[1].axs_ylabel = "Tg (Y)"
97
+ @plot[1].axs_xautomin = "NO"
98
+ @plot[1].axs_xautomax = "NO"
99
+ @plot[1].axs_yautomin = "NO"
100
+ @plot[1].axs_yautomax = "NO"
101
+ @plot[1].axs_xmin = 10
102
+ @plot[1].axs_xmax = 60
103
+ @plot[1].axs_ymin = -0.5
104
+ @plot[1].axs_ymax = 0.5
105
+ @plot[1].axs_xcrossorigin = "NO"
106
+ @plot[1].axs_ycrossorigin = "NO"
107
+ @plot[1].axs_xfontstyle = "BOLD"
108
+ @plot[1].axs_yfontstyle = "BOLD"
109
+ @plot[1].axs_xreverse = "YES"
110
+ @plot[1].gridcolor = "128 255 128"
111
+ @plot[1].gridlinestyle = "DOTTED"
112
+ @plot[1].grid = "YES"
113
+ @plot[1].legendshow = "YES"
114
+
115
+ theFac = 1.0/(100*100*100)
116
+ @plot[1].PPlotBegin(0)
117
+ for theI in 0..100
118
+ x = 1.0*(theI)
119
+ y = theFac*theI*theI*theI;
120
+ @plot[1].PPlotAdd(x, y)
121
+ end
122
+ @plot[1].PPlotEnd()
123
+
124
+ theFac = 2.0/100
125
+ @plot[1].PPlotBegin(0)
126
+ for theI in 0..100
127
+ x = 1.0*(theI)
128
+ y = -theFac*theI
129
+ @plot[1].PPlotAdd(x, y)
130
+ end
131
+ @plot[1].PPlotEnd()
132
+
133
+ # PLOT 2 - MakeExamplePlot4
134
+ @plot[2].title = "Log Scale"
135
+ @plot[2].titlefontsize = 16
136
+ @plot[2].margintop = 40
137
+ @plot[2].marginleft = 70
138
+ @plot[2].marginbottom = 50
139
+ @plot[2].grid = "YES"
140
+ @plot[2].axs_xscale = "LOG10"
141
+ @plot[2].axs_yscale = "LOG2"
142
+ @plot[2].axs_xlabel = "Tg (X)"
143
+ @plot[2].axs_ylabel = "Tg (Y)"
144
+ @plot[2].axs_xfontstyle = "BOLD"
145
+ @plot[2].axs_yfontstyle = "BOLD"
146
+
147
+ theFac = 100.0/(100*100*100)
148
+ @plot[2].PPlotBegin(0)
149
+ for theI in 0..100
150
+ x = (0.0001+theI*0.001)
151
+ y = (0.01+theFac*theI*theI*theI)
152
+ @plot[2].PPlotAdd(x, y)
153
+ end
154
+ @plot[2].PPlotEnd()
155
+ @plot[2].ds_color = "100 100 200"
156
+
157
+ #PLOT 3 - MakeExamplePlot5
158
+ @plot[3].title = "Bar Mode"
159
+ @plot[3].titlefontsize = 16
160
+ @plot[3].margintop = 40
161
+ @plot[3].marginleft = 30
162
+ @plot[3].marginbottom = 30
163
+ kLables = ["jan","feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
164
+ kData = [1,2,3,4,5,6,7,8,9,0,1,2]
165
+
166
+ @plot[3].PPlotBegin(1)
167
+ for theI in 0...12
168
+ @plot[3].PPlotAddStr(kLables[theI], kData[theI])
169
+ end
170
+ @plot[3].PPlotEnd()
171
+ @plot[3].ds_color = "100 100 200"
172
+ @plot[3].ds_mode = "BAR"
173
+
174
+ #PLOT 4 - MakeExamplePlot6
175
+ @plot[4].title = "Marks Mode"
176
+ @plot[4].titlefontsize = 16
177
+ @plot[4].margintop = 40
178
+ @plot[4].marginleft = 45
179
+ @plot[4].marginbottom = 40
180
+ @plot[4].axs_xautomin = "NO"
181
+ @plot[4].axs_xautomax = "NO"
182
+ @plot[4].axs_yautomin = "NO"
183
+ @plot[4].axs_yautomax = "NO"
184
+ @plot[4].axs_xmin = 0
185
+ @plot[4].axs_xmax = 0.011
186
+ @plot[4].axs_ymin = 0
187
+ @plot[4].axs_ymax = 0.22
188
+ @plot[4].axs_xcrossorigin = "NO"
189
+ @plot[4].axs_ycrossorigin = "NO"
190
+ @plot[4].axs_xtickformat = "%1.3f"
191
+ @plot[4].legendshow = "YES"
192
+ @plot[4].legendpos = "BOTTOMRIGHT"
193
+
194
+ theFac = 100.0/(100*100*100)
195
+ @plot[4].PPlotBegin(0)
196
+ for theI in 0..10
197
+ x = (0.0001+theI*0.001)
198
+ y = (0.01+theFac*theI*theI)
199
+ @plot[4].PPlotAdd(x, y)
200
+ end
201
+ @plot[4].PPlotEnd()
202
+ @plot[4].ds_mode = "MARKLINE"
203
+ @plot[4].ds_showvalues = "YES"
204
+
205
+ @plot[4].PPlotBegin(0)
206
+ for theI in 0..10
207
+ x = (0.0001+theI*0.001)
208
+ y = (0.2-theFac*theI*theI)
209
+ @plot[4].PPlotAdd(x, y)
210
+ end
211
+ @plot[4].PPlotEnd()
212
+ @plot[4].ds_mode = "MARK"
213
+ @plot[4].ds_markstyle = "HOLLOW_CIRCLE"
214
+
215
+ #PLOT 5 - MakeExamplePlot8
216
+ @plot[5].title = "Data Selection and Editing"
217
+ @plot[5].titlefontsize = 16
218
+ @plot[5].margintop = 40
219
+
220
+ theFac = 100.0/(100*100*100)
221
+ @plot[5].PPlotBegin(0)
222
+ for theI in -10..10
223
+ x = (0.001*theI)
224
+ y = (0.01+theFac*theI*theI*theI)
225
+ @plot[5].PPlotAdd(x, y)
226
+ end
227
+ @plot[5].PPlotEnd()
228
+ @plot[5].ds_color = "100 100 200"
229
+ @plot[5].ds_edit = "YES"
230
+ @plot[5].delete_cb = delete_cb
231
+ @plot[5].select_cb = select_cb
232
+ @plot[5].postdraw_cb = postdraw_cb
233
+ @plot[5].predraw_cb = predraw_cb
234
+ @plot[5].edit_cb = edit_cb
235
+ end
236
+
237
+ def tabs_get_index()
238
+ @tabs.valuepos.to_i
239
+ end
240
+
241
+ def initialize
242
+ # Some processing required by current tab change: the controls at left
243
+ # will be updated according to current @plot props
244
+ tabs_tabchange_cb = lambda do |ih, new_tab, old_tab|
245
+ ii=0
246
+
247
+ ss = new_tab.tabtitle
248
+ ss = ss[5..-1] # Skip "Plot "
249
+ ii = ss.to_i
250
+
251
+ # autoscaling
252
+ # X axis
253
+ if (@plot[ii].axs_xautomin=="YES" && @plot[ii].axs_xautomax=="YES")
254
+ @tgg2.value = "ON"
255
+ @dial2.active = "NO"
256
+ else
257
+ @tgg2.value = "OFF"
258
+ @dial2.active = "YES"
259
+ end
260
+ # Y axis
261
+ if (@plot[ii].axs_yautomin=="YES" && @plot[ii].axs_yautomax=="YES")
262
+ @tgg1.value = "ON"
263
+ @dial1.active = "NO"
264
+ else
265
+ @tgg1.value = "OFF"
266
+ @dial1.active = "YES"
267
+ end
268
+
269
+ # grid
270
+ if (@plot[ii].grid=="YES")
271
+ @tgg3.value = "ON"
272
+ @tgg4.value = "ON"
273
+ else
274
+ # X axis
275
+ if (@plot[ii].grid == 'VERTICAL')
276
+ @tgg3.value = "ON"
277
+ else
278
+ @tgg3.value = "OFF"
279
+ end
280
+ # Y axis
281
+ if (@plot[ii].grid == 'HORIZONTAL')
282
+ @tgg4.value = "ON"
283
+ else
284
+ @tgg4.value = "OFF"
285
+ end
286
+ end
287
+
288
+ # legend
289
+ if (@plot[ii].legendshow == "YES")
290
+ @tgg5.value = "ON"
291
+ else
292
+ @tgg5.value = "OFF"
293
+ end
294
+
295
+ Iup::DEFAULT
296
+ end
297
+
298
+
299
+ # show/hide V grid
300
+ tgg3_cb = lambda do |ih,v|
301
+ ii = tabs_get_index()
302
+
303
+ if (v!=0)
304
+ if (@tgg4.value == "ON")
305
+ @plot[ii].grid = "YES"
306
+ else
307
+ @plot[ii].grid = "VERTICAL"
308
+ end
309
+ else
310
+ if (@tgg4.value == "OFF")
311
+ @plot[ii].grid = "NO"
312
+ else
313
+ @plot[ii].grid = "HORIZONTAL"
314
+ end
315
+ end
316
+ @plot[ii].redraw = nil
317
+
318
+ Iup::DEFAULT
319
+ end
320
+
321
+
322
+ # show/hide H grid
323
+ tgg4_cb = lambda do |ih, v|
324
+ ii = tabs_get_index()
325
+
326
+ if (v!=0)
327
+ if (@tgg3.value == "ON")
328
+ @plot[ii].grid = "YES"
329
+ else
330
+ @plot[ii].grid = "HORIZONTAL"
331
+ end
332
+ else
333
+ if (@tgg3.value == "OFF")
334
+ @plot[ii].grid = "NO"
335
+ else
336
+ @plot[ii].grid = "VERTICAL"
337
+ end
338
+ end
339
+ @plot[ii].redraw = nil
340
+
341
+ Iup::DEFAULT
342
+ end
343
+
344
+
345
+ # show/hide legend
346
+ tgg5_cb = lambda do |ih, v|
347
+ ii = tabs_get_index()
348
+
349
+ if (v!=0)
350
+ @plot[ii].legendshow = "YES"
351
+ else
352
+ @plot[ii].legendshow = "NO"
353
+ end
354
+ @plot[ii].redraw = nil
355
+
356
+ Iup::DEFAULT
357
+ end
358
+
359
+
360
+ # autoscale Y
361
+ tgg1_cb = lambda do |ih, v|
362
+ ii = tabs_get_index()
363
+
364
+ if (v!=0)
365
+ @dial1.active = "NO"
366
+ @plot[ii].axs_yautomin = "YES"
367
+ @plot[ii].axs_yautomax = "YES"
368
+ else
369
+ @dial1.active = "YES"
370
+ @plot[ii].axs_yautomin = "NO"
371
+ @plot[ii].axs_yautomax = "NO"
372
+ end
373
+ @plot[ii].redraw = nil
374
+
375
+ Iup::DEFAULT
376
+ end
377
+
378
+
379
+ # autoscale X
380
+ tgg2_cb = lambda do |ih, v|
381
+ ii = tabs_get_index()
382
+
383
+ if (v!=0)
384
+ @dial2.active = "NO"
385
+ @plot[ii].axs_xautomin = "YES"
386
+ @plot[ii].axs_xautomax = "YES"
387
+ else
388
+ @dial2.active = "YES"
389
+ @plot[ii].axs_xautomin = "NO"
390
+ @plot[ii].axs_xautomax = "NO"
391
+ end
392
+ @plot[ii].redraw = nil
393
+
394
+ Iup::DEFAULT
395
+ end
396
+
397
+
398
+ # Y zoom
399
+ dial1_btndown_cb = lambda do |ih, angle|
400
+ ii = tabs_get_index()
401
+
402
+ @plot[ii].old_ymin = @plot[ii].axs_ymin
403
+ @plot[ii].old_ymax = @plot[ii].axs_ymax
404
+
405
+ Iup::DEFAULT
406
+ end
407
+
408
+ dial1_btnup_cb = lambda do |ih, angle|
409
+ ii = tabs_get_index()
410
+
411
+ x1 = @plot[ii].old_ymin.to_f
412
+ x2 = @plot[ii].old_ymax.to_f
413
+
414
+ ss = @plot[ii].axs_ymode
415
+ if ( ss && ss[3,1]=='2' )
416
+ # LOG2: one circle will zoom 2 times
417
+ xm = 4.0 * fabs(angle) / 3.141592
418
+ if (angle>0.0)
419
+ x2 /= xm
420
+ x1 *= xm
421
+ else
422
+ x2 *= xm
423
+ x1 /= xm
424
+ end
425
+ end
426
+ if ( ss && ss[3,1]=='1' )
427
+ # LOG10: one circle will zoom 10 times
428
+ xm = 10.0 * fabs(angle) / 3.141592
429
+ if (angle>0.0)
430
+ x2 /= xm
431
+ x1 *= xm
432
+ else
433
+ x2 *= xm
434
+ x1 /= xm
435
+ end
436
+ else
437
+ # LIN: one circle will zoom 2 times
438
+ xm = (x1 + x2) / 2.0
439
+ x1 = xm - (xm - x1)*(1.0-angle*1.0/3.141592)
440
+ x2 = xm + (x2 - xm)*(1.0-angle*1.0/3.141592)
441
+ end
442
+
443
+ if (x1<x2)
444
+ @plot[ii].axs_ymin = x1
445
+ @plot[ii].axs_ymax = x2
446
+ end
447
+ @plot[ii].redraw = nil
448
+
449
+ return Iup::DEFAULT
450
+ end
451
+
452
+
453
+ # X zoom
454
+ dial2_btndown_cb = lambda do |ih, angle|
455
+ ii = tabs_get_index()
456
+
457
+ @plot[ii].old_xmin = @plot[ii].axs_xmin
458
+ @plot[ii].old_xmax = @plot[ii].axs_xmax
459
+
460
+ Iup::DEFAULT
461
+ end
462
+
463
+ dial2_btnup_cb = lambda do |ih, angle|
464
+ ii = tabs_get_index()
465
+
466
+ x1 = @plot[ii].old_xmin.to_f
467
+ x2 = @plot[ii].old_xmax.to_f
468
+
469
+ xm = (x1 + x2) / 2.0
470
+
471
+ x1 = xm - (xm - x1)*(1.0-angle*1.0/3.141592) # one circle will zoom 2 times
472
+ x2 = xm + (x2 - xm)*(1.0-angle*1.0/3.141592)
473
+
474
+ @plot[ii].axs_xmin = x1
475
+ @plot[ii].axs_xmax = x2
476
+
477
+ @plot[ii].redraw = nil
478
+
479
+ Iup::DEFAULT
480
+ end
481
+
482
+ bt1_cb = lambda do |ih|
483
+ p "bt1_cb"
484
+ ii = tabs_get_index()
485
+ # cnv = Cd.CreateCanvas(Cd.ContextPDF(), "pplot.pdf -o")
486
+ # Iup.PPlotPaintTo(@plot[ii], cnv)
487
+ # Cd.KillCanvas(cnv)
488
+ Iup::DEFAULT
489
+ end
490
+
491
+
492
+ @plot = Array.new(MAXPLOT)
493
+ # create plots
494
+ for ii in 0...MAXPLOT
495
+ @plot[ii] = Iup.PPlot()
496
+ end
497
+
498
+ # left panel: @plot control
499
+ # Y zooming
500
+ @dial1 = Iup.Dial("VERTICAL")
501
+ lbl1 = Iup.Label("+")
502
+ lbl2 = Iup.Label("-")
503
+ boxinfo = Iup.Vbox([lbl1, Iup.Fill(),lbl2])
504
+ boxdial1 = Iup.Hbox([boxinfo, @dial1])
505
+
506
+ boxdial1.align = "ACENTER"
507
+ boxinfo.align = "ACENTER"
508
+ boxinfo.size = "20x52"
509
+ boxinfo.gap = 2
510
+ boxinfo.margin = 4
511
+ boxinfo.expand = "YES"
512
+ lbl1.expand = "NO"
513
+ lbl2.expand = "NO"
514
+
515
+ @dial1.active = "NO"
516
+ @dial1.size = "20x52"
517
+ @dial1.button_press_cb = dial1_btndown_cb
518
+ @dial1.mousemove_cb = dial1_btnup_cb
519
+ @dial1.button_release_cb = dial1_btnup_cb
520
+
521
+ @tgg1 = Iup.Toggle("Y Autoscale")
522
+ @tgg1.action = tgg1_cb
523
+ @tgg1.value = "ON"
524
+
525
+ f1 = Iup.Frame( Iup.Vbox([boxdial1, @tgg1]),:title=> "Y Zoom" )
526
+
527
+ # X zooming
528
+ @dial2 = Iup.Dial("HORIZONTAL")
529
+ lbl1 = Iup.Label("-")
530
+ lbl2 = Iup.Label("+")
531
+ boxinfo = Iup.Hbox([lbl1, Iup.Fill(), lbl2])
532
+ boxdial2 = Iup.Vbox([@dial2, boxinfo])
533
+
534
+ boxdial2.align = "ACENTER"
535
+ boxinfo.align = "ACENTER"
536
+ boxinfo.size = "64x16"
537
+ boxinfo.gap = 2
538
+ boxinfo.margin = 4
539
+ boxinfo.expand = "HORIZONTAL"
540
+
541
+ lbl1.expand = "NO"
542
+ lbl2.expand = "NO"
543
+
544
+ @dial2.active = "NO"
545
+ @dial2.size = "64x16"
546
+ @dial2.button_press_cb = dial2_btndown_cb
547
+ @dial2.mousemove_cb = dial2_btnup_cb
548
+ @dial2.button_release_cb = dial2_btnup_cb
549
+
550
+ @tgg2 = Iup.Toggle("X Autoscale")
551
+ @tgg2.action = tgg2_cb
552
+ @tgg2.value = "ON"
553
+
554
+ f2 = Iup.Frame( Iup.Vbox([boxdial2, @tgg2]),:title=> "X Zoom")
555
+
556
+ lbl1 = Iup.Label(:title=>"",:separator=>"HORIZONTAL")
557
+
558
+ @tgg3 = Iup.Toggle("Vertical Grid")
559
+ @tgg3.action = tgg3_cb
560
+
561
+ @tgg4 = Iup.Toggle("Hirozontal Grid")
562
+ @tgg4.action = tgg4_cb
563
+
564
+ lbl2 = Iup.Label(:title=>"",:separator=>"HORIZONTAL")
565
+
566
+ @tgg5 = Iup.Toggle("Legend", nil)
567
+ @tgg5.action = tgg5_cb
568
+
569
+ lbl3 = Iup.Label(:title=>"",:separator=>"HORIZONTAL")
570
+
571
+ bt1 = Iup.Button("Export PDF")
572
+ bt1.action = bt1_cb
573
+
574
+ vboxl = Iup.Vbox([f1, f2, lbl1, @tgg3, @tgg4, lbl2, @tgg5, lbl3, bt1],:gap=>4,:expand=>"NO")
575
+
576
+ vboxr = Array.new(MAXPLOT) # tabs containing the plots
577
+ # right panel: tabs with plots
578
+ for ii in 0...MAXPLOT
579
+ vboxr[ii] = Iup.Vbox([@plot[ii]]) # each @plot a tab
580
+ vboxr[ii].tabtitle = "Plot #{ii}"
581
+ end
582
+
583
+ @tabs = Iup.Tabs(vboxr) # create tabs
584
+ @tabs.tabchange_cb = tabs_tabchange_cb
585
+
586
+ # dialog
587
+ hbox = Iup.Hbox([vboxl, @tabs],:margin =>"4x4",:gap=>10)
588
+
589
+ dlg = Iup.Dialog(hbox,:size=>"600x240",:title=>"IupPPlot Example")
590
+
591
+ InitPlots() # It must be able to be done independent of dialog Mapping
592
+
593
+ #tabs_tabchange_cb.call(@tabs, vboxr[0], 0)
594
+
595
+ dlg.ShowXY(Iup::CENTER, Iup::CENTER)
596
+ Iup.MainLoop
597
+ dlg.Destroy
598
+ end
599
+ end
600
+
601
+ plot = IupPlotTest.new