Class: Iup::Tabs
- Includes:
- AttributeReference
- Defined in:
- lib/wrapped/tabs.rb
Overview
A container for multiple widgets, placing the widgets in layers with a single layer visible. The user can change the visible layer by selecting a tab.
Example
The following creates two tabs, each containing a VBox. The callback reports when the tabs are changed:
Iup::Tabs.new(vbox1, vbox2) do |t|
t.tabchangepos_cb = ->(n, o) {
puts "Selected tab was #{o} and is now #{n}"
}
t.tabtitle(0, 'Tab A')
t.tabtitle(1, 'Tab B')
end
See also: ZBox
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#clientoffset ⇒ Object
:attr_reader: clientoffset returns current offset of box in its client as "widthxheight".
-
#clientsize ⇒ Object
:attr_reader: clientsize returns current size of box as "widthxheight".
-
#count ⇒ Object
--.
-
#expand ⇒ Object
:attr: expand Allows control to fill available space in indicated direction.
-
#initialize(*widgets) {|_self| ... } ⇒ Tabs
constructor
Creates an instance of the tabs control.
-
#padding ⇒ Object
:attr: padding Margin in x and y directions, value as "mxn".
-
#position ⇒ Object
:attr_reader: position returns position in pixels within client window.
-
#rastersize ⇒ Object
:attr: rastersize Size of the control, in pixels, value as "widthxheight".
-
#rightclick_cb=(callback) ⇒ Object
--.
-
#screenposition ⇒ Object
:attr_reader: screenposition returns position in pixels on screen as "x,y".
-
#showclose ⇒ Object
:attr: showclose 'no' / 'yes', shows the 'close' button on each tab.
-
#tabchange_cb=(callback) ⇒ Object
--.
-
#tabchangepos_cb=(callback) ⇒ Object
--.
-
#tabclose_cb=(callback) ⇒ Object
--.
-
#tabimage(index, image) ⇒ Object
Sets the image of a tab: *
index- the index of the tab (0-indexed) *image- image to place on tab. -
#taborientation ⇒ Object
:attr: taborientation 'horizontal' / 'vertical'.
-
#tabtitle(index, title) ⇒ Object
Sets the title of a tab: *
index- the index of the tab (0-indexed) *title- text to use for the title. -
#tabtype ⇒ Object
:attr: tabtype 'top' / 'bottom' / 'left' / 'right', indicates position of tabs.
-
#tabvisible(index, val = nil) ⇒ Object
:call-seq: tabs.tabvisible(index) tabs.tabvisible(index, val).
-
#tip ⇒ Object
:attr: tip Tooltip string.
-
#valuepos ⇒ Object
--.
-
#valuepos=(val) ⇒ Object
:nodoc:.
Methods included from AttributeReference
Methods inherited from Widget
#active, #assign_handle, #bgcolor, #destroy, #enterwindow_cb=, #fgcolor, #font, #getfocus_cb=, #help_cb=, #k_any=, #killfocus_cb=, #leavewindow_cb=, #map_cb=, #maxsize, #minsize, #open_controls, #size, #unmap_cb=, #visible, #wid, #zorder
Methods included from AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_reader, #define_id_writer, #define_property_attribute, #define_property_reader, #define_property_writer, #define_reader, #define_writer
Methods included from CallbackSetter
Constructor Details
#initialize(*widgets) {|_self| ... } ⇒ Tabs
Creates an instance of the tabs control. If a block is given, the new instance is yielded to it.
widgets- one or more child widgets
29 30 31 32 33 34 35 |
# File 'lib/wrapped/tabs.rb', line 29 def initialize * @handle = IupLib.IupTabs(*()) @widgets = # store the widgets # run any provided block on instance, to set up further attributes yield self if block_given? end |
Instance Method Details
#clientoffset ⇒ Object
:attr_reader: clientoffset returns current offset of box in its client as "widthxheight".
42 |
# File 'lib/wrapped/tabs.rb', line 42 define_reader :clientoffset |
#clientsize ⇒ Object
:attr_reader: clientsize returns current size of box as "widthxheight".
47 |
# File 'lib/wrapped/tabs.rb', line 47 define_reader :clientsize |
#count ⇒ Object
--
54 55 56 |
# File 'lib/wrapped/tabs.rb', line 54 def count IupLib.IupGetAttribute(@handle, 'COUNT').first.to_i end |
#expand ⇒ Object
:attr: expand Allows control to fill available space in indicated direction. Values 'no' / 'horizontal' / 'vertical' / 'yes'.
62 |
# File 'lib/wrapped/tabs.rb', line 62 define_attribute :expand |
#padding ⇒ Object
:attr: padding Margin in x and y directions, value as "mxn".
67 |
# File 'lib/wrapped/tabs.rb', line 67 define_attribute :padding |
#position ⇒ Object
:attr_reader: position returns position in pixels within client window
72 |
# File 'lib/wrapped/tabs.rb', line 72 define_reader :position |
#rastersize ⇒ Object
:attr: rastersize Size of the control, in pixels, value as "widthxheight".
77 |
# File 'lib/wrapped/tabs.rb', line 77 define_attribute :rastersize |
#rightclick_cb=(callback) ⇒ Object
--
155 156 157 158 159 160 161 162 163 |
# File 'lib/wrapped/tabs.rb', line 155 def rightclick_cb= callback unless callback.arity == 1 raise ArgumentError, 'rightclick_cb callback must take 1 argument, the tab number' end cb = Proc.new do |ih, tn| callback.call tn end define_callback cb, 'RIGHTCLICK_CB', :i_i end |
#screenposition ⇒ Object
:attr_reader: screenposition returns position in pixels on screen as "x,y".
82 |
# File 'lib/wrapped/tabs.rb', line 82 define_reader :screenposition |
#showclose ⇒ Object
:attr: showclose 'no' / 'yes', shows the 'close' button on each tab. Clicking this hides tab unless tabclose_cb defined.
88 |
# File 'lib/wrapped/tabs.rb', line 88 define_attribute :showclose |
#tabchange_cb=(callback) ⇒ Object
--
173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/wrapped/tabs.rb', line 173 def tabchange_cb= callback unless callback.arity == 2 raise ArgumentError, 'tabchange_cb callback must take 2 argument, the new and old tab handles' end cb = Proc.new do |ih, hnew, hold| new_tab = @widgets.find {|| .handle.address == hnew.address} old_tab = @widgets.find {|| .handle.address == hold.address} callback.call new_tab, old_tab end define_callback cb, 'TABCHANGE_CB', :pp_i end |
#tabchangepos_cb=(callback) ⇒ Object
--
194 195 196 197 198 199 200 201 202 |
# File 'lib/wrapped/tabs.rb', line 194 def tabchangepos_cb= callback unless callback.arity == 2 raise ArgumentError, 'tabchangepos_cb callback must take 2 argument, the new and old tab numbers' end cb = Proc.new do |ih, tnew, told| callback.call tnew, told end define_callback cb, 'TABCHANGEPOS_CB', :ii_i end |
#tabclose_cb=(callback) ⇒ Object
--
212 213 214 215 216 217 218 219 220 |
# File 'lib/wrapped/tabs.rb', line 212 def tabclose_cb= callback unless callback.arity == 1 raise ArgumentError, 'tabclose_cb callback must take 1 argument, the tab number' end cb = Proc.new do |ih, tn| callback.call tn end define_callback cb, 'TABCLOSE_CB', :i_i end |
#tabimage(index, image) ⇒ Object
Sets the image of a tab:
index- the index of the tab (0-indexed)image- image to place on tab
98 99 100 |
# File 'lib/wrapped/tabs.rb', line 98 def tabimage(index, image) attribute_reference("TABIMAGE#{index}", ImageWidget, image) end |
#taborientation ⇒ Object
:attr: taborientation 'horizontal' / 'vertical'.
93 |
# File 'lib/wrapped/tabs.rb', line 93 define_attribute :taborientation |
#tabtitle(index, title) ⇒ Object
Sets the title of a tab:
index- the index of the tab (0-indexed)title- text to use for the title
105 106 107 |
# File 'lib/wrapped/tabs.rb', line 105 def tabtitle(index, title) IupLib.IupSetAttribute(@handle, "TABTITLE#{index}", title) end |
#tabtype ⇒ Object
:attr: tabtype 'top' / 'bottom' / 'left' / 'right', indicates position of tabs.
112 |
# File 'lib/wrapped/tabs.rb', line 112 define_attribute :tabtype |
#tabvisible(index, val = nil) ⇒ Object
:call-seq:
tabs.tabvisible(index)
tabs.tabvisible(index, val)
Accesses visibility of tab index.
119 120 121 122 123 124 125 |
# File 'lib/wrapped/tabs.rb', line 119 def tabvisible index, val=nil if val.nil? IupLib.IupGetAttribute(@handle, "TABVISIBLE#{index}").first else IupLib.IupSetAttribute @handle, "TABVISIBLE#{index}", val end end |
#tip ⇒ Object
:attr: tip Tooltip string.
130 |
# File 'lib/wrapped/tabs.rb', line 130 define_attribute :tip |
#valuepos ⇒ Object
--
137 138 139 |
# File 'lib/wrapped/tabs.rb', line 137 def valuepos IupLib.IupGetAttribute(@handle, 'VALUEPOS').first.to_i end |
#valuepos=(val) ⇒ Object
:nodoc:
141 142 143 |
# File 'lib/wrapped/tabs.rb', line 141 def valuepos= val # :nodoc: IupLib.IupSetAttribute(@handle, 'VALUEPOS', val.to_s) end |