Class Tk::TkTable
In: tk/lib/tkextlib/tktable/tktable.rb
Parent: TkWindow

Methods

Included Modules

Scrollable Tk::TkTable::ConfigMethod Tk::ValidateConfigure

Classes and Modules

Module Tk::TkTable::ConfigMethod
Class Tk::TkTable::BrowseCommand
Class Tk::TkTable::CellCommand
Class Tk::TkTable::CellTag
Class Tk::TkTable::NamedCellTag
Class Tk::TkTable::SelectionCommand
Class Tk::TkTable::ValidateCommand

Constants

TkCommandNames = ['table'.freeze].freeze
WidgetClassName = 'Table'.freeze

Public Class methods

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 20
    def self.package_version
      begin
        TkPackage.require('Tktable')
      rescue
        ''
      end
    end

Public Instance methods

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 202
  def __destroy_hook__
    Tk::TkTable::CelTag::CellTagID_TBL.delete(@path)
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 337
  def __validation_class_list
    super << 
      BrowseCommand << CellCommand << SelectionCommand << ValidateCommand
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 349
  def activate(idx)
    tk_send('activate', tagid(idx))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 353
  def bbox(idx)
    list(tk_send('bbox', tagid(idx)))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 366
  def border_dragto(x, y)
    tk_send('scan', 'dragto', x, y)
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 357
  def border_mark(x, y)
    simplelist(tk_send('scan', 'mark', x, y))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 363
  def border_mark_col(x, y)
    tk_send('scan', 'mark', x, y, 'col')
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 360
  def border_mark_row(x, y)
    tk_send('scan', 'mark', x, y, 'row')
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 382
  def clear_all(first=None, last=None)
    tk_send('clear', 'all', tagid(first), tagid(last))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 370
  def clear_cache(first=None, last=None)
    tk_send('clear', 'cache', tagid(first), tagid(last))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 374
  def clear_sizes(first=None, last=None)
    tk_send('clear', 'sizes', tagid(first), tagid(last))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 378
  def clear_tags(first=None, last=None)
    tk_send('clear', 'tags', tagid(first), tagid(last))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 480
  def col_index(idx)
    number(tk_send('index', tagid(idx), 'col'))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 387
  def curselection
    simplelist(tk_send('curselection'))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 390
  def curselection=(val)
    tk_send('curselection', val)
    val
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 395
  def curvalue
    tk_tcl2ruby(tk_send('curvalue'), true, false)
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 398
  def curvalue=(val)
    tk_send('curvalue', val)
    val
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 403
  def delete_active(idx1, idx2=None)
    tk_send('delete', 'active', tagid(idx1), tagid(idx2))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 407
  def delete_cols(*args) # ?switches_array?, index, ?count?

    params = []
    if args[0].kind_of?(Array)
      switches = args.shift
      switches.each{|k| params << "-#{k}"}
    end
    params << '--'
    params << tagid(args.shift)
    params.concat(args)
    tk_send('delete', 'cols', *params)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 419
  def delete_rows(*args) # ?switches_array?, index, ?count?

    params = []
    if args[0].kind_of?(Array)
      switches = args.shift
      switches.each{|k| params << "-#{k}"}
    end
    params << '--'
    params << tagid(args.shift)
    params.concat(args)
    tk_send('delete', 'rows', *params)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 432
  def get(idx)
    tk_tcl2ruby(tk_send('get', tagid(idx)), true, false)
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 435
  def get_area(idx1, idx2)
    simplelist(tk_send('get', tagid(idx1), tagid(idx2))).collect{|v|
      tk_tcl2ruby(v, true, false)
    }
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 444
  def height(row)
    number(tk_send('height', row))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 441
  def height_list
    list(tk_send('height'))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 455
  def hidden?(idx, *args)
    if args.empty?
      if (ret = tk_send('hidden', tagid(idx))) == ''
        false
      else
        ret
      end
    else
      bool(tk_send('hidden', tagid(idx), *(args.collect{|i| tagid(i)})))
    end
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 452
  def hidden_list
    simplelist(tk_send('hidden'))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 467
  def icursor
    number(tk_send('icursor'))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 470
  def icursor_set(idx)
    number(tk_send('icursor', tagid(idx)))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 474
  def index(idx)
    tk_send('index', tagid(idx))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 484
  def insert_active(idx, val)
    tk_send('insert', 'active', tagid(idx), val)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 488
  def insert_cols(*args) # ?switches_array?, index, ?count?

    params = []
    if args[0].kind_of?(Array)
      switches = args.shift
      switches.each{|k| params << "-#{k}"}
    end
    params << '--'
    params.concat(args)
    params << tagid(args.shift)
    tk_send('insert', 'cols', *params)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 500
  def insert_rows(*args) # ?switches_array?, index, ?count?

    params = []
    if args[0].kind_of?(Array)
      switches = args.shift
      switches.each{|k| params << "-#{k}"}
    end
    params << '--'
    params << tagid(args.shift)
    params.concat(args)
    tk_send('insert', 'rows', *params)
    self
  end

def postscript(*args)

  tk_send('postscript', *args)

