Class: Iup::Label
- Includes:
- ButtonCallback, DragDropAttributes, ImageAttributes
- Defined in:
- lib/wrapped/label.rb
Overview
A Label is a a static control. It can display some text or an image, or act as a separator.
The following example (see “examples/label.rb”) displays three labels:
-
a label with some text given in blue, a large font, and center aligned.
-
a label as a horizontal separator.
-
a label using an image.
labeltext = "This label has the following attributes set:\nBGCOLOR = 255 255 0\nFGCOLOR = 0 0 255\nFONT = 'Courier, Normal 14'\nALIGNMENT = ACENTER\n"
lbl = Label.new labeltext do # <1>
bgcolor '255 255 0'
fgcolor '0 0 255'
font 'Courier, Normal 14'
alignment 'ACENTER'
end
lbl_explain = Label.new 'The label on the right has the image of a star'
lbl_star = Label.new do # <2>
image img_star # reference to an image
end
separator = Label.new do # <3>
separator 'HORIZONTAL'
end
Dialog.new(VBox.new(lbl, separator, HBox.new(lbl_explain, lbl_star))) do
title 'IupLabel Example'
end.show
-
A label with text, modifying the attributes of the text.
-
A label with an image.
-
A label which acts as an horizontal separator.
Attributes
- alignment
-
Sets the horizontal and vertical alignment. The value is a string “horizontal:vertical”, with options ALEFT, ACENTER, ARIGHT or none.
- ellipsis
-
If set, adds “…” to the text if there is inadequate space, values ‘yes’ / ‘no’.
- expand
-
Allows label to fill available space in indicated direction. Values ‘no’ / ‘horizontal’ / ‘vertical’ / ‘yes’.
- image
-
Sets the image to display. This can be an actual image object, or the name of an image.
- iminactive
-
Sets the image to display wihen inactive.
- padding
-
Margin in x and y directions, value as “mxn”.
- position
-
read-only returns position in pixels within client window as “x,y”.
- rastersize
-
Size of the label, in pixels, value as “widthxheight”.
- separator
-
‘horizontal’ / ‘vertical’, makes line into a line separator.
- screenposition
-
read-only returns position in pixels on screen as “x,y”.
- spacing
-
Space between image and text, value as a number.
- tip
-
Tooltip string.
- title
-
text to display (unless label has an image or is a separator).
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#initialize(text = nil, &block) ⇒ Label
constructor
Creates an instance of a label.
Methods included from ButtonCallback
Methods included from DragDropAttributes
#dragbegin_cb, #dragdata_cb, #dragdatasize_cb, #dragend_cb, #dropdata_cb, #dropmotion_cb
Methods included from AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_readonly, #define_id_writeonly, #define_property_attribute, #define_property_writeonly, #define_readonly, #define_writeonly
Methods included from ImageAttributes
Methods included from AttributeReference
Methods inherited from Widget
#assign_handle, #enterwindow_cb, #getfocus_cb, #help_cb, #k_any, #killfocus_cb, #leavewindow_cb, #map_cb, #open_controls, #unmap_cb
Methods included from CallbackSetter
Constructor Details
#initialize(text = nil, &block) ⇒ Label
Creates an instance of a label.
- text
-
optional text to use for label.
- block
-
optional block to set label’s attributes.
74 75 76 77 78 79 |
# File 'lib/wrapped/label.rb', line 74 def initialize text=nil, &block @handle = IupLib.IupLabel text # run any provided block on instance, to set up further attributes self.instance_eval &block if block_given? end |