diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-21 08:57:35 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-21 08:57:35 +0000 |
commit | 59a07a0690ea964aa1f6d2f250a9ef176cac49ab (patch) | |
tree | b75ba8b89ab8151fdcb14b9b358bb18c88afbc41 /ext/tk/lib/tkextlib | |
parent | d66a188c4a1aa269be94c5707df3aeff185dd076 (diff) |
Ruby/Tk :: provisional support on Ruby-VM and Tcl/Tk8.5.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib')
-rw-r--r-- | ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb | 5 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile.rb | 81 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/style.rb | 37 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tpaned.rb | 8 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tscrollbar.rb | 19 |
5 files changed, 113 insertions, 37 deletions
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb index fdafc8dc7f..12fc453e26 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 RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!!! + return txt.length + end + ########################### + if $KCODE !~ /n/i return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length end diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb index acc7bebe4e..7ed33b03e8 100644 --- a/ext/tk/lib/tkextlib/tile.rb +++ b/ext/tk/lib/tkextlib/tile.rb @@ -15,33 +15,69 @@ require 'tkextlib/tile/setup.rb' # TkPackage.require('tile', '0.4') # TkPackage.require('tile', '0.6') # TkPackage.require('tile', '0.7') -verstr = TkPackage.require('tile') +if Tk::TK_MAJOR_VERSION > 8 || + (Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION >= 5) + begin + verstr = TkPackage.require('Ttk') + rescue RuntimeError + verstr = TkPackage.require('tile') + end +else + verstr = TkPackage.require('tile') +end + ver = verstr.split('.') -if ver[0].to_i == 0 && ver[1].to_i <= 4 - # version 0.4 or former - module Tk - module Tile - USE_TILE_NAMESPACE = true - USE_TTK_NAMESPACE = false - TILE_SPEC_VERSION_ID = 0 +if ver[0].to_i == 0 + # Tile extension package + if ver[1].to_i <= 4 + # version 0.4 or former + module Tk + module Tile + USE_TILE_NAMESPACE = true + USE_TTK_NAMESPACE = false + TILE_SPEC_VERSION_ID = 0 + end end - end -elsif ver[0].to_i == 0 && ver[1].to_i <= 6 - # version 0.5 -- version 0.6 - module Tk - module Tile - USE_TILE_NAMESPACE = true - USE_TTK_NAMESPACE = true - TILE_SPEC_VERSION_ID = 5 + elsif ver[1].to_i <= 6 + # version 0.5 -- version 0.6 + module Tk + module Tile + USE_TILE_NAMESPACE = true + USE_TTK_NAMESPACE = true + TILE_SPEC_VERSION_ID = 5 + end + end + elsif ver[1].to_i <= 7 + module Tk + module Tile + USE_TILE_NAMESPACE = false + USE_TTK_NAMESPACE = true + TILE_SPEC_VERSION_ID = 7 + end + end + else + # version 0.8 or later + module Tk + module Tile + USE_TILE_NAMESPACE = false + USE_TTK_NAMESPACE = true + TILE_SPEC_VERSION_ID = 8 + end end end + + module Tk::Tile + PACKAGE_NAME = 'tile'.freeze + end else - # version 0.7 or later + # Ttk package merged Tcl/Tk core (Tcl/Tk 8.5+) module Tk module Tile USE_TILE_NAMESPACE = false USE_TTK_NAMESPACE = true - TILE_SPEC_VERSION_ID = 7 + TILE_SPEC_VERSION_ID = 8 + + PACKAGE_NAME = 'Ttk'.freeze end end end @@ -51,14 +87,13 @@ module Tk module Tile TkComm::TkExtlibAutoloadModule.unshift(self) - PACKAGE_NAME = 'tile'.freeze def self.package_name PACKAGE_NAME end def self.package_version begin - TkPackage.require('tile') + TkPackage.require(PACKAGE_NAME) rescue '' end @@ -200,6 +235,8 @@ module Tk autoload :TPaned, 'tkextlib/tile/tpaned' autoload :Paned, 'tkextlib/tile/tpaned' + autoload :PanedWindow, 'tkextlib/tile/tpaned' + autoload :Panedwindow, 'tkextlib/tile/tpaned' autoload :TProgressbar, 'tkextlib/tile/tprogressbar' autoload :Progressbar, 'tkextlib/tile/tprogressbar' @@ -216,6 +253,8 @@ module Tk autoload :TScrollbar, 'tkextlib/tile/tscrollbar' autoload :Scrollbar, 'tkextlib/tile/tscrollbar' + autoload :XScrollbar, 'tkextlib/tile/tscrollbar' + autoload :YScrollbar, 'tkextlib/tile/tscrollbar' autoload :TSeparator, 'tkextlib/tile/tseparator' autoload :Separator, 'tkextlib/tile/tseparator' @@ -228,3 +267,5 @@ module Tk autoload :Style, 'tkextlib/tile/style' end end + +Ttk = Tk::Tile diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb index 59bc4b0d78..b319d24d54 100644 --- a/ext/tk/lib/tkextlib/tile/style.rb +++ b/ext/tk/lib/tkextlib/tile/style.rb @@ -17,6 +17,12 @@ module Tk::Tile::Style end class << Tk::Tile::Style + if Tk::Tile::TILE_SPEC_VERSION_ID < 8 + TkCommandNames = ['style'.freeze].freeze + else + TkCommandNames = ['::ttk::style'.freeze].freeze + end + def configure(style=nil, keys=nil) if style.kind_of?(Hash) keys = style @@ -31,9 +37,9 @@ class << Tk::Tile::Style end if keys && keys != None - tk_call('style', sub_cmd, style, *hash_kv(keys)) + tk_call(TkCommandNames[0], sub_cmd, style, *hash_kv(keys)) else - tk_call('style', sub_cmd, style) + tk_call(TkCommandNames[0], sub_cmd, style) end end alias default configure @@ -46,14 +52,15 @@ class << Tk::Tile::Style style = '.' unless style if keys && keys != None - tk_call('style', 'map', style, *hash_kv(keys)) + tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys)) else - tk_call('style', 'map', style) + tk_call(TkCommandNames[0], 'map', style) end end def lookup(style, opt, state=None, fallback_value=None) - tk_call('style', 'lookup', style, '-' << opt.to_s, state, fallback_value) + tk_call(TkCommandNames[0], 'lookup', style, + '-' << opt.to_s, state, fallback_value) end include Tk::Tile::ParseStyleLayout @@ -66,42 +73,42 @@ class << Tk::Tile::Style style = '.' unless style if spec - tk_call('style', 'layout', style, spec) + tk_call(TkCommandNames[0], 'layout', style, spec) else - _style_layout(list(tk_call('style', 'layout', style))) + _style_layout(list(tk_call(TkCommandNames[0], 'layout', style))) end end def element_create(name, type, *args) - tk_call('style', 'element', 'create', name, type, *args) + tk_call(TkCommandNames[0], 'element', 'create', name, type, *args) end def element_names() - list(tk_call('style', 'element', 'names')) + list(tk_call(TkCommandNames[0], 'element', 'names')) end def element_options(elem) - simplelist(tk_call('style', 'element', 'options', elem)) + simplelist(tk_call(TkCommandNames[0], 'element', 'options', elem)) end def theme_create(name, keys=nil) if keys && keys != None - tk_call('style', 'theme', 'create', name, *hash_kv(keys)) + tk_call(TkCommandNames[0], 'theme', 'create', name, *hash_kv(keys)) else - tk_call('style', 'theme', 'create', name) + tk_call(TkCommandNames[0], 'theme', 'create', name) end end def theme_settings(name, cmd=nil, &b) cmd = Proc.new(&b) if !cmd && b - tk_call('style', 'theme', 'settings', name, cmd) + tk_call(TkCommandNames[0], 'theme', 'settings', name, cmd) end def theme_names() - list(tk_call('style', 'theme', 'names')) + list(tk_call(TkCommandNames[0], 'theme', 'names')) end def theme_use(name) - tk_call('style', 'theme', 'use', name) + tk_call(TkCommandNames[0], 'theme', 'use', name) end end diff --git a/ext/tk/lib/tkextlib/tile/tpaned.rb b/ext/tk/lib/tkextlib/tile/tpaned.rb index 11178b19d3..2a2a25ea59 100644 --- a/ext/tk/lib/tkextlib/tile/tpaned.rb +++ b/ext/tk/lib/tkextlib/tile/tpaned.rb @@ -9,7 +9,7 @@ module Tk module Tile class TPaned < TkWindow end - Paned = TPaned + PanedWindow = Panedwindow = Paned = TPaned end end @@ -17,7 +17,11 @@ class Tk::Tile::TPaned < TkWindow include Tk::Tile::TileWidget if Tk::Tile::USE_TTK_NAMESPACE - TkCommandNames = ['::ttk::paned'.freeze].freeze + if Tk::Tile::TILE_SPEC_VERSION_ID < 8 + TkCommandNames = ['::ttk::paned'.freeze].freeze + else + TkCommandNames = ['::ttk::panedwindow'.freeze].freeze + end else TkCommandNames = ['::tpaned'.freeze].freeze end diff --git a/ext/tk/lib/tkextlib/tile/tscrollbar.rb b/ext/tk/lib/tkextlib/tile/tscrollbar.rb index bd49ae18e3..10b84e84a0 100644 --- a/ext/tk/lib/tkextlib/tile/tscrollbar.rb +++ b/ext/tk/lib/tkextlib/tile/tscrollbar.rb @@ -28,3 +28,22 @@ class Tk::Tile::TScrollbar < TkScrollbar [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.') end end + +class Tk::Tile::XScrollbar < Tk::Tile::TScrollbar + def create_self(keys) + keys = {} unless keys + keys['orient'] = 'horizontal' + super(keys) + end + private :create_self +end + +class Tk::Tile::YScrollbar < Tk::Tile::TScrollbar + def create_self(keys) + keys = {} unless keys + keys['orient'] = 'vertical' + super(keys) + end + private :create_self +end + |