iup-ffi 0.13.0-x86_64-linux

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 (70) hide show
  1. checksums.yaml +7 -0
  2. data/LICENCE.md +21 -0
  3. data/README.md +139 -0
  4. data/lib/iup-ffi-plain.rb +51 -0
  5. data/lib/iup-ffi.rb +70 -0
  6. data/lib/library/linux/libcd.so +0 -0
  7. data/lib/library/linux/libim.so +0 -0
  8. data/lib/library/linux/libiup.so +0 -0
  9. data/lib/library/linux/libiup_scintilla.so +0 -0
  10. data/lib/library/linux/libiupcd.so +0 -0
  11. data/lib/library/linux/libiupcontrols.so +0 -0
  12. data/lib/library/linux/libiupim.so +0 -0
  13. data/lib/library/linux/libiupimglib.so +0 -0
  14. data/lib/plain/iupcdlib.rb +158 -0
  15. data/lib/plain/iupcontrolslib.rb +28 -0
  16. data/lib/plain/iupimglib.rb +15 -0
  17. data/lib/plain/iupimlib.rb +18 -0
  18. data/lib/plain/iuplib.rb +354 -0
  19. data/lib/plain/scintilla-lib.rb +17 -0
  20. data/lib/wrapped/attribute-builders.rb +93 -0
  21. data/lib/wrapped/attribute-reference.rb +27 -0
  22. data/lib/wrapped/background-box.rb +37 -0
  23. data/lib/wrapped/button.rb +152 -0
  24. data/lib/wrapped/callback-setter.rb +78 -0
  25. data/lib/wrapped/canvas.rb +698 -0
  26. data/lib/wrapped/colorbar.rb +212 -0
  27. data/lib/wrapped/colordialog.rb +121 -0
  28. data/lib/wrapped/common-attributes.rb +34 -0
  29. data/lib/wrapped/constants.rb +504 -0
  30. data/lib/wrapped/dial.rb +129 -0
  31. data/lib/wrapped/dialog.rb +309 -0
  32. data/lib/wrapped/drag-drop-attributes.rb +98 -0
  33. data/lib/wrapped/dynamic-fill-methods.rb +22 -0
  34. data/lib/wrapped/expander.rb +128 -0
  35. data/lib/wrapped/filedialog.rb +168 -0
  36. data/lib/wrapped/fill.rb +29 -0
  37. data/lib/wrapped/fontdialog.rb +71 -0
  38. data/lib/wrapped/frame.rb +70 -0
  39. data/lib/wrapped/gridbox.rb +188 -0
  40. data/lib/wrapped/hbox.rb +90 -0
  41. data/lib/wrapped/image-attributes.rb +58 -0
  42. data/lib/wrapped/image.rb +178 -0
  43. data/lib/wrapped/iup-global.rb +46 -0
  44. data/lib/wrapped/label.rb +110 -0
  45. data/lib/wrapped/link.rb +54 -0
  46. data/lib/wrapped/list.rb +567 -0
  47. data/lib/wrapped/matrix.rb +575 -0
  48. data/lib/wrapped/menu.rb +91 -0
  49. data/lib/wrapped/menuitem.rb +150 -0
  50. data/lib/wrapped/messagedialog.rb +127 -0
  51. data/lib/wrapped/progressbar.rb +91 -0
  52. data/lib/wrapped/progressdialog.rb +85 -0
  53. data/lib/wrapped/radio.rb +74 -0
  54. data/lib/wrapped/scintilla.rb +1112 -0
  55. data/lib/wrapped/scrollbar-attributes.rb +178 -0
  56. data/lib/wrapped/scrollbox.rb +40 -0
  57. data/lib/wrapped/separator.rb +24 -0
  58. data/lib/wrapped/splitbox.rb +114 -0
  59. data/lib/wrapped/stretchbox.rb +70 -0
  60. data/lib/wrapped/submenu.rb +58 -0
  61. data/lib/wrapped/tabs.rb +223 -0
  62. data/lib/wrapped/text.rb +382 -0
  63. data/lib/wrapped/timer.rb +82 -0
  64. data/lib/wrapped/toggle.rb +150 -0
  65. data/lib/wrapped/tree.rb +612 -0
  66. data/lib/wrapped/val.rb +162 -0
  67. data/lib/wrapped/vbox.rb +93 -0
  68. data/lib/wrapped/widget.rb +282 -0
  69. data/lib/wrapped/zbox.rb +80 -0
  70. metadata +131 -0
