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,141 @@
1
+ module Iup
2
+
3
+ # Attributes for widgets that permit a scrollbar.
4
+ #
5
+ # For all these attributes, the optional argument is used to _set_ the value,
6
+ # else the current value is returned.
7
+ #
8
+ # == Attributes
9
+ #
10
+ # xautohide:: If set, hides horizontal scrollbar if not required. Values 'yes' / 'no'.
11
+ # yautohide:: If set, hides vertical scrollbar if not required. Values 'yes' / 'no'.
12
+ #
13
+ module ScrollBarAttributes
14
+ extend AttributeBuilders
15
+
16
+ define_attribute :scrollbar
17
+
18
+ # Defines the size of the horizontal thumbnail.
19
+ # Size defaults to 0.1, and must be in range 0 < value < (xmax-xmin).
20
+ def dx val=nil
21
+ if val.nil?
22
+ result = IupLib.IupGetAttribute(@handle, 'DX').first
23
+ result.to_f
24
+ else
25
+ IupLib.IupSetAttribute @handle, 'DX', val.to_s
26
+ end
27
+ end
28
+
29
+ # Defines the size of the vertical thumbnail.
30
+ # Size defaults to 0.1, and must be in range 0 < value < (ymax-ymin).
31
+ def dy val=nil
32
+ if val.nil?
33
+ result = IupLib.IupGetAttribute(@handle, 'DY').first
34
+ result.to_f
35
+ else
36
+ IupLib.IupSetAttribute @handle, 'DY', val.to_s
37
+ end
38
+ end
39
+
40
+ # Position of horizontal thumbnail.
41
+ # Size starts at 0.0, and must be in range xmin < value < (xmax-dx).
42
+ def posx val=nil
43
+ if val.nil?
44
+ result = IupLib.IupGetAttribute(@handle, 'POSX').first
45
+ result.to_f
46
+ else
47
+ IupLib.IupSetAttribute @handle, 'POSX', val.to_s
48
+ end
49
+ end
50
+
51
+ # Position of vertical thumbnail.
52
+ # Size starts at 0.0, and must be in range ymin < value < (ymax-dy).
53
+ def posy val=nil
54
+ if val.nil?
55
+ result = IupLib.IupGetAttribute(@handle, 'POSY').first
56
+ result.to_f
57
+ else
58
+ IupLib.IupSetAttribute @handle, 'POSY', val.to_s
59
+ end
60
+ end
61
+
62
+ # Minimum value of horizontal scrollbar. Starts at 0.0.
63
+ def xmin val=nil
64
+ if val.nil?
65
+ result = IupLib.IupGetAttribute(@handle, 'XMIN').first
66
+ result.to_f
67
+ else
68
+ IupLib.IupSetAttribute @handle, 'XMIN', val.to_s
69
+ end
70
+ end
71
+
72
+ # Minimum value of vertical scrollbar. Starts at 0.0.
73
+ def ymin val=nil
74
+ if val.nil?
75
+ result = IupLib.IupGetAttribute(@handle, 'YMIN').first
76
+ result.to_f
77
+ else
78
+ IupLib.IupSetAttribute @handle, 'YMIN', val.to_s
79
+ end
80
+ end
81
+
82
+ # Maximum value of horizontal scrollbar. Defaults to 1.0.
83
+ def xmax val=nil
84
+ if val.nil?
85
+ result = IupLib.IupGetAttribute(@handle, 'XMAX').first
86
+ result.to_f
87
+ else
88
+ IupLib.IupSetAttribute @handle, 'XMAX', val.to_s
89
+ end
90
+ end
91
+
92
+ # Maximum value of vertical scrollbar. Defaults to 1.0.
93
+ def ymax val=nil
94
+ if val.nil?
95
+ result = IupLib.IupGetAttribute(@handle, 'YMAX').first
96
+ result.to_f
97
+ else
98
+ IupLib.IupSetAttribute @handle, 'YMAX', val.to_s
99
+ end
100
+ end
101
+
102
+ # Amount thumb moves in horizontal direction. Default is dx/10.
103
+ def linex val=nil
104
+ if val.nil?
105
+ result = IupLib.IupGetAttribute(@handle, 'LINEX').first
106
+ result.to_f
107
+ else
108
+ IupLib.IupSetAttribute @handle, 'LINEX', val.to_s
109
+ end
110
+ end
111
+
112
+ # Amount thumb moves in vertical direction. Default is dy/10.
113
+ def liney val=nil
114
+ if val.nil?
115
+ result = IupLib.IupGetAttribute(@handle, 'LINEY').first
116
+ result.to_f
117
+ else
118
+ IupLib.IupSetAttribute @handle, 'LINEY', val.to_s
119
+ end
120
+ end
121
+
122
+ define_attribute :xautohide
123
+ define_attribute :yautohide
124
+
125
+ # Called when scrollbar used.
126
+ # Callback must take three arguments:
127
+ # op:: operation performed on scrollbar, see Iup
128
+ # posx:: x position of scroll thumb (same as posx attribute)
129
+ # posy:: y position of scroll thumb (same as posy attribute)
130
+ def scroll_cb callback
131
+ unless callback.arity == 3
132
+ raise ArgumentError, 'scroll_cb callback must take 3 arguments: (op, posx, posy)'
133
+ end
134
+ cb = Proc.new do |ih, op, posx, posy|
135
+ callback.call op, posx, posy
136
+ end
137
+ define_callback cb, 'SCROLL_CB', :iff_i
138
+ end
139
+
140
+ end
141
+ end
@@ -0,0 +1,147 @@
1
+ module Iup
2
+
3
+ # A container holding a single child widget,
4
+ # enabling that child widget to be scrolled.
5
+ #
6
+ # == Attributes
7
+ #
8
+ # border:: Set to show a border around the scrollbox. Values 'yes' / 'no'.
9
+ # canfocus:: Always 'no' - control cannot gain focus.
10
+ # clientoffset:: <b>read-only</b>, returns current offset of box in its client
11
+ # as "widthxheight".
12
+ # clientsize:: <b>read-only</b>, returns current size of box as "widthxheight".
13
+ # cursor:: Name of the mouse shape / cursor for the scrollbox.
14
+ # drawsize:: Size of drawing area in pixels, as "widthxheight".
15
+ # expand:: Allows container to fill available space in indicated direction.
16
+ # Values 'no' / 'horizontal' / 'vertical' / 'yes'.
17
+ # padding:: Margin in x and y directions in pixels, value as "mxn".
18
+ # position:: <b>read-only</b> returns position in pixels within client window
19
+ # as "x,y".
20
+ # rastersize:: Size of the container, in pixels, value as "widthxheight".
21
+ # screenposition:: <b>read-only</b> returns position in pixels on screen
22
+ # as "x,y".
23
+ # scrollbar:: Selects 'no' / 'horizontal' / 'vertical' / 'yes' (for both) scrollbars.
24
+ # tip:: Tooltip string.
25
+ #
26
+ class ScrollBox < Widget
27
+ include DragDropAttributes
28
+ include ScrollBarAttributes
29
+
30
+ # Creates a new instance of the container.
31
+ # child:: a child widget
32
+ # block:: optional block to set up attributes
33
+ def initialize child, &block
34
+ @handle = IupLib.IupScrollBox child.handle
35
+
36
+ # run any provided block on instance, to set up further attributes
37
+ self.instance_eval &block if block_given?
38
+ end
39
+
40
+ # -- attributes
41
+
42
+ define_attribute :border
43
+ define_attribute :canfocus
44
+ define_attribute :clientoffset
45
+ define_attribute :clientsize
46
+ define_attribute :cursor
47
+ define_attribute :drawsize
48
+ define_attribute :expand
49
+ define_attribute :padding
50
+ define_readonly :position
51
+ define_attribute :rastersize
52
+ define_readonly :screenposition
53
+ define_attribute :tip
54
+
55
+ # -- callbacks
56
+
57
+ # Action generated when the scrollbar needs to be redrawn.
58
+ # action takes a callback which accepts 2 arguments (posx, posy).
59
+ # posx, posy are the position of the horizontal and vertical thumbs of the scrollbar.
60
+ def action callback
61
+ unless callback.arity == 2
62
+ raise ArgumentError, 'action must take 2 arguments: (posx, posy)'
63
+ end
64
+ cb = Proc.new do |ih, posx, posy|
65
+ callback.call posx, posy
66
+ end
67
+ define_callback cb, 'ACTION', :ff_i
68
+ end
69
+
70
+ include ButtonCallback
71
+
72
+ # Called when the scrollbar gets or loses the keyboard focus.
73
+ # Callback takes a single parameter: (focus)
74
+ # focus:: non-zero if canvas gaining focus, else zero.
75
+ def focus_cb callback
76
+ unless callback.arity == 1
77
+ raise ArgumentError, 'focus_cb callback must take 1 argument, the focus'
78
+ end
79
+ cb = Proc.new do |ih, focus|
80
+ callback.call focus
81
+ end
82
+ define_callback cb, 'FOCUS_CB', :i_i
83
+ end
84
+
85
+ # Action generated when a key is pressed or released.
86
+ # keypress_cb takes a 2-argument callback: (character, pressed).
87
+ # pressed == 1 if key is pressed,
88
+ # pressed == 0 if key is released.
89
+ def keypress_cb callback
90
+ unless callback.arity == 2
91
+ raise ArgumentError, 'keypress_cb callback must take 2 arguments: (char, press)'
92
+ end
93
+ cb = Proc.new do |ih, char, press|
94
+ callback.call char, press
95
+ end
96
+ define_callback cb, 'KEYPRESS_CB', :ii_i
97
+ end
98
+
99
+ # Action generated when the mouse is moved.
100
+ # Callback takes 3 arguments: (x, y, state)
101
+ # x:: x position of mouse
102
+ # y:: y position of mouse
103
+ # state:: status of mouse buttons and certain keyboard keys at the moment the event was generated.
104
+ #--
105
+ # TODO: include functions, as in button_cb
106
+ #
107
+ def motion_cb callback
108
+ unless callback.arity == 3
109
+ raise ArgumentError, 'motion_cb callback must take 3 arguments: (x, y, state)'
110
+ end
111
+ cb = Proc.new do |ih, x, y, state|
112
+ callback.call x, y, state
113
+ end
114
+ define_callback cb, 'MOTION_CB', :iis_i
115
+ end
116
+
117
+ # Action generated when the scrollbar size is changed.
118
+ # resize_cb a 2-argument callback: (width, height).
119
+ # width:: internal width of canvas (client width)
120
+ # height:: internal height of canvas (client height)
121
+ def resize_cb callback
122
+ unless callback.arity == 2
123
+ raise ArgumentError, 'resize_cb callback must take 2 arguments: (width, height)'
124
+ end
125
+ cb = Proc.new do |ih, width, height|
126
+ callback.call width, height
127
+ end
128
+ define_callback cb, 'RESIZE_CB', :ii_i
129
+ end
130
+
131
+ # Action generated when the mouse wheel is rotated.
132
+ # wheel_cb a 4-argument callback: (delta, x, y, status).
133
+ # delta:: the amount the wheel was rotated in notches.
134
+ # x, y:: position in the canvas where the event has occurred, in pixels.
135
+ # status:: status of mouse buttons and certain keyboard keys at the moment the event was generated.
136
+ def wheel_cb callback
137
+ unless callback.arity == 4
138
+ raise ArgumentError, 'wheel_cb callback must take 4 arguments: (delta, x, y, status)'
139
+ end
140
+ cb = Proc.new do |ih, delta, x, y, status_ptr|
141
+ status = FFI::Pointer.new(status_ptr).read_string
142
+ callback.call delta, x, y, status
143
+ end
144
+ define_callback cb, 'WHEEL_CB', :fiis_i
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,11 @@
1
+ module Iup
2
+
3
+ # A Separator is used within a menu, appears as a horizontal line.
4
+ class Separator < Widget
5
+
6
+ # Creates an instance.
7
+ def initialize
8
+ @handle = IupLib.IupSeparator
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,48 @@
1
+ module Iup
2
+
3
+ # A container for two child widgets, with a moveable divider between them.
4
+ # Note that moving the divider cannot affect other widgets.
5
+ #
6
+ # == Attributes
7
+ #
8
+ # autohide:: If set, hides a child if the child client area is smaller than
9
+ # the bar size. Values 'yes' / 'no'.
10
+ # barsize:: Controls the size of the bar handler, defaults to 5.
11
+ # color:: Colour of the bar grip, as "r g b".
12
+ # expand:: Allows container to fill available space in indicated direction.
13
+ # Values 'no' / 'horizontal' / 'vertical' / 'yes'.
14
+ # layoutdrag:: Updates the children's layout when bar moved automatically.
15
+ # Values 'yes' / 'no'.
16
+ # orientation:: Bar handler can be either 'horizontal' or 'vertical'.
17
+ # position:: <b>read-only</b> returns position in pixels within client window
18
+ # as "x,y".
19
+ # rastersize:: Size of the container, in pixels, value as "widthxheight".
20
+ # showgrip:: If set, shows the bar grip. Values 'yes' / 'no'.
21
+ # value:: 0 <= n <= 1000 sets the proportion of the left/top area relative to whole.
22
+ #
23
+ class SplitBox < Widget
24
+
25
+ # Creates an instance of the SplitBox.
26
+ # child1:: the left or top child widget
27
+ # child2:: the right or bottom child widget
28
+ # block:: optional block to set up the box's attributes.
29
+ def initialize child1, child2, &block
30
+ @handle = IupLib.IupSplit child1.handle, child2.handle
31
+
32
+ # run any provided block on instance, to set up further attributes
33
+ self.instance_eval &block if block_given?
34
+ end
35
+
36
+ define_attribute :autohide
37
+ define_attribute :barsize
38
+ define_attribute :color
39
+ define_attribute :expand
40
+ define_attribute :layoutdrag
41
+ define_attribute :minmax
42
+ define_attribute :orientation
43
+ define_readonly :position
44
+ define_attribute :rastersize
45
+ define_attribute :showgrip
46
+ define_attribute :value
47
+ end
48
+ end
@@ -0,0 +1,42 @@
1
+ module Iup
2
+
3
+ # A stretchable container around one child widget.
4
+ #
5
+ # == Attributes
6
+ #
7
+ # clientoffset:: read-only, returns current offset of box in its client
8
+ # as "widthxheight".
9
+ # clientsize:: read-only, returns current size of box as "widthxheight".
10
+ # color:: Specify RGB values for stretch bar colour, as "r g b".
11
+ # direction:: Direction and position of the stretch bar.
12
+ # Values as 'east' / 'west' / 'north' / 'south'.
13
+ # expand:: Allows container to fill available space in indicated direction,
14
+ # but only on the side away from the stretch bar.
15
+ # Values 'no' / 'horizontal' / 'vertical' / 'yes'.
16
+ # position:: <b>read-only</b> returns position in pixels within client window
17
+ # as "x,y".
18
+ # rastersize:: Size of the container, in pixels, value as "widthxheight".
19
+ #
20
+ class StretchBox < Widget
21
+
22
+ # Creates an instance of the container.
23
+ # widget:: the child widget to contain
24
+ # block:: optional block to set up the container's attributes.
25
+ def initialize widget, &block
26
+ @handle = IupLib.IupSbox widget.handle
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
+ # -- attributes
33
+
34
+ define_attribute :clientoffset
35
+ define_attribute :clientsize
36
+ define_attribute :color
37
+ define_attribute :direction
38
+ define_attribute :expand
39
+ define_attribute :position
40
+ define_attribute :rastersize
41
+ end
42
+ end
@@ -0,0 +1,34 @@
1
+ module Iup
2
+
3
+ # A menu item that, when selected, opens another menu.
4
+ #
5
+ # == Attributes
6
+ #
7
+ # image:: Image to show on menu.
8
+ # title:: Label of menu.
9
+ # wid:: <b>read-only</b> Native widget identifier.
10
+ #
11
+ class SubMenu < Widget
12
+
13
+ # Creates instance of a SubMenu.
14
+ #
15
+ # title:: Label of menu
16
+ # item:: child menu to open
17
+ # block:: optional block to set menu's attributes
18
+ def initialize title, item, &block
19
+ @handle = IupLib.IupSubmenu title, item.handle
20
+
21
+ # run any provided block on instance, to set up further attributes
22
+ self.instance_eval &block if block_given?
23
+ end
24
+
25
+ # -- attributes
26
+
27
+ def image val=nil # :nodoc:
28
+ attribute_reference 'IMAGE', ImageWidget, val
29
+ end
30
+
31
+ define_attribute :title
32
+ define_readonly :wid
33
+ end
34
+ end
@@ -0,0 +1,149 @@
1
+ module Iup
2
+
3
+ # Tabs is a container for multiple widgets, placing the widgets in layers
4
+ # with a single layer visible. The user can change the visible layer by
5
+ # selecting a tab.
6
+ #
7
+ # == Attributes
8
+ #
9
+ # clientoffset:: <b>read-only</b>, returns current offset of box in its client
10
+ # as "widthxheight".
11
+ # clientsize:: <b>read-only</b>, returns current size of box as "widthxheight".
12
+ # count:: <b>read-only</b> Returns the number of tabs.
13
+ # expand:: Allows control to fill available space in indicated direction.
14
+ # Values 'no' / 'horizontal' / 'vertical' / 'yes'.
15
+ # padding:: Margin in x and y directions, value as "mxn".
16
+ # position:: <b>read-only</b> returns position in pixels within client window
17
+ # rastersize:: Size of the control, in pixels, value as "widthxheight".
18
+ # screenposition:: <b>read-only</b> returns position in pixels on screen
19
+ # as "x,y".
20
+ # showclose:: 'no' / 'yes', shows the 'close' button on each tab.
21
+ # Clicking this hides tab unless tabclose_cb defined.
22
+ # taborientation:: 'horizontal' / 'vertical'.
23
+ # tabtype:: 'top' / 'bottom' / 'left' / 'right', indicates position of tabs.
24
+ # tip:: Tooltip string.
25
+ #
26
+ class Tabs < Widget
27
+ include AttributeReference
28
+
29
+ # Creates an instance of the tabs control.
30
+ # *widgets:: one or more child widgets
31
+ # block:: optional block to set up the control's attributes.
32
+ def initialize *widgets, &block
33
+ @handle = IupLib.IupTabs *widget_list(widgets)
34
+ @widgets = widgets # store the widgets
35
+
36
+ # run any provided block on instance, to set up further attributes
37
+ self.instance_eval &block if block_given?
38
+ end
39
+
40
+ # -- attributes
41
+
42
+ define_readonly :clientoffset
43
+ define_readonly :clientsize
44
+
45
+ def count # :nodoc:
46
+ result = IupLib.IupGetAttribute(@handle, 'COUNT').first
47
+ return result.to_i
48
+ end
49
+
50
+ define_attribute :expand
51
+ define_attribute :padding
52
+ define_readonly :position
53
+ define_attribute :rastersize
54
+ define_readonly :screenposition
55
+ define_attribute :showclose
56
+ define_attribute :taborientation
57
+
58
+ # Sets the title of a tab:
59
+ # index:: the index of the tab (0-indexed)
60
+ # title:: text to use for the title
61
+ # image:: optional image
62
+ def tabtitle index, title, image=nil
63
+ IupLib.IupSetAttribute @handle, "TABTITLE#{index}", title
64
+ attribute_reference "TABIMAGE#{index}", ImageWidget, image
65
+ end
66
+
67
+ define_attribute :tabtype
68
+
69
+ # If val given, sets visibility of tab index, else returns its visibility.
70
+ def tabvisible index, val=nil
71
+ if val.nil?
72
+ IupLib.IupGetAttribute(@handle, "TABVISIBLE#{index}").first
73
+ else
74
+ IupLib.IupSetAttribute @handle, "TABVISIBLE#{index}", val
75
+ end
76
+ end
77
+
78
+ define_attribute :tip
79
+
80
+ # If val given, changes visible tab to its position (0-indexed).
81
+ # Otherwise, returns currently visible tab position.
82
+ def valuepos val=nil
83
+ if val.nil?
84
+ result = IupLib.IupGetAttribute(@handle, 'VALUEPOS').first
85
+ result.to_i
86
+ else
87
+ IupLib.IupSetAttribute @handle, 'VALUEPOS', val.to_s
88
+ end
89
+ end
90
+
91
+ # -- callbacks
92
+
93
+ # Callback called when the user clicks on some tab using the right mouse button.
94
+ # rightclick_cb takes a 1-argument callback, the argument
95
+ # being the tab number that was clicked
96
+ def rightclick_cb callback
97
+ unless callback.arity == 1
98
+ raise ArgumentError, 'rightclick_cb callback must take 1 argument, the tab number'
99
+ end
100
+ cb = Proc.new do |ih, tn|
101
+ callback.call tn
102
+ end
103
+ define_callback cb, 'RIGHTCLICK_CB', :i_i
104
+ end
105
+
106
+ # Callback called when the user shifts the active tab.
107
+ # tabchange_cb takes a 2-argument callback,
108
+ # the new selected tab, and the old selected tab.
109
+ def tabchange_cb callback
110
+ unless callback.arity == 2
111
+ raise ArgumentError, 'tabchange_cb callback must take 2 argument, the new and old tab handles'
112
+ end
113
+ cb = Proc.new do |ih, hnew, hold|
114
+ new_tab = @widgets.find {|widget| widget.handle.address == hnew.address}
115
+ old_tab = @widgets.find {|widget| widget.handle.address == hold.address}
116
+ callback.call new_tab, old_tab
117
+ end
118
+ define_callback cb, 'TABCHANGE_CB', :pp_i
119
+ end
120
+
121
+ # Callback called when the user shifts the active tab.
122
+ # Called only when TABCHANGE_CB is not defined.
123
+ # tabchangepos_cb takes a 2-argument callback,
124
+ # the new selected tab number and the old selected tab number.
125
+ def tabchangepos_cb callback
126
+ unless callback.arity == 2
127
+ raise ArgumentError, 'tabchangepos_cb callback must take 2 argument, the new and old tab numbers'
128
+ end
129
+ cb = Proc.new do |ih, tnew, told|
130
+ callback.call tnew, told
131
+ end
132
+ define_callback cb, 'TABCHANGEPOS_CB', :ii_i
133
+ end
134
+
135
+ # Callback called when the user clicks on the close button (since 3.10).
136
+ # Called only when SHOWCLOSE=Yes.
137
+ # Callback takes one argument, the tab number.
138
+ def tabclose_cb callback
139
+ unless callback.arity == 1
140
+ raise ArgumentError, 'tabclose_cb callback must take 1 argument, the tab number'
141
+ end
142
+ cb = Proc.new do |ih, tn|
143
+ callback.call tn
144
+ end
145
+ define_callback cb, 'TABCLOSE_CB', :i_i
146
+ end
147
+
148
+ end
149
+ end