Class: Iup::Label

Inherits:
Widget show all
Includes:
ButtonCallback, DragDropAttributes, ImageAttributes
Defined in:
lib/wrapped/label.rb

Overview

A static control used to display some text or an image, or act as a separator.

Example

(1) label with text and setting font and colors:

Iup::Label.new("Iup Label Text") do |l|
  l.bgcolor = '255 255 0'
  l.fgcolor = '0 0 255'
  l.font = 'Courier, Normal 14'
  l.alignment = 'ACENTER'
 end

(2) label with image aligned to right

Iup::Label.new do |l|
  l.image = img_star
end

(3) label as a horizontal separator

Iup::Label.new do |l|
  l.separator = 'HORIZONTAL'
end

Direct Known Subclasses

Link

Instance Attribute Summary

Attributes inherited from Widget

#handle

Instance Method Summary collapse

Methods included from ButtonCallback

#button_cb=

Methods included from DragDropAttributes

#dragbegin_cb=, #dragdata_cb=, #dragdatasize_cb=, #dragend_cb=, #dragsource, #dragsourcemove, #dragtypes, #dropdata_cb=, #dropmotion_cb=, #droptarget, #droptypes

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 ImageAttributes

#image, #image=, #iminactive, #iminactive=, #impress, #impress=

Methods included from AttributeReference

#attribute_reference

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 CallbackSetter

#define_callback

Constructor Details

#initialize(text = nil) {|_self| ... } ⇒ Label

Creates an instance of a label. If a block is given, the new instance is yielded to it.

  • text - optional text to use for label.

Yields:

  • (_self)

Yield Parameters:

  • _self (Iup::Label)

    the object that the method was called on



36
37
38
39
40
41
# File 'lib/wrapped/label.rb', line 36

def initialize text=nil
  @handle = IupLib.IupLabel(text)

  # run any provided block on instance, to set up further attributes
  yield self if block_given?
end

Instance Method Details

#alignmentObject

:attr: alignment Sets the horizontal and vertical alignment. The value is a string “horizontal:vertical”, with horizontal options ALEFT, ACENTER, ARIGHT and vertical options ATOP, ACENTER, ABOTTOM. Partial values also accepted, e.g. “ARIGHT”, “:ATOP”.



52
# File 'lib/wrapped/label.rb', line 52

define_attribute :alignment

#ellipsisObject

:attr: ellipsis If set, adds “…” to the text if there is inadequate space, values ‘yes’ / ‘no’.



58
# File 'lib/wrapped/label.rb', line 58

define_attribute :ellipsis

#expandObject

:attr: expand Allows label to fill available space in indicated direction. Values ‘no’ / ‘horizontal’ / ‘vertical’ / ‘yes’.



64
# File 'lib/wrapped/label.rb', line 64

define_attribute :expand

#paddingObject

:attr: padding Margin in x and y directions, value as “mxn”.



69
# File 'lib/wrapped/label.rb', line 69

define_attribute :padding

#positionObject

:attr_reader: position Returns position in pixels within client window as “x,y”.



74
# File 'lib/wrapped/label.rb', line 74

define_reader :position

#rastersizeObject

:attr: rastersize Size of the label, in pixels, value as “widthxheight”.



79
# File 'lib/wrapped/label.rb', line 79

define_attribute :rastersize

#screenpositionObject

:attr_reader: screenposition returns position in pixels on screen as “x,y”.



84
# File 'lib/wrapped/label.rb', line 84

define_reader :screenposition

#separatorObject

:attr: separator ‘horizontal’ / ‘vertical’, makes line into a line separator.



89
# File 'lib/wrapped/label.rb', line 89

define_attribute :separator

#spacingObject

:attr: spacing Space between image and text, value as a number.



94
# File 'lib/wrapped/label.rb', line 94

define_attribute :spacing

#tipObject

:attr: tip Tooltip string.



99
# File 'lib/wrapped/label.rb', line 99

define_attribute :tip

#titleObject

:attr: title text to display (unless label has an image or is a separator).



104
# File 'lib/wrapped/label.rb', line 104

define_attribute :title