end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 517
  def reread
    tk_send('reread')
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 477
  def row_index(idx)
    number(tk_send('index', tagid(idx), 'row'))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 526
  def scan_dragto(x, y)
    tk_send('scan', 'dragto', x, y)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 522
  def scan_mark(x, y)
    tk_send('scan', 'mark', x, y)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 531
  def see(idx)
    tk_send('see', tagid(idx))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 536
  def selection_anchor(idx)
    tk_send('selection', 'anchor', tagid(idx))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 540
  def selection_clear(first, last=None)
    tk_send('selection', 'clear', tagid(first), tagid(last))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 544
  def selection_clear_all
    selection_clear('all')
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 547
  def selection_include?(idx)
    bool(tk_send('selection', 'includes', tagid(idx)))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 550
  def selection_set(first, last=None)
    tk_send('selection', 'set', tagid(first), tagid(last))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 555
  def set(*pairs) # idx, val, idx, val, ... 

    args = []
    0.step(pairs.size-1, 2){|i|
      args << tagid(pairs[i])
      args << pairs[i+1]
    }
    tk_send('set', *args)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 573
  def set_col(*pairs) # idx, val, idx, val, ... 

    args = []
    0.step(pairs.size-1, 2){|i|
      args << tagid(pairs[i])
      args << pairs[i+1]
    }
    tk_send('set', 'col', *args)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 447
  def set_height(*pairs)
    tk_send('height', *(pairs.flatten))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 564
  def set_row(*pairs) # idx, val, idx, val, ... 

    args = []
    0.step(pairs.size-1, 2){|i|
      args << tagid(pairs[i])
      args << pairs[i+1]
    }
    tk_send('set', 'row', *args)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 651
  def set_spans(*pairs)
    # idx, val, idx, val, ... 

    args = []
    0.step(pairs.size-1, 2){|i|
      args << tagid(pairs[i])
      val = pairs[i+1]
      if val.kind_of?(Array)
        args << val.join(',')
      else
        args << val
      end
    }
    tk_send('spans', *args)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 788
  def set_width(*pairs)
    tk_send('width', *(pairs.flatten))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 645
  def span(idx)
    lst = simplelist(tk_send('spans', tagid(idx)))
    idx = lst[0]
    rows, cols = lst[1].split(',').map!{|n| Integer(n)}
    [idx [rows, cols]]
  end
span_list()

Alias for spans

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 636
  def spans
    simplelist(tk_send('spans')).collect{|inf|
      lst = simplelist(inf)
      idx = lst[0]
      rows, cols = lst[1].split(',').map!{|n| Integer(n)}
      [idx [rows, cols]]
    }
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 725
  def tag_cell(tag, *cells)
    tk_send('tag', 'cell', tagid(tag), *(cells.collect{|idx| tagid(idx)}))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 733
  def tag_col(tag, *cols)
    tk_send('tag', 'col', tagid(tag), *cols)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 737
  def tag_col_reset(*cols)
    tk_send('tag', 'col', '', *cols)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 741
  def tag_delete(tag)
    tk_send('tag', 'delete', tagid(tag))
    if Tk::TkTable::CellTag::CellTagID_TBL[@path]
      if tag.kind_of? Tk::TkTable::CellTag
        Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id) 
      else
        Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag) 
      end
    end
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 752
  def tag_exist?(tag)
    bool(tk_send('tag', 'exists', tagid(tag)))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 755
  def tag_include?(tag, idx)
    bool(tk_send('tag', 'includes', tagid(tag), tagid(idx)))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 758
  def tag_lower(tag, target=None)
    tk_send('tag', 'lower', tagid(tag), tagid(target))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 762
  def tag_names(pat=None)
    simplelist(tk_send('tag', 'names', pat)).collect{|tag| tagid2obj(tag)}
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 765
  def tag_raise(tag, target=None)
    tk_send('tag', 'raise', tagid(tag), tagid(target))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 729
  def tag_reset(*cells)
    tk_send('tag', 'cell', '', *(cells.collect{|idx| tagid(idx)}))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 769
  def tag_row(tag, *rows)
    tk_send('tag', 'row', tagid(tag), *rows)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 773
  def tag_row_reset(*rows)
    tk_send('tag', 'row', '', *rows)
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 698
  def tagid(tag)
    if tag.kind_of?(Tk::TkTable::CellTag)
      tag.id
    elsif tag.kind_of?(Array)
      if tag[0].kind_of?(Integer) && tag[1].kind_of?(Integer)
        # [row, col]

        tag.join(',')
      else
        tag
      end
    else
      tag
    end
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 713
  def tagid2obj(tagid)
    if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path)
      if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid)
        Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid]
      else
        tagid
      end
    else
      tagid
    end
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 778
  def validate(idx)
    bool(tk_send('validate', tagid(idx)))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 785
  def width(row)
    number(tk_send('width', row))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 782
  def width_list
    list(tk_send('width'))
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 793
  def window_delete(*args)
    tk_send('window', 'delete', *(args.collect{|idx| tagid(idx)}))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 797
  def window_move(from_idx, to_idx)
    tk_send('window', 'move', tagid(from_idx), tagid(to_idx))
    self
  end

[Source]

# File tk/lib/tkextlib/tktable/tktable.rb, line 801
  def window_names(pat=None)
    simplelist(tk_send('window', 'names', pat))
  end

[Validate]