diff options
Diffstat (limited to 'ext/tk/lib/tkextlib/iwidgets')
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/calendar.rb | 17 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/checkbox.rb | 16 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/entryfield.rb | 17 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/hierarchy.rb | 52 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/notebook.rb | 11 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/radiobox.rb | 11 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb | 10 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb | 5 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/selectionbox.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/spinner.rb | 17 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb | 16 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/tabset.rb | 44 |
13 files changed, 203 insertions, 17 deletions
diff --git a/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/ext/tk/lib/tkextlib/iwidgets/calendar.rb index 0152f8593a..236ca96f00 100644 --- a/ext/tk/lib/tkextlib/iwidgets/calendar.rb +++ b/ext/tk/lib/tkextlib/iwidgets/calendar.rb @@ -45,6 +45,23 @@ class Tk::Iwidgets::Calendar class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ [?d, ?s, :date], nil ] PROC_TBL = [ [?s, TkComm.method(:string) ], nil ] + + # 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 + } + _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) diff --git a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb index 46ca389db2..7d2b41f806 100644 --- a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb +++ b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb @@ -85,12 +85,24 @@ class Tk::Iwidgets::Checkbox self end - def get(idx) - simplelist(tk_call(@path, 'get', index(idx))).collect{|id| + 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 diff --git a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb index 6aa933ce06..1f9effb46e 100644 --- a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb +++ b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb @@ -42,6 +42,23 @@ class Tk::Iwidgets::Entryfield [ ?w, TkComm.method(:window) ], nil ] + + # 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 + } + _setup_subst_table(KEY_TBL, PROC_TBL); end diff --git a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb index 4cc6aeecbd..4e7d8f8579 100644 --- a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb +++ b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb @@ -30,6 +30,23 @@ class Tk::Iwidgets::Hierarchy class ValidateArgs < TkUtil::CallbackSubst KEY_TBL = [ [?n, ?s, :node], nil ] PROC_TBL = [ [?s, TkComm.method(:string) ], nil ] + + # 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 + } + _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) @@ -57,6 +74,22 @@ class Tk::Iwidgets::Hierarchy nil ] + # 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 + } + _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) @@ -78,6 +111,23 @@ class Tk::Iwidgets::Hierarchy nil ] PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ] + + # 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 + } + _setup_subst_table(KEY_TBL, PROC_TBL); def self.ret_val(val) @@ -207,7 +257,7 @@ class Tk::Iwidgets::Hierarchy self end - # based on TkText widget + # based on Tk::Text widget def bbox(index) list(tk_send_without_enc('bbox', _get_eval_enc_str(index))) diff --git a/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/ext/tk/lib/tkextlib/iwidgets/notebook.rb index 0f9d713ea1..268452afec 100644 --- a/ext/tk/lib/tkextlib/iwidgets/notebook.rb +++ b/ext/tk/lib/tkextlib/iwidgets/notebook.rb @@ -146,7 +146,12 @@ class Tk::Iwidgets::Notebook def view(*idxs) if idxs.size == 0 - window(tk_send_without_enc('view')) + 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 @@ -160,8 +165,8 @@ class Tk::Iwidgets::Notebook end alias xview_moveto view_moveto alias yview_moveto view_moveto - def view_scroll(*idxs) - view('scroll', *idxs) + def view_scroll(index, what='pages') + view('scroll', index, what) end alias xview_scroll view_scroll alias yview_scroll view_scroll diff --git a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb index 1a2821bd6a..cfcbca1aad 100644 --- a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb +++ b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb @@ -85,10 +85,13 @@ class Tk::Iwidgets::Radiobox self end - def get(idx) - simplelist(tk_call(@path, 'get', index(idx))).collect{|id| - Tk::Itk::Component.id2obj(self, id) - } + 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) diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb index 407c8f2aad..b07602e340 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb @@ -171,10 +171,16 @@ class Tk::Iwidgets::Scrolledcanvas end def delete(*args) - if TkcItem::CItemID_TBL[self.path] + 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[self.path].delete(item.id) + TkcItem::CItemID_TBL.mutex.synchronize{ + tbl.delete(item.id) + } end } end diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb index fdafc8dc7f..2887b60815 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb @@ -322,6 +322,11 @@ class Tk::Iwidgets::Scrolledtext 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 diff --git a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb index bb81fcca5e..bf9b5ec30a 100644 --- a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb +++ b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb @@ -59,7 +59,7 @@ class Tk::Iwidgets::Selectionbox self end - # based on TkListbox ( and TkTextWin ) + # based on Tk::Listbox ( and TkTextWin ) def curselection list(tk_send_without_enc('curselection')) end diff --git a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb index ab790e97a6..f772ecf8c2 100644 --- a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb +++ b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb @@ -49,7 +49,7 @@ class Tk::Iwidgets::Selectiondialog self end - # based on TkListbox ( and TkTextWin ) + # based on Tk::Listbox ( and TkTextWin ) def curselection list(tk_send_without_enc('curselection')) end diff --git a/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ext/tk/lib/tkextlib/iwidgets/spinner.rb index 174b9bd506..126cfe7c95 100644 --- a/ext/tk/lib/tkextlib/iwidgets/spinner.rb +++ b/ext/tk/lib/tkextlib/iwidgets/spinner.rb @@ -37,6 +37,23 @@ class Tk::Iwidgets::Spinner [ ?w, TkComm.method(:window) ], nil ] + + # 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 + } + _setup_subst_table(KEY_TBL, PROC_TBL); end diff --git a/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb index 0d9715f87b..382604102e 100644 --- a/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb +++ b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb @@ -116,6 +116,11 @@ class Tk::Iwidgets::Tabnotebook self end + def show_tab(idx) + @tabset.show_tab(idx) + self + end + def scrollcommand(cmd=Proc.new) configure_cmd 'scrollcommand', cmd self @@ -147,7 +152,12 @@ class Tk::Iwidgets::Tabnotebook def view(*index) if index.size == 0 - window(tk_send_without_enc('view')) + 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 @@ -161,8 +171,8 @@ class Tk::Iwidgets::Tabnotebook end alias xview_moveto view_moveto alias yview_moveto view_moveto - def view_scroll(*index) - view('scroll', *index) + def view_scroll(index, what='pages') + view('scroll', index, what) end alias xview_scroll view_scroll alias yview_scroll view_scroll diff --git a/ext/tk/lib/tkextlib/iwidgets/tabset.rb b/ext/tk/lib/tkextlib/iwidgets/tabset.rb index 54e56d0514..618260e8e3 100644 --- a/ext/tk/lib/tkextlib/iwidgets/tabset.rb +++ b/ext/tk/lib/tkextlib/iwidgets/tabset.rb @@ -96,4 +96,48 @@ class Tk::Iwidgets::Tabset 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 |