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.
- data/CHANGES +3 -0
- data/MANIFEST +8 -0
- data/MIT-LICENSE +18 -0
- data/README +12 -0
- data/Rakefile +85 -0
- data/doc/README +10 -0
- data/doc/build_install.txt +74 -0
- data/examples/README +16 -0
- data/examples/ctrl/cbox.rb +220 -0
- data/examples/ctrl/checkboard.rb +33 -0
- data/examples/ctrl/degrade.rb +76 -0
- data/examples/ctrl/example1.rb +53 -0
- data/examples/ctrl/example2.rb +39 -0
- data/examples/ctrl/iupcolorbar.rb +95 -0
- data/examples/ctrl/iupcolorbrowser.rb +45 -0
- data/examples/ctrl/iupdial.rb +117 -0
- data/examples/ctrl/iupgauge.rb +242 -0
- data/examples/ctrl/iupgetcolor.rb +8 -0
- data/examples/ctrl/iupgetparam.rb +62 -0
- data/examples/ctrl/iupglcanvas.rb +172 -0
- data/examples/ctrl/iupmask.rb +13 -0
- data/examples/ctrl/iupmatrix.rb +39 -0
- data/examples/ctrl/iupplot2.rb +601 -0
- data/examples/ctrl/iuptabs.rb +22 -0
- data/examples/ctrl/iuptree.rb +190 -0
- data/examples/ctrl/iupval.rb +71 -0
- data/examples/ctrl/numbering.rb +46 -0
- data/examples/ctrl/sample.rb +166 -0
- data/examples/dlg/iupalarm.rb +16 -0
- data/examples/dlg/iupfiledlg.rb +19 -0
- data/examples/dlg/iupgetfile.rb +19 -0
- data/examples/dlg/iuplistdialog.rb +26 -0
- data/examples/dlg/iupmessage.rb +5 -0
- data/examples/dlg/iupscanf.rb +17 -0
- data/examples/elem/iupbutton.rb +180 -0
- data/examples/elem/iupcanvas.rb +29 -0
- data/examples/elem/iupcanvas2.rb +114 -0
- data/examples/elem/iupcanvas3.rb +52 -0
- data/examples/elem/iupdialog.rb +67 -0
- data/examples/elem/iupdialog2.rb +25 -0
- data/examples/elem/iupfill.rb +51 -0
- data/examples/elem/iupframe.rb +25 -0
- data/examples/elem/iuphbox.rb +68 -0
- data/examples/elem/iupimage.rb +113 -0
- data/examples/elem/iupitem.rb +60 -0
- data/examples/elem/iuplabel.rb +57 -0
- data/examples/elem/iuplist.rb +41 -0
- data/examples/elem/iuplist2.rb +125 -0
- data/examples/elem/iupmenu.rb +32 -0
- data/examples/elem/iupmultiline.rb +24 -0
- data/examples/elem/iupmultiline2.rb +156 -0
- data/examples/elem/iupradio.rb +32 -0
- data/examples/elem/iupseparator.rb +81 -0
- data/examples/elem/iupsubmenu.rb +85 -0
- data/examples/elem/iuptimer.rb +36 -0
- data/examples/elem/iuptoggle.rb +110 -0
- data/examples/elem/iupvbox.rb +87 -0
- data/examples/elem/iupzbox.rb +60 -0
- data/examples/elem/mdisample.rb +377 -0
- data/examples/elem/progressbar.rb +280 -0
- data/examples/elem/scrollbar.rb +66 -0
- data/examples/elem/tray.rb +90 -0
- data/examples/func/iupgetattribute.rb +32 -0
- data/examples/func/iupidle.rb +48 -0
- data/lib/iup.so +0 -0
- data/ruby-iup.gemspec +26 -0
- data/test/test_ruby_iup.rb +25 -0
- metadata +132 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
# Shows a dialog similar to the one shown when you exit a program without saving.
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'iup'
|
5
|
+
|
6
|
+
case(Iup.Alarm("IupAlarm Example","File not saved! Save it now?", "Yes", "No", "Cancel"))
|
7
|
+
when 1
|
8
|
+
Iup.Message("Save file", "File saved sucessfully - leaving program")
|
9
|
+
when 2
|
10
|
+
Iup.Message("Save file", "File not saved - leaving program anyway")
|
11
|
+
when 3
|
12
|
+
Iup.Message("Save file", "Operation canceled")
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
|
5
|
+
filedlg = Iup.FileDlg(:dialogtype=>"SAVE",:title=>"File Save",:filter=>"*.jpg",:filterinfo=>"JPEG Files")
|
6
|
+
|
7
|
+
filedlg.Popup(Iup::CENTER, Iup::CENTER)
|
8
|
+
|
9
|
+
case(filedlg.status)
|
10
|
+
when '1'
|
11
|
+
Iup.Message("New file",filedlg.value)
|
12
|
+
when '0'
|
13
|
+
Iup.Message("File already exists",filedlg.value)
|
14
|
+
when '-1'
|
15
|
+
Iup.Message("IupFileDlg","Operation Canceled")
|
16
|
+
end
|
17
|
+
|
18
|
+
filedlg.Destroy()
|
19
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
file = "./*.txt"
|
5
|
+
file,err = Iup.GetFile(file)
|
6
|
+
case(err)
|
7
|
+
when 1
|
8
|
+
Iup.Message("New file",file)
|
9
|
+
when 0
|
10
|
+
Iup.Message("File already exists",file)
|
11
|
+
when -1
|
12
|
+
Iup.Message("IupFileDlg","Operation canceled")
|
13
|
+
when -2
|
14
|
+
Iup.Message("IupFileDlg","Allocation error")
|
15
|
+
when -3
|
16
|
+
Iup.Message("IupFileDlg","Invalid parameter")
|
17
|
+
end
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
marks = [0,0,0,0,1,1,0,0]
|
5
|
+
options = ["Blue","Red","Green" ,"Yellow","Black","White","Gray","Brown"]
|
6
|
+
size = options.size
|
7
|
+
|
8
|
+
marks,error = Iup.ListDialog(2,"Color Selection",size,options,0,16,5,marks)
|
9
|
+
|
10
|
+
if(error == -1)
|
11
|
+
Iup.Message("IupListDialog","Operation canceled");
|
12
|
+
else
|
13
|
+
selection = ""
|
14
|
+
|
15
|
+
marks.each_index {|i|
|
16
|
+
selection += options[i]+"\n" if(marks[i]==1)
|
17
|
+
}
|
18
|
+
|
19
|
+
if(selection!="")
|
20
|
+
Iup.Message("Options selected",selection)
|
21
|
+
else
|
22
|
+
Iup.Message("IupListDialog","No option selected")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'iup'
|
3
|
+
|
4
|
+
text = "This is a vector of characters"
|
5
|
+
real = 0.0012
|
6
|
+
integer = 12
|
7
|
+
fmt = "Data entering example\n" +
|
8
|
+
"text = %300.40%s\n" +
|
9
|
+
"real = %20.10%g\n" +
|
10
|
+
"integer = %20.10%d\n"
|
11
|
+
text,real,integer = Iup.Scanf(fmt,text,real,integer)
|
12
|
+
if text.nil? then
|
13
|
+
Iup.Message("IupScanf","Operation canceled")
|
14
|
+
else
|
15
|
+
string = "Text: #{text}\nReal: #{real}\nInteger: #{integer}\n"
|
16
|
+
Iup.Message("IupScanf",string)
|
17
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
#
|
2
|
+
# IupButton example
|
3
|
+
# Description : Creates four buttons. The first uses images, the second
|
4
|
+
# turns the first on and off, the third exits the
|
5
|
+
# application and the last does nothing
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'iup'
|
10
|
+
|
11
|
+
#* Defines released button's image
|
12
|
+
|
13
|
+
pixmap_release = [
|
14
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
15
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,
|
16
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
17
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
18
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
19
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
20
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
21
|
+
1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2,
|
22
|
+
1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2,
|
23
|
+
1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2,
|
24
|
+
1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2,
|
25
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
26
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
27
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
28
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
29
|
+
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
30
|
+
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
|
31
|
+
]
|
32
|
+
|
33
|
+
#* Defines pressed button's image
|
34
|
+
pixmap_press = [
|
35
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
36
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,
|
37
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
38
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
39
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
40
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
41
|
+
1,1,3,3,3,3,3,4,4,3,3,3,3,3,2,2,
|
42
|
+
1,1,3,3,3,3,4,4,4,4,3,3,3,3,2,2,
|
43
|
+
1,1,3,3,3,3,4,4,4,4,3,3,3,3,2,2,
|
44
|
+
1,1,3,3,3,3,3,4,4,3,3,3,3,3,2,2,
|
45
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
46
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
47
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
48
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
49
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
50
|
+
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
51
|
+
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
|
52
|
+
]
|
53
|
+
|
54
|
+
#* Defines inactive button's image
|
55
|
+
pixmap_inactive = [
|
56
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
57
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,
|
58
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
59
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
60
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
61
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
62
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
63
|
+
1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2,
|
64
|
+
1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2,
|
65
|
+
1,1,3,3,3,3,3,4,4,4,4,3,3,3,2,2,
|
66
|
+
1,1,3,3,3,3,3,3,4,4,3,3,3,3,2,2,
|
67
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
68
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
69
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
70
|
+
1,1,3,3,3,3,3,3,3,3,3,3,3,3,2,2,
|
71
|
+
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
72
|
+
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
|
73
|
+
]
|
74
|
+
|
75
|
+
# Creates a text
|
76
|
+
text = Iup.Text(:readonly=>"YES")
|
77
|
+
|
78
|
+
# Defines released button's image size
|
79
|
+
img_release = Iup.Image(16, 16, pixmap_release)
|
80
|
+
|
81
|
+
# Defines released button's image colors
|
82
|
+
img_release["1"] = "215 215 215"
|
83
|
+
img_release["2"] = "40 40 40"
|
84
|
+
img_release["3"] = "30 50 210"
|
85
|
+
img_release["4"] = "240 0 0"
|
86
|
+
|
87
|
+
# Defines pressed button's image size
|
88
|
+
img_press = Iup.Image( 16, 16, pixmap_press )
|
89
|
+
|
90
|
+
# Defines pressed button's image colors
|
91
|
+
img_press["1"] = "40 40 40"
|
92
|
+
img_press["2"] = "215 215 215"
|
93
|
+
img_press["3"] = "0 20 180"
|
94
|
+
img_press["4"] = "210 0 0"
|
95
|
+
|
96
|
+
# Defines inactive button's image size
|
97
|
+
img_inactive = Iup.Image( 16, 16, pixmap_inactive )
|
98
|
+
|
99
|
+
# Defines inactive button's image colors
|
100
|
+
img_inactive["1"] = "215 215 215"
|
101
|
+
img_inactive["2"] = "40 40 40"
|
102
|
+
img_inactive["3"] = "100 100 100"
|
103
|
+
img_inactive["4"] = "200 200 200"
|
104
|
+
|
105
|
+
# Creates a button
|
106
|
+
btn_image = Iup.Button(:title=>"Button with image",:image=>img_release,:impress=>img_press,:iminactive=>img_inactive)
|
107
|
+
|
108
|
+
# Creates a button
|
109
|
+
btn_big = Iup.Button(:title=>"Big useless button",:size=>"EIGHTHxEIGHTH")
|
110
|
+
|
111
|
+
# Creates a button entitled Exit associated with action exit_act
|
112
|
+
btn_exit = Iup.Button("Exit")
|
113
|
+
|
114
|
+
# Creates a button entitled on/off associated with action onoff_act
|
115
|
+
btn_on_off = Iup.Button("on/off")
|
116
|
+
|
117
|
+
# Creates dialog with the four buttons and the text
|
118
|
+
dlg = Iup.Dialog(
|
119
|
+
Iup.Vbox([
|
120
|
+
Iup.Hbox([
|
121
|
+
btn_image,
|
122
|
+
btn_on_off,
|
123
|
+
btn_exit]),
|
124
|
+
text,
|
125
|
+
btn_big]),
|
126
|
+
:expand=>"YES",:title=>"IupButton",:resize=>"NO",
|
127
|
+
:menubox=>"NO",:maxbox=>"NO",:minbox=>"NO")
|
128
|
+
|
129
|
+
|
130
|
+
btn_on_off_cb = lambda do |ih|
|
131
|
+
# If the button with with image is active...
|
132
|
+
if(btn_image.active=="YES")
|
133
|
+
# Deactivates the button with image
|
134
|
+
btn_image.active = "NO"
|
135
|
+
# else it is inactive
|
136
|
+
else
|
137
|
+
# Activates the button with image
|
138
|
+
btn_image.active = "YES"
|
139
|
+
end
|
140
|
+
|
141
|
+
# Executed function sucessfully
|
142
|
+
Iup::DEFAULT
|
143
|
+
end
|
144
|
+
|
145
|
+
btn_image_button_cb = lambda do |ih,b,e,x,y,status|
|
146
|
+
# If the left button changed its state...
|
147
|
+
if b == Iup::BUTTON1
|
148
|
+
# If the button was pressed...
|
149
|
+
if e == 1
|
150
|
+
# Sets text's value
|
151
|
+
text.value = "Red button pressed"
|
152
|
+
# else the button was released
|
153
|
+
else
|
154
|
+
# Sets text's value
|
155
|
+
text.value = "Red button released"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# Executed function sucessfully
|
160
|
+
Iup::DEFAULT
|
161
|
+
end
|
162
|
+
|
163
|
+
btn_exit_cb = lambda do |ih|
|
164
|
+
# Exits the program
|
165
|
+
Iup::CLOSE
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
# Registers callbacks
|
170
|
+
btn_exit.action = btn_exit_cb
|
171
|
+
btn_on_off.action = btn_on_off_cb
|
172
|
+
btn_image.button_cb = btn_image_button_cb
|
173
|
+
|
174
|
+
# Shows dialog on the center of the screen
|
175
|
+
dlg.ShowXY(Iup::CENTER, Iup::CENTER )
|
176
|
+
|
177
|
+
# Initializes IUP main loop
|
178
|
+
Iup.MainLoop()
|
179
|
+
|
180
|
+
dlg.Destroy()
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# IupCanvas example
|
2
|
+
# Description : Creates a IUP canvas and uses CD to draw on it
|
3
|
+
# Remark : IUP must be linked to the CD library
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'iup'
|
7
|
+
|
8
|
+
|
9
|
+
cdcanvas = nil
|
10
|
+
|
11
|
+
repaint_cb = lambda do |ih,x,y|
|
12
|
+
cdcanvas.CanvasActivate()
|
13
|
+
cdcanvas.CanvasBackground(Cd::BLACK)
|
14
|
+
cdcanvas.CanvasClear()
|
15
|
+
cdcanvas.CanvasForeground(Cd::BLUE)
|
16
|
+
cdcanvas.CanvasBox(0, 100, 0, 100)
|
17
|
+
Iup::DEFAULT
|
18
|
+
end
|
19
|
+
|
20
|
+
cnvs = Iup.Canvas(:action=>repaint_cb,:size=>"300x100")
|
21
|
+
dlg = Iup.Dialog(Iup.Frame(cnvs),:title=>"IupCanvas + Canvas Draw" )
|
22
|
+
dlg.Map
|
23
|
+
|
24
|
+
cdcanvas = Cd.CreateCanvas( Cd.CD_IUP, cnvs )
|
25
|
+
|
26
|
+
dlg.ShowXY(Iup::CENTER, Iup::CENTER )
|
27
|
+
|
28
|
+
Iup.MainLoop()
|
29
|
+
dlg.Destroy()
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# Advanced IupCanvas example
|
2
|
+
# Description : This example shows how several canvas callbacks are used and how the scrollbar works.
|
3
|
+
# Remark : IUP must be linked to the CD library
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'iup'
|
7
|
+
|
8
|
+
|
9
|
+
image = []
|
10
|
+
for x in 0...640
|
11
|
+
image[x] = []
|
12
|
+
for y in 0...400
|
13
|
+
image[x][y]=0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
label = Iup.Label("IupCanvas")
|
18
|
+
|
19
|
+
iupcanvas = Iup.Canvas()
|
20
|
+
iupcanvas.attr = "CURSOR=CROSS, RASTERSIZE=320x200, EXPAND=NO, SCROLLBAR=YES, DX=0.5, DY=0.5"
|
21
|
+
|
22
|
+
repaint_cb = lambda do |ih,x,y|
|
23
|
+
sx = ih.posx.to_f
|
24
|
+
sy = -ih.posy.to_f
|
25
|
+
|
26
|
+
cdcanvas = Cd.ActiveCanvas()
|
27
|
+
return Iup::DEFAULT if cdcanvas == nil
|
28
|
+
|
29
|
+
cdcanvas.CanvasClear()
|
30
|
+
|
31
|
+
for x in 0...320
|
32
|
+
for y in 0...200
|
33
|
+
cdcanvas.CanvasMark(x,y) if(image[(320.0*sx).to_i+x][(200.0*sy).to_i+y]!=0)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
Iup::DEFAULT
|
37
|
+
end
|
38
|
+
|
39
|
+
button_cb = lambda do |ih, botao, estado, x, y,status|
|
40
|
+
sx = ih.posx.to_f
|
41
|
+
sy = -ih.posy.to_f
|
42
|
+
|
43
|
+
cdcanvas = Cd.ActiveCanvas()
|
44
|
+
y = cdcanvas.CanvasUpdateYAxis(y)
|
45
|
+
if(botao == Iup::BUTTON1 && estado!=0)
|
46
|
+
cdcanvas.CanvasMark(x,y)
|
47
|
+
image[(320.0*sx).to_i+x][(200.0*sy).to_i+y] = 1
|
48
|
+
end
|
49
|
+
|
50
|
+
Iup::DEFAULT
|
51
|
+
end
|
52
|
+
|
53
|
+
motion_cb = lambda do |ih, x, y,status|
|
54
|
+
sx = ih.posx.to_f
|
55
|
+
|
56
|
+
sy = -ih.posy.to_f
|
57
|
+
|
58
|
+
buffer = "(#{(320.0*sx).to_i+x}, #{(200.0*sy).to_i+y})"
|
59
|
+
|
60
|
+
label.title = buffer
|
61
|
+
|
62
|
+
Iup::DEFAULT
|
63
|
+
end
|
64
|
+
|
65
|
+
scroll_cb = lambda do |ih,op,posx,posy|
|
66
|
+
repaint_cb.call(ih,0.0,0.0)
|
67
|
+
|
68
|
+
Iup::DEFAULT
|
69
|
+
end
|
70
|
+
|
71
|
+
enter_cb = lambda do |ih|
|
72
|
+
Cd.Background(Cd::WHITE)
|
73
|
+
repaint_cb.call(ih,0.0,0.0)
|
74
|
+
|
75
|
+
Iup::DEFAULT
|
76
|
+
end
|
77
|
+
|
78
|
+
leave_cb = lambda do |ih|
|
79
|
+
Cd.Background(Cd::GRAY)
|
80
|
+
repaint_cb.call(ih,0.0,0.0)
|
81
|
+
label = Iup.GetHandle("label")
|
82
|
+
label.title = "IupCanvas"
|
83
|
+
|
84
|
+
Iup::DEFAULT
|
85
|
+
end
|
86
|
+
|
87
|
+
iupcanvas.action = repaint_cb
|
88
|
+
iupcanvas.button_cb = button_cb
|
89
|
+
iupcanvas.scroll_cb = scroll_cb
|
90
|
+
iupcanvas.motion_cb = motion_cb
|
91
|
+
iupcanvas.enterwindow_cb = enter_cb
|
92
|
+
iupcanvas.leavewindow_cb = leave_cb
|
93
|
+
|
94
|
+
dlg = Iup.Dialog(Iup.Vbox([iupcanvas,Iup.Hbox([Iup.Fill(), label, Iup.Fill()])]))
|
95
|
+
dlg.attr = "TITLE=IupCanvas, RESIZE=NO, MAXBOX=NO"
|
96
|
+
|
97
|
+
dlg.ShowXY(Iup::CENTER,Iup::CENTER)
|
98
|
+
|
99
|
+
cdcanvas = Cd.CreateCanvas(Cd.CD_IUP, iupcanvas)
|
100
|
+
if(cdcanvas==nil)
|
101
|
+
Iup.Message("IupCanvas","Error creating canvas")
|
102
|
+
dlg.Destroy
|
103
|
+
exit
|
104
|
+
end
|
105
|
+
|
106
|
+
if(cdcanvas.Activate() == Cd::ERROR)
|
107
|
+
Iup.Message("IupCanvas","Error creating canvas")
|
108
|
+
dlg.Destroy
|
109
|
+
exit
|
110
|
+
end
|
111
|
+
|
112
|
+
cdcanvas.CanvasClear
|
113
|
+
Iup.MainLoop
|
114
|
+
dlg.Destroy
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# IupCanvas Redraw example
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'iup'
|
5
|
+
|
6
|
+
need_redraw = 0
|
7
|
+
redraw_count = 0
|
8
|
+
cdcanvas = nil
|
9
|
+
|
10
|
+
|
11
|
+
gauge = Iup.ProgressBar()
|
12
|
+
cv = Iup.Canvas()
|
13
|
+
bt = Iup.Button("Start/Stop")
|
14
|
+
bt.size = "50x50"
|
15
|
+
gauge.size = "200x15"
|
16
|
+
cv.size = "200x200"
|
17
|
+
dlg = Iup.Dialog(Iup.Vbox([cv, Iup.Hbox([gauge, bt])]),:title=>"Redraw test")
|
18
|
+
|
19
|
+
toggle_redraw = lambda do |ih|
|
20
|
+
cdcanvas.CanvasActivate() if cdcanvas
|
21
|
+
need_redraw = 1 - need_redraw
|
22
|
+
Iup::DEFAULT
|
23
|
+
end
|
24
|
+
|
25
|
+
redraw = lambda do
|
26
|
+
if(need_redraw == 1)
|
27
|
+
cdcanvas.CanvasBox(0, 300, 0, redraw_count/100)
|
28
|
+
gauge.value = redraw_count/30000.0
|
29
|
+
redraw_count += 1
|
30
|
+
if(redraw_count==30000)
|
31
|
+
cdcanvas.CanvasClear()
|
32
|
+
redraw_count = 0
|
33
|
+
need_redraw = 0
|
34
|
+
end
|
35
|
+
end
|
36
|
+
Iup::DEFAULT
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
Iup.SetIdle(redraw)
|
41
|
+
|
42
|
+
dlg.Map()
|
43
|
+
|
44
|
+
cdcanvas = Cd.CreateCanvas(Cd.CD_IUP, cv)
|
45
|
+
cdcanvas.CanvasForeground(Cd::BLUE)
|
46
|
+
cdcanvas.CanvasClear()
|
47
|
+
|
48
|
+
bt.action = toggle_redraw
|
49
|
+
|
50
|
+
dlg.ShowXY(Iup::CENTER, Iup::CENTER)
|
51
|
+
Iup.MainLoop()
|
52
|
+
dlg.Destroy()
|