In Files

  • tk/lib/tkextlib/itk/incr_tk.rb

Class/Module Index [+]

Quicksearch

Tk::Itk::Component

Public Class Methods

id2obj(master, id) click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 160
def self.id2obj(master, id)
  if master.kind_of?(TkObject)
    master = master.path
  else
    master = master.to_s
  end
  ComponentID_TBL.mutex.synchronize{
    if ComponentID_TBL.key?(master)
      (ComponentID_TBL[master].key?(id))? ComponentID_TBL[master][id]: id
    else
      id
    end
  }
end
            
new(master, component) click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 206
def initialize(master, component)
  @master = master
  @component = component

  ComponentID_TBL.mutex.synchronize{
    ComponentID_TBL[@master][@component] = self
  }

  begin
    @widget = window(tk_call(@master, 'component', @component))
    @path = @widget.path
  rescue
    @widget = nil
    @path = nil
  end
end
            
new(master, component=nil) click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 175
def self.new(master, component=nil)
  if master.kind_of?(TkObject)
    master = master.path
  else
    master = master.to_s
  end

  if component.kind_of?(Tk::Itk::Component)
    component = component.name
  elsif component
    component = component.to_s
  else
    Itk_Component_ID.mutex.synchronize{
      component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
      Itk_Component_ID[1].succ!
    }
  end

  ComponentID_TBL.mutex.synchronize{
    if ComponentID_TBL.key?(master)
      if ComponentID_TBL[master].key?(component)
        return ComponentID_TBL[master][component]
      end
    else
      ComponentID_TBL[master] = {}
    end
  }

  super(master, component)
end
            

Public Instance Methods

bind(context, *args) click to toggle source

def bind(*args)

unless @widget
  begin
    @widget = window(tk_call(@master, 'component', @component))
    @path = @widget.path
  rescue
    fail RuntimeError, 'component is not assigned to a widget'
  end
end
@widget.bind(*args)

end

 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 374
def bind(context, *args)
  unless @widget
    begin
      @widget = window(tk_call(@master, 'component', @component))
      @path = @widget.path
    rescue
      fail RuntimeError, 'component is not assigned to a widget'
    end
  end
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
  if TkComm._callback_entry?(args[0]) || !block_given?
    cmd = args.shift
  else
    cmd = Proc.new
  end
  @widget.bind(context, cmd, *args)
end
            
bind_append(context, *args) click to toggle source

def #bind_append(*args)

unless @widget
  begin
    @widget = window(tk_call(@master, 'component', @component))
    @path = @widget.path
  rescue
    fail RuntimeError, 'component is not assigned to a widget'
  end
end
@widget.bind_append(*args)

end

 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 403
def bind_append(context, *args)
  unless @widget
    begin
      @widget = window(tk_call(@master, 'component', @component))
      @path = @widget.path
    rescue
      fail RuntimeError, 'component is not assigned to a widget'
    end
  end
  # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
  if TkComm._callback_entry?(args[0]) || !block_given?
    cmd = args.shift
  else
    cmd = Proc.new
  end
  @widget.bind_append(context, cmd, *args)
end
            
bind_remove(*args) click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 421
def bind_remove(*args)
  unless @widget
    begin
      @widget = window(tk_call(@master, 'component', @component))
      @path = @widget.path
    rescue
      fail RuntimeError, 'component is not assigned to a widget'
    end
  end
  @widget.bind_remove(*args)
end
            
bindinfo(*args) click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 433
def bindinfo(*args)
  unless @widget
    begin
      @widget = window(tk_call(@master, 'component', @component))
      @path = @widget.path
    rescue
      fail RuntimeError, 'component is not assigned to a widget'
    end
  end
  @widget.bindinfo(*args)
end
            
epath() click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 235
def epath
  path()
end
            
master() click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 243
def master
  @master
end
            
method_missing(id, *args) click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 275
def method_missing(id, *args)
  name = id.id2name

  # try 1 : component command
  begin
    return tk_call(@master, 'component', @component, name, *args)
  rescue
  end

  # try 2 : component configure
  len = args.length
  begin
    case len
    when 1
      if name[-1] == ?=
        return configure(name[0..-2], args[0])
      else
        return configure(name, args[0])
      end
    when 0
      return cget(name)
    end
  rescue
  end

  # try 3 : widget method or widget configure
  begin
    unless @widget
      @widget = window(tk_call(@master, 'component', @component))
      @path = @widget.path
    end
    @widget.__send__(id, *args)
  rescue
  end

  # unknown method
  super(id, *args)
  # fail RuntimeError, "unknown method '#{name}' for #{self.inspect}"
end
            
mutex() click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 152
def mutex; @mutex; end
            
name() click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 247
def name
  @component
end
            
path() click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 223
def path
  unless @path
    begin
      @widget = window(tk_call(@master, 'component', @component))
      @path = @widget.path
    rescue
      fail RuntimeError, 'component is not assigned to a widget'
    end
  end
  @path
end
            
tk_send(cmd, *rest) click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 315
def tk_send(cmd, *rest)
  begin
    tk_call(@master, 'component', @component, cmd, *rest)
  rescue
    unless @path
      begin
        @widget = window(tk_call(@master, 'component', @component))
        @path = @widget.path
      rescue
        fail RuntimeError, 'component is not assigned to a widget'
      end
    end
    tk_call(@path, cmd, *rest)
  end
end
            
tk_send_with_enc(cmd, *rest) click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 347
def tk_send_with_enc(cmd, *rest)
  begin
    tk_call_with_enc(@master, 'component', @component, cmd, *rest)
  rescue
    unless @path
      begin
        @widget = window(tk_call(@master, 'component', @component))
        @path = @widget.path
      rescue
        fail RuntimeError, 'component is not assigned to a widget'
      end
    end
    tk_call_with_enc(@path, cmd, *rest)
  end
end
            
tk_send_without_enc(cmd, *rest) click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 331
def tk_send_without_enc(cmd, *rest)
  begin
    tk_call_without_enc(@master, 'component', @component, cmd, *rest)
  rescue
    unless @path
      begin
        @widget = window(tk_call(@master, 'component', @component))
        @path = @widget.path
      rescue
        fail RuntimeError, 'component is not assigned to a widget'
      end
    end
    tk_call_without_enc(@path, cmd, *rest)
  end
end
            
to_eval() click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 239
def to_eval
  path()
end
            
widget() click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 251
def widget
  unless @widget
    begin
      @widget = window(tk_call(@master, 'component', @component))
      @path = @widget.path
    rescue
      fail RuntimeError, 'component is not assigned to a widget'
    end
  end
  @widget
end
            
widget_class() click to toggle source
 
               # File tk/lib/tkextlib/itk/incr_tk.rb, line 263
def widget_class
  unless @widget
    begin
      @widget = window(tk_call(@master, 'component', @component))
      @path = @widget.path
      @widget.classname
    rescue
      nil
    end
  end
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.