diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-09 19:29:29 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-09 19:29:29 +0000 |
commit | e55330c9c415f673ca5565a9dbd0b84775d53419 (patch) | |
tree | ab1c6145288ce3d209e605fe3dbc10c66f487f2f /ext/tk/lib/tkextlib/iwidgets | |
parent | 29c3cb6d2061d2d476ef50066b44a5596dd51d99 (diff) |
* ext/tk/lib/tk.rb: better operation for SIGINT when processing callbacks.
* ext/tk/lib/tk/msgcat.rb: ditto.
* ext/tk/lib/tk/variable.rb: ditto.
* ext/tk/lib/tk/timer.rb: ditto.
* ext/tk/lib/tk/validation.rb: add Tk::ValidateConfigure.__def_validcmd()
to define validatecommand methods easier
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib/iwidgets')
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/buttonbox.rb | 3 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/calendar.rb | 3 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/checkbox.rb | 3 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/combobox.rb | 3 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/datefield.rb | 3 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/dialogshell.rb | 3 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/entryfield.rb | 3 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/hierarchy.rb | 294 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb | 40 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/mainwindow.rb | 52 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/messagebox.rb | 81 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/messagedialog.rb | 20 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/radiobox.rb | 107 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb | 20 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/timeentry.rb | 20 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/timefield.rb | 43 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/toolbar.rb | 86 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/watch.rb | 45 |
18 files changed, 824 insertions, 5 deletions
diff --git a/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb b/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb index fef442a769..5ca48ed229 100644 --- a/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb +++ b/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb @@ -36,7 +36,8 @@ class Tk::Iwidgets::Buttonbox if tagOrId.kind_of?(Tk::Itk::Component) tagOrId.name else - _get_eval_string(tagOrId) + #_get_eval_string(tagOrId) + tagOrId end end diff --git a/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/ext/tk/lib/tkextlib/iwidgets/calendar.rb index 7a9763addc..dab10b118b 100644 --- a/ext/tk/lib/tkextlib/iwidgets/calendar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/calendar.rb @@ -48,6 +48,8 @@ class Tk::Iwidgets::Calendar 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) @@ -57,6 +59,7 @@ class Tk::Iwidgets::Calendar configure('command', cmd) end end +=end #################################### diff --git a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb index 9845439ac4..5e0fb5e7b6 100644 --- a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb +++ b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb @@ -36,7 +36,8 @@ class Tk::Iwidgets::Checkbox if tagOrId.kind_of?(Tk::Itk::Component) tagOrId.name else - _get_eval_string(tagOrId) + #_get_eval_string(tagOrId) + tagOrId end end diff --git a/ext/tk/lib/tkextlib/iwidgets/combobox.rb b/ext/tk/lib/tkextlib/iwidgets/combobox.rb index ca0e57c233..1cf10b4004 100644 --- a/ext/tk/lib/tkextlib/iwidgets/combobox.rb +++ b/ext/tk/lib/tkextlib/iwidgets/combobox.rb @@ -82,7 +82,7 @@ class Tk::Iwidgets::Combobox def sort(*params, &b) # see 'lsort' man page about params if b - tk_call(@path, 'sort', *params, -'command', proc(&b)) + tk_call(@path, 'sort', '-command', proc(&b), *params) else tk_call(@path, 'sort', *params) end @@ -91,6 +91,7 @@ class Tk::Iwidgets::Combobox def sort_ascending tk_call(@path, 'sort', 'ascending') self + end def sort_descending tk_call(@path, 'sort', 'descending') self diff --git a/ext/tk/lib/tkextlib/iwidgets/datefield.rb b/ext/tk/lib/tkextlib/iwidgets/datefield.rb index a757403d6e..924aef9c4d 100644 --- a/ext/tk/lib/tkextlib/iwidgets/datefield.rb +++ b/ext/tk/lib/tkextlib/iwidgets/datefield.rb @@ -30,8 +30,9 @@ class Tk::Iwidgets::Datefield def valid? bool(tk_call(@path, 'isvalid')) end + alias isvalid? valid? - def show(date) + def show(date=None) tk_call(@path, 'show', date) self end diff --git a/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb b/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb index 8359a3c551..4736ebab77 100644 --- a/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb +++ b/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb @@ -36,7 +36,8 @@ class Tk::Iwidgets::Dialogshell if tagOrId.kind_of?(Tk::Itk::Component) tagOrId.name else - _get_eval_string(tagOrId) + #_get_eval_string(tagOrId) + tagOrId end end diff --git a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb index b38615a671..6299259b9b 100644 --- a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb +++ b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb @@ -49,6 +49,8 @@ class Tk::Iwidgets::Entryfield 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) @@ -68,6 +70,7 @@ class Tk::Iwidgets::Entryfield configure('invalid', cmd) end end +=end #################################### diff --git a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb new file mode 100644 index 0000000000..a7024356ac --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb @@ -0,0 +1,294 @@ +# +# tkextlib/iwidgets/hierarchy.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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 ] + _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 + ] + + _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 ] + _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 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 TkText 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/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb b/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb new file mode 100644 index 0000000000..22e86339a6 --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb @@ -0,0 +1,40 @@ +# +# tkextlib/iwidgets/hyperhelp.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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 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/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb b/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb new file mode 100644 index 0000000000..4570afc6d0 --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb @@ -0,0 +1,52 @@ +# +# tkextlib/iwidgets/mainwindow.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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 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/ext/tk/lib/tkextlib/iwidgets/messagebox.rb b/ext/tk/lib/tkextlib/iwidgets/messagebox.rb new file mode 100644 index 0000000000..a9d9775c75 --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/messagebox.rb @@ -0,0 +1,81 @@ +# +# tkextlib/iwidgets/messagebox.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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 + + alias type_cget itemcget + alias type_configure itemconfigure + alias type_configinfo itemconfiginfo + alias current_type_configinfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :itemconfiginfo, :current_itemconfiginfo + + #################################### + + 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/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb b/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb new file mode 100644 index 0000000000..c19b83e517 --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb @@ -0,0 +1,20 @@ +# +# tkextlib/iwidgets/messagedialog.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb new file mode 100644 index 0000000000..dd96089ffa --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb @@ -0,0 +1,107 @@ +# +# tkextlib/iwidgets/radiobox.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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 tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + alias buttoncget itemcget + alias buttonconfigure itemconfigure + alias buttonconfiginfo itemconfiginfo + alias current_buttonconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :itemconfiginfo, :current_itemconfiginfo + + #################################### + + def 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, '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(idx) + simplelist(tk_call(@path, 'get', index(idx))).collect{|id| + Tk::Itk::Component.id2obj(id) + } + 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 + unless tag + 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/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb new file mode 100644 index 0000000000..eef093d314 --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb @@ -0,0 +1,20 @@ +# +# tkextlib/iwidgets/scrolledwidget.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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/ext/tk/lib/tkextlib/iwidgets/timeentry.rb b/ext/tk/lib/tkextlib/iwidgets/timeentry.rb new file mode 100644 index 0000000000..987cddc1e0 --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/timeentry.rb @@ -0,0 +1,20 @@ +# +# tkextlib/iwidgets/timeentry.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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 +end diff --git a/ext/tk/lib/tkextlib/iwidgets/timefield.rb b/ext/tk/lib/tkextlib/iwidgets/timefield.rb new file mode 100644 index 0000000000..602093eb7e --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/timefield.rb @@ -0,0 +1,43 @@ +# +# tkextlib/iwidgets/timefield.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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 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/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb new file mode 100644 index 0000000000..81239f9b97 --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/toolbar.rb @@ -0,0 +1,86 @@ +# +# tkextlib/iwidgets/toolbar.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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 + + #################################### + + include TkItemConfigMethod + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::Itk::Component) + tagOrId.name + else + #_get_eval_string(tagOrId) + tagOrId + end + end + + #################################### + + def add(type, 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, '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 + unless tag + tag = Tk::Itk::Component.new(self) + end + tk_call(@path, 'insert', index(idx), type, 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/ext/tk/lib/tkextlib/iwidgets/watch.rb b/ext/tk/lib/tkextlib/iwidgets/watch.rb new file mode 100644 index 0000000000..f62c0b931e --- /dev/null +++ b/ext/tk/lib/tkextlib/iwidgets/watch.rb @@ -0,0 +1,45 @@ +# +# tkextlib/iwidgets/watch.rb +# by Hidetoshi NAGAI ([email protected]) +# + +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 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 |