diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/ext/tk/lib/tkextlib/iwidgets |
Fresh start
Diffstat (limited to 'jni/ruby/ext/tk/lib/tkextlib/iwidgets')
54 files changed, 5280 insertions, 0 deletions
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb new file mode 100644 index 0000000..91e06d1 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb @@ -0,0 +1,121 @@ +# +# tkextlib/iwidgets/buttonbox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Buttonbox < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Buttonbox + TkCommandNames = ['::iwidgets::buttonbox'.freeze].freeze + WidgetClassName = 'Buttonbox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'buttoncget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'buttonconfigure', id] + end + private :__item_config_cmd + + def __item_boolval_optkeys(id) + super(id) << 'defaultring' + end + private :__item_boolval_optkeys + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias buttoncget_tkstring itemcget_tkstring + alias buttoncget itemcget + alias buttoncget_strict itemcget_strict + alias buttonconfigure itemconfigure + alias buttonconfiginfo itemconfiginfo + alias current_buttonconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def add(tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'add', tagid(tag), *hash_kv(keys)) + tag + end + + def default(idx) + tk_call(@path, 'default', index(idx)) + self + end + + def delete(idx) + tk_call(@path, 'delete', index(idx)) + self + end + + def hide(idx) + tk_call(@path, 'hide', index(idx)) + self + end + + def index(idx) + number(tk_call(@path, 'index', tagid(idx))) + end + + def insert(idx, tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)) + tag + end + + def invoke(idx=nil) + if idx + tk_call(@path, 'invoke', index(idx)) + else + tk_call(@path, 'invoke') + end + self + end + + def show(idx) + tk_call(@path, 'show', index(idx)) + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb new file mode 100644 index 0000000..a5478c7 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb @@ -0,0 +1,125 @@ +# +# tkextlib/iwidgets/calendar.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Calendar < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Calendar + TkCommandNames = ['::iwidgets::calendar'.freeze].freeze + WidgetClassName = 'Calendar'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() + [ + 'buttonforeground', 'outline', 'selectcolor', + 'weekdaybackground', 'weekendbackground' + ] + end + private :__strval_optkeys + + def __listval_optkeys + super() << 'days' + end + private :__listval_optkeys + + def __font_optkeys + super() + ['currentdatefont', 'datefont', 'dayfont', 'titlefont'] + end + private :__font_optkeys + + #################################### + + include Tk::ValidateConfigure + + class CalendarCommand < TkValidateCommand + #class CalCmdArgs < TkUtil::CallbackSubst + class ValidateArgs < TkUtil::CallbackSubst + KEY_TBL = [ [?d, ?s, :date], nil ] + PROC_TBL = [ [?s, TkComm.method(:string) ], nil ] + +=begin + # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) + KEY_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String) + end + inf + } + + PROC_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + end + inf + } +=end + + _setup_subst_table(KEY_TBL, PROC_TBL); + + def self.ret_val(val) + val + end + end + + def self._config_keys + # array of config-option key (string or symbol) + ['command'] + end + + #def initialize(cmd = Proc.new, *args) + # _initialize_for_cb_class(CalCmdArgs, cmd, *args) + #end + end + + def __validation_class_list + super() << CalendarCommand + end + + Tk::ValidateConfigure.__def_validcmd(binding, CalendarCommand) +=begin + def command(cmd = Proc.new, args = nil) + if cmd.kind_of?(CalendarCommand) + configure('command', cmd) + elsif args + configure('command', [cmd, args]) + else + configure('command', cmd) + end + end +=end + + #################################### + + def get_string + tk_call(@path, 'get', '-string') + end + alias get get_string + + def get_clicks + number(tk_call(@path, 'get', '-clicks')) + end + + def select(date) + tk_call(@path, 'select', date) + self + end + + def show(date) + tk_call(@path, 'show', date) + self + end + def show_now + tk_call(@path, 'show', 'now') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb new file mode 100644 index 0000000..398eec3 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb @@ -0,0 +1,53 @@ +# +# tkextlib/iwidgets/canvasprintbox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Canvasprintbox < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Canvasprintbox + TkCommandNames = ['::iwidgets::canvasprintbox'.freeze].freeze + WidgetClassName = 'Canvasprintbox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'filename' + end + private :__strval_optkeys + + def __boolval_optkeys + super() << 'stretch' + end + private :__boolval_optkeys + + def get_output + tk_call(@path, 'getoutput') + end + + def print + bool(tk_call(@path, 'print')) + end + + def refresh + tk_call(@path, 'refresh') + self + end + + def set_canvas(win) + tk_call(@path, 'setcanvas', win) + self + end + + def stop + tk_call(@path, 'stop') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb new file mode 100644 index 0000000..e64d815 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb @@ -0,0 +1,38 @@ +# +# tkextlib/iwidgets/canvasprintdialog.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Canvasprintdialog < Tk::Iwidgets::Dialog + end + end +end + +class Tk::Iwidgets::Canvasprintdialog + TkCommandNames = ['::iwidgets::canvasprintdialog'.freeze].freeze + WidgetClassName = 'Canvasprintdialog'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def get_output + tk_call(@path, 'getoutput') + end + + def print + bool(tk_call(@path, 'print')) + end + + def refresh + tk_call(@path, 'refresh') + self + end + + def set_canvas(win) + tk_call(@path, 'setcanvas', win) + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb new file mode 100644 index 0000000..a7476c8 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb @@ -0,0 +1,130 @@ +# +# tkextlib/iwidgets/checkbox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Checkbox < Tk::Iwidgets::Labeledframe + end + end +end + +class Tk::Iwidgets::Checkbox + TkCommandNames = ['::iwidgets::checkbox'.freeze].freeze + WidgetClassName = 'Checkbox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'buttoncget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'buttonconfigure', id] + end + private :__item_config_cmd + + def __item_boolval_optkeys(id) + super(id) << 'defaultring' + end + private :__item_boolval_optkeys + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias buttoncget_tkstring itemcget_tkstring + alias buttoncget itemcget + alias buttoncget_strict itemcget_strict + alias buttonconfigure itemconfigure + alias buttonconfiginfo itemconfiginfo + alias current_buttonconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def add(tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'add', tagid(tag), *hash_kv(keys)) + tag + end + + def delete(idx) + tk_call(@path, 'delete', index(idx)) + self + end + + def deselect(idx) + tk_call(@path, 'deselect', index(idx)) + self + end + + def flash(idx) + tk_call(@path, 'flash', index(idx)) + self + end + + def get_tags + simplelist(tk_call_without_enc(@path, 'get')) + end + + def get_objs + simplelist(tk_call_without_enc(@path, 'get')).collect{|id| + Tk::Itk::Component.id2obj(self, id) + } + end + + def get(idx=nil) + if idx + bool(tk_call_without_enc(@path, 'get', index(idx))) + else + get_tags + end + end + + def index(idx) + number(tk_call(@path, 'index', tagid(idx))) + end + + def insert(idx, tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)) + tag + end + + def select(idx) + tk_call(@path, 'select', index(idx)) + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb new file mode 100644 index 0000000..82dcf25 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb @@ -0,0 +1,104 @@ +# +# tkextlib/iwidgets/combobox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Combobox < Tk::Iwidgets::Entryfield + end + end +end + +class Tk::Iwidgets::Combobox + TkCommandNames = ['::iwidgets::combobox'.freeze].freeze + WidgetClassName = 'Combobox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'completion' << 'dropdown' << 'editable' << 'unique' + end + private :__boolval_optkeys + + def clear(component=None) + tk_call(@path, 'clear', component) + self + end + + def delete_list(first, last=None) + tk_call(@path, 'delete', 'list', first, last) + self + end + + def delete_entry(first, last=None) + tk_call(@path, 'delete', 'entry', first, last) + self + end + + def get_list_contents(index) + tk_call(@path, 'get', index) + end + + def insert_list(idx, *elems) + tk_call(@path, 'insert', 'list', idx, *elems) + self + end + + def insert_entry(idx, *elems) + tk_call(@path, 'insert', 'entry', idx, *elems) + self + end + + # listbox methods + def size + tk_send_without_enc('size').to_i + end + def see(index) + tk_send_without_enc('see', index) + self + end + def selection_anchor(index) + tk_send_without_enc('selection', 'anchor', index) + self + end + def selection_clear(first, last=None) + tk_send_without_enc('selection', 'clear', first, last) + self + end + def selection_includes(index) + bool(tk_send_without_enc('selection', 'includes', index)) + end + def selection_set(first, last=None) + tk_send_without_enc('selection', 'set', first, last) + self + end + + # scrolledlistbox methods + def get_curselection + tk_call(@path, 'getcurselection') + end + def justify(dir) + tk_call(@path, 'justify', dir) + self + end + def sort(*params, &b) + # see 'lsort' man page about params + if b + tk_call(@path, 'sort', '-command', proc(&b), *params) + else + tk_call(@path, 'sort', *params) + end + self + end + def sort_ascending + tk_call(@path, 'sort', 'ascending') + self + end + def sort_descending + tk_call(@path, 'sort', 'descending') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb new file mode 100644 index 0000000..98a0051 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb @@ -0,0 +1,20 @@ +# +# tkextlib/iwidgets/dateentry.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Dateentry < Tk::Iwidgets::Datefield + end + end +end + +class Tk::Iwidgets::Dateentry + TkCommandNames = ['::iwidgets::dateentry'.freeze].freeze + WidgetClassName = 'Dateentry'.freeze + WidgetClassNames[WidgetClassName] ||= self +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb new file mode 100644 index 0000000..50d5405 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb @@ -0,0 +1,58 @@ +# +# tkextlib/iwidgets/datefield.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Datefield < Tk::Iwidgets::Labeledwidget + end + end +end + +class Tk::Iwidgets::Datefield + TkCommandNames = ['::iwidgets::datefield'.freeze].freeze + WidgetClassName = 'Datefield'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'gmt' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'textbackground' + end + private :__strval_optkeys + + def __font_optkeys + super() << 'textfont' + end + private :__font_optkeys + + def get_string + tk_call(@path, 'get', '-string') + end + alias get get_string + + def get_clicks + number(tk_call(@path, 'get', '-clicks')) + end + + def valid? + bool(tk_call(@path, 'isvalid')) + end + alias isvalid? valid? + + def show(date=None) + tk_call(@path, 'show', date) + self + end + def show_now + tk_call(@path, 'show', 'now') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb new file mode 100644 index 0000000..2d554ca --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb @@ -0,0 +1,20 @@ +# +# tkextlib/iwidgets/dialog.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Dialog < Tk::Iwidgets::Dialogshell + end + end +end + +class Tk::Iwidgets::Dialog + TkCommandNames = ['::iwidgets::dialog'.freeze].freeze + WidgetClassName = 'Dialog'.freeze + WidgetClassNames[WidgetClassName] ||= self +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb new file mode 100644 index 0000000..e880594 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb @@ -0,0 +1,121 @@ +# +# tkextlib/iwidgets/dialogshell.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Dialogshell < Tk::Iwidgets::Shell + end + end +end + +class Tk::Iwidgets::Dialogshell + TkCommandNames = ['::iwidgets::dialogshell'.freeze].freeze + WidgetClassName = 'Dialogshell'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'buttoncget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'buttonconfigure', id] + end + private :__item_config_cmd + + def __item_boolval_optkeys(id) + super(id) << 'defaultring' + end + private :__item_boolval_optkeys + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias buttoncget_tkstring itemcget_tkstring + alias buttoncget itemcget + alias buttoncget_strict itemcget_strict + alias buttonconfigure itemconfigure + alias buttonconfiginfo itemconfiginfo + alias current_buttonconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def add(tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'add', tagid(tag), *hash_kv(keys)) + tag + end + + def default(idx) + tk_call(@path, 'default', index(idx)) + self + end + + def delete(idx) + tk_call(@path, 'delete', index(idx)) + self + end + + def hide(idx) + tk_call(@path, 'hide', index(idx)) + self + end + + def index(idx) + number(tk_call(@path, 'index', tagid(idx))) + end + + def insert(idx, tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)) + tag + end + + def invoke(idx=nil) + if idx + tk_call(@path, 'invoke', index(idx)) + else + tk_call(@path, 'invoke') + end + self + end + + def show(idx) + tk_call(@path, 'show', index(idx)) + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb new file mode 100644 index 0000000..07ab025 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb @@ -0,0 +1,50 @@ +# +# tkextlib/iwidgets/disjointlistbox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Disjointlistbox < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Disjointlistbox + TkCommandNames = ['::iwidgets::disjointlistbox'.freeze].freeze + WidgetClassName = 'Disjointlistbox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'lhslabeltext' << 'rhslabeltext' << 'lhsbuttonlabel' << 'rhsbuttonlabel' + end + private :__strval_optkeys + + def set_lhs(*items) + tk_call(@path, 'setlhs', items) + self + end + def set_rhs(*items) + tk_call(@path, 'setrhs', items) + self + end + + def get_lhs + simplelist(tk_call(@path, 'getlhs')) + end + def get_rhs + simplelist(tk_call(@path, 'getrhs')) + end + + def insert_lhs(*items) + tk_call(@path, 'insertlhs', items) + self + end + def insert_rhs(*items) + tk_call(@path, 'insertrhs', items) + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb new file mode 100644 index 0000000..3e7149a --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb @@ -0,0 +1,185 @@ +# +# tkextlib/iwidgets/entryfield.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Entryfield < Tk::Iwidgets::Labeledwidget + end + end +end + +class Tk::Iwidgets::Entryfield + TkCommandNames = ['::iwidgets::entryfield'.freeze].freeze + WidgetClassName = 'Entryfield'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __font_optkeys + super() << 'textfont' + end + private :__font_optkeys + + #################################### + + include Tk::ValidateConfigure + + class EntryfieldValidate < TkValidateCommand + #class CalCmdArgs < TkUtil::CallbackSubst + class ValidateArgs < TkUtil::CallbackSubst + KEY_TBL = [ + [ ?c, ?s, :char ], + [ ?P, ?s, :post ], + [ ?S, ?s, :current ], + [ ?W, ?w, :widget ], + nil + ] + PROC_TBL = [ + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + nil + ] + +=begin + # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) + KEY_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String) + end + inf + } + + PROC_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + end + inf + } +=end + + _setup_subst_table(KEY_TBL, PROC_TBL); + end + + def self._config_keys + ['validate', 'invalid'] + end + end + + def __validation_class_list + super() << EntryfieldValidate + end + + Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate) +=begin + def validate(cmd = Proc.new, args = nil) + if cmd.kind_of?(ValidateCmd) + configure('validate', cmd) + elsif args + configure('validate', [cmd, args]) + else + configure('validate', cmd) + end + end + + def invalid(cmd = Proc.new, args = nil) + if cmd.kind_of?(ValidateCmd) + configure('invalid', cmd) + elsif args + configure('invalid', [cmd, args]) + else + configure('invalid', cmd) + end + end +=end + + #################################### + + def clear + tk_call(@path, 'clear') + self + end + + def delete(first, last=None) + tk_send_without_enc('delete', first, last) + self + end + + def value + _fromUTF8(tk_send_without_enc('get')) + end + def value= (val) + tk_send_without_enc('delete', 0, 'end') + tk_send_without_enc('insert', 0, _get_eval_enc_str(val)) + val + end + alias get value + alias set value= + + def cursor=(index) + tk_send_without_enc('icursor', index) + #self + index + end + alias icursor cursor= + + def index(index) + number(tk_send_without_enc('index', index)) + end + + def insert(pos,text) + tk_send_without_enc('insert', pos, _get_eval_enc_str(text)) + self + end + + def mark(pos) + tk_send_without_enc('scan', 'mark', pos) + self + end + def dragto(pos) + tk_send_without_enc('scan', 'dragto', pos) + self + end + def selection_adjust(index) + tk_send_without_enc('selection', 'adjust', index) + self + end + def selection_clear + tk_send_without_enc('selection', 'clear') + self + end + def selection_from(index) + tk_send_without_enc('selection', 'from', index) + self + end + def selection_present() + bool(tk_send_without_enc('selection', 'present')) + end + def selection_range(s, e) + tk_send_without_enc('selection', 'range', s, e) + self + end + def selection_to(index) + tk_send_without_enc('selection', 'to', index) + self + end + + # based on tk/scrollable.rb + def xview(*index) + if index.size == 0 + list(tk_send_without_enc('xview')) + else + tk_send_without_enc('xview', *index) + self + end + end + def xview_moveto(*index) + xview('moveto', *index) + end + def xview_scroll(*index) + xview('scroll', *index) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb new file mode 100644 index 0000000..e744fba --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb @@ -0,0 +1,40 @@ +# +# tkextlib/iwidgets/extbutton.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Extbutton < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Extbutton + TkCommandNames = ['::iwidgets::extbutton'.freeze].freeze + WidgetClassName = 'Extbutton'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'bitmapforeground' << 'ringbackground' + end + private :__strval_optkeys + + def __boolval_optkeys + super() << 'defaultring' + end + private :__boolval_optkeys + + def invoke + tk_call(@path, 'invoke') + self + end + + def flash + tk_call(@path, 'flash') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb new file mode 100644 index 0000000..2ff15bb --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb @@ -0,0 +1,46 @@ +# +# tkextlib/iwidgets/extfileselectionbox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Extfileselectionbox < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Extfileselectionbox + TkCommandNames = ['::iwidgets::extfileselectionbox'.freeze].freeze + WidgetClassName = 'Extfileselectionbox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() + [ + 'dirslabel', 'fileslabel', 'filterlabel', 'mask', 'nomatchstring', + 'selectionlabel' + ] + end + private :__strval_optkeys + + def __boolval_optkeys + super() + ['dirson', 'fileson', 'filteron', 'selectionon'] + end + private :__boolval_optkeys + + def child_site + window(tk_call(@path, 'childsite')) + end + + def filter + tk_call(@path, 'filter') + self + end + + def get + tk_call(@path, 'get') + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb new file mode 100644 index 0000000..509fdcf --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb @@ -0,0 +1,33 @@ +# +# tkextlib/iwidgets/extfileselectiondialog.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Extfileselectiondialog < Tk::Iwidgets::Dialog + end + end +end + +class Tk::Iwidgets::Extfileselectiondialog + TkCommandNames = ['::iwidgets::extfileselectiondialog'.freeze].freeze + WidgetClassName = 'Extfileselectiondialog'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def child_site + window(tk_call(@path, 'childsite')) + end + + def filter + tk_call(@path, 'filter') + self + end + + def get + tk_call(@path, 'get') + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb new file mode 100644 index 0000000..29d04c8 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb @@ -0,0 +1,35 @@ +# +# tkextlib/iwidgets/feedback.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Feedback < Tk::Iwidgets::Labeledwidget + end + end +end + +class Tk::Iwidgets::Feedback + TkCommandNames = ['::iwidgets::feedback'.freeze].freeze + WidgetClassName = 'Feedback'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'barcolor' + end + private :__strval_optkeys + + def reset + tk_call(@path, 'reset') + self + end + + def step(inc=1) + tk_call(@path, 'step', inc) + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb new file mode 100644 index 0000000..a425b53 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb @@ -0,0 +1,46 @@ +# +# tkextlib/iwidgets/fileselectionbox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Fileselectionbox < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Fileselectionbox + TkCommandNames = ['::iwidgets::fileselectionbox'.freeze].freeze + WidgetClassName = 'Fileselectionbox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() + [ + 'directory', 'dirslabel', 'fileslabel', 'filterlabel', 'mask', + 'nomatchstring', 'selectionlabel' + ] + end + private :__strval_optkeys + + def __boolval_optkeys + super() + ['dirson', 'fileson', 'filteron', 'selectionon'] + end + private :__boolval_optkeys + + def child_site + window(tk_call(@path, 'childsite')) + end + + def filter + tk_call(@path, 'filter') + self + end + + def get + tk_call(@path, 'get') + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb new file mode 100644 index 0000000..ebcdaf8 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb @@ -0,0 +1,33 @@ +# +# tkextlib/iwidgets/fileselectiondialog.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Fileselectiondialog < Tk::Iwidgets::Dialog + end + end +end + +class Tk::Iwidgets::Fileselectiondialog + TkCommandNames = ['::iwidgets::fileselectiondialog'.freeze].freeze + WidgetClassName = 'Fileselectiondialog'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def child_site + window(tk_call(@path, 'childsite')) + end + + def filter + tk_call(@path, 'filter') + self + end + + def get + tk_call(@path, 'get') + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb new file mode 100644 index 0000000..3d522e0 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb @@ -0,0 +1,42 @@ +# +# tkextlib/iwidgets/finddialog.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Finddialog < Tk::Iwidgets::Dialogshell + end + end +end + +class Tk::Iwidgets::Finddialog + TkCommandNames = ['::iwidgets::finddialog'.freeze].freeze + WidgetClassName = 'Finddialog'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() + [ + 'patternbackground', 'patternforeground', + 'searchbackground', 'searchforeground' + ] + end + private :__strval_optkeys + + def __val2ruby_optkeys # { key=>proc, ... } + super().update('textwidget'=>proc{|v| window(v)}) + end + private :__val2ruby_optkeys + + def clear + tk_call(@path, 'clear') + self + end + + def find + tk_call(@path, 'find') + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb new file mode 100644 index 0000000..cb9301d --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb @@ -0,0 +1,365 @@ +# +# tkextlib/iwidgets/hierarchy.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tk/text' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Hierarchy < Tk::Iwidgets::Scrolledwidget + end + end +end + +class Tk::Iwidgets::Hierarchy + ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze + include TkTextTagConfig + + TkCommandNames = ['::iwidgets::hierarchy'.freeze].freeze + WidgetClassName = 'Hierarchy'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include Tk::ValidateConfigure + + class QueryCommand < TkValidateCommand + class ValidateArgs < TkUtil::CallbackSubst + KEY_TBL = [ [?n, ?s, :node], nil ] + PROC_TBL = [ [?s, TkComm.method(:string) ], nil ] + +=begin + # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) + KEY_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String) + end + inf + } + + PROC_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + end + inf + } +=end + + _setup_subst_table(KEY_TBL, PROC_TBL); + + def self.ret_val(val) + val + end + end + + def self._config_keys + # array of config-option key (string or symbol) + ['querycommand'] + end + end + + class IndicatorCommand < TkValidateCommand + class ValidateArgs < TkUtil::CallbackSubst + KEY_TBL = [ + [ ?n, ?s, :node ], + [ ?s, ?b, :status ], + nil + ] + + PROC_TBL = [ + [ ?s, TkComm.method(:string) ], + [ ?b, TkComm.method(:bool) ], + nil + ] + +=begin + # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) + KEY_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String) + end + inf + } + + PROC_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + end + inf + } +=end + + _setup_subst_table(KEY_TBL, PROC_TBL); + + def self.ret_val(val) + val + end + end + + def self._config_keys + # array of config-option key (string or symbol) + ['iconcommand', 'icondblcommand', 'imagedblcommand'] + end + end + + class IconCommand < TkValidateCommand + class ValidateArgs < TkUtil::CallbackSubst + KEY_TBL = [ + [ ?n, ?s, :node ], + [ ?i, ?s, :icon ], + nil + ] + PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ] + +=begin + # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) + KEY_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String) + end + inf + } + + PROC_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + end + inf + } +=end + + _setup_subst_table(KEY_TBL, PROC_TBL); + + def self.ret_val(val) + val + end + end + + def self._config_keys + # array of config-option key (string or symbol) + ['dblclickcommand', 'imagecommand', 'selectcommand'] + end + end + + def __validation_class_list + super() << QueryCommand << IndicatorCommand << IconCommand + end + + Tk::ValidateConfigure.__def_validcmd(binding, QueryCommand) + Tk::ValidateConfigure.__def_validcmd(binding, IndicatorCommand) + Tk::ValidateConfigure.__def_validcmd(binding, IconCommand) + + #################################### + + def __boolval_optkeys + super() << 'alwaysquery' << 'expanded' << 'filter' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'markbackground' << 'markforeground' << 'textbackground' + end + private :__strval_optkeys + + def __font_optkeys + super() << 'textfont' + end + private :__font_optkeys + + def clear + tk_call(@path, 'clear') + self + end + + def collapse(node) + tk_call(@path, 'collapse') + self + end + + def current + tk_call(@path, 'current') + end + + def draw(mode=None) + case mode + when None + # do nothing + when 'now', :now + mode = '-now' + when 'eventually', :eventually + mode = '-eventually' + when String, Symbol + mode = mode.to_s + mode = '-' << mode if mode[0] != ?- + end + tk_call(@path, 'draw', mode) + end + + def expand(node) + tk_call(@path, 'expand', node) + self + end + + def expanded?(node) + bool(tk_call(@path, 'expanded', node)) + end + + def exp_state + list(tk_call(@path, 'expState')) + end + alias expand_state exp_state + alias expanded_list exp_state + + def mark_clear + tk_call(@path, 'mark', 'clear') + self + end + def mark_add(*nodes) + tk_call(@path, 'mark', 'add', *nodes) + self + end + def mark_remove(*nodes) + tk_call(@path, 'mark', 'remove', *nodes) + self + end + def mark_get + list(tk_call(@path, 'mark', 'get')) + end + + def refresh(node) + tk_call(@path, 'refresh', node) + self + end + + def prune(node) + tk_call(@path, 'prune', node) + self + end + + def selection_clear + tk_call(@path, 'selection', 'clear') + self + end + def selection_add(*nodes) + tk_call(@path, 'selection', 'add', *nodes) + self + end + def selection_remove(*nodes) + tk_call(@path, 'selection', 'remove', *nodes) + self + end + def selection_get + list(tk_call(@path, 'selection', 'get')) + end + + def toggle(node) + tk_call(@path, 'toggle', node) + self + end + + # based on Tk::Text widget + + def bbox(index) + list(tk_send_without_enc('bbox', _get_eval_enc_str(index))) + end + + def compare(idx1, op, idx2) + bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1), + op, _get_eval_enc_str(idx2))) + end + + def debug + bool(tk_send_without_enc('debug')) + end + def debug=(boolean) + tk_send_without_enc('debug', boolean) + #self + boolean + end + + def delete(first, last=None) + tk_send_without_enc('delete', first, last) + self + end + + def dlineinfo(index) + list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index))) + end + + def get(*index) + _fromUTF8(tk_send_without_enc('get', *index)) + end + + def index(index) + tk_send_without_enc('index', _get_eval_enc_str(index)) + end + + def insert(index, chars, *tags) + if tags[0].kind_of? Array + # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ... + args = [chars] + while tags.size > 0 + args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist + args << tags.shift if tags.size > 0 # chars + end + super(index, *args) + else + # single chars-taglist argument :: str, tag, tag, ... + if tags.size == 0 + super(index, chars) + else + super(index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ')) + end + end + end + + def scan_mark(x, y) + tk_send_without_enc('scan', 'mark', x, y) + self + end + def scan_dragto(x, y) + tk_send_without_enc('scan', 'dragto', x, y) + self + end + def see(index) + tk_send_without_enc('see', index) + self + end + + # based on tk/scrollable.rb + def xview(*index) + if index.size == 0 + list(tk_send_without_enc('xview')) + else + tk_send_without_enc('xview', *index) + self + end + end + def xview_moveto(*index) + xview('moveto', *index) + end + def xview_scroll(*index) + xview('scroll', *index) + end + + def yview(*index) + if index.size == 0 + list(tk_send_without_enc('yview')) + else + tk_send_without_enc('yview', *index) + self + end + end + def yview_moveto(*index) + yview('moveto', *index) + end + def yview_scroll(*index) + yview('scroll', *index) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb new file mode 100644 index 0000000..d4ea1aa --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb @@ -0,0 +1,50 @@ +# +# tkextlib/iwidgets/hyperhelp.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Hyperhelp < Tk::Iwidgets::Shell + end + end +end + +class Tk::Iwidgets::Hyperhelp + TkCommandNames = ['::iwidgets::hyperhelp'.freeze].freeze + WidgetClassName = 'Hyperhelp'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'helpdir' + end + private :__strval_optkeys + + def __listval_optkeys + super() << 'topics' + end + private :__listval_optkeys + + def show_topic(topic) + tk_call(@path, 'showtopic', topic) + self + end + + def follow_link(href) + tk_call(@path, 'followlink', href) + self + end + + def forward + tk_call(@path, 'forward') + self + end + + def back + tk_call(@path, 'back') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb new file mode 100644 index 0000000..6595398 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb @@ -0,0 +1,39 @@ +# +# tkextlib/iwidgets/labeledframe.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Labeledframe < Tk::Itk::Archetype + end + end +end + +class Tk::Iwidgets::Labeledframe + TkCommandNames = ['::iwidgets::labeledframe'.freeze].freeze + WidgetClassName = 'Labeledframe'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'labeltext' + end + private :__strval_optkeys + + def __tkvariable_optkeys + super() << 'labelvariable' + end + private :__tkvariable_optkeys + + def __font_optkeys + super() << 'labelfont' + end + private :__font_optkeys + + def child_site + window(tk_call(@path, 'childsite')) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb new file mode 100644 index 0000000..d36d428 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb @@ -0,0 +1,45 @@ +# +# tkextlib/iwidgets/labeledwidget.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Labeledwidget < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Labeledwidget + extend TkCore + + TkCommandNames = ['::iwidgets::labeledwidget'.freeze].freeze + WidgetClassName = 'Labeledwidget'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'labeltext' + end + private :__strval_optkeys + + def __tkvariable_optkeys + super() << 'labelvariable' + end + private :__tkvariable_optkeys + + def __font_optkeys + super() << 'labelfont' + end + private :__font_optkeys + + def self.alignlabels(*wins) + tk_call('::iwidgets::Labeledwidget::alignlabels', *wins) + end + + def child_site + window(tk_call(@path, 'childsite')) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb new file mode 100644 index 0000000..ebf4802 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb @@ -0,0 +1,67 @@ +# +# tkextlib/iwidgets/mainwindow.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Mainwindow < Tk::Iwidgets::Shell + end + end +end + +class Tk::Iwidgets::Mainwindow + TkCommandNames = ['::iwidgets::mainwindow'.freeze].freeze + WidgetClassName = 'Mainwindow'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'helpline' << 'statusline' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'menubarbackground' << 'menubarforeground' << 'toolbarforeground' + end + private :__strval_optkeys + + def __font_optkeys + super() << 'menubarfont' << 'toolbarfont' + end + private :__font_optkeys + + def child_site + window(tk_call(@path, 'childsite')) + end + + def menubar(*args) + unless args.empty? + tk_call(@path, 'menubar', *args) + end + window(tk_call(@path, 'menubar')) + end + + def mousebar(*args) + unless args.empty? + tk_call(@path, 'mousebar', *args) + end + window(tk_call(@path, 'mousebar')) + end + + def msgd(*args) + unless args.empty? + tk_call(@path, 'msgd', *args) + end + window(tk_call(@path, 'msgd')) + end + + def toolbar(*args) + unless args.empty? + tk_call(@path, 'toolbar', *args) + end + window(tk_call(@path, 'toolbar')) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb new file mode 100644 index 0000000..f9a17d0 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb @@ -0,0 +1,212 @@ +# +# tkextlib/iwidgets/menubar.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Menubar < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Menubar + TkCommandNames = ['::iwidgets::menubar'.freeze].freeze + WidgetClassName = 'Menubar'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'menubuttons' + end + private :__strval_optkeys + + def __tkvariable_optkeys + super() << 'helpvariable' + end + private :__tkvariable_optkeys + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'menucget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'menuconfigure', id] + end + private :__item_config_cmd + + def __item_strval_optkeys(id) + super(id) << 'selectcolor' + end + private :__item_strval_optkeys + + def __item_tkvariable_optkeys(id) + super(id) << 'helpstr' + end + private :__item_tkvariable_optkeys + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias menucget_tkstring itemcget_tkstring + alias menucget itemcget + alias menucget_strict itemcget_strict + alias menuconfigure itemconfigure + alias menuconfiginfo itemconfiginfo + alias current_menuconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def __methodcall_optkeys + {'menubuttons'=>'menubuttons'} + end + + def menubuttons(val = nil) + unless val + return tk_call(@path, 'cget', '-menubuttons') + end + + tk_call(@path, 'configure', '-menubuttons', _parse_menu_spec(val)) + self + end + + def _parse_menu_spec(menu_spec) + ret = '' + menu_spec.each{|spec| + next unless spec + + if spec.kind_of?(Hash) + args = [spec] + type = 'options' + else + type, *args = spec + end + + type = type.to_s + case type + when 'options' + keys = args[0] + ary = [type] + ary.concat(hash_kv(keys)) + ret << array2tk_list(ary) << "\n" + + when 'menubutton', 'cascade' + name, keys = args + if keys + ary = [type, name] + keys = _symbolkey2str(keys) + keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu') + ary.concat(hash_kv(keys)) + ret << array2tk_list(ary) << "\n" + else + ret << array2tk_list([type, name]) << "\n" + end + + else + name, keys = args + if keys + ary = [type, name] + ary.concat(hash_kv(keys)) + ret << array2tk_list(ary) << "\n" + else + ret << array2tk_list([type, name]) << "\n" + end + end + } + ret + end + + #################################### + + def add(type, tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + keys = _symbolkey2str(keys) + keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu') + tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys)) + tag + end + + def delete(path1, path2=nil) + if path2 + else + tk_call(@path, 'delete', index(idx)) + end + self + end + + def index(idx) + number(tk_call(@path, 'index', tagid(idx))) + end + + def insert(idx, type, tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + keys = _symbolkey2str(keys) + keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu') + tk_call(@path, 'insert', index(idx), type, tagid(tag), *hash_kv(keys)) + tag + end + + def invoke(idx) + tk_call(@path, 'invoke', index(idx)) + self + end + + def menupath(pat) + if (win = tk_call(@path, 'path', pat)) == '-1' + return nil + end + window(win) + end + def menupath_glob(pat) + if (win = tk_call(@path, 'path', '-glob', pat)) == '-1' + return nil + end + window(win) + end + def menupath_tclregexp(pat) + if (win = tk_call(@path, 'path', '-regexp', pat)) == '-1' + return nil + end + window(win) + end + + def type(path) + tk_call(@path, 'type', path) + end + + def yposition(path) + number(tk_call(@path, 'yposition', path)) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb new file mode 100644 index 0000000..6adb53d --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb @@ -0,0 +1,93 @@ +# +# tkextlib/iwidgets/messagebox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Messagebox < Tk::Iwidgets::Scrolledwidget + end + end +end + +class Tk::Iwidgets::Messagebox + TkCommandNames = ['::iwidgets::messagebox'.freeze].freeze + WidgetClassName = 'Messagebox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'type', 'cget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'type', 'configure', id] + end + private :__item_config_cmd + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + def __item_boolval_optkeys(id) + super(id) << 'bell' << 'show' + end + private :__item_boolval_optkeys + + alias typecget_tkstring itemcget_tkstring + alias typecget itemcget + alias typecget_strict itemcget_strict + alias typeconfigure itemconfigure + alias typeconfiginfo itemconfiginfo + alias current_typeconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def __strval_optkeys + super() << 'filename' << 'savedir' + end + private :__strval_optkeys + + def type_add(tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + unless tag + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'type', 'add', tagid(tag), *hash_kv(keys)) + tag + end + + def clear + tk_call(@path, 'clear') + self + end + + def export(file) + tk_call(@path, 'export', file) + self + end + + def issue(string, type=None, *args) + tk_call(@path, 'issue', string, tagid(type), *args) + self + end + +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb new file mode 100644 index 0000000..9aa5900 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb @@ -0,0 +1,20 @@ +# +# tkextlib/iwidgets/messagedialog.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Messagedialog < Tk::Iwidgets::Dialog + end + end +end + +class Tk::Iwidgets::Messagedialog + TkCommandNames = ['::iwidgets::messagedialog'.freeze].freeze + WidgetClassName = 'Messagedialog'.freeze + WidgetClassNames[WidgetClassName] ||= self +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb new file mode 100644 index 0000000..7ed4126 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb @@ -0,0 +1,175 @@ +# +# tkextlib/iwidgets/notebook.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Notebook < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Notebook + TkCommandNames = ['::iwidgets::notebook'.freeze].freeze + WidgetClassName = 'Notebook'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'pagecget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'pageconfigure', id] + end + private :__item_config_cmd + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias pagecget_tkstring itemcget_tkstring + alias pagecget itemcget + alias pagecget_strict itemcget_strict + alias pageconfigure itemconfigure + alias pageconfiginfo itemconfiginfo + alias current_pageconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def __boolval_optkeys + super() << 'auto' + end + private :__boolval_optkeys + + def add(keys={}) + window(tk_call(@path, 'add', *hash_kv(keys))) + end + + def child_site_list + list(tk_call(@path, 'childsite')) + end + + def child_site(idx) + if (new_idx = self.index(idx)) < 0 + new_idx = tagid(idx) + end + window(tk_call(@path, 'childsite', new_idx)) + end + + def delete(idx1, idx2=nil) + if (new_idx1 = self.index(idx1)) < 0 + new_idx1 = tagid(idx1) + end + if idx2 + if (new_idx2 = self.index(idx2)) < 0 + new_idx2 = tagid(idx2) + end + tk_call(@path, 'delete', new_idx1, new_idx2) + else + tk_call(@path, 'delete', new_idx1) + end + self + end + + def index(idx) + number(tk_call(@path, 'index', tagid(idx))) + end + + def insert(idx, keys={}) + if (new_idx = self.index(idx)) < 0 + new_idx = tagid(idx) + end + window(tk_call(@path, 'insert', new_idx, *hash_kv(keys))) + end + + def next + tk_call(@path, 'next') + self + end + + def prev + tk_call(@path, 'prev') + self + end + + def select(idx) + if (new_idx = self.index(idx)) < 0 + new_idx = tagid(idx) + end + tk_call(@path, 'select', new_idx) + self + end + + def scrollcommand(cmd=Proc.new) + configure_cmd 'scrollcommand', cmd + self + end + alias xscrollcommand scrollcommand + alias yscrollcommand scrollcommand + + def xscrollbar(bar=nil) + if bar + @scrollbar = bar + @scrollbar.orient 'horizontal' + self.scrollcommand {|*arg| @scrollbar.set(*arg)} + @scrollbar.command {|*arg| self.xview(*arg)} + Tk.update # avoid scrollbar trouble + end + @scrollbar + end + def yscrollbar(bar=nil) + if bar + @scrollbar = bar + @scrollbar.orient 'vertical' + self.scrollcommand {|*arg| @scrollbar.set(*arg)} + @scrollbar.command {|*arg| self.yview(*arg)} + Tk.update # avoid scrollbar trouble + end + @scrollbar + end + alias scrollbar yscrollbar + + def view(*idxs) + if idxs.size == 0 + idx = num_or_str(tk_send_without_enc('view')) + if idx.kind_of?(Fixnum) && idx < 0 + nil + else + idx + end + else + tk_send_without_enc('view', *idxs) + self + end + end + alias xview view + alias yview view + + def view_moveto(*idxs) + view('moveto', *idxs) + end + alias xview_moveto view_moveto + alias yview_moveto view_moveto + def view_scroll(index, what='pages') + view('scroll', index, what) + end + alias xview_scroll view_scroll + alias yview_scroll view_scroll +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb new file mode 100644 index 0000000..57a3cc7 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb @@ -0,0 +1,92 @@ +# +# tkextlib/iwidgets/optionmenu.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Optionmenu < Tk::Iwidgets::Labeledwidget + end + end +end + +class Tk::Iwidgets::Optionmenu + TkCommandNames = ['::iwidgets::optionmenu'.freeze].freeze + WidgetClassName = 'Optionmenu'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'cyclicon' + end + private :__boolval_optkeys + + def delete(first, last=nil) + if last + tk_call(@path, 'delete', first, last) + else + tk_call(@path, 'delete', first) + end + self + end + + def disable(idx) + tk_call(@path, 'disable', idx) + self + end + + def enable(idx) + tk_call(@path, 'enable', idx) + self + end + + def get(first=nil, last=nil) + if last + simplelist(tk_call(@path, 'get', first, last)) + elsif first + tk_call(@path, 'get', first) + else + tk_call(@path, 'get') + end + end + def get_range(first, last) + get(first, last) + end + def get_selected + get() + end + + def index(idx) + number(tk_call(@path, 'index', idx)) + end + + def insert(idx, *args) + tk_call(@path, 'insert', idx, *args) + self + end + + def select(idx) + tk_call(@path, 'select', idx) + self + end + + def sort(*params, &b) + # see 'lsort' man page about params + if b + tk_call(@path, 'sort', '-command', proc(&b), *params) + else + tk_call(@path, 'sort', *params) + end + self + end + def sort_ascending + tk_call(@path, 'sort', 'ascending') + self + end + def sort_descending + tk_call(@path, 'sort', 'descending') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb new file mode 100644 index 0000000..65463cc --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb @@ -0,0 +1,134 @@ +# +# tkextlib/iwidgets/panedwindow.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Panedwindow < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Panedwindow + TkCommandNames = ['::iwidgets::panedwindow'.freeze].freeze + WidgetClassName = 'Panedwindow'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'panecget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'paneconfigure', id] + end + private :__item_config_cmd + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias panecget_tkstring itemcget_tkstring + alias panecget itemcget + alias panecget_strict itemcget_strict + alias paneconfigure itemconfigure + alias paneconfiginfo itemconfiginfo + alias current_paneconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def __boolval_optkeys + super() << 'showhandle' + end + private :__boolval_optkeys + + def add(tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + window(tk_call(@path, 'add', tagid(tag), *hash_kv(keys))) + tag + end + + def child_site_list + list(tk_call(@path, 'childsite')) + end + + def child_site(idx) + window(tk_call(@path, 'childsite', index(idx))) + end + + def delete(idx) + tk_call(@path, 'delete', index(idx)) + self + end + + def fraction(*percentages) + tk_call(@path, 'fraction', *percentages) + self + end + + def hide(idx) + tk_call(@path, 'hide', index(idx)) + self + end + + def index(idx) + number(tk_call(@path, 'index', tagid(idx))) + end + + def insert(idx, tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + window(tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))) + tag + end + + def invoke(idx=nil) + if idx + tk_call(@path, 'invoke', index(idx)) + else + tk_call(@path, 'invoke') + end + self + end + + def reset + tk_call(@path, 'reset') + self + end + + def show(idx) + tk_call(@path, 'show', index(idx)) + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb new file mode 100644 index 0000000..7c7ff7a --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb @@ -0,0 +1,131 @@ +# +# tkextlib/iwidgets/promptdialog.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Promptdialog < Tk::Iwidgets::Dialog + end + end +end + +class Tk::Iwidgets::Promptdialog + TkCommandNames = ['::iwidgets::promptdialog'.freeze].freeze + WidgetClassName = 'Promptdialog'.freeze + WidgetClassNames[WidgetClassName] ||= self + + # index method is not available, because it shows index of the entry field + def default(name) + tk_call(@path, 'default', tagid(name)) + self + end + + def hide(name) + tk_call(@path, 'hide', tagid(name)) + self + end + + def invoke(name=nil) + if name + tk_call(@path, 'invoke', tagid(name)) + else + tk_call(@path, 'invoke') + end + self + end + + def show(name) + tk_call(@path, 'show', tagid(name)) + self + end + + + # based on Tk::Iwidgets::Entryfield + def clear + tk_call(@path, 'clear') + self + end + + def delete(first, last=None) + tk_send_without_enc('delete', first, last) + self + end + + def value + _fromUTF8(tk_send_without_enc('get')) + end + def value= (val) + tk_send_without_enc('delete', 0, 'end') + tk_send_without_enc('insert', 0, _get_eval_enc_str(val)) + val + end + alias get value + alias set value= + + def cursor=(index) + tk_send_without_enc('icursor', index) + #self + index + end + alias icursor cursor= + + def index(idx) + number(tk_send_without_enc('index', idx)) + end + + def insert(pos,text) + tk_send_without_enc('insert', pos, _get_eval_enc_str(text)) + self + end + + def mark(pos) + tk_send_without_enc('scan', 'mark', pos) + self + end + def dragto(pos) + tk_send_without_enc('scan', 'dragto', pos) + self + end + def selection_adjust(index) + tk_send_without_enc('selection', 'adjust', index) + self + end + def selection_clear + tk_send_without_enc('selection', 'clear') + self + end + def selection_from(index) + tk_send_without_enc('selection', 'from', index) + self + end + def selection_present() + bool(tk_send_without_enc('selection', 'present')) + end + def selection_range(s, e) + tk_send_without_enc('selection', 'range', s, e) + self + end + def selection_to(index) + tk_send_without_enc('selection', 'to', index) + self + end + + def xview(*index) + if index.size == 0 + list(tk_send_without_enc('xview')) + else + tk_send_without_enc('xview', *index) + self + end + end + def xview_moveto(*index) + xview('moveto', *index) + end + def xview_scroll(*index) + xview('scroll', *index) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb new file mode 100644 index 0000000..ae56788 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb @@ -0,0 +1,35 @@ +# +# tkextlib/iwidgets/pushbutton.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Pushbutton < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Pushbutton + TkCommandNames = ['::iwidgets::pushbutton'.freeze].freeze + WidgetClassName = 'Pushbutton'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'defaultring' + end + private :__boolval_optkeys + + def invoke + tk_call_without_enc(@path, 'invoke') + self + end + + def flash + tk_call_without_enc(@path, 'flash') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb new file mode 100644 index 0000000..2118177 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb @@ -0,0 +1,121 @@ +# +# tkextlib/iwidgets/radiobox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Radiobox < Tk::Iwidgets::Labeledframe + end + end +end + +class Tk::Iwidgets::Radiobox + TkCommandNames = ['::iwidgets::radiobox'.freeze].freeze + WidgetClassName = 'Radiobox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'buttoncget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'buttonconfigure', id] + end + private :__item_config_cmd + + def __item_boolval_optkeys(id) + super(id) << 'defaultring' + end + private :__item_boolval_optkeys + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias buttoncget_tkstring itemcget_tkstring + alias buttoncget itemcget + alias buttoncget_strict itemcget_strict + alias buttonconfigure itemconfigure + alias buttonconfiginfo itemconfiginfo + alias current_buttonconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def add(tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'add', tagid(tag), *hash_kv(keys)) + tag + end + + def delete(idx) + tk_call(@path, 'delete', index(idx)) + self + end + + def deselect(idx) + tk_call(@path, 'deselect', index(idx)) + self + end + + def flash(idx) + tk_call(@path, 'flash', index(idx)) + self + end + + def get_tag + ((tag = tk_call_without_enc(@path, 'get')).empty?)? nil: tag + end + alias get get_tag + + def get_obj + (tag = get_tag)? Tk::Itk::Component.id2obj(self, tag): nil + end + + def index(idx) + number(tk_call(@path, 'index', tagid(idx))) + end + + def insert(idx, tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)) + tag + end + + def select(idx) + tk_call(@path, 'select', index(idx)) + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb new file mode 100644 index 0000000..056cd85 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb @@ -0,0 +1,24 @@ +# +# tkextlib/iwidgets/buttonbox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Scopedobject < TkObject + end + end +end + +class Tk::Iwidgets::Scopedobject + TkCommandNames = ['::iwidgets::scopedobject'.freeze].freeze + WidgetClassName = 'Scopedobject'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def initialize(obj_name, keys={}) + @path = tk_call(self.class::TkCommandNames[0], obj_name, *hash_kv(keys)) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb new file mode 100644 index 0000000..4dea2f2 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb @@ -0,0 +1,353 @@ +# +# tkextlib/iwidgets/scrolledcanvas.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tk/canvas' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Scrolledcanvas < Tk::Iwidgets::Scrolledwidget + end + end +end + +class Tk::Iwidgets::Scrolledcanvas + TkCommandNames = ['::iwidgets::scrolledcanvas'.freeze].freeze + WidgetClassName = 'Scrolledcanvas'.freeze + WidgetClassNames[WidgetClassName] ||= self + + ################################ + + def __boolval_optkeys + super() << 'autoresize' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'textbackground' + end + private :__strval_optkeys + + def initialize(*args) + super(*args) + @canvas = component_widget('canvas') + end + + def method_missing(id, *args) + if @canvas.respond_to?(id) + @canvas.__send__(id, *args) + else + super(id, *args) + end + end + + ################################ + + def child_site + window(tk_call(@path, 'childsite')) + end + + def justify(dir) + tk_call(@path, 'justify', dir) + self + end + + ########################## + include TkCanvasItemConfig + + def tagid(tag) + if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag) + tag.id + elsif tag.kind_of?(Tk::Itk::Component) + tag.name + else + tag # maybe an Array of configure parameters + end + end + private :tagid + + # create a canvas item without creating a TkcItem object + def create(type, *args) + type.create(self, *args) + end + + ####################### + + def addtag(tag, mode, *args) + tk_send_without_enc('addtag', tagid(tag), mode, *args) + self + end + def addtag_above(tagOrId, target) + addtag(tagOrId, 'above', tagid(target)) + end + def addtag_all(tagOrId) + addtag(tagOrId, 'all') + end + def addtag_below(tagOrId, target) + addtag(tagOrId, 'below', tagid(target)) + end + def addtag_closest(tagOrId, x, y, halo=None, start=None) + addtag(tagOrId, 'closest', x, y, halo, start) + end + def addtag_enclosed(tagOrId, x1, y1, x2, y2) + addtag(tagOrId, 'enclosed', x1, y1, x2, y2) + end + def addtag_overlapping(tagOrId, x1, y1, x2, y2) + addtag(tagOrId, 'overlapping', x1, y1, x2, y2) + end + def addtag_withtag(tagOrId, tag) + addtag(tagOrId, 'withtag', tagid(tag)) + end + + def bbox(tagOrId, *tags) + list(tk_send_without_enc('bbox', tagid(tagOrId), + *tags.collect{|t| tagid(t)})) + end + + #def itembind(tag, context, cmd=Proc.new, *args) + # _bind([path, "bind", tagid(tag)], context, cmd, *args) + # self + #end + def itembind(tag, 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([path, "bind", tagid(tag)], context, cmd, *args) + self + end + + #def itembind_append(tag, context, cmd=Proc.new, *args) + # _bind_append([path, "bind", tagid(tag)], context, cmd, *args) + # self + #end + def itembind_append(tag, 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([path, "bind", tagid(tag)], context, cmd, *args) + self + end + + def itembind_remove(tag, context) + _bind_remove([path, "bind", tagid(tag)], context) + self + end + + def itembindinfo(tag, context=nil) + _bindinfo([path, "bind", tagid(tag)], context) + end + + def canvasx(screen_x, *args) + #tk_tcl2ruby(tk_send_without_enc('canvasx', screen_x, *args)) + number(tk_send_without_enc('canvasx', screen_x, *args)) + end + def canvasy(screen_y, *args) + #tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args)) + number(tk_send_without_enc('canvasy', screen_y, *args)) + end + + def coords(tag, *args) + if args == [] + tk_split_list(tk_send_without_enc('coords', tagid(tag))) + else + tk_send_without_enc('coords', tagid(tag), *(args.flatten)) + self + end + end + + def dchars(tag, first, last=None) + tk_send_without_enc('dchars', tagid(tag), + _get_eval_enc_str(first), _get_eval_enc_str(last)) + self + end + + def delete(*args) + tbl = nil + TkcItem::CItemID_TBL.mutex.synchronize{ + tbl = TkcItem::CItemID_TBL[self.path] + } + if tbl + find('withtag', *args).each{|item| + if item.kind_of?(TkcItem) + TkcItem::CItemID_TBL.mutex.synchronize{ + tbl.delete(item.id) + } + end + } + end + tk_send_without_enc('delete', *args.collect{|t| tagid(t)}) + self + end + alias remove delete + + def dtag(tag, tag_to_del=None) + tk_send_without_enc('dtag', tagid(tag), tag_to_del) + self + end + + def find(mode, *args) + list(tk_send_without_enc('find', mode, *args)).collect!{|id| + TkcItem.id2obj(self, id) + } + end + def find_above(target) + find('above', tagid(target)) + end + def find_all + find('all') + end + def find_below(target) + find('below', tagid(target)) + end + def find_closest(x, y, halo=None, start=None) + find('closest', x, y, halo, start) + end + def find_enclosed(x1, y1, x2, y2) + find('enclosed', x1, y1, x2, y2) + end + def find_overlapping(x1, y1, x2, y2) + find('overlapping', x1, y1, x2, y2) + end + def find_withtag(tag) + find('withtag', tag) + end + + def itemfocus(tagOrId=nil) + if tagOrId + tk_send_without_enc('focus', tagid(tagOrId)) + self + else + ret = tk_send_without_enc('focus') + if ret == "" + nil + else + TkcItem.id2obj(self, ret) + end + end + end + + def gettags(tagOrId) + list(tk_send_without_enc('gettags', tagid(tagOrId))).collect{|tag| + TkcTag.id2obj(self, tag) + } + end + + def icursor(tagOrId, index) + tk_send_without_enc('icursor', tagid(tagOrId), index) + self + end + + def index(tagOrId, idx) + number(tk_send_without_enc('index', tagid(tagOrId), idx)) + end + + def insert(tagOrId, index, string) + tk_send_without_enc('insert', tagid(tagOrId), index, + _get_eval_enc_str(string)) + self + end + + def lower(tag, below=nil) + if below + tk_send_without_enc('lower', tagid(tag), tagid(below)) + else + tk_send_without_enc('lower', tagid(tag)) + end + self + end + + def move(tag, x, y) + tk_send_without_enc('move', tagid(tag), x, y) + self + end + + def postscript(keys) + tk_send("postscript", *hash_kv(keys)) + end + + def raise(tag, above=nil) + if above + tk_send_without_enc('raise', tagid(tag), tagid(above)) + else + tk_send_without_enc('raise', tagid(tag)) + end + self + end + + def scale(tag, x, y, xs, ys) + tk_send_without_enc('scale', tagid(tag), x, y, xs, ys) + self + end + + def scan_mark(x, y) + tk_send_without_enc('scan', 'mark', x, y) + self + end + def scan_dragto(x, y) + tk_send_without_enc('scan', 'dragto', x, y) + self + end + + def select(mode, *args) + r = tk_send_without_enc('select', mode, *args) + (mode == 'item')? TkcItem.id2obj(self, r): self + end + def select_adjust(tagOrId, index) + select('adjust', tagid(tagOrId), index) + end + def select_clear + select('clear') + end + def select_from(tagOrId, index) + select('from', tagid(tagOrId), index) + end + def select_item + select('item') + end + def select_to(tagOrId, index) + select('to', tagid(tagOrId), index) + end + + def itemtype(tag) + TkcItem.type2class(tk_send('type', tagid(tag))) + end + + def xview(*index) + if index.size == 0 + list(tk_send_without_enc('xview')) + else + tk_send_without_enc('xview', *index) + self + end + end + def xview_moveto(*index) + xview('moveto', *index) + end + def xview_scroll(*index) + xview('scroll', *index) + end + + def yview(*index) + if index.size == 0 + list(tk_send_without_enc('yview')) + else + tk_send_without_enc('yview', *index) + self + end + end + def yview_moveto(*index) + yview('moveto', *index) + end + def yview_scroll(*index) + yview('scroll', *index) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb new file mode 100644 index 0000000..7b7b95d --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb @@ -0,0 +1,59 @@ +# +# tkextlib/iwidgets/scrolledframe.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Scrolledframe < Tk::Iwidgets::Scrolledwidget + end + end +end + +class Tk::Iwidgets::Scrolledframe + TkCommandNames = ['::iwidgets::scrolledframe'.freeze].freeze + WidgetClassName = 'Scrolledframe'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def child_site + window(tk_call(@path, 'childsite')) + end + + def justify(dir) + tk_call(@path, 'justify', dir) + self + end + + def xview(*index) + if index.size == 0 + list(tk_send_without_enc('xview')) + else + tk_send_without_enc('xview', *index) + self + end + end + def xview_moveto(*index) + xview('moveto', *index) + end + def xview_scroll(*index) + xview('scroll', *index) + end + + def yview(*index) + if index.size == 0 + list(tk_send_without_enc('yview')) + else + tk_send_without_enc('yview', *index) + self + end + end + def yview_moveto(*index) + yview('moveto', *index) + end + def yview_scroll(*index) + yview('scroll', *index) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb new file mode 100644 index 0000000..dc2966b --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb @@ -0,0 +1,58 @@ +# +# tkextlib/iwidgets/scrolledhtml.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Scrolledhtml < Tk::Iwidgets::Scrolledtext + end + end +end + +class Tk::Iwidgets::Scrolledhtml + TkCommandNames = ['::iwidgets::scrolledhtml'.freeze].freeze + WidgetClassName = 'Scrolledhtml'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'update' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'fontname' << 'link' << 'alink' << 'textbackground' + end + private :__strval_optkeys + + def __font_optkeys + super() << 'fixedfont' + end + private :__font_optkeys + + def import(href) + tk_call(@path, 'import', href) + self + end + + def import_link(href) + tk_call(@path, 'import', '-link', href) + self + end + + def pwd + tk_call(@path, 'pwd') + end + + def render(htmltext, workdir=None) + tk_call(@path, 'render', htmltext, workdir) + self + end + + def title + tk_call(@path, 'title') + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb new file mode 100644 index 0000000..20a4cd1 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb @@ -0,0 +1,207 @@ +# +# tkextlib/iwidgets/scrolledlistbox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tk/listbox' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Scrolledlistbox < Tk::Iwidgets::Scrolledwidget + end + end +end + +class Tk::Iwidgets::Scrolledlistbox + TkCommandNames = ['::iwidgets::scrolledlistbox'.freeze].freeze + WidgetClassName = 'Scrolledlistbox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'textbackground' + end + private :__strval_optkeys + + def __tkvariable_optkeys + super() << 'listvariable' + end + private :__tkvariable_optkeys + + def __font_optkeys + super() << 'textfont' + end + private :__font_optkeys + + ################################ + + def initialize(*args) + super(*args) + @listbox = component_widget('listbox') + end + + def method_missing(id, *args) + if @listbox.respond_to?(id) + @listbox.__send__(id, *args) + else + super(id, *args) + end + end + + ################################ + + def clear + tk_call(@path, 'clear') + self + end + + def get_curselection + tk_call(@path, 'getcurselection') + end + + def justify(dir) + tk_call(@path, 'justify', dir) + self + end + + def selected_item_count + number(tk_call(@path, 'selecteditemcount')) + end + + def sort(*params, &b) + # see 'lsort' man page about params + if b + tk_call(@path, 'sort', '-command', proc(&b), *params) + else + tk_call(@path, 'sort', *params) + end + self + end + def sort_ascending + tk_call(@path, 'sort', 'ascending') + self + end + def sort_descending + tk_call(@path, 'sort', 'descending') + self + end + + ##################################### + + def bbox(index) + list(tk_send_without_enc('bbox', index)) + end + def delete(first, last=None) + tk_send_without_enc('delete', first, last) + self + end + def get(*index) + _fromUTF8(tk_send_without_enc('get', *index)) + end + def insert(index, *args) + tk_send('insert', index, *args) + self + end + def scan_mark(x, y) + tk_send_without_enc('scan', 'mark', x, y) + self + end + def scan_dragto(x, y) + tk_send_without_enc('scan', 'dragto', x, y) + self + end + def see(index) + tk_send_without_enc('see', index) + self + end + + ##################################### + + include TkListItemConfig + + def tagid(tag) + if tag.kind_of?(Tk::Itk::Component) + tag.name + else + super(tag) + end + end + private :tagid + + ##################################### + + def activate(y) + tk_send_without_enc('activate', y) + self + end + def curselection + list(tk_send_without_enc('curselection')) + end + def get(first, last=nil) + if last + # tk_split_simplelist(_fromUTF8(tk_send_without_enc('get', first, last))) + tk_split_simplelist(tk_send_without_enc('get', first, last), + false, true) + else + _fromUTF8(tk_send_without_enc('get', first)) + end + end + def nearest(y) + tk_send_without_enc('nearest', y).to_i + end + def size + tk_send_without_enc('size').to_i + end + def selection_anchor(index) + tk_send_without_enc('selection', 'anchor', index) + self + end + def selection_clear(first, last=None) + tk_send_without_enc('selection', 'clear', first, last) + self + end + def selection_includes(index) + bool(tk_send_without_enc('selection', 'includes', index)) + end + def selection_set(first, last=None) + tk_send_without_enc('selection', 'set', first, last) + self + end + + def index(idx) + tk_send_without_enc('index', idx).to_i + end + + ##################################### + + def xview(*index) + if index.size == 0 + list(tk_send_without_enc('xview')) + else + tk_send_without_enc('xview', *index) + self + end + end + def xview_moveto(*index) + xview('moveto', *index) + end + def xview_scroll(*index) + xview('scroll', *index) + end + + def yview(*index) + if index.size == 0 + list(tk_send_without_enc('yview')) + else + tk_send_without_enc('yview', *index) + self + end + end + def yview_moveto(*index) + yview('moveto', *index) + end + def yview_scroll(*index) + yview('scroll', *index) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb new file mode 100644 index 0000000..69b7d31 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb @@ -0,0 +1,568 @@ +# +# tkextlib/iwidgets/scrolledtext.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tk/text' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Scrolledtext < Tk::Iwidgets::Scrolledwidget + end + end +end + +class Tk::Iwidgets::Scrolledtext + TkCommandNames = ['::iwidgets::scrolledtext'.freeze].freeze + WidgetClassName = 'Scrolledtext'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'textbackground' + end + private :__strval_optkeys + + def __font_optkeys + super() << 'textfont' + end + private :__font_optkeys + + ################################ + + def initialize(*args) + super(*args) + @text = component_widget('text') + end + + def method_missing(id, *args) + if @text.respond_to?(id) + @text.__send__(id, *args) + else + super(id, *args) + end + end + + ################################ + + def child_site + window(tk_call(@path, 'childsite')) + end + + def clear + tk_call(@path, 'clear') + self + end + + def import(file, idx=nil) + if idx + tk_call(@path, 'import', file, index(idx)) + else + tk_call(@path, 'import', file) + end + self + end + + def export(file) + tk_call(@path, 'export', file) + self + end + + ##################################### + + include TkTextTagConfig + + def tagid(tag) + if tag.kind_of?(Tk::Itk::Component) + tag.name + else + super(tag) + end + end + private :tagid + + def bbox(index) + list(tk_send('bbox', index)) + end + def compare(idx1, op, idx2) + bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1), + op, _get_eval_enc_str(idx2))) + end + + def debug + bool(tk_send_without_enc('debug')) + end + def debug=(boolean) + tk_send_without_enc('debug', boolean) + #self + boolean + end + + def delete(first, last=None) + tk_send_without_enc('delete', first, last) + self + end + + def dlineinfo(index) + list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index))) + end + + def get(*index) + _fromUTF8(tk_send_without_enc('get', *index)) + end + def get_displaychars(*index) + # Tk8.5 feature + get('-displaychars', *index) + end + + def image_cget_tkstring(index, slot) + _fromUTF8(tk_send_without_enc('image', 'cget', + _get_eval_enc_str(index), "-#{slot.to_s}")) + end + def image_cget_strict(index, slot) + case slot.to_s + when 'text', 'label', 'show', 'data', 'file' + _fromUTF8(tk_send_without_enc('image', 'cget', + _get_eval_enc_str(index), "-#{slot}")) + else + tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget', + _get_eval_enc_str(index), + "-#{slot}"))) + end + end + def image_cget(index, slot) + unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ + image_cget_strict(index, slot) + else + begin + image_cget_strict(index, slot) + rescue => e + begin + if current_image_configinfo.has_key?(slot.to_s) + # error on known option + fail e + else + # unknown option + nil + end + rescue + fail e # tag error + end + end + end + end + + def image_configure(index, slot, value=None) + if slot.kind_of? Hash + _fromUTF8(tk_send_without_enc('image', 'configure', + _get_eval_enc_str(index), + *hash_kv(slot, true))) + else + _fromUTF8(tk_send_without_enc('image', 'configure', + _get_eval_enc_str(index), + "-#{slot}", + _get_eval_enc_str(value))) + end + self + end + + def image_configinfo(index, slot = nil) + if TkComm::GET_CONFIGINFO_AS_ARRAY + if slot + case slot.to_s + when 'text', 'label', 'show', 'data', 'file' + #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true) + else + #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true) + end + conf[0] = conf[0][1..-1] + conf + else + #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist| + # conf = tk_split_simplelist(conflist) + tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).collect{|conflist| + conf = tk_split_simplelist(conflist, false, true) + conf[0] = conf[0][1..-1] + case conf[0] + when 'text', 'label', 'show', 'data', 'file' + else + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + if conf[4] + if conf[4].index('{') + conf[4] = tk_split_list(conf[4]) + else + conf[4] = tk_tcl2ruby(conf[4]) + end + end + end + conf[1] = conf[1][1..-1] if conf.size == 2 # alias info + conf + } + end + else # ! TkComm::GET_CONFIGINFO_AS_ARRAY + if slot + case slot.to_s + when 'text', 'label', 'show', 'data', 'file' + #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true) + else + #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"))) + conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true) + end + key = conf.shift[1..-1] + { key => conf } + else + ret = {} + #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist| + # conf = tk_split_simplelist(conflist) + tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).each{|conflist| + conf = tk_split_simplelist(conflist, false, true) + key = conf.shift[1..-1] + case key + when 'text', 'label', 'show', 'data', 'file' + else + if conf[2] + if conf[2].index('{') + conf[2] = tk_split_list(conf[2]) + else + conf[2] = tk_tcl2ruby(conf[2]) + end + end + if conf[3] + if conf[3].index('{') + conf[3] = tk_split_list(conf[3]) + else + conf[3] = tk_tcl2ruby(conf[3]) + end + end + end + if conf.size == 1 + ret[key] = conf[0][1..-1] # alias info + else + ret[key] = conf + end + } + ret + end + end + end + + def current_image_configinfo(index, slot = nil) + if TkComm::GET_CONFIGINFO_AS_ARRAY + if slot + conf = image_configinfo(index, slot) + {conf[0] => conf[4]} + else + ret = {} + image_configinfo(index).each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret + end + else # ! TkComm::GET_CONFIGINFO_AS_ARRAY + ret = {} + image_configinfo(index, slot).each{|k, conf| + ret[k] = conf[-1] if conf.kind_of?(Array) + } + ret + end + end + + def image_names + #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'names'))).collect{|elt| + tk_split_simplelist(tk_send_without_enc('image', 'names'), false, true).collect{|elt| + tagid2obj(elt) + } + end + + def index(idx) + tk_send_without_enc('index', _get_eval_enc_str(idx)) + end + + def insert(index, *args) + tk_send('insert', index, *args) + self + end + + def mark_names + #tk_split_simplelist(_fromUTF8(tk_send_without_enc('mark', 'names'))).collect{|elt| + tk_split_simplelist(tk_send_without_enc('mark', 'names'), false, true).collect{|elt| + tagid2obj(elt) + } + end + + def mark_gravity(mark, direction=nil) + if direction + tk_send_without_enc('mark', 'gravity', + _get_eval_enc_str(mark), direction) + self + else + tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark)) + end + end + + def mark_set(mark, index) + tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark), + _get_eval_enc_str(index)) + self + end + alias set_mark mark_set + + def mark_unset(*marks) + tk_send_without_enc('mark', 'unset', + *(marks.collect{|mark| _get_eval_enc_str(mark)})) + self + end + alias unset_mark mark_unset + + def mark_next(index) + tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next', + _get_eval_enc_str(index)))) + end + alias next_mark mark_next + + def mark_previous(index) + tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous', + _get_eval_enc_str(index)))) + end + alias previous_mark mark_previous + + def scan_mark(x, y) + tk_send_without_enc('scan', 'mark', x, y) + self + end + def scan_dragto(x, y) + tk_send_without_enc('scan', 'dragto', x, y) + self + end + + + def _ktext_length(txt) + if TkCore::WITH_ENCODING ### Ruby 1.9 !!!!!!!!!!!!! + return txt.length + end + ########################### + + if $KCODE !~ /n/i + return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length + end + + # $KCODE == 'NONE' + if JAPANIZED_TK + tk_call_without_enc('kstring', 'length', + _get_eval_enc_str(txt)).to_i + else + begin + tk_call_without_enc('encoding', 'convertto', 'ascii', + _get_eval_enc_str(txt)).length + rescue StandardError, NameError + # sorry, I have no plan + txt.length + end + end + end + private :_ktext_length + + def tksearch(*args) + # call 'search' subcommand of text widget + # args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>] + # If <pattern> is regexp, then it must be a regular expression of Tcl + if args[0].kind_of?(Array) + opts = args.shift.collect{|opt| '-' + opt.to_s } + else + opts = [] + end + + opts << '--' + + ret = tk_send('search', *(opts + args)) + if ret == "" + nil + else + ret + end + end + + def tksearch_with_count(*args) + # call 'search' subcommand of text widget + # args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>] + # If <pattern> is regexp, then it must be a regular expression of Tcl + if args[0].kind_of?(Array) + opts = args.shift.collect{|opt| '-' + opt.to_s } + else + opts = [] + end + + opts << '-count' << args.shift << '--' + + ret = tk_send('search', *(opts + args)) + if ret == "" + nil + else + ret + end + end + + def search_with_length(pat,start,stop=None) + pat = pat.chr if pat.kind_of? Integer + if stop != None + return ["", 0] if compare(start,'>=',stop) + txt = get(start,stop) + if (pos = txt.index(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index(start + " + #{pos} chars"), pat.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(pat), pat.dup] + else + #return [index(start + " + #{pos} chars"), $&.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(match), match] + end + else + return ["", 0] + end + else + txt = get(start,'end - 1 char') + if (pos = txt.index(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index(start + " + #{pos} chars"), pat.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(pat), pat.dup] + else + #return [index(start + " + #{pos} chars"), $&.split('').length] + return [index(start + " + #{pos} chars"), + _ktext_length(match), match] + end + else + txt = get('1.0','end - 1 char') + if (pos = txt.index(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index("1.0 + #{pos} chars"), pat.split('').length] + return [index("1.0 + #{pos} chars"), + _ktext_length(pat), pat.dup] + else + #return [index("1.0 + #{pos} chars"), $&.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(match), match] + end + else + return ["", 0] + end + end + end + end + + def search(pat,start,stop=None) + search_with_length(pat,start,stop)[0] + end + + def rsearch_with_length(pat,start,stop=None) + pat = pat.chr if pat.kind_of? Integer + if stop != None + return ["", 0] if compare(start,'<=',stop) + txt = get(stop,start) + if (pos = txt.rindex(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index(stop + " + #{pos} chars"), pat.split('').length] + return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup] + else + #return [index(stop + " + #{pos} chars"), $&.split('').length] + return [index(stop + " + #{pos} chars"), _ktext_length(match), match] + end + else + return ["", 0] + end + else + txt = get('1.0',start) + if (pos = txt.rindex(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index("1.0 + #{pos} chars"), pat.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] + else + #return [index("1.0 + #{pos} chars"), $&.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(match), match] + end + else + txt = get('1.0','end - 1 char') + if (pos = txt.rindex(pat)) + match = $& + #pos = txt[0..(pos-1)].split('').length if pos > 0 + pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 + if pat.kind_of? String + #return [index("1.0 + #{pos} chars"), pat.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] + else + #return [index("1.0 + #{pos} chars"), $&.split('').length] + return [index("1.0 + #{pos} chars"), _ktext_length(match), match] + end + else + return ["", 0] + end + end + end + end + + def rsearch(pat,start,stop=None) + rsearch_with_length(pat,start,stop)[0] + end + + def see(index) + tk_send_without_enc('see', index) + self + end + + ############################### + + def xview(*index) + if index.size == 0 + list(tk_send_without_enc('xview')) + else + tk_send_without_enc('xview', *index) + self + end + end + def xview_moveto(*index) + xview('moveto', *index) + end + def xview_scroll(*index) + xview('scroll', *index) + end + + def yview(*index) + if index.size == 0 + list(tk_send_without_enc('yview')) + else + tk_send_without_enc('yview', *index) + self + end + end + def yview_moveto(*index) + yview('moveto', *index) + end + def yview_scroll(*index) + yview('scroll', *index) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb new file mode 100644 index 0000000..5ecd2d7 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb @@ -0,0 +1,20 @@ +# +# tkextlib/iwidgets/scrolledwidget.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Scrolledwidget < Tk::Iwidgets::Labeledwidget + end + end +end + +class Tk::Iwidgets::Scrolledwidget + TkCommandNames = ['::iwidgets::scrolledwidget'.freeze].freeze + WidgetClassName = 'Scrolledwidget'.freeze + WidgetClassNames[WidgetClassName] ||= self +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb new file mode 100644 index 0000000..eb8fe3a --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb @@ -0,0 +1,102 @@ +# +# tkextlib/iwidgets/selectionbox.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Selectionbox < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Selectionbox + TkCommandNames = ['::iwidgets::selectionbox'.freeze].freeze + WidgetClassName = 'Selectionbox'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'itemson' << 'selectionon' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'itemslabel' << 'selectionlabel' + end + private :__strval_optkeys + + def child_site + window(tk_call(@path, 'childsite')) + end + + def clear_items + tk_call(@path, 'clear', 'items') + self + end + + def clear_selection + tk_call(@path, 'clear', 'selection') + self + end + + def get + tk_call(@path, 'get') + end + + def insert_items(idx, *args) + tk_call(@path, 'insert', 'items', idx, *args) + end + + def insert_selection(pos, text) + tk_call(@path, 'insert', 'selection', pos, text) + end + + def select_item + tk_call(@path, 'selectitem') + self + end + + # based on Tk::Listbox ( and TkTextWin ) + def curselection + list(tk_send_without_enc('curselection')) + end + def delete(first, last=None) + tk_send_without_enc('delete', first, last) + self + end + def index(idx) + tk_send_without_enc('index', idx).to_i + end + def nearest(y) + tk_send_without_enc('nearest', y).to_i + end + def scan_mark(x, y) + tk_send_without_enc('scan', 'mark', x, y) + self + end + def scan_dragto(x, y) + tk_send_without_enc('scan', 'dragto', x, y) + self + end + def selection_anchor(index) + tk_send_without_enc('selection', 'anchor', index) + self + end + def selection_clear(first, last=None) + tk_send_without_enc('selection', 'clear', first, last) + self + end + def selection_includes(index) + bool(tk_send_without_enc('selection', 'includes', index)) + end + def selection_set(first, last=None) + tk_send_without_enc('selection', 'set', first, last) + self + end + def size + tk_send_without_enc('size').to_i + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb new file mode 100644 index 0000000..45aecf3 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb @@ -0,0 +1,92 @@ +# +# tkextlib/iwidgets/selectiondialog.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Selectiondialog < Tk::Iwidgets::Dialog + end + end +end + +class Tk::Iwidgets::Selectiondialog + TkCommandNames = ['::iwidgets::selectiondialog'.freeze].freeze + WidgetClassName = 'Selectiondialog'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def child_site + window(tk_call(@path, 'childsite')) + end + + def clear_items + tk_call(@path, 'clear', 'items') + self + end + + def clear_selection + tk_call(@path, 'clear', 'selection') + self + end + + def get + tk_call(@path, 'get') + end + + def insert_items(idx, *args) + tk_call(@path, 'insert', 'items', idx, *args) + end + + def insert_selection(pos, text) + tk_call(@path, 'insert', 'selection', pos, text) + end + + def select_item + tk_call(@path, 'selectitem') + self + end + + # based on Tk::Listbox ( and TkTextWin ) + def curselection + list(tk_send_without_enc('curselection')) + end + def delete(first, last=None) + tk_send_without_enc('delete', first, last) + self + end + def index(idx) + tk_send_without_enc('index', idx).to_i + end + def nearest(y) + tk_send_without_enc('nearest', y).to_i + end + def scan_mark(x, y) + tk_send_without_enc('scan', 'mark', x, y) + self + end + def scan_dragto(x, y) + tk_send_without_enc('scan', 'dragto', x, y) + self + end + def selection_anchor(index) + tk_send_without_enc('selection', 'anchor', index) + self + end + def selection_clear(first, last=None) + tk_send_without_enc('selection', 'clear', first, last) + self + end + def selection_includes(index) + bool(tk_send_without_enc('selection', 'includes', index)) + end + def selection_set(first, last=None) + tk_send_without_enc('selection', 'set', first, last) + self + end + def size + tk_send_without_enc('size').to_i + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb new file mode 100644 index 0000000..ee406c6 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb @@ -0,0 +1,8 @@ +# +# setup.rb -- setup script before calling TkPackage.require() +# +# If you need some setup operations (for example, add a library path +# to the library search path) before using Tcl/Tk library packages +# wrapped by Ruby scripts in this directory, please write the setup +# operations in this file. +# diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb new file mode 100644 index 0000000..c560e3a --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb @@ -0,0 +1,38 @@ +# +# tkextlib/iwidgets/shell.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Shell < Tk::Itk::Toplevel + end + end +end + +class Tk::Iwidgets::Shell + TkCommandNames = ['::iwidgets::shell'.freeze].freeze + WidgetClassName = 'Shell'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def activate + tk_call(@path, 'activate') # may return val of deactibate method + end + + def center(win=None) + tk_call(@path, 'center', win) + self + end + + def child_site + window(tk_call(@path, 'childsite')) + end + + def deactivate(val=None) + tk_call(@path, 'deactivate', val) + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb new file mode 100644 index 0000000..b3de9ed --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb @@ -0,0 +1,48 @@ +# +# tkextlib/iwidgets/spindate.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Spindate < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Spindate + TkCommandNames = ['::iwidgets::spindate'.freeze].freeze + WidgetClassName = 'Spindate'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'dayon' << 'monthon' << 'yearon' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'daylabel' << 'monthformat' << 'monthlabel' << 'yearlabel' + end + private :__strval_optkeys + + def get_string + tk_call(@path, 'get', '-string') + end + alias get get_string + + def get_clicks + number(tk_call(@path, 'get', '-clicks')) + end + + def show(date=None) + tk_call(@path, 'show', date) + self + end + def show_now + tk_call(@path, 'show', 'now') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb new file mode 100644 index 0000000..bede3bb --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb @@ -0,0 +1,30 @@ +# +# tkextlib/iwidgets/spinint.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Spinint < Tk::Iwidgets::Spinner + end + end +end + +class Tk::Iwidgets::Spinint + TkCommandNames = ['::iwidgets::spinint'.freeze].freeze + WidgetClassName = 'Spinint'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'wrap' + end + private :__boolval_optkeys + + def __numlistval_optkeys + super() << 'range' + end + private :__numlistval_optkeys +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb new file mode 100644 index 0000000..d960996 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb @@ -0,0 +1,169 @@ +# +# tkextlib/iwidgets/spinner.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Spinner < Tk::Iwidgets::Labeledwidget + end + end +end + +class Tk::Iwidgets::Spinner + TkCommandNames = ['::iwidgets::spinner'.freeze].freeze + WidgetClassName = 'Spinner'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include Tk::ValidateConfigure + + class EntryfieldValidate < TkValidateCommand + #class CalCmdArgs < TkUtil::CallbackSubst + class ValidateArgs < TkUtil::CallbackSubst + KEY_TBL = [ + [ ?c, ?s, :char ], + [ ?P, ?s, :post ], + [ ?S, ?s, :current ], + [ ?W, ?w, :widget ], + nil + ] + PROC_TBL = [ + [ ?s, TkComm.method(:string) ], + [ ?w, TkComm.method(:window) ], + nil + ] + +=begin + # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) + KEY_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String) + end + inf + } + + PROC_TBL.map!{|inf| + if inf.kind_of?(Array) + inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String) + end + inf + } +=end + + _setup_subst_table(KEY_TBL, PROC_TBL); + end + + def self._config_keys + ['validate', 'invalid'] + end + end + + def __validation_class_list + super() << EntryfieldValidate + end + + Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate) + + #################################### + + def up + tk_call_without_enc(@path, 'up') + self + end + + def down + tk_call_without_enc(@path, 'down') + self + end + + def clear + tk_call_without_enc(@path, 'clear') + self + end + + def delete(first, last=None) + tk_send_without_enc('delete', first, last) + self + end + + def value + _fromUTF8(tk_send_without_enc('get')) + end + def value= (val) + tk_send_without_enc('delete', 0, 'end') + tk_send_without_enc('insert', 0, _get_eval_enc_str(val)) + val + end + alias get value + alias set value= + + def cursor=(index) + tk_send_without_enc('icursor', index) + #self + index + end + alias icursor cursor= + + def index(idx) + number(tk_send_without_enc('index', idx)) + end + + def insert(pos,text) + tk_send_without_enc('insert', pos, _get_eval_enc_str(text)) + self + end + + def mark(pos) + tk_send_without_enc('scan', 'mark', pos) + self + end + def dragto(pos) + tk_send_without_enc('scan', 'dragto', pos) + self + end + def selection_adjust(index) + tk_send_without_enc('selection', 'adjust', index) + self + end + def selection_clear + tk_send_without_enc('selection', 'clear') + self + end + def selection_from(index) + tk_send_without_enc('selection', 'from', index) + self + end + def selection_present() + bool(tk_send_without_enc('selection', 'present')) + end + def selection_range(s, e) + tk_send_without_enc('selection', 'range', s, e) + self + end + def selection_to(index) + tk_send_without_enc('selection', 'to', index) + self + end + + # based on tk/scrollable.rb + def xview(*index) + if index.size == 0 + list(tk_send_without_enc('xview')) + else + tk_send_without_enc('xview', *index) + self + end + end + def xview_moveto(*index) + xview('moveto', *index) + end + def xview_scroll(*index) + xview('scroll', *index) + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb new file mode 100644 index 0000000..20f8197 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb @@ -0,0 +1,48 @@ +# +# tkextlib/iwidgets/spintime.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Spintime < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Spintime + TkCommandNames = ['::iwidgets::spintime'.freeze].freeze + WidgetClassName = 'Spintime'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'houron' << 'militaryon' << 'minutelabel' << 'secondlabel' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'hourlabel' << 'minuteon' << 'secondon' + end + private :__strval_optkeys + + def get_string + tk_call(@path, 'get', '-string') + end + alias get get_string + + def get_clicks + number(tk_call(@path, 'get', '-clicks')) + end + + def show(date=None) + tk_call(@path, 'show', date) + self + end + def show_now + tk_call(@path, 'show', 'now') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb new file mode 100644 index 0000000..f56efa9 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb @@ -0,0 +1,181 @@ +# +# tkextlib/iwidgets/tabnotebook.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Tabnotebook < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Tabnotebook + TkCommandNames = ['::iwidgets::tabnotebook'.freeze].freeze + WidgetClassName = 'Tabnotebook'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'pagecget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'pageconfigure', id] + end + private :__item_config_cmd + + def __item_strval_optkeys(id) + super(id) << 'tabbackground' << 'tabforeground' + end + private :__item_strval_optkeys + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias pagecget_tkstring itemcget_tkstring + alias pagecget itemcget + alias pagecget_strict itemcget_strict + alias pageconfigure itemconfigure + alias pageconfiginfo itemconfiginfo + alias current_pageconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def __boolval_optkeys + super() << 'auto' << 'equaltabs' << 'raiseselect' << 'tabborders' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'backdrop' << 'tabbackground' << 'tabforeground' + end + private :__strval_optkeys + + def initialize(*args) + super(*args) + @tabset = self.component_widget('tabset') + end + + def add(keys={}) + window(tk_call(@path, 'add', *hash_kv(keys))) + end + + def child_site_list + list(tk_call(@path, 'childsite')) + end + + def child_site(idx) + window(tk_call(@path, 'childsite', index(idx))) + end + + def delete(idx1, idx2=nil) + if idx2 + tk_call(@path, 'delete', index(idx1), index(idx2)) + else + tk_call(@path, 'delete', index(idx1)) + end + self + end + + def index(idx) + #number(tk_call(@path, 'index', tagid(idx))) + @tabset.index(tagid(idx)) + end + + def insert(idx, keys={}) + window(tk_call(@path, 'insert', index(idx), *hash_kv(keys))) + end + + def next + tk_call(@path, 'next') + self + end + + def prev + tk_call(@path, 'prev') + self + end + + def select(idx) + tk_call(@path, 'select', index(idx)) + self + end + + def show_tab(idx) + @tabset.show_tab(idx) + self + end + + def scrollcommand(cmd=Proc.new) + configure_cmd 'scrollcommand', cmd + self + end + alias xscrollcommand scrollcommand + alias yscrollcommand scrollcommand + + def xscrollbar(bar=nil) + if bar + @scrollbar = bar + @scrollbar.orient 'horizontal' + self.scrollcommand {|*arg| @scrollbar.set(*arg)} + @scrollbar.command {|*arg| self.xview(*arg)} + Tk.update # avoid scrollbar trouble + end + @scrollbar + end + def yscrollbar(bar=nil) + if bar + @scrollbar = bar + @scrollbar.orient 'vertical' + self.scrollcommand {|*arg| @scrollbar.set(*arg)} + @scrollbar.command {|*arg| self.yview(*arg)} + Tk.update # avoid scrollbar trouble + end + @scrollbar + end + alias scrollbar yscrollbar + + def view(*index) + if index.size == 0 + idx = num_or_str(tk_send_without_enc('view')) + if idx.kind_of?(Fixnum) && idx < 0 + nil + else + idx + end + else + tk_send_without_enc('view', *index) + self + end + end + alias xview view + alias yview view + + def view_moveto(*index) + view('moveto', *index) + end + alias xview_moveto view_moveto + alias yview_moveto view_moveto + def view_scroll(index, what='pages') + view('scroll', index, what) + end + alias xview_scroll view_scroll + alias yview_scroll view_scroll +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb new file mode 100644 index 0000000..501ead4 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb @@ -0,0 +1,145 @@ +# +# tkextlib/iwidgets/tabset.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Tabset < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Tabset + TkCommandNames = ['::iwidgets::tabset'.freeze].freeze + WidgetClassName = 'Tabset'.freeze + WidgetClassNames[WidgetClassName] ||= self + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'tabcget', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'tabconfigure', id] + end + private :__item_config_cmd + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias tabcget_tkstring itemcget_tkstring + alias tabcget itemcget + alias tabcget_strict itemcget_strict + alias tabconfigure itemconfigure + alias tabconfiginfo itemconfiginfo + alias current_tabconfiginfo current_itemconfiginfo + + private :itemcget_tkstring, :itemcget, :itemcget_strict + private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def __boolval_optkeys + super() << 'equaltabs' << 'raiseselect' << 'tabborders' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'backdrop' + end + private :__strval_optkeys + + def add(keys={}) + window(tk_call(@path, 'add', *hash_kv(keys))) + end + + def delete(idx1, idx2=nil) + if idx2 + tk_call(@path, 'delete', index(idx1), index(idx2)) + else + tk_call(@path, 'delete', index(idx1)) + end + self + end + + def index(idx) + number(tk_call(@path, 'index', tagid(idx))) + end + + def insert(idx, keys={}) + window(tk_call(@path, 'insert', index(idx), *hash_kv(keys))) + end + + def next + tk_call(@path, 'next') + self + end + + def prev + tk_call(@path, 'prev') + self + end + + def select(idx) + tk_call(@path, 'select', index(idx)) + self + end + + def show_tab(idx) + if index(idx) == 0 + self.start = 0 + return + end + + reutrn unless @canvas ||= self.winfo_children[0] + + delta = 1 if (delta = cget(:gap)) == 'overlap' || + (delta = self.winfo_pixels(delta) + 1) <= 0 + + case cget(:tabpos) + when 's', 'n' + if (head = tabcget(idx, :left)) < 0 + self.start -= head + return + end + tabs_size = @canvas.winfo_width + tab_start, tab_end = @canvas . + find_overlapping(head, 0, head + delta, @canvas.winfo_height) . + find_all{|id| @canvas.itemtype(id) == TkcPolygon} . + map!{|id| bbox = @canvas.bbox(id); [bbox[0], bbox[2]]} . max + + when 'e', 'w' + if (head = tabcget(idx, :top)) < 0 + self.start -= head + return + end + tabs_size = @canvas.winfo_height + tab_start, tab_end = @canvas . + find_overlapping(0, head, @canvas.winfo_width, head + delta) . + find_all{|id| @canvas.itemtype(id) == TkcPolygon} . + map!{|id| bbox = @canvas.bbox(id); [bbox[1], bbox[3]]} . max + end + + if (size = tab_end - tab_start + 1) > tabs_size + self.start -= tab_start + elsif head + size > tabs_size + self.start -= head + size - tabs_size + end + + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb new file mode 100644 index 0000000..b0afb3a --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb @@ -0,0 +1,25 @@ +# +# tkextlib/iwidgets/timeentry.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Timeentry < Tk::Iwidgets::Timefield + end + end +end + +class Tk::Iwidgets::Timeentry + TkCommandNames = ['::iwidgets::timeentry'.freeze].freeze + WidgetClassName = 'Timeentry'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __strval_optkeys + super() << 'closetext' + end + private :__strval_optkeys +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb new file mode 100644 index 0000000..c34281d --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb @@ -0,0 +1,58 @@ +# +# tkextlib/iwidgets/timefield.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Timefield < Tk::Iwidgets::Labeledwidget + end + end +end + +class Tk::Iwidgets::Timefield + TkCommandNames = ['::iwidgets::timefield'.freeze].freeze + WidgetClassName = 'Timefield'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'gmt' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'textbackground' + end + private :__strval_optkeys + + def __font_optkeys + super() << 'textfont' + end + private :__font_optkeys + + def get_string + tk_call(@path, 'get', '-string') + end + alias get get_string + + def get_clicks + number(tk_call(@path, 'get', '-clicks')) + end + + def valid? + bool(tk_call(@path, 'isvalid')) + end + alias isvalid? valid? + + def show(time=None) + tk_call(@path, 'show', time) + self + end + def show_now + tk_call(@path, 'show', 'now') + self + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb new file mode 100644 index 0000000..5b474c3 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb @@ -0,0 +1,112 @@ +# +# tkextlib/iwidgets/toolbar.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Toolbar < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Toolbar + TkCommandNames = ['::iwidgets::toolbar'.freeze].freeze + WidgetClassName = 'Toolbar'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __tkvariable_optkeys + super() << 'helpvariable' + end + private :__tkvariable_optkeys + + #################################### + + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'itemcget', self.index(id)] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'itemconfigure', self.index(id)] + end + private :__item_config_cmd + + def __item_strval_optkeys(id) + super(id) << 'helpstr' << 'balloonstr' + end + private :__item_strval_optkeys + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + #################################### + + def __strval_optkeys + super() << 'balloonbackground' << 'balloonforeground' + end + private :__strval_optkeys + + def __tkvariable_optkeys + super() << 'helpvariable' + end + private :__tkvariable_optkeys + + def __font_optkeys + super() << 'balloonfont' + end + private :__font_optkeys + + def add(type, tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + window(tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys))) + tag + end + + def delete(idx1, idx2=nil) + if idx2 + tk_call(@path, 'delete', index(idx1), index(idx2)) + else + tk_call(@path, 'delete', index(idx1)) + end + self + end + + def index(idx) + number(tk_call(@path, 'index', tagid(idx))) + end + + def insert(idx, type, tag=nil, keys={}) + if tag.kind_of?(Hash) + keys = tag + tag = nil + end + if tag + tag = Tk::Itk::Component.new(self, tagid(tag)) + else + tag = Tk::Itk::Component.new(self) + end + window(tk_call(@path, 'insert', index(idx), type, + tagid(tag), *hash_kv(keys))) + tag + end +end diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb new file mode 100644 index 0000000..f10ec54 --- /dev/null +++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb @@ -0,0 +1,56 @@ +# +# tkextlib/iwidgets/watch.rb +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# + +require 'tk' +require 'tkextlib/iwidgets.rb' + +module Tk + module Iwidgets + class Watch < Tk::Itk::Widget + end + end +end + +class Tk::Iwidgets::Watch + TkCommandNames = ['::iwidgets::watch'.freeze].freeze + WidgetClassName = 'Watch'.freeze + WidgetClassNames[WidgetClassName] ||= self + + def __boolval_optkeys + super() << 'showampm' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'clockcolor' << 'hourcolor' << 'minutecolor' << + 'pivotcolor' << 'secondcolor' << 'tickcolor' + end + private :__strval_optkeys + + def get_string + tk_call(@path, 'get', '-string') + end + alias get get_string + + def get_clicks + number(tk_call(@path, 'get', '-clicks')) + end + + def show(time=None) + tk_call(@path, 'show', time) + self + end + def show_now + tk_call(@path, 'show', 'now') + self + end + + def watch(*args) + unless args.empty? + tk_call(@path, 'watch', *args) + end + component_path('canvas') + end +end |