Class: Iup::Expander

Inherits:
Widget show all
Defined in:
lib/wrapped/expander.rb

Overview

An expandable container for a single widget. The user can show or hide the child widget, as required.

Example

The following places a button in an expandable area, with a blue title:

bt = Iup::Button.new('Button ONE')

exp = Iup::Expander.new(bt) do |e|
  e.title = 'Expander title'
  e.forecolor = '0 0 255'
end

Instance Attribute Summary

Attributes inherited from Widget

#handle

Instance Method Summary collapse

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

#define_callback

Constructor Details

#initialize(child) {|_self| ... } ⇒ Expander

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

  • child - the child widget to display.

Yields:

  • (_self)

Yield Parameters:

  • _self (Iup::Expander)

    the object that the method was called on



23
24
25
26
27
# File 'lib/wrapped/expander.rb', line 23

def initialize child
  @handle = IupLib.IupExpander(child.handle)

  yield self if block_given?
end

Instance Method Details

#action=(callback) ⇒ Object



101
102
103
104
105
106
107
108
109
# File 'lib/wrapped/expander.rb', line 101

def action= callback
  unless callback.arity.zero?
    raise ArgumentError, 'action callback must take 0 arguments'
  end
  cb = Proc.new do |ih|
    callback.call
  end
  define_callback cb, 'ACTION', :plain
end

#autoshowObject

:attr: autoshow If set, child will be shown when mouse hovers over container. Values ‘yes’ / ‘no’.



35
# File 'lib/wrapped/expander.rb', line 35

define_attribute :autoshow

#backcolorObject

:attr: backcolor Color of background in title area, as “r g b”.



40
# File 'lib/wrapped/expander.rb', line 40

define_attribute :backcolor

#barpositionObject

:attr: barposition Position of expander bar, as ‘top’ / ‘bottom’ / ‘left’ / ‘right’.



45
# File 'lib/wrapped/expander.rb', line 45

define_attribute :barposition

#barsizeObject

:attr: barsize Size of bar - defaults to text line height + 5.



50
# File 'lib/wrapped/expander.rb', line 50

define_attribute :barsize

#clientoffsetObject

:attr_reader: clientoffset Returns current offset of box in its client as “widthxheight”.



55
# File 'lib/wrapped/expander.rb', line 55

define_reader :clientoffset

#clientsizeObject

:attr_reader: clientsize Returns current size of box as “widthxheight”.



60
# File 'lib/wrapped/expander.rb', line 60

define_reader :clientsize

#expandObject

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



66
# File 'lib/wrapped/expander.rb', line 66

define_attribute :expand

#forecolorObject

:attr: forecolor Color of text in title area, as “r g b”.



71
# File 'lib/wrapped/expander.rb', line 71

define_attribute :forecolor

#openclose_cb=(callback) ⇒ Object



118
119
120
121
122
123
124
125
126
# File 'lib/wrapped/expander.rb', line 118

def openclose_cb= callback
  unless callback.arity.zero?
    raise ArgumentError, 'openclose_cb callback must take 0 arguments'
  end
  cb = Proc.new do |ih|
    callback.call
  end
  define_callback cb, 'OPENCLOSE_CB', :plain
end

#positionObject

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



76
# File 'lib/wrapped/expander.rb', line 76

define_attribute :position

#rastersizeObject

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



81
# File 'lib/wrapped/expander.rb', line 81

define_attribute :rastersize

#stateObject

:attr: state Show or hide child, as ‘open’ / ‘close’.



86
# File 'lib/wrapped/expander.rb', line 86

define_attribute :state

#titleObject

:attr: title Displayed on box in title area.



91
# File 'lib/wrapped/expander.rb', line 91

define_attribute :title