class Iup::Tabs
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
Attributes
returns current offset of box in its client as âwidthxheightâ.
returns current size of box as âwidthxheightâ.
The number of tabs.
Allows control to fill available space in indicated direction. Values ânoâ / âhorizontalâ / âverticalâ / âyesâ.
Margin in x and y directions, value as âmxnâ.
returns position in pixels within client window
Size of the control, in pixels, value as âwidthxheightâ.
returns position in pixels on screen as âx,yâ.
ânoâ / âyesâ, shows the âcloseâ button on each tab. Clicking this hides tab unless tabclose_cb defined.
âhorizontalâ / âverticalâ.
âtopâ / âbottomâ / âleftâ / ârightâ, indicates position of tabs.
Tooltip string.
Position of visible tab (0-indexed).
Public Class Methods
Source
# File lib/wrapped/tabs.rb, line 29 def initialize *widgets @handle = IupLib.IupTabs(*widget_list(widgets)) @widgets = widgets # store the widgets # run any provided block on instance, to set up further attributes yield self if block_given? end
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
Public Instance Methods
Source
# File lib/wrapped/tabs.rb, line 98 def tabimage(index, image) attribute_reference("TABIMAGE#{index}", ImageWidget, image) end
Sets the image of a tab:
-
index- the index of the tab (0-indexed) -
image- image to place on tab
Source
# File lib/wrapped/tabs.rb, line 105 def tabtitle(index, title) IupLib.IupSetAttribute(@handle, "TABTITLE#{index}", title) end
Sets the title of a tab:
-
index- the index of the tab (0-indexed) -
title- text to use for the title
Source
# 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
Accesses visibility of tab index.
Callbacks
Attributes
Callback called when the user clicks on some tab using the right mouse button. Callback must respond to call and takes a 1-argument callback, the argument being the tab number that was clicked
Callback called when the user shifts the active tab. Callback must respond to call and takes a 2-argument callback: (hnew, hold)
-
hnew- new selected tab -
hold- old (previous) selected tab.
Callback called when the user shifts the active tab. Called only when TABCHANGE_CB is not defined. Callback must respond to call and takes a 2-argument callback: (hnew, hold)
-
hnew- new selected tab -
hold- old (previous) selected tab.
Callback called when the user clicks on the close button (since 3.10). Called only when SHOWCLOSE=Yes. Callback must respond to call and takes one argument: (tab)
-
tab- the number of the closing tab.