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.

Attributes

autoshow

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

backcolor

Colour of background in title area, as “r g b”.

barposition

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

barsize

n, size of bar - defaults to text line height + 5.

clientoffset

read-only, returns current offset of box in its client as “widthxheight”.

clientsize

read-only, returns current size of box as “widthxheight”.

expand

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

forecolor

Colour of text in title area, as “r g b”.

position

read-only returns position in pixels within client window as “x,y”.

rastersize

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

state

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

title

Displayed on box in title area.

Instance Attribute Summary

Attributes inherited from Widget

#handle

Instance Method Summary collapse

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 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 CallbackSetter

#define_callback

Constructor Details

#initialize(child, &block) ⇒ Expander

Creates an instance of the Expander.

child

the child widget

block

optional block to set up the container’s attributes.



30
31
32
33
34
# File 'lib/wrapped/expander.rb', line 30

def initialize child, &block
  @handle = IupLib.IupExpander child.handle

  self.instance_eval &block if block_given?
end

Instance Method Details

#action_cb(callback) ⇒ Object

Action generated after the expander state is interactively changed.

callback

a zero-argument procedure



55
56
57
58
59
60
61
62
63
# File 'lib/wrapped/expander.rb', line 55

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