module Iup
  class Expander < Widget
    def initialize child, &block
      @handle = IupLib.IupExpander child.handle

      self.instance_eval &block if block_given?
    end

    # -- attributes

    define_attribute :autoshow
    define_attribute :backcolor
    define_attribute :barposition
    define_attribute :barsize
    define_readonly :clientoffset
    define_readonly :clientsize
    define_attribute :expand
    define_attribute :font
    define_attribute :forecolor
    define_attribute :maxsize
    define_attribute :minsize
    define_attribute :position
    define_attribute :rastersize
    define_attribute :size
    define_attribute :state
    define_attribute :title
    define_readonly :wid

    # -- callbacks

    # Action generated after the expander state is interactively changed.
    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
  end
end
