1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.

* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets' 
  instate/state/identify method to avoid the conflict with standard
  widget options. Those methods are renamed to ttk_instate/ttk_state/
  ttk_identify (tile_instate/tile_state/tile_identify are available 
  too). Although I don't recommend, if you realy need old methods, 
  please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before 
  "require 'tkextlib/tile'".

* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
  is obsolete. It outputs warning. To control default widget set, 
  use "Tk.default_widget_set = :Ttk".

* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and 
  __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind 
  as module methods of TkConfigMethod. It may help users to wrap old 
  Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
  Ttk widgets don't have some options of standard widgets which are 
  control the view of widgets. When set ignore-mode true, configure 
  method tries to ignoure such unknown options with no exception. 
  Of course, it may raise other troubles on the GUI design. 
  So, those are a little danger methods. 

* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ 
  method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method 
  are defind as module methods of TkItemConfigMethod as the same 
  purpose as TkConfigMethod's ones.

* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for 
  wrapping old Ruby/Tk scripts (which use standard widgets) to use 
  Ttk (Tile) widgets as default.

* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state 
  method instead of instate/state method.

* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
  ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's  
  are replaced to "instance_exec(self)".

* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not 
  a character code on Ruby1.9).

* ext/tk/lib/tk/variable.rb: support new style of operation argument 
  on Tcl/Tk's 'trace' command for variables. 

* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix

* ext/tk/sammple/demos-jp/textpeer.rb, 
  ext/tk/sammple/demos-en/textpeer.rb: new widget demo.

* ext/tk/tcltklib.c: decrase SEGV troubles (probably)

* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9

* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)

* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command 
  to make Tcl/Tk theme sources (based on different version of Tile 
  extension) available. 
  (Tk::Tile::__define_LoadImages_proc_for_comaptibility__)

* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
  (Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets 
  as toplevel widgets.

* ext/tk/lib/tkextlib/tile/style.rb: ditto.
  (Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)

* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get 
  properties as a hash. metrics_hash method returns a boolean value 
  for 'fixed' option. But metrics method returns numeric value 
  (0 or 1) for 'fixed' option, because of backward compatibility. 

* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.

* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep 
  doesn't block the eventloop. It will be better to use the method 
  in event callbacks.

* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2008-03-29 05:25:12 +00:00
parent b62af05a98
commit 3024ffdc3a
121 changed files with 7879 additions and 2218 deletions

View file

@ -40,7 +40,13 @@ class Tk::BWidget::ButtonBox
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
@ -62,7 +68,13 @@ class Tk::BWidget::ButtonBox
def insert(idx, keys={}, &b)
win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -25,7 +25,13 @@ class Tk::BWidget::ComboBox
def get_listbox(&b)
win = window(tk_send_without_enc('getlistbox'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -112,19 +112,37 @@ class Tk::BWidget::Dialog
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
def get_frame(&b)
win = window(tk_send('getframe'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
def get_buttonbox(&b)
win = window(@path + '.bbox')
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -40,7 +40,13 @@ class Tk::BWidget::LabelFrame
end
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
end

View file

@ -211,14 +211,26 @@ class Tk::BWidget::ListBox::Item
include TkTreatTagFont
ListItem_TBL = TkCore::INTERP.create_table
ListItem_ID = ['bw:item'.freeze, '00000'.taint].freeze
TkCore::INTERP.init_ip_env{ ListItem_TBL.clear }
(ListItem_ID = ['bw:item'.freeze, '00000'.taint]).instance_eval{
@mutex = Mutex.new
def mutex; @mutex; end
freeze
}
TkCore::INTERP.init_ip_env{
ListItem_TBL.mutex.synchronize{ ListItem_TBL.clear }
}
def self.id2obj(lbox, id)
lpath = lbox.path
return id unless ListItem_TBL[lpath]
ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
ListItem_TBL.mutex.synchronize{
if ListItem_TBL[lpath]
ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
else
id
end
}
end
def initialize(lbox, *args)
@ -250,13 +262,17 @@ class Tk::BWidget::ListBox::Item
if keys.key?('itemname')
@path = @id = keys.delete('itemname')
else
@path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
ListItem_ID[1].succ!
ListItem_ID.mutex.synchronize{
@path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
ListItem_ID[1].succ!
}
end
ListItem_TBL[@id] = self
ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
ListItem_TBL[@lpath][@id] = self
ListItem_TBL.mutex.synchronize{
ListItem_TBL[@id] = self
ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
ListItem_TBL[@lpath][@id] = self
}
@listbox.insert(index, @id, keys)
end

View file

@ -41,37 +41,73 @@ class Tk::BWidget::MainFrame
def add_indicator(keys={}, &b)
win = window(tk_send('addindicator', *hash_kv(keys)))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
def add_toolbar(&b)
win = window(tk_send('addtoolbar'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
def get_frame(&b)
win = window(tk_send('getframe'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
def get_indicator(idx, &b)
win = window(tk_send('getindicator', idx))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
def get_menu(menu_id, &b)
win = window(tk_send('getmenu', menu_id))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
def get_toolbar(idx, &b)
win = window(tk_send('gettoolbar', idx))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -173,6 +173,9 @@ class Tk::BWidget::MessageDlg
end
def create
num_or_str(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
# return the index of the pressed button, or nil if it is destroyed
ret = num_or_str(tk_call(self.class::TkCommandNames[0],
@path, *hash_kv(@keys)))
(ret < 0)? nil: ret
end
end

View file

@ -89,7 +89,13 @@ class Tk::BWidget::NoteBook
def add(page, &b)
win = window(tk_send('add', tagid(page)))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
@ -105,7 +111,13 @@ class Tk::BWidget::NoteBook
def get_frame(page, &b)
win = window(tk_send('getframe', tagid(page)))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
@ -115,7 +127,13 @@ class Tk::BWidget::NoteBook
def insert(index, page, keys={}, &b)
win = window(tk_send('insert', index, tagid(page), *hash_kv(keys)))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -26,7 +26,13 @@ class Tk::BWidget::PagesManager
def add(page, &b)
win = window(tk_send('add', tagid(page)))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
@ -42,7 +48,13 @@ class Tk::BWidget::PagesManager
def get_frame(page, &b)
win = window(tk_send('getframe', tagid(page)))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -25,7 +25,13 @@ class Tk::BWidget::PanedWindow
def get_frame(idx, &b)
win = window(tk_send_without_enc('getframe', idx))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
end

View file

@ -36,7 +36,13 @@ class Tk::BWidget::PanelFrame
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -51,4 +51,8 @@ class Tk::BWidget::ProgressDlg
def value= (val)
@keys['variable'].value = val
end
def create
window(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
end
end

View file

@ -23,7 +23,13 @@ class Tk::BWidget::ScrollableFrame
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -21,7 +21,13 @@ class Tk::BWidget::ScrolledWindow
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -10,6 +10,11 @@ require 'tkextlib/bwidget/messagedlg'
module Tk
module BWidget
class SelectColor < Tk::BWidget::MessageDlg
class Dialog < Tk::BWidget::SelectColor
end
class Menubutton < Tk::Menubutton
end
MenuButton = Menubutton
end
end
end
@ -43,3 +48,26 @@ class Tk::BWidget::SelectColor
tk_call('SelectColor::setcolor', idx, color)
end
end
class Tk::BWidget::SelectColor::Dialog
def create_self(keys)
super(keys)
@keys['type'] = 'dialog'
end
def create
@keys['type'] = 'dialog' # 'dialog' type returns color
tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
@path, *hash_kv(@keys))
end
end
class Tk::BWidget::SelectColor::Menubutton
def create_self(keys)
keys = {} unless keys
keys = _symbolkey2str(keys)
keys['type'] = 'menubutton' # 'toolbar' type returns widget path
window(tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
@path, *hash_kv(keys)))
end
end

View file

@ -66,7 +66,7 @@ class Tk::BWidget::SelectFont::Dialog
end
def create
@keys['type'] = 'dialog'
@keys['type'] = 'dialog' # 'dialog' type returns font name
tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(@keys))
end
end
@ -79,7 +79,8 @@ class Tk::BWidget::SelectFont::Toolbar
def create_self(keys)
keys = {} unless keys
keys = _symbolkey2str(keys)
keys['type'] = 'toolbar'
tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(keys))
keys['type'] = 'toolbar' # 'toolbar' type returns widget path
window(tk_call(Tk::BWidget::SelectFont::TkCommandNames[0],
@path, *hash_kv(keys)))
end
end

View file

@ -36,7 +36,13 @@ class Tk::BWidget::StatusBar
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end

View file

@ -21,7 +21,13 @@ class Tk::BWidget::TitleFrame
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end
end

View file

@ -263,14 +263,26 @@ class Tk::BWidget::Tree::Node
include TkTreatTagFont
TreeNode_TBL = TkCore::INTERP.create_table
TreeNode_ID = ['bw:node'.freeze, '00000'.taint].freeze
TkCore::INTERP.init_ip_env{ TreeNode_TBL.clear }
(TreeNode_ID = ['bw:node'.freeze, '00000'.taint]).instance_eval{
@mutex = Mutex.new
def mutex; @mutex; end
freeze
}
TkCore::INTERP.init_ip_env{
TreeNode_TBL.mutex.synchronize{ TreeNode_TBL.clear }
}
def self.id2obj(tree, id)
tpath = tree.path
return id unless TreeNode_TBL[tpath]
TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
TreeNode_TBL.mutex.synchronize{
if TreeNode_TBL[tpath]
TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
else
id
end
}
end
def initialize(tree, *args)
@ -311,13 +323,17 @@ class Tk::BWidget::Tree::Node
if keys.key?('nodename')
@path = @id = keys.delete('nodename')
else
@path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
TreeNode_ID[1].succ!
TreeNode_ID.mutex.synchronize{
@path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
TreeNode_ID[1].succ!
}
end
TreeNode_TBL[@id] = self
TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
TreeNode_TBL[@tpath][@id] = self
TreeNode_TBL.mutex.synchronize{
TreeNode_TBL[@id] = self
TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
TreeNode_TBL[@tpath][@id] = self
}
@tree.insert(index, parent, @id, keys)
end

View file

@ -43,7 +43,13 @@ module Tk::BWidget::Widget
def self.create(klass, path, rename=None, &b)
win = window(tk_call('Widget::create', klass, path, rename))
win.instance_eval(&b) if b
if b
if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
win.instance_exec(self, &b)
else
win.instance_eval(&b)
end
end
win
end