iup-ffi 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/LICENCE.txt +21 -0
  3. data/README.rdoc +348 -0
  4. data/lib/iup-ffi-plain.rb +9 -0
  5. data/lib/iup-ffi.rb +76 -0
  6. data/lib/plain/iupcdlib.rb +107 -0
  7. data/lib/plain/iupcontrolslib.rb +24 -0
  8. data/lib/plain/iupimglib.rb +14 -0
  9. data/lib/plain/iupimlib.rb +16 -0
  10. data/lib/plain/iuplib.rb +209 -0
  11. data/lib/plain/scintilla-lib.rb +15 -0
  12. data/lib/wrapped/attribute-builders.rb +105 -0
  13. data/lib/wrapped/attribute-reference.rb +27 -0
  14. data/lib/wrapped/background-box.rb +33 -0
  15. data/lib/wrapped/button.rb +108 -0
  16. data/lib/wrapped/callback-setter.rb +78 -0
  17. data/lib/wrapped/canvas.rb +467 -0
  18. data/lib/wrapped/colourbar.rb +94 -0
  19. data/lib/wrapped/colourdialog.rb +63 -0
  20. data/lib/wrapped/common-attributes.rb +64 -0
  21. data/lib/wrapped/constants.rb +953 -0
  22. data/lib/wrapped/dial.rb +87 -0
  23. data/lib/wrapped/dialog.rb +176 -0
  24. data/lib/wrapped/dialogs.rb +106 -0
  25. data/lib/wrapped/drag-drop-attributes.rb +57 -0
  26. data/lib/wrapped/dynamic-fill-methods.rb +27 -0
  27. data/lib/wrapped/expander.rb +65 -0
  28. data/lib/wrapped/filedialog.rb +93 -0
  29. data/lib/wrapped/fill.rb +26 -0
  30. data/lib/wrapped/fontdialog.rb +42 -0
  31. data/lib/wrapped/frame.rb +47 -0
  32. data/lib/wrapped/gridbox.rb +94 -0
  33. data/lib/wrapped/hbox.rb +49 -0
  34. data/lib/wrapped/image-attributes.rb +27 -0
  35. data/lib/wrapped/image.rb +118 -0
  36. data/lib/wrapped/internal-drag-drop-attributes.rb +21 -0
  37. data/lib/wrapped/iup-global.rb +51 -0
  38. data/lib/wrapped/label.rb +98 -0
  39. data/lib/wrapped/link.rb +59 -0
  40. data/lib/wrapped/list.rb +353 -0
  41. data/lib/wrapped/matrix.rb +233 -0
  42. data/lib/wrapped/menu.rb +50 -0
  43. data/lib/wrapped/menuitem.rb +80 -0
  44. data/lib/wrapped/messagedialog.rb +51 -0
  45. data/lib/wrapped/progressbar.rb +48 -0
  46. data/lib/wrapped/progressdialog.rb +111 -0
  47. data/lib/wrapped/radio.rb +43 -0
  48. data/lib/wrapped/scintilla.rb +277 -0
  49. data/lib/wrapped/scrollbar-attributes.rb +141 -0
  50. data/lib/wrapped/scrollbox.rb +147 -0
  51. data/lib/wrapped/separator.rb +11 -0
  52. data/lib/wrapped/splitbox.rb +48 -0
  53. data/lib/wrapped/stretchbox.rb +42 -0
  54. data/lib/wrapped/submenu.rb +34 -0
  55. data/lib/wrapped/tabs.rb +149 -0
  56. data/lib/wrapped/text.rb +225 -0
  57. data/lib/wrapped/timer.rb +42 -0
  58. data/lib/wrapped/toggle.rb +98 -0
  59. data/lib/wrapped/tree.rb +465 -0
  60. data/lib/wrapped/val.rb +97 -0
  61. data/lib/wrapped/vbox.rb +51 -0
  62. data/lib/wrapped/widget.rb +137 -0
  63. data/lib/wrapped/zbox.rb +54 -0
  64. metadata +124 -0
