# ex:ts=8
# vim:sts=4:sw=4:tw=120
#
# Copyright (C) 2003 Eivind Eklund.  Available under the same license terms as Ruby.
#
# $Id: lagopus.rb,v 1.8 2003/04/29 11:40:02 eivind Exp $

require 'fox'

# Sets of class constructors we need to wrap.
module Lagopus
module LagopusInternal
include Fox
WINDOWS = [
["ColorDialog", :owner, nil, :name, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["DialogBox", :app_or_owner, nil, :name, nil, :opts, DECOR_TITLE|DECOR_BORDER, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 10, :pr, 10, :pt, 10, :pb, 10, :hs, 4, :vs, 4, ],
["DirDialog", :owner, nil, :name, nil, :opts, 0, :x, 0, :y, 0, :w, 500, :h, 300, ],
["FileDialog", :owner, nil, :name, nil, :opts, 0, :x, 0, :y, 0, :w, 500, :h, 300, ],
["FontDialog", :owner, nil, :name, nil, :opts, 0, :x, 0, :y, 0, :w, 600, :h, 380, ],
["InputDialog", :owner, nil, :caption, nil, :label, nil, :ic, nil, :opts, INPUTDIALOG_STRING, :x, 0, :y, 0, :w, 0, :h, 0, ],
["MDIMenu", :owner, nil, :tgt, nil, ],
["MainWindow", :app, nil, :name, nil, :ic, nil, :mi, nil, :opts, DECOR_ALL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 0, :pr, 0, :pt, 0, :pb, 0, :hs, 0, :vs, 0, ],
["MenuPane", :owner, nil, :opts, 0, ],
["MessageBox", :app_or_owner, nil, :caption, nil, :text, nil, :ic, nil, :opts, 0, :x, 0, :y, 0, ],
["Popup", :owner, nil, :opts, POPUP_VERTICAL|FRAME_RAISED|FRAME_THICK, :x, 0, :y, 0, :w, 0, :h, 0, ],
["PrintDialog", :owner, nil, :name, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["ProgressDialog", :owner, nil, :caption, nil, :label, nil, :opts, PROGRESSDIALOG_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["ReplaceDialog", :owner, nil, :caption, nil, :ic, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["RootWindow", :app, nil, :vis, nil, ],
["SearchDialog", :owner, nil, :caption, nil, :ic, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["Shell", :app_or_owner, nil, :opts, nil, :x, nil, :y, nil, :w, nil, :h, nil, ],
["ToolbarShell", :owner, nil, :opts, FRAME_RAISED|FRAME_THICK, :x, 0, :y, 0, :w, 0, :h, 0, :hs, 4, :vs, 4, ],
["Tooltip", :app, nil, :opts, TOOLTIP_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["TopWindow", :app_or_owner, nil, :name, nil, :ic, nil, :mi, nil, :opts, nil, :x, nil, :y, nil, :w, nil, :h, nil, :pl, nil, :pr, nil, :pt, nil, :pb, nil, :hs, nil, :vs, nil, ],
]

CONTAINERS = [
#["4Splitter", :p, nil,                       :opts, FOURSPLITTER_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["4Splitter", :p, nil, :tgt, nil, :sel, nil, :opts, FOURSPLITTER_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["ColorSelector", :p, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["ComboBox", :p, nil, :cols, nil, :nvis, nil, :tgt, nil, :sel, 0, :opts, COMBOBOX_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
#["Composite", :a, nil, :vis, nil, ],
#["Composite", :a, nil, :own, nil, :opts, nil, :x, nil, :y, nil, :w, nil, :h, nil, ],
#["Composite", :p, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["DirBox", :p, nil, :nvis, nil, :tgt, nil, :sel, 0, :opts, FRAME_SUNKEN|FRAME_THICK|TREELISTBOX_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["DirList", :p, nil, :nvis, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["DirSelector", :p, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["DriveBox", :p, nil, :nvis, nil, :tgt, nil, :sel, 0, :opts, FRAME_SUNKEN|FRAME_THICK|LISTBOX_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["FileList", :p, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["FileSelector", :p, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["FontSelector", :p, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["GroupBox", :p, nil, :text, nil, :opts, GROUPBOX_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
["HorizontalFrame", :p, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
["IconList", :p, nil, :tgt, nil, :sel, 0, :opts, ICONLIST_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["ImageView", :p, nil, :img, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["List", :p, nil, :nvis, nil, :tgt, nil, :sel, 0, :opts, LIST_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["ListBox", :p, nil, :nvis, nil, :tgt, nil, :sel, 0, :opts, FRAME_SUNKEN|FRAME_THICK|LISTBOX_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["MDIChild", :p, nil, :name, nil, :ic, nil, :mn, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["MDIClient", :p, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["Matrix", :p, nil, :n, 1, :opts, MATRIX_BY_ROWS, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
["Menubar", :p, nil, :q, nil, :opts, LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 3, :pr, 3, :pt, 2, :pb, 2, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
#["Menubar", :p, nil, :opts, LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 3, :pr, 3, :pt, 2, :pb, 2, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
["Packer", :p, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
["ScrollArea", :p, nil, :opts, nil, :x, nil, :y, nil, :w, nil, :h, nil, ],
["ScrollWindow", :p, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["Shutter", :p, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
["ShutterItem", :p, nil, :text, nil, :icon, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
["Spinner", :p, nil, :cols, nil, :tgt, nil, :sel, 0, :opts, SPIN_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
#["Splitter", :p, nil, :opts, SPLITTER_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["Splitter", :p, nil, :tgt, nil, :sel, nil, :opts, SPLITTER_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["Statusbar", :p, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 3, :pr, 3, :pt, 2, :pb, 2, :hs, 4, :vs, 0, ],
["Switcher", :p, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, ],
["TabBar", :p, nil, :tgt, nil, :sel, 0, :opts, TABBOOK_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, ],
["TabBook", :p, nil, :tgt, nil, :sel, 0, :opts, TABBOOK_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, ],
["Table", :p, nil, :nr, nil, :nc, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_MARGIN, :pr, DEFAULT_MARGIN, :pt, DEFAULT_MARGIN, :pb, DEFAULT_MARGIN, ],
["Text", :p, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["Toolbar", :p, nil, :q, nil, :opts, LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 3, :pr, 3, :pt, 2, :pb, 2, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
#["Toolbar", :p, nil, :opts, LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 2, :pr, 3, :pt, 3, :pb, 2, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
["TreeList", :p, nil, :nvis, nil, :tgt, nil, :sel, 0, :opts, TREELIST_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["TreeListBox", :p, nil, :nvis, nil, :tgt, nil, :sel, 0, :opts, FRAME_SUNKEN|FRAME_THICK|TREELISTBOX_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["VerticalFrame", :p, nil, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_SPACING, :pr, DEFAULT_SPACING, :pt, DEFAULT_SPACING, :pb, DEFAULT_SPACING, :hs, DEFAULT_SPACING, :vs, DEFAULT_SPACING, ],
]
CLIENTS = [
["ArrowButton", :p, nil, :tgt, nil, :sel, 0, :opts, ARROW_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["Button", :p, nil, :text, nil, :ic, nil, :tgt, nil, :sel, 0, :opts, BUTTON_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["Canvas", :p, nil, :tgt, nil, :sel, 0, :opts, FRAME_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["CheckButton", :p, nil, :text, nil, :tgt, nil, :sel, 0, :opts, CHECKBUTTON_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["ColorBar", :p, nil, :tgt, nil, :sel, 0, :opts, FRAME_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["ColorWell", :p, nil, :clr, 0, :tgt, nil, :sel, 0, :opts, COLORWELL_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["ColorWheel", :p, nil, :tgt, nil, :sel, 0, :opts, FRAME_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["Dial", :p, nil, :tgt, nil, :sel, 0, :opts, DIAL_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["DragCorner", :p, nil, ],
["Frame", :p, nil, :opts, FRAME_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
#["GLCanvas", :p, nil, :vis, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["GLCanvas", :p, nil, :vis, nil, :sharegroup, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
#["GLViewer", :p, nil, :vis, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["GLViewer", :p, nil, :vis, nil, :sharegroup, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["Header", :p, nil, :tgt, nil, :sel, 0, :opts, HEADER_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["HorizontalSeparator", :p, nil, :opts, SEPARATOR_GROOVE|LAYOUT_FILL_X, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 1, :pr, 1, :pt, 0, :pb, 0, ],
["Label", :p, nil, :text, nil, :ic, 0, :opts, LABEL_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["MDIDeleteButton", :p, nil, :tgt, nil, :sel, 0, :opts, FRAME_RAISED, :x, 0, :y, 0, :w, 0, :h, 0, ],
["MDIMaximizeButton", :p, nil, :tgt, nil, :sel, 0, :opts, FRAME_RAISED, :x, 0, :y, 0, :w, 0, :h, 0, ],
["MDIMinimizeButton", :p, nil, :tgt, nil, :sel, 0, :opts, FRAME_RAISED, :x, 0, :y, 0, :w, 0, :h, 0, ],
["MDIRestoreButton", :p, nil, :tgt, nil, :sel, 0, :opts, FRAME_RAISED, :x, 0, :y, 0, :w, 0, :h, 0, ],
["MDIWindowButton", :p, nil, :tgt, nil, :sel, 0, :opts, 0, :x, 0, :y, 0, :w, 0, :h, 0, ],
["MenuButton", :p, nil, :text, nil, :ic, nil, :pup, nil, :opts, JUSTIFY_NORMAL|ICON_BEFORE_TEXT|MENUBUTTON_DOWN, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["MenuCaption", :p, nil, :text, nil, :ic, nil, :opts, 0, ],
["MenuCascade", :p, nil, :text, nil, :ic, nil, :pup, nil, :opts, 0, ],
["MenuCommand", :p, nil, :text, nil, :ic, nil, :tgt, nil, :sel, 0, :opts, 0, ],
["MenuSeparator", :p, nil, :opts, 0, ],
["MenuTitle", :p, nil, :text, nil, :ic, nil, :pup, nil, :opts, 0, ],
["Option", :p, nil, :text, nil, :ic, nil, :tgt, nil, :sel, 0, :opts, JUSTIFY_NORMAL|ICON_BEFORE_TEXT|MENUBUTTON_DOWN, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["OptionMenu", :p, nil, :pup, nil, :opts, JUSTIFY_NORMAL|ICON_BEFORE_TEXT, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["Picker", :p, nil, :text, nil, :ic, nil, :tgt, nil, :sel, 0, :opts, BUTTON_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["ProgressBar", :p, nil, :target, nil, :sel, 0, :opts, PROGRESSBAR_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["RadioButton", :p, nil, :text, nil, :tgt, nil, :sel, 0, :opts, RADIOBUTTON_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["ScrollCorner", :p, nil, ],
["Scrollbar", :p, nil, :tgt, nil, :sel, 0, :opts, SCROLLBAR_VERTICAL, :x, 0, :y, 0, :w, 0, :h, 0, ],
["Slider", :p, nil, :tgt, nil, :sel, 0, :opts, SLIDER_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 0, :pr, 0, :pt, 0, :pb, 0, ],
["Statusline", :p, nil, :tgt, nil, :sel, 0, ],
["TabItem", :p, nil, :text, nil, :ic, 0, :opts, TAB_TOP_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["TextField", :p, nil, :ncols, nil, :tgt, nil, :sel, 0, :opts, TEXTFIELD_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["ToggleButton", :p, nil, :text1, nil, :text2, nil, :icon1, nil, :icon2, nil, :tgt, nil, :sel, 0, :opts, TOGGLEBUTTON_NORMAL, :x, 0, :y, 0, :w, 0, :h, 0, :pl, DEFAULT_PAD, :pr, DEFAULT_PAD, :pt, DEFAULT_PAD, :pb, DEFAULT_PAD, ],
["ToolbarGrip", :p, nil, :tgt, nil, :sel, 0, :opts, TOOLBARGRIP_SINGLE, :x, 0, :y, 0, :w, 0, :h, 0, ],
["ToolbarTab", :p, nil, :tgt, nil, :sel, 0, :opts, FRAME_RAISED, :x, 0, :y, 0, :w, 0, :h, 0, ],
["VerticalSeparator", :p, nil, :opts, SEPARATOR_GROOVE|LAYOUT_FILL_Y, :x, 0, :y, 0, :w, 0, :h, 0, :pl, 0, :pr, 0, :pt, 1, :pb, 1, ],
]
end
end

module Lagopus
    module LagopusInternal
	@@containers = []
	def containers
	    @@containers
	end
	module_function :containers
	class Selector
	    def initialize(selector)
		@selector = selector
	    end
	    attr_reader :selector
	end
    end
    #
    # Active parent right now
    #
    def lg_parent
	LagopusInternal::containers[-1]
    end
    #
    # Represent a particular selector.
    #
    def lg_sel(selector = Fox::SEL_COMMAND)
	raise ArgumentError, "Wrong type selector" unless selector.kind_of? Integer
	LagopusInternal::Selector.new(selector)
    end

    #
    # Add a wrapper around a particular constructor
    #
    def self.add_constructor(objname, constructor, shouldyield, shouldparent)	    # :nodoc:
	out = <<EOD
    def lg#{objname}(*inargs)
	raise ArgumentError, "Too many args to lg#{objname}" if inargs.length > 1
	if inargs.length == 0
	    inargs = {}
	else
	    inargs = inargs[0]
	    raise ArgumentError, "lg#{objname} takes named arguments" unless inargs.kind_of? Hash
	end
	origargs = inargs.dup
	outargs = []
EOD
	
	if shouldparent
	    out << <<EOD
	unless inargs.has_key? :parent
	    raise RuntimeError, "No containers available" unless LagopusInternal::containers.length > 0
	    outargs.push LagopusInternal::containers[-1]
	else
	    outargs.push inargs[:parent]
	    inargs.delete :parent
	end
EOD
	    # Skip parent specification
	    constructor.shift
	    constructor.shift
	elsif constructor[0] == :app_or_owner
	    out << <<EOD
	    if inargs.has_key? :app
		raise ArgumentError, "Both :app and :owner" if inargs.has_key? :owner
		key = :app
	    elsif inargs.has_key? :owner
		key = :owner
	    else
		raise ArgumentError, "Neither :app nor :owner"
	    end
	    outargs.push inargs[key]
	    inargs.delete key
EOD
	    # Skip app/owner specification
	    constructor.shift
	    constructor.shift
	end
	LagopusInternal.module_eval "Container#{objname}Args = []"
	while key = constructor.shift
	    value = constructor.shift
	    eval "LagopusInternal::Container#{objname}Args[key] = value"
	    if key == :opts
		out << <<EOD
	inargs.delete :sel
	if inargs[:opts]
	    opts = inargs[:opts]
	    inargs.delete :opts
	else
	    opts = LagopusInternal::Container#{objname}Args[:opts]
	end
	opts &= ~inargs[:delopts] if inargs[:delopts]
	inargs.delete :delopts
	opts |= inargs[:addopts] if inargs[:addopts]
	outargs.push opts
EOD
	    else
		out << <<EOD
	outargs.push(inargs.has_key?(#{key.inspect}) ? inargs[#{key.inspect}] : LagopusInternal::Container#{objname}Args[#{key.inspect}])
	inargs.delete #{key.inspect}
EOD
	    end
	end
	out << <<EOD
	inargs.each { |key, arg|
	    if key.kind_of? LagopusInternal::Selector
		raise ArgumentError, "Both handler for SEL_COMMAND and target/selector" \
		    if key.selector == Fox::SEL_COMMAND && origargs.has_key?(:tgt)
	    else
		raise ArgumentError, "Unknown key \#{key.inspect}"
	    end
	}
	widget = Fox::FX#{objname}.new(*outargs)
	inargs.each { |key, arg|
	    arg = case arg
	    when Symbol,String
		method(arg)
	    else
		arg
	    end
	    widget.connect(key.selector, &arg)
	}
EOD
	if shouldyield
	    out << <<EOD
	if block_given?
	    LagopusInternal::containers.push widget
	    yield widget
	    LagopusInternal::containers.pop
	end
EOD
	else
	    out << <<EOD
	raise ArgumentError, "Block given to lg#{objname}" if block_given?
EOD
	end
	out << <<EOD
	return widget
    end
EOD
	module_eval out
    end
    def self.add_constructors(constructors, shouldyield, noparent)
	constructors.each { |constructor|
	    constructor = constructor.dup
	    objname = constructor.shift
	    add_constructor(objname, constructor, shouldyield, noparent)
	}
    end
    add_constructors(LagopusInternal::CONTAINERS, true, true)
    add_constructors(LagopusInternal::CLIENTS, false, true)
    add_constructors(LagopusInternal::WINDOWS, true, false)
end
