Module: TkComm

Extended by:
TkEvent, TkUtil
Includes:
TkEvent, TkUtil
Defined in:
lib/tk.rb,
lib/tk.rb

Overview

define TkComm module (step 2: event binding)

Constant Summary collapse

WidgetClassNames =
{}.taint
TkExtlibAutoloadModule =
[].taint
Tk_IDs =

Tk_CMDTBL = {} Tk_WINDOWS = {}

["00000".taint, "00000".taint].freeze
Tk_CMDTBL =

for backward compatibility

Object.new
Tk_WINDOWS =
Object.new
GET_CONFIGINFO_AS_ARRAY =

GET_CONFIGINFO_AS_ARRAY = false => returns a Hash { opt =>val, ... }

true  => returns an Array [[opt,val], ... ]

val is a list which includes resource info.

true
GET_CONFIGINFOwoRES_AS_ARRAY =

for configinfo without resource info; list of [opt, value] pair

false => returns a Hash { opt=>val, ... }
true  => returns an Array [[opt,val], ... ]
true
USE_TCLs_LIST_FUNCTIONS =
true

Constants included from TkUtil

TkUtil::None, TkUtil::RELEASE_DATE

Instance Method Summary collapse

Methods included from TkEvent

install_bind, install_bind_for_event_class

Methods included from TkUtil

_conv_args, _conv_args, _get_eval_enc_str, _get_eval_enc_str, _get_eval_string, _get_eval_string, _symbolkey2str, _symbolkey2str, bool, callback, eval_cmd, hash_kv, hash_kv, install_cmd, num_or_str, number, string, uninstall_cmd

Instance Method Details

#_at(x, y = nil) ⇒ Object



183
184
185
186
187
188
189
# File 'lib/tk.rb', line 183

def _at(x,y=nil)
  if y
    "@#{Integer(x)},#{Integer(y)}"
  else
    "@#{Integer(x)}"
  end
end

#bind(tagOrClass, context, *args) ⇒ Object

def bind(tagOrClass, context, cmd=Proc.new, *args)

_bind(["bind", tagOrClass], context, cmd, *args)
tagOrClass

end



1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
# File 'lib/tk.rb', line 1005

def bind(tagOrClass, context, *args)
  # 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
  _bind(["bind", tagOrClass], context, cmd, *args)
  tagOrClass
end

#bind_all(context, *args) ⇒ Object

def bind_all(context, cmd=Proc.new, *args)

_bind(['bind', 'all'], context, cmd, *args)
TkBindTag::ALL

end



1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
# File 'lib/tk.rb', line 1044

def bind_all(context, *args)
  # 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
  _bind(['bind', 'all'], context, cmd, *args)
  TkBindTag::ALL
end

#bind_append(tagOrClass, context, *args) ⇒ Object

def bind_append(tagOrClass, context, cmd=Proc.new, *args)

_bind_append(["bind", tagOrClass], context, cmd, *args)
tagOrClass

end



1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
# File 'lib/tk.rb', line 1020

def bind_append(tagOrClass, context, *args)
  # 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
  _bind_append(["bind", tagOrClass], context, cmd, *args)
  tagOrClass
end

#bind_append_all(context, *args) ⇒ Object

def bind_append_all(context, cmd=Proc.new, *args)

_bind_append(['bind', 'all'], context, cmd, *args)
TkBindTag::ALL

end



1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
# File 'lib/tk.rb', line 1059

def bind_append_all(context, *args)
  # 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
  _bind_append(['bind', 'all'], context, cmd, *args)
  TkBindTag::ALL
end

#bind_remove(tagOrClass, context) ⇒ Object



1031
1032
1033
1034
# File 'lib/tk.rb', line 1031

def bind_remove(tagOrClass, context)
  _bind_remove(['bind', tagOrClass], context)
  tagOrClass
end

#bind_remove_all(context) ⇒ Object



1070
1071
1072
1073
# File 'lib/tk.rb', line 1070

def bind_remove_all(context)
  _bind_remove(['bind', 'all'], context)
  TkBindTag::ALL
end

#bindinfo(tagOrClass, context = nil) ⇒ Object



1036
1037
1038
# File 'lib/tk.rb', line 1036

def bindinfo(tagOrClass, context=nil)
  _bindinfo(['bind', tagOrClass], context)
end

#bindinfo_all(context = nil) ⇒ Object



1075
1076
1077
# File 'lib/tk.rb', line 1075

def bindinfo_all(context=nil)
  _bindinfo(['bind', 'all'], context)
end

#image_obj(val) ⇒ Object



602
603
604
605
606
607
608
# File 'lib/tk.rb', line 602

def image_obj(val)
  if val =~ /^i(_\d+_)?\d+$/
    TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
  else
    val
  end
end

#install_cmd(cmd) ⇒ Object



794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
# File 'lib/tk.rb', line 794

def install_cmd(cmd)
  return '' if cmd == ''
  begin
    ns = TkCore::INTERP._invoke_without_enc('namespace', 'current')
    ns = nil if ns == '::' # for backward compatibility
  rescue
    # probably, Tcl7.6
    ns = nil
  end
  id = _next_cmd_id
  #Tk_CMDTBL[id] = cmd
  if cmd.kind_of?(TkCallbackEntry)
    TkCore::INTERP.tk_cmd_tbl[id] = cmd
  else
    TkCore::INTERP.tk_cmd_tbl[id] = TkCore::INTERP.get_cb_entry(cmd)
  end
  @cmdtbl = [] unless defined? @cmdtbl
  @cmdtbl.taint unless @cmdtbl.tainted?
  @cmdtbl.push id
  #return Kernel.format("rb_out %s", id);
  if ns
    'rb_out' << TkCore::INTERP._ip_id_ << ' ' << ns << ' ' << id
  else
    'rb_out' << TkCore::INTERP._ip_id_ << ' ' << id
  end
end

#subst(str, *opts) ⇒ Object



628
629
630
631
632
633
634
635
# File 'lib/tk.rb', line 628

def subst(str, *opts)
  # opts := :nobackslashes | :nocommands | novariables
  tk_call('subst', 
          *(opts.collect{|opt|
              opt = opt.to_s
              (opt[0] == ?-)? opt: '-' << opt
            } << str))
end

#uninstall_cmd(id) ⇒ Object



820
821
822
823
824
825
# File 'lib/tk.rb', line 820

def uninstall_cmd(id)
  #id = $1 if /rb_out\S* (c(_\d+_)?\d+)/ =~ id
  id = $4 if id =~ /rb_out\S*(?:\s+(::\S*|[{](::.*)[}]|["](::.*)["]))? (c(_\d+_)?(\d+))/
  #Tk_CMDTBL.delete(id)
  TkCore::INTERP.tk_cmd_tbl.delete(id)
end