@@ -0,0 +1,80 @@
1
+ module Iup
2
+
3
+ # A menu item is part of a menu, and acts like a button.
4
+ # The menu item can display a simple text label, an image,
5
+ # or act as a check box.
6
+ #
7
+ # == Attributes
8
+ #
9
+ # autotoggle:: Sets auto toggle for item when menu activated, values 'yes' / 'no'.
10
+ # hidemark:: If set, hides the mark. Values 'yes' / 'no'.
11
+ # image:: Image used when check enabled.
12
+ # impress:: Image used when check disabled.
13
+ # title:: Label to display on menu item.
14
+ # titleimage:: Image to show on menu item.
15
+ # value:: Determines if check is enabled or not, values 'off' / 'on'.
16
+ # wid:: <b>read-only</b> Native widget identifier.
17
+ #
18
+ class MenuItem < Widget
19
+
20
+ # Creates an instance of MenuItem.
21
+ #
22
+ # title:: Label to display
23
+ # callback:: Optional action to call when MenuItem is clicked.
24
+ # block:: Optional block to set up menu item's attributes.
25
+ def initialize title, callback = nil, &block
26
+ @handle = IupLib.IupItem title, nil
27
+
28
+ action callback unless callback.nil?
29
+
30
+ # run any provided block on instance, to set up further attributes
31
+ self.instance_eval &block if block_given?
32
+ end
33
+
34
+ # -- attributes
35
+
36
+ define_attribute :autotoggle
37
+ define_attribute :hidemark
38
+
39
+ def image val=nil # :nodoc:
40
+ attribute_reference 'IMAGE', ImageWidget, val
41
+ end
42
+
43
+ def iminactive val=nil # :nodoc:
44
+ attribute_reference 'IMINACTION', ImageWidget, val
45
+ end
46
+
47
+ define_attribute :title
48
+
49
+ def titleimage val=nil # :nodoc:
50
+ attribute_reference 'TITLEIMAGE', ImageWidget, val
51
+ end
52
+
53
+ define_attribute :value
54
+ define_attribute :wid
55
+
56
+ # -- callbacks
57
+
58
+ # Action generated when the element is activated.
59
+ def action callback
60
+ unless callback.arity.zero?
61
+ raise ArgumentError, 'action callback must take 0 arguments'
62
+ end
63
+ cb = Proc.new do |ih|
64
+ callback.call
65
+ end
66
+ define_callback cb, 'ACTION', :plain
67
+ end
68
+
69
+ # Action generated when the item is highlighted.
70
+ def highlight_cb callback
71
+ unless callback.arity.zero?
72
+ raise ArgumentError, 'highlight_cb callback must take 0 arguments'
73
+ end
74
+ cb = Proc.new do |ih|
75
+ callback.call
76
+ end
77
+ define_callback cb, 'HIGHLIGHT_CB', :plain
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,51 @@
1
+ module Iup
2
+
3
+ # A MessageDialog is used to display a message along with one or more buttons.
4
+ #
5
+ # Also see: Iup#message
6
+ #
7
+ # == Attributes
8
+ #
9
+ # buttondefault:: Index of default button, '1' / '2' / '3'.
10
+ # buttonresponse:: Index of the pressed button, '1' / '2' / '3'.
11
+ # buttons:: Choice of buttons to display: 'OK' / 'OKCANCEL' / 'RETRYCANCEL' / 'YESNO' / 'YESNOCANCEL'.
12
+ # If help_cb is defined, then a 'help' button is also displayed.
13
+ # dialogtype:: Selects the icon to display:
14
+ # 'error' / 'information' / 'message' / 'question' / 'warning'.
15
+ # parentdialog:: This dialog will be always in front of the parent dialog.
16
+ # If the parent is minimized, this dialog is automatically minimized.
17
+ # *Important* Closing the parent will also close the child, but the
18
+ # child dialog's CLOSE_CB method will not be called.
19
+ # title:: Title text for the message dialog.
20
+ # value:: Message text to display within the dialog.
21
+ #
22
+ class MessageDialog < Widget
23
+
24
+ # Creates a dialog, using the optional block to set its attributes.
25
+ def initialize &block
26
+ @handle = IupLib.IupMessageDlg
27
+
28
+ self.instance_eval &block if block_given?
29
+ end
30
+
31
+ # Shows the dialog at position x, y.
32
+ def popup x=0, y=0
33
+ IupLib.IupPopup @handle, x, y
34
+ end
35
+
36
+ # -- attributes
37
+
38
+ define_attribute :buttondefault
39
+ define_attribute :buttonresponse
40
+ define_attribute :buttons
41
+ define_attribute :dialogtype
42
+
43
+ def parentdialog parent=nil # :nodoc:
44
+ attribute_reference 'PARENTDIALOG', Dialog, parent
45
+ end
46
+
47
+ define_attribute :title
48
+ define_attribute :value
49
+ end
50
+ end
51
+
@@ -0,0 +1,48 @@
1
+ module Iup
2
+
3
+ # A progress bar control, showing a percent-complete value.
4
+ #
5
+ # == Attributes
6
+ #
7
+ # dashed:: Changes style of progress bar to a dashed pattern, as 'yes' / 'no'.
8
+ # expand:: Allows bar to fill available space in indicated direction.
9
+ # Values 'no' / 'horizontal' / 'vertical' / 'yes'.
10
+ # marquee:: Displays an undefined state if set. Values 'yes' / 'no'.
11
+ # max:: maximum value, default 1.
12
+ # min:: minimum value, default 0.
13
+ # orientation:: 'horizontal' / 'vertical'.
14
+ # position:: <b>read-only</b> returns position in pixels within client window
15
+ # as "x,y".
16
+ # rastersize:: Size of the widget, in pixels, value as "widthxheight".
17
+ # screenposition:: <b>read-only</b> returns position in pixels on screen
18
+ # as "x,y".
19
+ # tip:: Tooltip string.
20
+ # value:: number between +min+ and +max+, for current position.
21
+ #
22
+ class ProgressBar < Widget
23
+
24
+ # Creates an instance of a progress bar.
25
+ # block:: optional block to set up the widget's appearance.
26
+ def initialize &block
27
+ @handle = IupLib.IupProgressBar
28
+
29
+ # run any provided block on instance, to set up further attributes
30
+ self.instance_eval &block if block_given?
31
+ end
32
+
33
+ # -- attributes
34
+
35
+ define_attribute :dashed
36
+ define_attribute :expand
37
+ define_attribute :marquee
38
+ define_attribute :max
39
+ define_attribute :min
40
+ define_attribute :orientation
41
+ define_readonly :position
42
+ define_attribute :rastersize
43
+ define_readonly :screenposition
44
+ define_attribute :tip
45
+ define_attribute :value
46
+
47
+ end
48
+ end
@@ -0,0 +1,111 @@
1
+ module Iup
2
+
3
+ # A dialog to show the progress of an operation.
4
+ #
5
+ # == Attributes
6
+ #
7
+ # count:: n, number of iterations completed so far.
8
+ # description:: The text to show within the dialog, describing operation.
9
+ # inc:: n, <b>write-only</b> increases progress by +n+.
10
+ # parentdialog:: This dialog will be always in front of the parent dialog.
11
+ # If the parent is minimized, this dialog is automatically minimized.
12
+ # *Important* Closing the parent will also close the child, but the
13
+ # child dialog's CLOSE_CB method will not be called.
14
+ # percent:: n, current percent of iterations.
15
+ # state:: current state of the iteration, values 'idle' / 'processing' /
16
+ # 'undefined' / 'aborted'.
17
+ # title:: Title text for the progress dialog.
18
+ # totalcount:: n, total number of iterations to complete.
19
+ #
20
+ class ProgressDialog < Widget
21
+ include AttributeReference
22
+
23
+ # Creates an instance of the dialog.
24
+ # block:: optional block to set up the dialog's attributes.
25
+ def initialize &block
26
+ @handle = IupLib.IupProgressDlg
27
+
28
+ # run any provided block on instance, to set up further attributes
29
+ self.instance_eval &block if block_given?
30
+ end
31
+
32
+ # Hides the dialog.
33
+ def hide
34
+ IupLib.IupHide @handle
35
+ end
36
+
37
+ # Shows the dialog, at an optional (x, y) position.
38
+ def show x=nil, y=nil
39
+ if x.nil? and y.nil?
40
+ IupLib.IupShow @handle
41
+ else
42
+ IupLib.IupShowXY @handle, x.to_i, y.to_i
43
+ end
44
+ end
45
+
46
+ # -- attributes
47
+
48
+ define_attribute :count
49
+ define_attribute :description
50
+ define_writeonly :inc
51
+
52
+ def parentdialog parent=nil # :nodoc:
53
+ attribute_reference 'PARENTDIALOG', Dialog, parent
54
+ end
55
+
56
+ define_attribute :percent
57
+ define_attribute :state
58
+ define_attribute :title
59
+ define_attribute :totalcount
60
+
61
+ # -- callbacks
62
+
63
+ # Action generated when the user clicked on the Cancel button.
64
+ def cancel_cb callback
65
+ unless callback.arity.zero?
66
+ raise ArgumentError, 'cancel_cb callback must take 0 arguments'
67
+ end
68
+ cb = Proc.new do |ih|
69
+ callback.call
70
+ end
71
+ define_callback cb, 'CANCEL_CB', :plain
72
+ end
73
+
74
+ # Called right before the dialog is closed.
75
+ def close_cb callback
76
+ unless callback.arity.zero?
77
+ raise ArgumentError, 'close_cb callback must take 0 arguments'
78
+ end
79
+ cb = Proc.new do |ih|
80
+ callback.call
81
+ end
82
+ define_callback cb, 'CLOSE_CB', :plain
83
+ end
84
+
85
+ # Action generated when the dialog size is changed.
86
+ # resize_cb a 2-argument callback: (width, height).
87
+ # width:: internal width of canvas (client width)
88
+ # height:: internal height of canvas (client height)
89
+ def resize_cb callback
90
+ unless callback.arity == 2
91
+ raise ArgumentError, 'resize_cb callback must take 2 arguments: (width, height)'
92
+ end
93
+ cb = Proc.new do |ih, width, height|
94
+ callback.call width, height
95
+ end
96
+ define_callback cb, 'RESIZE_CB', :ii_i
97
+ end
98
+
99
+ # Called right after the dialog is shown, hidden, maximized, minimized or restored from minimized/maximized.
100
+ # Callback takes one argument, the state of the change.
101
+ def show_cb callback
102
+ unless callback.arity == 1
103
+ raise ArgumentError, 'show_cb callback must take 1 argument: (state)'
104
+ end
105
+ cb = Proc.new do |ih, state|
106
+ callback.call state
107
+ end
108
+ define_callback cb, 'SHOW_CB', :i_i
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,43 @@
1
+ module Iup
2
+
3
+ # A Radio container is used to group toggle controls together, so that only one
4
+ # out of the group will be active at a time.
5
+ #
6
+ # To use the Radio control, place the toggle controls within a vbox/hbox, which
7
+ # is the child widget.
8
+ #
9
+ # == Attributes
10
+ #
11
+ # clientoffset:: read-only, returns current offset of frame in its client
12
+ # as "widthxheight".
13
+ # clientsize:: read-only, returns current size of frame as "widthxheight".
14
+ # expand:: Allows container to fill available space in indicated direction.
15
+ # Values 'no' / 'horizontal' / 'vertical' / 'yes'.
16
+ # position:: <b>read-only</b> returns position in pixels within client window
17
+ # as "x,y".
18
+ # value:: Name identifier of the active toggle.
19
+ # value_handle:: Changes the active toggle to given name.
20
+ #
21
+ class Radio < Widget
22
+
23
+ # Creates an instance of the radio container.
24
+ # toggles:: a vbox or hbox containing the toggle controls
25
+ # block:: optional block to set up the container's attributes.
26
+ def initialize toggles, &block
27
+ @handle = IupLib.IupRadio toggles.handle
28
+
29
+ # run any provided block on instance, to set up further attributes
30
+ self.instance_eval &block if block_given?
31
+ end
32
+
33
+ # -- attributes
34
+
35
+ define_readonly :clientoffset
36
+ define_readonly :clientsize
37
+ define_attribute :expand
38
+ define_readonly :position
39
+ define_attribute :value
40
+ define_attribute :value_handle
41
+ end
42
+ end
43
+
@@ -0,0 +1,277 @@
1
+ module Iup
2
+
3
+ # Scintilla widget
4
+ #--
5
+ # TODO: This class's actions are incomplete
6
+ #
7
+ class Scintilla < Widget
8
+ @@opened = false
9
+
10
+ def initialize &block
11
+ unless @@opened
12
+ # make sure the scintilla library is opened on first use
13
+ ScintillaLib.IupScintillaOpen
14
+ @@opened = true
15
+ end
16
+ @handle = ScintillaLib.IupScintilla
17
+
18
+ self.instance_eval &block if block_given?
19
+ end
20
+
21
+ # -- general
22
+
23
+ define_attribute :border
24
+ define_attribute :canfocus
25
+ define_attribute :clipboard
26
+ define_attribute :cursor
27
+ define_attribute :overwrite
28
+ define_attribute :readonly
29
+ define_attribute :savedstate
30
+ define_attribute :size
31
+ define_attribute :usepopup
32
+ define_attribute :visiblecolumns
33
+ define_attribute :visiblelines
34
+ define_readonly :visiblelinescount
35
+ define_attribute :wordwrap
36
+ define_attribute :wordwrapvisualflags
37
+
38
+ # -- text retrieval / modification
39
+
40
+ define_writeonly :append
41
+ define_id_readonly :char
42
+ define_writeonly :clearall
43
+ define_readonly :count
44
+ define_writeonly :deleterange
45
+ define_id_writeonly :insert
46
+ define_id_readonly :line
47
+ define_readonly :linecount
48
+ define_readonly :linevalue
49
+ define_writeonly :prepend
50
+ define_attribute :value
51
+
52
+ # -- annotation
53
+
54
+ define_id_attribute :annotationtext
55
+ define_id_attribute :annotationstyle
56
+ define_attribute :annotationstyleoffset
57
+ define_attribute :annotationvisible
58
+ define_attribute :annotationclearall
59
+
60
+ # -- auto-completion
61
+
62
+ define_id_writeonly :autocshow
63
+ define_writeonly :autoccancel
64
+ define_readonly :autocactive
65
+ define_readonly :autocposstart
66
+ define_writeonly :autoccomplete
67
+ define_writeonly :autocselect
68
+ define_readonly :autocselectedindex
69
+ define_attribute :autocdroprestofword
70
+ define_attribute :autocmaxheight
71
+ define_attribute :autocmaxwidth
72
+
73
+ # -- brace highlighting
74
+
75
+ define_writeonly :bracehighlight
76
+ define_writeonly :bracebadlight
77
+ define_id_readonly :bracematch
78
+
79
+ # -- caret and selection
80
+
81
+ define_attribute :caret
82
+ define_attribute :caretpos
83
+ define_writeonly :carettoview
84
+ define_attribute :selectedtext
85
+ define_attribute :selection
86
+ define_attribute :selectionpos
87
+
88
+ # -- folding
89
+
90
+ define_writeonly :foldflags
91
+ define_id_attribute :foldlevel
92
+ define_writeonly :foldtoggle
93
+
94
+ # -- lexer
95
+
96
+ define_id_writeonly :keywords
97
+ define_readonly :keywordsets
98
+ define_attribute :lexerlanguage
99
+ define_writeonly :loadlexerlibrary
100
+ define_property_attribute :property
101
+ define_attribute :propertynames # TODO: better syntax needed
102
+
103
+ # -- margins
104
+
105
+ define_id_attribute :marginmaskfolders
106
+ define_id_attribute :marginsensitive
107
+ define_id_attribute :margintype
108
+ define_id_attribute :marginwidth
109
+ define_id_attribute :marginleft
110
+ define_id_attribute :marginright
111
+ define_id_attribute :margintext
112
+ define_id_attribute :margintextstyle
113
+ define_id_attribute :margintextclearall
114
+ define_id_attribute :margincursor
115
+
116
+ # -- markers
117
+
118
+ define_property_writeonly :markerdefine
119
+ define_id_attribute :markersymbol
120
+ define_id_writeonly :markerfgcolor
121
+ define_id_writeonly :bgcolor
122
+ define_id_writeonly :markerbgcolorsel
123
+ define_id_writeonly :markeralpha
124
+ define_id_writeonly :markerrgbimage
125
+ define_id_writeonly :markerrgbimagescale
126
+ define_attribute :markerhighlight
127
+ define_id_writeonly :markeradd
128
+ define_id_writeonly :markerdelete
129
+ define_id_writeonly :markerdeleteall
130
+ define_id_readonly :markerget
131
+ define_id_writeonly :markernext
132
+ define_id_writeonly :markerprevious
133
+ define_id_readonly :markerlinefromhandle
134
+ define_writeonly :markerdeletehandle
135
+ define_readonly :lastmarkeraddhandle
136
+ define_readonly :lastmarkerfound
137
+
138
+ # -- scrolling
139
+
140
+ define_attribute :scrollbar
141
+ define_writeonly :scrollto
142
+ define_writeonly :scrolltocaret
143
+ define_writeonly :scrolltopos
144
+ define_attribute :scrollwidth
145
+
146
+ # -- search and replace
147
+
148
+ define_writeonly :searchintarget
149
+ define_attribute :searchflags
150
+ define_attribute :targetstart
151
+ define_attribute :targetend
152
+ define_writeonly :targetfromselection
153
+ define_writeonly :replacetarget
154
+
155
+ # -- style definition
156
+
157
+ define_id_attribute :stylebgcolor
158
+ define_id_attribute :stylebold
159
+ define_id_attribute :stylecase
160
+ define_id_attribute :stylecharset
161
+ define_attribute :styleclearall
162
+ define_id_attribute :styleeolfilled
163
+ define_id_attribute :stylefgcolor
164
+ define_id_attribute :stylefont
165
+ define_id_attribute :stylefontsize
166
+ define_id_attribute :stylefontsizefrac
167
+ define_id_attribute :stylehotspot
168
+ define_id_attribute :styleitalic
169
+ define_id_attribute :stylereset
170
+ define_id_attribute :styleunderline
171
+ define_id_attribute :stylevisible
172
+ define_id_attribute :styleweight
173
+
174
+ # -- styling
175
+
176
+ define_writeonly :cleardocumentstyle
177
+ define_writeonly :startstyling
178
+ define_id_writeonly :styling
179
+
180
+ # -- tabs and indentation
181
+
182
+ define_attribute :tabsize
183
+ define_attribute :indentationguides
184
+ define_attribute :highlightguide
185
+ define_attribute :usetabs
186
+
187
+ # -- undo and redo
188
+
189
+ define_attribute :redo
190
+ define_attribute :undo
191
+ define_attribute :undocollect
192
+
193
+ # -- white space
194
+
195
+ define_attribute :extraascent
196
+ define_attribute :extradescent
197
+ define_attribute :whitespaceview
198
+ define_attribute :whitespacesize
199
+ define_writeonly :whitespacefgcolor
200
+ define_writeonly :whitespacebgcolor
201
+
202
+ # -- zooming
203
+
204
+ define_writeonly :zoomin
205
+ define_writeonly :zoomout
206
+ define_attribute :zoom
207
+
208
+ # -- standard
209
+
210
+ define_attribute :expand
211
+ define_readonly :position
212
+ define_attribute :rastersize
213
+ define_readonly :screenposition
214
+ define_attribute :tip
215
+
216
+ # -- callbacks
217
+
218
+ # Action generated when the text is edited, but before its value is actually changed.
219
+ # action takes a 4-argument callback: code, position, length, text
220
+ # called when indexed item is selected
221
+ # code is 1 for inserted text, 0 for deleted text
222
+ # note: text will be null if code is 0 (deleted)
223
+ def action callback
224
+ unless callback.arity == 4
225
+ raise ArgumentError, 'action callback must take 4 arguments: (code, position, length, text)'
226
+ end
227
+ cb = Proc.new do |ih, insert, pos, length, text|
228
+ callback.call insert, pos, length, text
229
+ end
230
+ define_callback cb, 'ACTION', :iiis_i
231
+ end
232
+
233
+ include ButtonCallback
234
+
235
+ # Action generated when the caret/cursor position is changed.
236
+ # caret_cb takes a callback which accepts 3 arguments (line, column, position) of caret
237
+ def caret_cb callback
238
+ unless callback.arity == 3
239
+ raise ArgumentError, 'caret_cb callback must take 3 arguments: (line, column, position)'
240
+ end
241
+ cb = Proc.new do |ih, lin, col, pos|
242
+ callback.call lin, col, pos
243
+ end
244
+ define_callback cb, 'CARET_CB', :iii_i
245
+ end
246
+
247
+ # Action generated when the mouse is moved.
248
+ # Callback takes 3 arguments: (x, y, state)
249
+ # x:: x position of mouse
250
+ # y:: y position of mouse
251
+ # state:: status of mouse buttons and certain keyboard keys at the moment the event was generated.
252
+ #--
253
+ # TODO: include functions, as in button_cb
254
+ #
255
+ def motion_cb callback
256
+ unless callback.arity == 3
257
+ raise ArgumentError, 'motion_cb callback must take 3 arguments: (x, y, state)'
258
+ end
259
+ cb = Proc.new do |ih, x, y, state|
260
+ callback.call x, y, state
261
+ end
262
+ define_callback cb, 'MOTION_CB', :iis_i
263
+ end
264
+
265
+ # Called after the value was interactively changed by the user. Called when
266
+ # the selection is changed or when the text is edited.
267
+ def valuechanged_cb callback
268
+ unless callback.arity.zero?
269
+ raise ArgumentError, 'valuechanged_cb callback must take 0 arguments'
270
+ end
271
+ cb = Proc.new do |ih|
272
+ callback.call
273
+ end
274
+ define_callback cb, 'VALUECHANGED_CB', :plain
275
+ end
276
+ end
277
+ end