@@ -0,0 +1,178 @@
1
+ module Iup
2
+
3
+ # Attributes for widgets that permit a scrollbar.
4
+ #
5
+ module ScrollBarAttributes
6
+ extend AttributeBuilders
7
+
8
+ ##
9
+ # :attr: scrollbar
10
+ # Selects 'no' / 'horizontal' / 'vertical' / 'yes' (for both) scrollbars.
11
+ define_attribute :scrollbar
12
+
13
+ ##
14
+ # :attr: dx
15
+ # Defines the size of the horizontal thumbnail.
16
+ # Size defaults to 0.1, and must be in range 0 < value < (xmax-xmin).
17
+
18
+ # --
19
+ def dx
20
+ IupLib.IupGetAttribute(@handle, 'DX').first.to_f
21
+ end
22
+
23
+ def dx= val # :nodoc:
24
+ IupLib.IupSetAttribute(@handle, 'DX', val.to_s)
25
+ end
26
+
27
+ ##
28
+ # :attr: dy
29
+ # Defines the size of the vertical thumbnail.
30
+ # Size defaults to 0.1, and must be in range 0 < value < (ymax-ymin).
31
+
32
+ # --
33
+ def dy
34
+ IupLib.IupGetAttribute(@handle, 'DY').first.to_f
35
+ end
36
+
37
+ def dy= val # :nodoc:
38
+ IupLib.IupSetAttribute(@handle, 'DY', val.to_s)
39
+ end
40
+
41
+ ##
42
+ # :attr: posx
43
+ # Position of horizontal thumbnail.
44
+ # Size starts at 0.0, and must be in range xmin < value < (xmax-dx).
45
+
46
+ # --
47
+ def posx
48
+ IupLib.IupGetAttribute(@handle, 'POSX').first.to_f
49
+ end
50
+
51
+ def posx= val # :nodoc:
52
+ IupLib.IupSetAttribute(@handle, 'POSX', val.to_s)
53
+ end
54
+
55
+ ##
56
+ # :attr: posy
57
+ # Position of vertical thumbnail.
58
+ # Size starts at 0.0, and must be in range ymin < value < (ymax-dy).
59
+
60
+ # --
61
+ def posy
62
+ IupLib.IupGetAttribute(@handle, 'POSY').first.to_f
63
+ end
64
+
65
+ def posy= val # :nodoc:
66
+ IupLib.IupSetAttribute(@handle, 'POSY', val.to_s)
67
+ end
68
+
69
+ ##
70
+ # :attr: xmin
71
+ # Minimum value of horizontal scrollbar. Starts at 0.0.
72
+
73
+ # --
74
+ def xmin
75
+ IupLib.IupGetAttribute(@handle, 'XMIN').first.to_f
76
+ end
77
+
78
+ def xmin= val # :nodoc:
79
+ IupLib.IupSetAttribute(@handle, 'XMIN', val.to_s)
80
+ end
81
+
82
+ ##
83
+ # :attr: ymin
84
+ # Minimum value of vertical scrollbar. Starts at 0.0.
85
+
86
+ # --
87
+ def ymin
88
+ IupLib.IupGetAttribute(@handle, 'YMIN').first.to_f
89
+ end
90
+
91
+ def ymin= val # :nodoc:
92
+ IupLib.IupSetAttribute(@handle, 'YMIN', val.to_s)
93
+ end
94
+
95
+ ##
96
+ # :attr: xmax
97
+ # Maximum value of horizontal scrollbar. Defaults to 1.0.
98
+
99
+ # --
100
+ def xmax
101
+ IupLib.IupGetAttribute(@handle, 'XMAX').first.to_f
102
+ end
103
+
104
+ def xmax= val # :nodoc:
105
+ IupLib.IupSetAttribute(@handle, 'XMAX', val.to_s)
106
+ end
107
+
108
+ ##
109
+ # :attr: ymax
110
+ # Maximum value of vertical scrollbar. Defaults to 1.0.
111
+
112
+ # --
113
+ def ymax
114
+ IupLib.IupGetAttribute(@handle, 'YMAX').first.to_f
115
+ end
116
+
117
+ def ymax= val # :nodoc:
118
+ IupLib.IupSetAttribute(@handle, 'YMAX', val.to_s)
119
+ end
120
+
121
+ ##
122
+ # :attr: linex
123
+ # Amount thumb moves in horizontal direction. Default is dx/10.
124
+
125
+ # --
126
+ def linex
127
+ IupLib.IupGetAttribute(@handle, 'LINEX').first.to_f
128
+ end
129
+
130
+ def linex= val # :nodoc:
131
+ IupLib.IupSetAttribute(@handle, 'LINEX', val.to_s)
132
+ end
133
+
134
+ ##
135
+ # :attr: liney
136
+ # Amount thumb moves in vertical direction. Default is dy/10.
137
+
138
+ # --
139
+ def liney
140
+ IupLib.IupGetAttribute(@handle, 'LINEY').first.to_f
141
+ end
142
+
143
+ def liney= val # :nodoc:
144
+ IupLib.IupSetAttribute(@handle, 'LINEY', val.to_s)
145
+ end
146
+
147
+ ##
148
+ # :attr: xautohide
149
+ # If set, hides horizontal scrollbar if not required. Values 'yes' / 'no'.
150
+ define_attribute :xautohide
151
+
152
+ ##
153
+ # :attr: yautohide
154
+ # If set, hides vertical scrollbar if not required. Values 'yes' / 'no'.
155
+ define_attribute :yautohide
156
+
157
+ # :section: Callbacks
158
+
159
+ ##
160
+ # :attr_writer: scroll_cb
161
+ # Called when scrollbar used.
162
+ # Callback must respond to +call+ and takes three arguments (op, posx, posy):
163
+ # * +op+ - operation performed on scrollbar (see {Scrollbar operations}[../Iup.html#Scrollbar+operations]).
164
+ # * +posx+ - x position of scroll thumb (same as posx attribute)
165
+ # * +posy+ - y position of scroll thumb (same as posy attribute)
166
+
167
+ # --
168
+ def scroll_cb= callback
169
+ unless callback.arity == 3
170
+ raise ArgumentError, 'scroll_cb callback must take 3 arguments: (op, posx, posy)'
171
+ end
172
+ cb = Proc.new do |ih, op, posx, posy|
173
+ callback.call op, posx, posy
174
+ end
175
+ define_callback cb, 'SCROLL_CB', :iff_i
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,40 @@
1
+ module Iup
2
+
3
+ # A container holding a single child widget, enabling that child widget to be
4
+ # scrolled.
5
+ #
6
+ # === Example
7
+ #
8
+ # Wrapping a matrix element in a scroll box before showing on a dialog:
9
+ #
10
+ # Iup::Dialog.new(
11
+ # Iup::ScrollBox.new(matrix)
12
+ # ).map
13
+ #
14
+ class ScrollBox < Iup::Canvas
15
+ include DynamicFillMethods
16
+
17
+ # Creates a new instance of the container.
18
+ # If a block is given, the new instance is yielded to it.
19
+ #
20
+ # * +widget+ - the child widget to display.
21
+ def initialize widget
22
+ @handle = IupLib.IupScrollBox(widget.handle)
23
+
24
+ # run any provided block on instance, to set up further attributes
25
+ yield self if block_given?
26
+ end
27
+
28
+ # -- attributes
29
+
30
+ ##
31
+ # :attr_reader: clientoffset
32
+ # Returns current offset of box in its client as "widthxheight".
33
+ define_reader :clientoffset
34
+
35
+ ##
36
+ # :attr_reader: clientsize
37
+ # Returns current size of box as "widthxheight".
38
+ define_reader :clientsize
39
+ end
40
+ end
@@ -0,0 +1,24 @@
1
+ module Iup
2
+
3
+ # A Separator is used within a menu, appears as a horizontal line.
4
+ #
5
+ # === Example
6
+ #
7
+ # The following shows construction of a typical file menu, with a
8
+ # separating line before the exit item:
9
+ #
10
+ # file_menu = Iup::Menu.new(
11
+ # item_open, item_save,
12
+ # Iup::Separator.new,
13
+ # item_exit)
14
+ #
15
+ # See also: Menu, MenuItem, SubMenu
16
+ #
17
+ class Separator < Iup::Widget
18
+
19
+ # Creates a new instance.
20
+ def initialize
21
+ @handle = IupLib.IupSeparator
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,114 @@
1
+
2
+
3
+ module Iup
4
+
5
+ # A container for two child widgets, with a moveable divider between them.
6
+ #
7
+ # Note: named IupSplit in Tecgraf's documentation.
8
+ #
9
+ # === Example
10
+ #
11
+ # The following code creates a split box between two text areas,
12
+ # with a blue divider oriented horizontally - so the text areas
13
+ # are placed one above the other:
14
+ #
15
+ # split = Iup::SplitBox.new(text1, text2) do |b|
16
+ # b.orientation = 'HORIZONTAL'
17
+ # b.color = '127 127 255'
18
+ # end
19
+ #
20
+ # Also see: StretchBox
21
+ #
22
+ class SplitBox < Iup::Widget
23
+ include DynamicFillMethods
24
+
25
+ # Creates an instance of the split box.
26
+ # If a block is given, the new instance is yielded to it.
27
+ #
28
+ # * +child1+ - the left or top child widget
29
+ # * +child2+ - the right or bottom child widget
30
+ def initialize child1, child2
31
+ @handle = IupLib.IupSplit(child1.handle, child2.handle)
32
+
33
+ # run any provided block on instance, to set up further attributes
34
+ yield self if block_given?
35
+ end
36
+
37
+ ##
38
+ # :attr: autohide
39
+ # If set, hides a child if the child client area is smaller than
40
+ # the bar size. Values 'yes' / 'no'.
41
+ define_attribute :autohide
42
+
43
+ ##
44
+ # :attr: barsize
45
+ # Controls the size of the bar handler, defaults to 5.
46
+ define_attribute :barsize
47
+
48
+ ##
49
+ # :attr: color
50
+ # Color of the bar grip, as "r g b".
51
+ define_attribute :color
52
+
53
+ ##
54
+ # :attr: expand
55
+ # Allows container to fill available space in indicated direction.
56
+ # Values 'no' / 'horizontal' / 'vertical' / 'yes'.
57
+ define_attribute :expand
58
+
59
+ ##
60
+ # :attr: layoutdrag
61
+ # Updates the children's layout when bar moved automatically.
62
+ # Values 'yes' / 'no'.
63
+ define_attribute :layoutdrag
64
+
65
+ ##
66
+ # :attr: minmax
67
+ # minimum/maximum values for +value+ in form "min:max", where +min+ and +max+
68
+ # are integers.
69
+ define_attribute :minmax
70
+
71
+ ##
72
+ # :attr: orientation
73
+ # Bar handler can be either 'horizontal' or 'vertical'.
74
+ define_attribute :orientation
75
+
76
+ ##
77
+ # :attr_reader: position
78
+ # returns position in pixels within client window as "x,y".
79
+ define_reader :position
80
+
81
+ ##
82
+ # :attr: rastersize
83
+ # Size of the container, in pixels, value as "widthxheight".
84
+ define_attribute :rastersize
85
+
86
+ ##
87
+ # :attr: showgrip
88
+ # If set, shows the bar grip. Values 'yes' / 'no'.
89
+ define_attribute :showgrip
90
+
91
+ ##
92
+ # :attr: value
93
+ # Proportion of the left/top area relative to whole, integer in range [0,1000].
94
+ define_attribute :value
95
+
96
+ # :section: Callbacks
97
+
98
+ ##
99
+ # :attr_writer: valuechanged_cb
100
+ # Callback called after the value was interactively changed by the user.
101
+ # Callback must respond to +call+ and take no arguments.
102
+
103
+ # --
104
+ def valuechanged_cb= callback
105
+ unless callback.arity.zero?
106
+ raise ArgumentError, 'valuechanged_cb callback must take 0 arguments'
107
+ end
108
+ cb = Proc.new do |ih|
109
+ callback.call
110
+ end
111
+ define_callback cb, 'VALUECHANGED_CB', :plain
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,70 @@
1
+ module Iup
2
+
3
+ # A stretchable container around one child widget.
4
+ #
5
+ # Note: named IupSBox in Tecgraf's documentation.
6
+ #
7
+ # Also see: SplitBox
8
+ #
9
+ class StretchBox < Iup::Widget
10
+ include DynamicFillMethods
11
+
12
+ # Creates an instance of the stretch box.
13
+ # If a block is given, the new instance is yielded to it.
14
+ #
15
+ # * +widget+ - the widget to contain
16
+ def initialize widget
17
+ @handle = IupLib.IupSbox(widget.handle)
18
+
19
+ # run any provided block on instance, to set up further attributes
20
+ yield self if block_given?
21
+ end
22
+
23
+ # -- attributes
24
+
25
+ ##
26
+ # :attr_reader: clientoffset
27
+ # returns current offset of box in its client as "widthxheight".
28
+ define_reader :clientoffset
29
+
30
+ ##
31
+ # :attr_reader: clientsize
32
+ # returns current size of box as "widthxheight".
33
+ define_reader :clientsize
34
+
35
+ ##
36
+ # :attr: color
37
+ # Specify RGB values for stretch bar color, as "r g b".
38
+ define_attribute :color
39
+
40
+ ##
41
+ # :attr: direction
42
+ # Direction and position of the stretch bar.
43
+ # Values as 'east' / 'west' / 'north' / 'south'.
44
+ define_attribute :direction
45
+
46
+ ##
47
+ # :attr: expand
48
+ # Allows container to fill available space in indicated direction,
49
+ # but only on the side away from the stretch bar.
50
+ # Values 'no' / 'horizontal' / 'vertical' / 'yes'.
51
+ define_attribute :expand
52
+
53
+ ##
54
+ # :attr_reader: position
55
+ # returns position in pixels within client window as "x,y".
56
+ define_attribute :position
57
+
58
+ ##
59
+ # :attr: rastersize
60
+ # Size of the container, in pixels, value as "widthxheight".
61
+ define_attribute :rastersize
62
+
63
+ ##
64
+ # :attr: showgrip
65
+ # Grip appearance:
66
+ # * "no" - grip is colored using +color+ setting,
67
+ # * "lines" - shows two parallel lines
68
+ define_attribute :showgrip
69
+ end
70
+ end
@@ -0,0 +1,58 @@
1
+ module Iup
2
+
3
+ # A menu item that, when selected, opens another menu.
4
+ # Apart from its text label, a menu item may include an
5
+ # optional image.
6
+ #
7
+ # === Example
8
+ #
9
+ # The following line associates the 'File' name with its
10
+ # menu, ready to place into a parent menu:
11
+ #
12
+ # file_submenu = Iup::SubMenu.new('File', file_menu))
13
+ #
14
+ # See also Menu, MenuItem, Separator
15
+ #
16
+ class SubMenu < Iup::Widget
17
+
18
+ # Creates instance of a submenu.
19
+ # If a block is given, the new instance is yielded to it.
20
+ #
21
+ # * +title+ - displayed name of menu
22
+ # * +child_menu+ - child menu to open
23
+ #
24
+ def initialize title, child_menu
25
+ @handle = IupLib.IupSubmenu(title, child_menu.handle)
26
+
27
+ # run any provided block on instance, to set up further attributes
28
+ yield self if block_given?
29
+ end
30
+
31
+ # -- attributes
32
+
33
+ ##
34
+ # :attr: image
35
+ # Image name or instance to show on menu.
36
+ # This can use an actual image object, or the name of an image
37
+ # from +IupImageLib+.
38
+
39
+ # --
40
+ def image
41
+ attribute_reference('IMAGE', ImageWidget, nil)
42
+ end
43
+
44
+ def image= val # :nodoc:
45
+ attribute_reference('IMAGE', ImageWidget, val)
46
+ end
47
+
48
+ ##
49
+ # :attr: title
50
+ # String to show on menu.
51
+ define_attribute :title
52
+
53
+ ##
54
+ # :attr_reader: wid
55
+ # Native widget identifier.
56
+ define_reader :wid
57
+ end
58
+ end
@@ -0,0 +1,223 @@
1
+ module Iup
2
+
3
+ # 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
+ # === Example
8
+ #
9
+ # The following creates two tabs, each containing a VBox. The callback
10
+ # reports when the tabs are changed:
11
+ #
12
+ # Iup::Tabs.new(vbox1, vbox2) do |t|
13
+ # t.tabchangepos_cb = ->(n, o) {
14
+ # puts "Selected tab was #{o} and is now #{n}"
15
+ # }
16
+ # t.tabtitle(0, 'Tab A')
17
+ # t.tabtitle(1, 'Tab B')
18
+ # end
19
+ #
20
+ # See also: ZBox
21
+ #
22
+ class Tabs < Iup::Widget
23
+ include AttributeReference
24
+
25
+ # Creates an instance of the tabs control.
26
+ # If a block is given, the new instance is yielded to it.
27
+ #
28
+ # * +widgets+ - one or more child widgets
29
+ def initialize *widgets
30
+ @handle = IupLib.IupTabs(*widget_list(widgets))
31
+ @widgets = widgets # store the widgets
32
+
33
+ # run any provided block on instance, to set up further attributes
34
+ yield self if block_given?
35
+ end
36
+
37
+ # -- attributes
38
+
39
+ ##
40
+ # :attr_reader: clientoffset
41
+ # returns current offset of box in its client as "widthxheight".
42
+ define_reader :clientoffset
43
+
44
+ ##
45
+ # :attr_reader: clientsize
46
+ # returns current size of box as "widthxheight".
47
+ define_reader :clientsize
48
+
49
+ ##
50
+ # :attr_reader: count
51
+ # The number of tabs.
52
+
53
+ # --
54
+ def count
55
+ IupLib.IupGetAttribute(@handle, 'COUNT').first.to_i
56
+ end
57
+
58
+ ##
59
+ # :attr: expand
60
+ # Allows control to fill available space in indicated direction.
61
+ # Values 'no' / 'horizontal' / 'vertical' / 'yes'.
62
+ define_attribute :expand
63
+
64
+ ##
65
+ # :attr: padding
66
+ # Margin in x and y directions, value as "mxn".
67
+ define_attribute :padding
68
+
69
+ ##
70
+ # :attr_reader: position
71
+ # returns position in pixels within client window
72
+ define_reader :position
73
+
74
+ ##
75
+ # :attr: rastersize
76
+ # Size of the control, in pixels, value as "widthxheight".
77
+ define_attribute :rastersize
78
+
79
+ ##
80
+ # :attr_reader: screenposition
81
+ # returns position in pixels on screen as "x,y".
82
+ define_reader :screenposition
83
+
84
+ ##
85
+ # :attr: showclose
86
+ # 'no' / 'yes', shows the 'close' button on each tab.
87
+ # Clicking this hides tab unless tabclose_cb defined.
88
+ define_attribute :showclose
89
+
90
+ ##
91
+ # :attr: taborientation
92
+ # 'horizontal' / 'vertical'.
93
+ define_attribute :taborientation
94
+
95
+ # Sets the image of a tab:
96
+ # * +index+ - the index of the tab (0-indexed)
97
+ # * +image+ - image to place on tab
98
+ def tabimage(index, image)
99
+ attribute_reference("TABIMAGE#{index}", ImageWidget, image)
100
+ end
101
+
102
+ # Sets the title of a tab:
103
+ # * +index+ - the index of the tab (0-indexed)
104
+ # * +title+ - text to use for the title
105
+ def tabtitle(index, title)
106
+ IupLib.IupSetAttribute(@handle, "TABTITLE#{index}", title)
107
+ end
108
+
109
+ ##
110
+ # :attr: tabtype
111
+ # 'top' / 'bottom' / 'left' / 'right', indicates position of tabs.
112
+ define_attribute :tabtype
113
+
114
+ # :call-seq:
115
+ # tabs.tabvisible(index)
116
+ # tabs.tabvisible(index, val)
117
+ #
118
+ # Accesses visibility of tab index.
119
+ def tabvisible index, val=nil
120
+ if val.nil?
121
+ IupLib.IupGetAttribute(@handle, "TABVISIBLE#{index}").first
122
+ else
123
+ IupLib.IupSetAttribute @handle, "TABVISIBLE#{index}", val
124
+ end
125
+ end
126
+
127
+ ##
128
+ # :attr: tip
129
+ # Tooltip string.
130
+ define_attribute :tip
131
+
132
+ ##
133
+ # :attr: valuepos
134
+ # Position of visible tab (0-indexed).
135
+
136
+ # --
137
+ def valuepos
138
+ IupLib.IupGetAttribute(@handle, 'VALUEPOS').first.to_i
139
+ end
140
+
141
+ def valuepos= val # :nodoc:
142
+ IupLib.IupSetAttribute(@handle, 'VALUEPOS', val.to_s)
143
+ end
144
+
145
+ # :section: Callbacks
146
+
147
+ ##
148
+ # :attr_writer: rightclick_cb
149
+ # Callback called when the user clicks on some tab using the right mouse
150
+ # button.
151
+ # Callback must respond to +call+ and takes a 1-argument callback, the
152
+ # argument being the tab number that was clicked
153
+
154
+ # --
155
+ def rightclick_cb= callback
156
+ unless callback.arity == 1
157
+ raise ArgumentError, 'rightclick_cb callback must take 1 argument, the tab number'
158
+ end
159
+ cb = Proc.new do |ih, tn|
160
+ callback.call tn
161
+ end
162
+ define_callback cb, 'RIGHTCLICK_CB', :i_i
163
+ end
164
+
165
+ ##
166
+ # :attr_writer: tabchange_cb
167
+ # Callback called when the user shifts the active tab.
168
+ # Callback must respond to +call+ and takes a 2-argument callback: (hnew, hold)
169
+ # * +hnew+ - new selected tab
170
+ # * +hold+ - old (previous) selected tab.
171
+
172
+ # --
173
+ def tabchange_cb= callback
174
+ unless callback.arity == 2
175
+ raise ArgumentError, 'tabchange_cb callback must take 2 argument, the new and old tab handles'
176
+ end
177
+ cb = Proc.new do |ih, hnew, hold|
178
+ new_tab = @widgets.find {|widget| widget.handle.address == hnew.address}
179
+ old_tab = @widgets.find {|widget| widget.handle.address == hold.address}
180
+ callback.call new_tab, old_tab
181
+ end
182
+ define_callback cb, 'TABCHANGE_CB', :pp_i
183
+ end
184
+
185
+ ##
186
+ # :attr_writer: tabchangepos_cb
187
+ # Callback called when the user shifts the active tab.
188
+ # Called only when TABCHANGE_CB is not defined.
189
+ # Callback must respond to +call+ and takes a 2-argument callback: (hnew, hold)
190
+ # * +hnew+ - new selected tab
191
+ # * +hold+ - old (previous) selected tab.
192
+
193
+ # --
194
+ def tabchangepos_cb= callback
195
+ unless callback.arity == 2
196
+ raise ArgumentError, 'tabchangepos_cb callback must take 2 argument, the new and old tab numbers'
197
+ end
198
+ cb = Proc.new do |ih, tnew, told|
199
+ callback.call tnew, told
200
+ end
201
+ define_callback cb, 'TABCHANGEPOS_CB', :ii_i
202
+ end
203
+
204
+ ##
205
+ # :attr_writer: tabclose_cb
206
+ # Callback called when the user clicks on the close button (since 3.10).
207
+ # Called only when SHOWCLOSE=Yes.
208
+ # Callback must respond to +call+ and takes one argument: (tab)
209
+ # * +tab+ - the number of the closing tab.
210
+
211
+ # --
212
+ def tabclose_cb= callback
213
+ unless callback.arity == 1
214
+ raise ArgumentError, 'tabclose_cb callback must take 1 argument, the tab number'
215
+ end
216
+ cb = Proc.new do |ih, tn|
217
+ callback.call tn
218
+ end
219
+ define_callback cb, 'TABCLOSE_CB', :i_i
220
+ end
221
+
222
+ end
223
+ end