Sha256: d5855e36157af99300ee0a3e49dec6c1896c6d9aaf0521216a5d6d9a11c5d404

Contents?: true

Size: 1.17 KB

Versions: 17

Compression:

Stored size: 1.17 KB

Contents

# Class for automatically managing layouts
class Wx::Sizer
  # Generic method to add items, supporting positional and named
  # arguments
  ADD_ITEM_PARAMS = [ Wx::Parameter[ :index, -1 ], 
                      Wx::Parameter[ :proportion, 0 ],
                      Wx::Parameter[ :flag, 0 ],
                      Wx::Parameter[ :border, 0 ],
                      Wx::Parameter[ :user_data, nil ] ]
  
  def add_item(item, *mixed_args)

    begin
      args = Wx::args_as_list(ADD_ITEM_PARAMS, *mixed_args)
    rescue => err
      err.set_backtrace(caller)
      Kernel.raise err
    end

    full_args = []

    # extract the width and the height in the case of a spacer
    # defined as an array
    if item.kind_of?(Array)
      Kernel.raise ArgumentError,
        "Invalid Sizer specification : [width, height] expected" if item.size != 2
      full_args << item[0] << item[1]
    else
      full_args << item
    end

    # update the full arguments list with the optional arguments (except index)
    idx = args.shift
    full_args.concat(args)

    # Call add to append if default position
    if idx == -1
      add(*full_args)
    else
      insert(idx, *full_args)
    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
wxruby3-0.9.0.pre.rc.3 lib/wx/core/sizer.rb
wxruby3-0.9.0.pre.rc.2 lib/wx/core/sizer.rb
wxruby3-0.9.0.pre.rc.1 lib/wx/core/sizer.rb
wxruby3-0.9.0.pre.beta.14 lib/wx/core/sizer.rb
wxruby3-0.9.0.pre.beta.13 lib/wx/core/sizer.rb
wxruby3-0.9.0.pre.beta.11 lib/wx/core/sizer.rb
wxruby3-0.9.0.pre.beta.10 lib/wx/core/sizer.rb
wxruby3-0.9.0.pre.beta.9 lib/wx/core/sizer.rb
wxruby3-0.9.0.pre.beta.8 lib/wx/core/sizer.rb
wxruby64-2.0.1-x64-mingw32 lib/wx/classes/sizer.rb
wxruby-ruby19-2.0.1-x86-mingw32 lib/wx/classes/sizer.rb
wxruby-ruby19-2.0.1-x86-linux lib/wx/classes/sizer.rb
wxruby-ruby19-2.0.1-x86-darwin-9 lib/wx/classes/sizer.rb
wxruby-2.0.1-x86-mswin32-60 lib/wx/classes/sizer.rb
wxruby-2.0.1-x86-mingw32 lib/wx/classes/sizer.rb
wxruby-2.0.1-x86-linux lib/wx/classes/sizer.rb
wxruby-2.0.1-universal-darwin-9 lib/wx/classes/sizer.rb