diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-27 18:44:31 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-02-27 18:44:31 +0000 |
commit | ee695fb164796dc203306f1585c4f6dd74f06806 (patch) | |
tree | 278f46cf1b6a9afafd3391af2b29e8a2ecf31dd4 /ext/tk/lib/tkextlib | |
parent | 4dd9fd71b34cd21613404a2900085868dfac5cd4 (diff) | |
download | ruby-ee695fb164796dc203306f1585c4f6dd74f06806.tar.gz |
* ext/tk/lib/tk.rb, ext/tk/lib/*: make default widget set
switchable between Tk (standard Tcl/Tk widget set) and
Ttk (Tile). Initial default widget set is Tk. Now, toplevel
widget classes are removed and defined as aliases.
For example, "TkButton" is an alias of the "Tk::Button" class.
Those aliases are replaced when switching default widget set.
"Tk.default_widget_set=" is the method for switching default
widget set. "Tk.default_widget_set = :Ttk" defines Ttk (Tile)
widget set as default. It means that "TkButton" denotes
"Tk::Tile::Button" class. And then, "TkButton.new" creates
a Tk::Tile::Button widget. Of course, you can back to use
standard Tk widgets as the default widget set by calling
"Tk.default_widget_set = :Tk", whenever you want. Based on
thie feature, you can use Ttk widget styling engine on your
old Ruby/Tk application without modifying its source, if you
don'tuse widget options unsupported on Ttk widgets (At first,
call "Tk.default_widget_set = :Ttk", and next load and run
your application).
This is one step for supporting Tcl/Tk8.5 features.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib')
51 files changed, 243 insertions, 78 deletions
diff --git a/ext/tk/lib/tkextlib/blt/busy.rb b/ext/tk/lib/tkextlib/blt/busy.rb index 4726e466f4..2f807fcd9c 100644 --- a/ext/tk/lib/tkextlib/blt/busy.rb +++ b/ext/tk/lib/tkextlib/blt/busy.rb @@ -19,7 +19,7 @@ module Tk::BLT class Shield < TkWindow def self.shield_path(win) win = window(win) unless win.kind_of?(TkWindow) - if win.kind_of?(TkToplevel) + if win.kind_of?(Tk::Toplevel) win.path + '._Busy' else win.path + '_Busy' diff --git a/ext/tk/lib/tkextlib/blt/eps.rb b/ext/tk/lib/tkextlib/blt/eps.rb index 586a42470c..0dba87a7cc 100644 --- a/ext/tk/lib/tkextlib/blt/eps.rb +++ b/ext/tk/lib/tkextlib/blt/eps.rb @@ -14,7 +14,7 @@ module Tk::BLT end end -class TkCanvas +class Tk::Canvas alias __BLT_EPS_item_strval_optkeys __item_strval_optkeys def __item_strval_optkeys(id) __BLT_EPS_item_strval_optkeys(id) + [ diff --git a/ext/tk/lib/tkextlib/blt/tile/button.rb b/ext/tk/lib/tkextlib/blt/tile/button.rb index dd715c8b98..2e0863cfbe 100644 --- a/ext/tk/lib/tkextlib/blt/tile/button.rb +++ b/ext/tk/lib/tkextlib/blt/tile/button.rb @@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb' module Tk::BLT module Tile - class Button < TkButton + class Button < Tk::Button TkCommandNames = ['::blt::tile::button'.freeze].freeze end end diff --git a/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb b/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb index ad58999d86..da230b5925 100644 --- a/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb +++ b/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb @@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb' module Tk::BLT module Tile - class CheckButton < TkCheckButton + class CheckButton < Tk::CheckButton TkCommandNames = ['::blt::tile::checkbutton'.freeze].freeze end Checkbutton = CheckButton diff --git a/ext/tk/lib/tkextlib/blt/tile/frame.rb b/ext/tk/lib/tkextlib/blt/tile/frame.rb index 10469fd35f..5434af4b72 100644 --- a/ext/tk/lib/tkextlib/blt/tile/frame.rb +++ b/ext/tk/lib/tkextlib/blt/tile/frame.rb @@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb' module Tk::BLT module Tile - class Frame < TkFrame + class Frame < Tk::Frame TkCommandNames = ['::blt::tile::frame'.freeze].freeze end end diff --git a/ext/tk/lib/tkextlib/blt/tile/label.rb b/ext/tk/lib/tkextlib/blt/tile/label.rb index ec67babd58..f370c1403b 100644 --- a/ext/tk/lib/tkextlib/blt/tile/label.rb +++ b/ext/tk/lib/tkextlib/blt/tile/label.rb @@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb' module Tk::BLT module Tile - class Label < TkLabel + class Label < Tk::Label TkCommandNames = ['::blt::tile::label'.freeze].freeze end end diff --git a/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb b/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb index 2316923b19..814f9a5cc4 100644 --- a/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb +++ b/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb @@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb' module Tk::BLT module Tile - class RadioButton < TkRadioButton + class RadioButton < Tk::RadioButton TkCommandNames = ['::blt::tile::radiobutton'.freeze].freeze end Radiobutton = RadioButton diff --git a/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb b/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb index ba3bf316f0..2ae871d518 100644 --- a/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb +++ b/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb @@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb' module Tk::BLT module Tile - class Scrollbar < TkScrollbar + class Scrollbar < Tk::Scrollbar TkCommandNames = ['::blt::tile::scrollbar'.freeze].freeze end end diff --git a/ext/tk/lib/tkextlib/blt/tile/toplevel.rb b/ext/tk/lib/tkextlib/blt/tile/toplevel.rb index 6cc2c91415..76d5f86b1b 100644 --- a/ext/tk/lib/tkextlib/blt/tile/toplevel.rb +++ b/ext/tk/lib/tkextlib/blt/tile/toplevel.rb @@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb' module Tk::BLT module Tile - class Toplevel < TkToplevel + class Toplevel < Tk::Toplevel TkCommandNames = ['::blt::tile::toplevel'.freeze].freeze end end diff --git a/ext/tk/lib/tkextlib/bwidget/button.rb b/ext/tk/lib/tkextlib/bwidget/button.rb index 4a9d4a7948..8f3087d098 100644 --- a/ext/tk/lib/tkextlib/bwidget/button.rb +++ b/ext/tk/lib/tkextlib/bwidget/button.rb @@ -9,7 +9,7 @@ require 'tkextlib/bwidget.rb' module Tk module BWidget - class Button < TkButton + class Button < Tk::Button end end end diff --git a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb index ef999239f9..a8f23e8749 100644 --- a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb +++ b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb @@ -31,7 +31,7 @@ class Tk::BWidget::ButtonBox name = tagOrId[:name] return index(name) unless name.empty? end - if tagOrId.kind_of?(TkButton) + if tagOrId.kind_of?(Tk::Button) return index(tagOrId[:text]) end # index(tagOrId.to_s) @@ -54,7 +54,7 @@ class Tk::BWidget::ButtonBox name = idx[:name] idx = name unless name.empty? end - if idx.kind_of?(TkButton) + if idx.kind_of?(Tk::Button) idx = idx[:text] end number(tk_send('index', idx.to_s)) diff --git a/ext/tk/lib/tkextlib/bwidget/dialog.rb b/ext/tk/lib/tkextlib/bwidget/dialog.rb index 2790d88d24..ae5f0238a3 100644 --- a/ext/tk/lib/tkextlib/bwidget/dialog.rb +++ b/ext/tk/lib/tkextlib/bwidget/dialog.rb @@ -103,7 +103,7 @@ class Tk::BWidget::Dialog name = tagOrId[:name] return index(name) unless name.empty? end - if tagOrId.kind_of?(TkButton) + if tagOrId.kind_of?(Tk::Button) return index(tagOrId[:text]) end # index(tagOrId.to_s) diff --git a/ext/tk/lib/tkextlib/bwidget/entry.rb b/ext/tk/lib/tkextlib/bwidget/entry.rb index aafb4aa7ff..a56890f4e3 100644 --- a/ext/tk/lib/tkextlib/bwidget/entry.rb +++ b/ext/tk/lib/tkextlib/bwidget/entry.rb @@ -9,7 +9,7 @@ require 'tkextlib/bwidget.rb' module Tk module BWidget - class Entry < TkEntry + class Entry < Tk::Entry end end end diff --git a/ext/tk/lib/tkextlib/bwidget/label.rb b/ext/tk/lib/tkextlib/bwidget/label.rb index ce10ecaf8b..88a504aa50 100644 --- a/ext/tk/lib/tkextlib/bwidget/label.rb +++ b/ext/tk/lib/tkextlib/bwidget/label.rb @@ -9,7 +9,7 @@ require 'tkextlib/bwidget.rb' module Tk module BWidget - class Label < TkLabel + class Label < Tk::Label end end end diff --git a/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/ext/tk/lib/tkextlib/bwidget/labelentry.rb index 931feb9b48..95b40946a6 100644 --- a/ext/tk/lib/tkextlib/bwidget/labelentry.rb +++ b/ext/tk/lib/tkextlib/bwidget/labelentry.rb @@ -11,7 +11,7 @@ require 'tkextlib/bwidget/entry' module Tk module BWidget - class LabelEntry < TkEntry + class LabelEntry < Tk::Entry end end end diff --git a/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/ext/tk/lib/tkextlib/bwidget/spinbox.rb index ca4c046e5c..48358baa5c 100644 --- a/ext/tk/lib/tkextlib/bwidget/spinbox.rb +++ b/ext/tk/lib/tkextlib/bwidget/spinbox.rb @@ -10,7 +10,7 @@ require 'tkextlib/bwidget/entry' module Tk module BWidget - class SpinBox < TkEntry + class SpinBox < Tk::Entry end end end diff --git a/ext/tk/lib/tkextlib/itk/incr_tk.rb b/ext/tk/lib/tkextlib/itk/incr_tk.rb index 0626536e36..c7b4e40af8 100644 --- a/ext/tk/lib/tkextlib/itk/incr_tk.rb +++ b/ext/tk/lib/tkextlib/itk/incr_tk.rb @@ -156,7 +156,7 @@ module Tk master = master.to_s end return id unless ComponentID_TBL.key?(master) - (ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id + (ComponentID_TBL[master].key?(id))? ComponentID_TBL[master][id]: id end def self.new(master, component=nil) 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/hierarchy.rb b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb index 4cc6aeecbd..028f6ac0e7 100644 --- a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb +++ b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb @@ -207,7 +207,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/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/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 diff --git a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb index 6940a9174c..7db3c2e2b7 100644 --- a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb +++ b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb @@ -108,7 +108,7 @@ module Tk end end -class TkScrollbar +class Tk::Scrollbar def autoscroll # Arranges for the already existing scrollbar to be mapped # and unmapped as needed. diff --git a/ext/tk/lib/tkextlib/tcllib/ctext.rb b/ext/tk/lib/tkextlib/tcllib/ctext.rb index 70a45dd8e7..9014037f3d 100644 --- a/ext/tk/lib/tkextlib/tcllib/ctext.rb +++ b/ext/tk/lib/tkextlib/tcllib/ctext.rb @@ -15,7 +15,7 @@ TkPackage.require('ctext') module Tk module Tcllib - class CText < TkText + class CText < Tk::Text PACKAGE_NAME = 'ctext'.freeze def self.package_name PACKAGE_NAME diff --git a/ext/tk/lib/tkextlib/tcllib/datefield.rb b/ext/tk/lib/tkextlib/tcllib/datefield.rb index bd84488101..2244dd7a9a 100644 --- a/ext/tk/lib/tkextlib/tcllib/datefield.rb +++ b/ext/tk/lib/tkextlib/tcllib/datefield.rb @@ -24,7 +24,7 @@ TkPackage.require('datefield') module Tk module Tcllib - class Datefield < TkEntry + class Datefield < Tk::Entry PACKAGE_NAME = 'datefield'.freeze def self.package_name PACKAGE_NAME diff --git a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb index 8c9e0bd683..c4b8240c04 100644 --- a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb +++ b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb @@ -18,7 +18,7 @@ TkPackage.require('ipentry') module Tk module Tcllib - class IP_Entry < TkEntry + class IP_Entry < Tk::Entry PACKAGE_NAME = 'ipentry'.freeze def self.package_name PACKAGE_NAME diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb index f5f344ceb3..cde42c8a0a 100644 --- a/ext/tk/lib/tkextlib/tcllib/plotchart.rb +++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb @@ -225,7 +225,7 @@ module Tk::Tcllib::Plotchart end ############################ - class XYPlot < TkCanvas + class XYPlot < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -247,7 +247,7 @@ module Tk::Tcllib::Plotchart @xaxis = args.shift @yaxis = args.shift - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -337,7 +337,7 @@ module Tk::Tcllib::Plotchart end ############################ - class PolarPlot < TkCanvas + class PolarPlot < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -356,7 +356,7 @@ module Tk::Tcllib::Plotchart @radius_data = args.shift - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -395,7 +395,7 @@ module Tk::Tcllib::Plotchart Polarplot = PolarPlot ############################ - class IsometricPlot < TkCanvas + class IsometricPlot < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -430,7 +430,7 @@ module Tk::Tcllib::Plotchart @stepsize = args.shift end - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -475,7 +475,7 @@ module Tk::Tcllib::Plotchart Isometricplot = IsometricPlot ############################ - class Plot3D < TkCanvas + class Plot3D < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -500,7 +500,7 @@ module Tk::Tcllib::Plotchart @yaxis = args.shift @zaxis = args.shift - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -557,7 +557,7 @@ module Tk::Tcllib::Plotchart end ############################ - class Piechart < TkCanvas + class Piechart < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -566,7 +566,7 @@ module Tk::Tcllib::Plotchart ].freeze def initialize(*args) # args := ([parent] [, keys]) - if args[0].kind_of?(TkCanvas) + if args[0].kind_of?(Tk::Canvas) parent = args.shift @path = parent.path else @@ -588,7 +588,7 @@ module Tk::Tcllib::Plotchart end ############################ - class Barchart < TkCanvas + class Barchart < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -626,7 +626,7 @@ module Tk::Tcllib::Plotchart @series_size = args.shift end - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -672,7 +672,7 @@ module Tk::Tcllib::Plotchart end ############################ - class Timechart < TkCanvas + class Timechart < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -699,7 +699,7 @@ module Tk::Tcllib::Plotchart @time_end = args.shift @items = args.shift - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -733,7 +733,7 @@ module Tk::Tcllib::Plotchart end ############################ - class Gnattchart < TkCanvas + class Gnattchart < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -772,7 +772,7 @@ module Tk::Tcllib::Plotchart @text_width = None end - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb index 7ed33b03e8..b527935a60 100644 --- a/ext/tk/lib/tkextlib/tile.rb +++ b/ext/tk/lib/tkextlib/tile.rb @@ -4,6 +4,7 @@ # require 'tk' +require 'tk/ttk_selector' # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' @@ -262,6 +263,9 @@ module Tk autoload :TSquare, 'tkextlib/tile/tsquare' autoload :Square, 'tkextlib/tile/tsquare' + autoload :SizeGrip, 'tkextlib/tile/sizegrip' + autoload :Sizegrip, 'tkextlib/tile/sizegrip' + autoload :Treeview, 'tkextlib/tile/treeview' autoload :Style, 'tkextlib/tile/style' diff --git a/ext/tk/lib/tkextlib/tile/sizegrip.rb b/ext/tk/lib/tkextlib/tile/sizegrip.rb index ea796583b0..c5068919a4 100644 --- a/ext/tk/lib/tkextlib/tile/sizegrip.rb +++ b/ext/tk/lib/tkextlib/tile/sizegrip.rb @@ -9,9 +9,13 @@ module Tk module Tile class SizeGrip < TkWindow end + Sizegrip = SizeGrip end end +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Sizegrip, :TkSizegrip, :TkSizeGrip) + + class Tk::Tile::SizeGrip < TkWindow include Tk::Tile::TileWidget diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb index b319d24d54..e01011cb21 100644 --- a/ext/tk/lib/tkextlib/tile/style.rb +++ b/ext/tk/lib/tkextlib/tile/style.rb @@ -52,11 +52,29 @@ class << Tk::Tile::Style style = '.' unless style if keys && keys != None - tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys)) + if keys.kind_of?(Hash) + tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys)) + else + simplelist(tk_call(TkCommandNames[0], 'map', style, '-' << keys.to_s)) + end else - tk_call(TkCommandNames[0], 'map', style) + ret = {} + Hash[*(simplelist(tk_call(TkCommandNames[0], 'map', style)))].each{|k, v| + ret[k[1..-1]] = list(v) + } + ret end end + alias map_configure map + + def map_configinfo(style=nil, key=None) + style = '.' unless style + map(style, key) + end + + def map_default_configinfo(key=None) + map('.', key) + end def lookup(style, opt, state=None, fallback_value=None) tk_call(TkCommandNames[0], 'lookup', style, @@ -92,16 +110,20 @@ class << Tk::Tile::Style end def theme_create(name, keys=nil) + name = name.to_s if keys && keys != None tk_call(TkCommandNames[0], 'theme', 'create', name, *hash_kv(keys)) else tk_call(TkCommandNames[0], 'theme', 'create', name) end + name end def theme_settings(name, cmd=nil, &b) + name = name.to_s cmd = Proc.new(&b) if !cmd && b tk_call(TkCommandNames[0], 'theme', 'settings', name, cmd) + name end def theme_names() @@ -109,6 +131,8 @@ class << Tk::Tile::Style end def theme_use(name) + name = name.to_s tk_call(TkCommandNames[0], 'theme', 'use', name) + name end end diff --git a/ext/tk/lib/tkextlib/tile/tbutton.rb b/ext/tk/lib/tkextlib/tile/tbutton.rb index 1142a27100..5d7db10fe9 100644 --- a/ext/tk/lib/tkextlib/tile/tbutton.rb +++ b/ext/tk/lib/tkextlib/tile/tbutton.rb @@ -7,13 +7,16 @@ require 'tkextlib/tile.rb' module Tk module Tile - class TButton < TkButton + class TButton < Tk::Button end Button = TButton end end -class Tk::Tile::TButton < TkButton +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Button, :TkButton) + + +class Tk::Tile::TButton < Tk::Button include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE diff --git a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb index fce799683d..172225fcec 100644 --- a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb +++ b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb @@ -7,7 +7,7 @@ require 'tkextlib/tile.rb' module Tk module Tile - class TCheckButton < TkCheckButton + class TCheckButton < Tk::CheckButton end TCheckbutton = TCheckButton CheckButton = TCheckButton @@ -15,7 +15,11 @@ module Tk end end -class Tk::Tile::TCheckButton < TkCheckButton +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Checkbutton, + :TkCheckbutton, :TkCheckButton) + + +class Tk::Tile::TCheckButton < Tk::CheckButton include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE diff --git a/ext/tk/lib/tkextlib/tile/tcombobox.rb b/ext/tk/lib/tkextlib/tile/tcombobox.rb index e8e042fbd9..b64372f1c9 100644 --- a/ext/tk/lib/tkextlib/tile/tcombobox.rb +++ b/ext/tk/lib/tkextlib/tile/tcombobox.rb @@ -13,6 +13,9 @@ module Tk end end +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Combobox, :TkCombobox) + + class Tk::Tile::TCombobox < Tk::Tile::TEntry include Tk::Tile::TileWidget diff --git a/ext/tk/lib/tkextlib/tile/tentry.rb b/ext/tk/lib/tkextlib/tile/tentry.rb index 4d57ce7756..4b221fcb88 100644 --- a/ext/tk/lib/tkextlib/tile/tentry.rb +++ b/ext/tk/lib/tkextlib/tile/tentry.rb @@ -7,13 +7,16 @@ require 'tkextlib/tile.rb' module Tk module Tile - class TEntry < TkEntry + class TEntry < Tk::Entry end Entry = TEntry end end -class Tk::Tile::TEntry < TkEntry +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Entry, :TkEntry) + + +class Tk::Tile::TEntry < Tk::Entry include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE diff --git a/ext/tk/lib/tkextlib/tile/tframe.rb b/ext/tk/lib/tkextlib/tile/tframe.rb index 691c9c42af..3b5f98bb6e 100644 --- a/ext/tk/lib/tkextlib/tile/tframe.rb +++ b/ext/tk/lib/tkextlib/tile/tframe.rb @@ -7,13 +7,16 @@ require 'tkextlib/tile.rb' module Tk module Tile - class TFrame < TkFrame + class TFrame < Tk::Frame end Frame = TFrame end end -class Tk::Tile::TFrame < TkFrame +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Frame, :TkFrame) + + +class Tk::Tile::TFrame < Tk::Frame include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE diff --git a/ext/tk/lib/tkextlib/tile/tlabel.rb b/ext/tk/lib/tkextlib/tile/tlabel.rb index 4111d1906a..7d074d3842 100644 --- a/ext/tk/lib/tkextlib/tile/tlabel.rb +++ b/ext/tk/lib/tkextlib/tile/tlabel.rb @@ -7,13 +7,16 @@ require 'tkextlib/tile.rb' module Tk module Tile - class TLabel < TkLabel + class TLabel < Tk::Label end Label = TLabel end end -class Tk::Tile::TLabel < TkLabel +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Label, :TkLabel) + + +class Tk::Tile::TLabel < Tk::Label include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE diff --git a/ext/tk/lib/tkextlib/tile/tlabelframe.rb b/ext/tk/lib/tkextlib/tile/tlabelframe.rb index 8981232b25..cff66d8658 100644 --- a/ext/tk/lib/tkextlib/tile/tlabelframe.rb +++ b/ext/tk/lib/tkextlib/tile/tlabelframe.rb @@ -9,10 +9,16 @@ module Tk module Tile class TLabelframe < Tk::Tile::TFrame end - Labelframe = TLabelframe + TLabelFrame = TLabelframe + Labelframe = TLabelframe + LabelFrame = TLabelframe end end +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Labelframe, + :TkLabelframe, :TkLabelFrame) + + class Tk::Tile::TLabelframe < Tk::Tile::TFrame include Tk::Tile::TileWidget diff --git a/ext/tk/lib/tkextlib/tile/tmenubutton.rb b/ext/tk/lib/tkextlib/tile/tmenubutton.rb index 4b81fa1c81..7c6ab28e52 100644 --- a/ext/tk/lib/tkextlib/tile/tmenubutton.rb +++ b/ext/tk/lib/tkextlib/tile/tmenubutton.rb @@ -7,13 +7,19 @@ require 'tkextlib/tile.rb' module Tk module Tile - class TMenubutton < TkMenubutton + class TMenubutton < Tk::Menubutton end - Menubutton = TMenubutton + TMenuButton = TMenubutton + Menubutton = TMenubutton + MenuButton = TMenubutton end end -class Tk::Tile::TMenubutton < TkMenubutton +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Menubutton, + :TkMenubutton, :TkMenuButton) + + +class Tk::Tile::TMenubutton < Tk::Menubutton include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE diff --git a/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ext/tk/lib/tkextlib/tile/tnotebook.rb index a928e64b61..76f225c579 100644 --- a/ext/tk/lib/tkextlib/tile/tnotebook.rb +++ b/ext/tk/lib/tkextlib/tile/tnotebook.rb @@ -13,6 +13,9 @@ module Tk end end +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Notebook, :TkNotebook) + + class Tk::Tile::TNotebook < TkWindow ################################ include TkItemConfigMethod diff --git a/ext/tk/lib/tkextlib/tile/tpaned.rb b/ext/tk/lib/tkextlib/tile/tpaned.rb index 2a2a25ea59..342b54d253 100644 --- a/ext/tk/lib/tkextlib/tile/tpaned.rb +++ b/ext/tk/lib/tkextlib/tile/tpaned.rb @@ -13,6 +13,10 @@ module Tk end end +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Panedwindow, + :TkPanedwindow, :TkPanedWindow) + + class Tk::Tile::TPaned < TkWindow include Tk::Tile::TileWidget diff --git a/ext/tk/lib/tkextlib/tile/tprogressbar.rb b/ext/tk/lib/tkextlib/tile/tprogressbar.rb index 36c1c75c23..f786d370dd 100644 --- a/ext/tk/lib/tkextlib/tile/tprogressbar.rb +++ b/ext/tk/lib/tkextlib/tile/tprogressbar.rb @@ -13,6 +13,9 @@ module Tk end end +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Progressbar, :TkProgressbar) + + class Tk::Tile::TProgressbar include Tk::Tile::TileWidget diff --git a/ext/tk/lib/tkextlib/tile/tradiobutton.rb b/ext/tk/lib/tkextlib/tile/tradiobutton.rb index e2f614cb97..d653a6d256 100644 --- a/ext/tk/lib/tkextlib/tile/tradiobutton.rb +++ b/ext/tk/lib/tkextlib/tile/tradiobutton.rb @@ -7,7 +7,7 @@ require 'tkextlib/tile.rb' module Tk module Tile - class TRadioButton < TkRadioButton + class TRadioButton < Tk::RadioButton end TRadiobutton = TRadioButton RadioButton = TRadioButton @@ -15,7 +15,11 @@ module Tk end end -class Tk::Tile::TRadioButton < TkRadioButton +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Radiobutton, + :TkRadiobutton, :TkRadioButton) + + +class Tk::Tile::TRadioButton < Tk::RadioButton include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE diff --git a/ext/tk/lib/tkextlib/tile/treeview.rb b/ext/tk/lib/tkextlib/tile/treeview.rb index 68e478896c..36496ee0b9 100644 --- a/ext/tk/lib/tkextlib/tile/treeview.rb +++ b/ext/tk/lib/tkextlib/tile/treeview.rb @@ -12,6 +12,9 @@ module Tk end end +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Treeview, :TkTreeview) + + module Tk::Tile::TreeviewConfig include TkItemConfigMethod diff --git a/ext/tk/lib/tkextlib/tile/tscale.rb b/ext/tk/lib/tkextlib/tile/tscale.rb index 7ec72e3515..2c46fd9bd4 100644 --- a/ext/tk/lib/tkextlib/tile/tscale.rb +++ b/ext/tk/lib/tkextlib/tile/tscale.rb @@ -7,7 +7,7 @@ require 'tkextlib/tile.rb' module Tk module Tile - class TScale < TkScale + class TScale < Tk::Scale end Scale = TScale @@ -17,7 +17,10 @@ module Tk end end -class Tk::Tile::TScale < TkScale +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scale, :TkScale) + + +class Tk::Tile::TScale < Tk::Scale include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE diff --git a/ext/tk/lib/tkextlib/tile/tscrollbar.rb b/ext/tk/lib/tkextlib/tile/tscrollbar.rb index 10b84e84a0..163b8f4713 100644 --- a/ext/tk/lib/tkextlib/tile/tscrollbar.rb +++ b/ext/tk/lib/tkextlib/tile/tscrollbar.rb @@ -7,13 +7,16 @@ require 'tkextlib/tile.rb' module Tk module Tile - class TScrollbar < TkScrollbar + class TScrollbar < Tk::Scrollbar end Scrollbar = TScrollbar end end -class Tk::Tile::TScrollbar < TkScrollbar +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scrollbar, :TkScrollbar) + + +class Tk::Tile::TScrollbar < Tk::Scrollbar include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE @@ -47,3 +50,5 @@ class Tk::Tile::YScrollbar < Tk::Tile::TScrollbar private :create_self end +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::XScrollbar, :TkXScrollbar) +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::YScrollbar, :TkYScrollbar) diff --git a/ext/tk/lib/tkextlib/tile/tseparator.rb b/ext/tk/lib/tkextlib/tile/tseparator.rb index ca731d4e5b..30fae2c525 100644 --- a/ext/tk/lib/tkextlib/tile/tseparator.rb +++ b/ext/tk/lib/tkextlib/tile/tseparator.rb @@ -13,6 +13,9 @@ module Tk end end +Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Separator, :TkSeparator) + + class Tk::Tile::TSeparator < TkWindow include Tk::Tile::TileWidget diff --git a/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/ext/tk/lib/tkextlib/tktrans/tktrans.rb index 665c57af0c..e051c09211 100644 --- a/ext/tk/lib/tkextlib/tktrans/tktrans.rb +++ b/ext/tk/lib/tkextlib/tktrans/tktrans.rb @@ -39,7 +39,7 @@ class TkWindow end end -class TkRoot +class Tk::Root undef tktrans_set_image, tktrans_get_image def tktrans_set_image(img) @@ -51,7 +51,7 @@ class TkRoot end end -class TkToplevel +class Tk::Toplevel undef tktrans_set_image, tktrans_get_image def tktrans_set_image(img) diff --git a/ext/tk/lib/tkextlib/vu/spinbox.rb b/ext/tk/lib/tkextlib/vu/spinbox.rb index b6499645a3..a7e40ea319 100644 --- a/ext/tk/lib/tkextlib/vu/spinbox.rb +++ b/ext/tk/lib/tkextlib/vu/spinbox.rb @@ -17,6 +17,6 @@ end module Tk module Vu - Spinbox = TkSpinbox + Spinbox = Tk::Spinbox end end |