Skip to content

Commit

Permalink
* (IMPORTANT BUG FIX) scan of event keywords doesn't work on recent
Browse files Browse the repository at this point in the history
  versions of Tck/Tk
* (bug fix) initialize error of instance variable on TkComposite
* (bug fix) initialize error on encoding-system on MultiTkIp
* (bug fix) trouble on destroying widgets
* (new) add JP and EN version of Ruby/Tk widget demos


git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nagai committed Jul 31, 2003
1 parent 13fc32a commit 9521e7d
Show file tree
Hide file tree
Showing 141 changed files with 19,495 additions and 25 deletions.
43 changes: 43 additions & 0 deletions ext/tk/lib/multi-tk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ def _create_receiver_and_watchdog()

@@DEFAULT_MASTER = self.allocate
@@DEFAULT_MASTER.instance_eval{
@encoding = []

@tk_windows = {}

@tk_table_list = []
Expand Down Expand Up @@ -433,6 +435,8 @@ def initialize(master, safeip=true, keys={})
fail ArgumentError, "expecting a Hash object for the 2nd argument"
end

@encoding = []

@tk_windows = {}

@tk_table_list = []
Expand Down Expand Up @@ -792,6 +796,10 @@ def get_eventloop_weight

# class methods to delegate to TclTkIp
class << MultiTkIp
def method_missing(id, *args)
__getip.send(id, *args)
end

def make_safe
__getip.make_safe
end
Expand Down Expand Up @@ -1141,6 +1149,41 @@ def self.transfer_stdio(dist, src = '')
end
end


# encoding convert
class MultiTkIp
# from tkencoding.rb by ttate@jaist.ac.jp
alias __eval _eval
alias __invoke _invoke
private :__eval
private :__invoke

def encoding
@encoding[0]
end
def encoding=(enc)
@encoding[0] = enc
end

def _eval(cmd)
if @encoding[0] != nil
_fromUTF8(__eval(_toUTF8(cmd, @encoding[0])), @encoding[0])
else
__eval(cmd)
end
end

def _invoke(*cmds)
if defined?(@encoding[0]) && @encoding[0] != nil
cmds = cmds.collect{|cmd| _toUTF8(cmd, @encoding[0])}
_fromUTF8(__invoke(*cmds), @encoding[0])
else
__invoke(*cmds)
end
end
end


# end of MultiTkIp definition

MultiTkIp.freeze # defend against modification
Expand Down
55 changes: 30 additions & 25 deletions ext/tk/lib/tk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,13 @@ def self.scan_args(arg_str, arg_val)
if num = EV_KEY.index($1)
case EV_TYPE[num]
when ?n
arg_cnv << TkComm::number(arg_val[idx])
begin
val = TkComm::number(arg_val[idx])
rescue ArgumentError
# ignore --> no convert
val = TkComm::string(arg_val[idx])
end
arg_cnv << val
when ?s
arg_cnv << TkComm::string(arg_val[idx])
when ?b
Expand Down Expand Up @@ -3748,24 +3754,28 @@ def colormodel model=None
self
end

def _destroy_children
def destroy
super
children = []
rexp = /^#{self.path}\.[^.]+$/
TkCore::INTERP.tk_windows.each{|path, obj|
children << obj if path =~ rexp
children << [path, obj] if path =~ rexp
}
children.each{|obj| obj.destroy}
end
private :_destroy_children

def destroy
super
_destroy_children
if defined?(@cmdtbl)
for id in @cmdtbl
uninstall_cmd id
end
end

children.each{|path, obj|
if defined?(@cmdtbl)
for id in @cmdtbl
uninstall_cmd id
end
end
TkCore::INTERP.tk_windows.delete(path)
}

tk_call 'destroy', epath
uninstall_win
end
Expand Down Expand Up @@ -5020,6 +5030,9 @@ module TkComposite
extend Tk

def initialize(parent=nil, *args)
@delegates = {}
@delegates['DEFAULT'] = @frame

if parent.kind_of? Hash
keys = _symbolkey2str(parent)
parent = keys['parent']
Expand All @@ -5031,10 +5044,6 @@ def initialize(parent=nil, *args)
@path = @epath = @frame.path
initialize_composite(*args)
end
unless defined? @delegates
@delegates = {}
@delegates['DEFAULT'] = @frame
end
end

def epath
Expand Down Expand Up @@ -5148,21 +5157,17 @@ def append(data, keys=nil)

# widget_destroy_hook
require 'tkvirtevent'
TkBindTag::ALL.bind(TkVirtualEvent.new('Destroy'), proc{|widget|
if widget.respond_to?(:path)
w = widget.path
else
w = widget.to_s
end
if widget.respond_to?(:__destroy_hook__)
begin
if TkCore::INTERP._invoke('winfo','exist',w) == '1'
TkBindTag::ALL.bind(TkVirtualEvent.new('Destroy'), proc{|xpath|
path = xpath[1..-1]
if (widget = TkCore::INTERP.tk_windows[path])
if widget.respond_to?(:__destroy_hook__)
begin
widget.__destroy_hook__
rescue Exception
end
rescue Exception
end
end
}, '%W')
}, 'x%W')

# autoload
autoload :TkCanvas, 'tkcanvas'
Expand Down
64 changes: 64 additions & 0 deletions ext/tk/sample/demos-en/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
2002-08-29 16:30 matt

* ChangeLog: ChangeLog is auto-generated *from* CVS log.

2002-08-29 16:27 matt

* ChangeLog.prev: [no log message]

2002-08-28 18:07 matt

* browse1, browse2, hello, ixset, rmt, rolodex, rolodex-j, square,
tcolor, timer, widget: Changed #! lines to the slightly more
portable '#!/usr/bin/env ruby'.

2002-08-28 17:56 matt

* icon.rb, items.rb, label.rb, menu.rb, ruler.rb: Changed bitmap
file extensions from .bmp to .xbm.

2002-08-28 17:55 matt

* images/: face.bmp, face.xbm, flagdown.bmp, flagdown.xbm,
flagup.bmp, flagup.xbm, gray25.bmp, gray25.xbm, letters.bmp,
letters.xbm, noletter.bmp, noletter.xbm, pattern.bmp, pattern.xbm:
Changed X bitmap file extensions from .bmp to the more intuitive
.xbm.

2002-08-28 17:35 matt

* bitmap.rb, colors.rb, cscroll.rb, ctext.rb, hello, ixset,
menubu.rb, patch_1.1c1, rmt, style.rb, timer, ChangeLog, README,
README.tkencoding, arrow.rb, bind.rb, browse1, browse2, button.rb,
check.rb, clrpick.rb, dialog1.rb, dialog2.rb, entry1.rb, entry2.rb,
filebox.rb, floor.rb, form.rb, hscale.rb, icon.rb, image1.rb,
image2.rb, items.rb, label.rb, menu.rb, msgbox.rb, plot.rb,
puzzle.rb, radio.rb, rolodex, rolodex-j, ruler.rb, sayings.rb,
search.rb, square, states.rb, tcolor, text.rb, tkencoding.rb,
twind.rb, vscale.rb, widget, doc.org/README, doc.org/README.JP,
doc.org/README.tk80, doc.org/license.terms,
doc.org/license.terms.tk80, images/earth.gif, images/earthris.gif,
images/face.bmp, images/flagdown.bmp, images/flagup.bmp,
images/gray25.bmp, images/grey.25, images/grey.5,
images/letters.bmp, images/noletter.bmp, images/pattern.bmp,
images/tcllogo.gif, images/teapot.ppm: Initial revision

2002-08-28 17:35 matt

* bitmap.rb, colors.rb, cscroll.rb, ctext.rb, hello, ixset,
menubu.rb, patch_1.1c1, rmt, style.rb, timer, ChangeLog, README,
README.tkencoding, arrow.rb, bind.rb, browse1, browse2, button.rb,
check.rb, clrpick.rb, dialog1.rb, dialog2.rb, entry1.rb, entry2.rb,
filebox.rb, floor.rb, form.rb, hscale.rb, icon.rb, image1.rb,
image2.rb, items.rb, label.rb, menu.rb, msgbox.rb, plot.rb,
puzzle.rb, radio.rb, rolodex, rolodex-j, ruler.rb, sayings.rb,
search.rb, square, states.rb, tcolor, text.rb, tkencoding.rb,
twind.rb, vscale.rb, widget, doc.org/README, doc.org/README.JP,
doc.org/README.tk80, doc.org/license.terms,
doc.org/license.terms.tk80, images/earth.gif, images/earthris.gif,
images/face.bmp, images/flagdown.bmp, images/flagup.bmp,
images/gray25.bmp, images/grey.25, images/grey.5,
images/letters.bmp, images/noletter.bmp, images/pattern.bmp,
images/tcllogo.gif, images/teapot.ppm: Taking over demo package
from Jonathan Conway.

9 changes: 9 additions & 0 deletions ext/tk/sample/demos-en/ChangeLog.prev
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
2001-07-26 <rise@leannan.knavery.net>

* Moved files to directory ruby-tk81-demos-english in tarball.

2001-07-26 <rise@knavery.net>

* Added test to widget and hello versus Tk::TCL_VERSION & Tk::JAPANIZED_TK (per Guy Decoux in [ruby-talk:18559]) before requiring tkencoding.rb.


138 changes: 138 additions & 0 deletions ext/tk/sample/demos-en/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
Current Maintainer:
Jonathan Conway
rise@knavery.net

Please direct all bug reports/requests/suggestions to the above
address.


Notes:

* The files hello and widget have been changed to test Tk::TCL_VERSION
and Tk::JAPANIZED_TK before requiring tkencoding.rb to prevent an
infinite loop. This test was taken from a message in
[ruby-talk:18559] by Guy Decoux.

* The .bmp files in the images directory are X bitmaps (i.e. XBM to many
graphics packages), not Windows bitmaps (.bmp). You will not be
able to use images exported by a graphics program as Windows
bitmaps with this demo collection nor will you be able to edit the
included images without setting the file type correctly.

-- Jonathan Conway, 2001-07-26


#------------------------------------------------------------------------------
# ==== Introduction. ====
#
# To create this version of the Ruby/Tk widget demo, I took the
# ruby-tk81-demos and removed all the Kanji strings and comments. I
# have tried to restore the original English strings and comments
# using the Tcl/Tk8.2.2 version of the widget demo.
#
# When I tried running the Kanji version, all I got was a mostly blank
# panel with a non-functional "File" button. I disovered that if all
# non-ASCII characters were replaced with blanks, then I could get the
# gutted stuff running.
#
# Since English Ruby/Tk documentation is lacking and I needed this
# code to see how it worked and to use as the basis of my try-it
# prototype (The Ruby Yielding Interactive Toolkit), plus the fact
# that no help was forthcoming for making the Kanji version work (plus
# the fact that I can't read Kanji anyway), I decided to embark on
# this English restoration project.
#
# Thanks to everyone who worked on the original Ruby/Tk widget demo
# (and the preceding Tcl/Tk version for that matter). The
# comparatively simple task of changing text strings and comments has
# made me appreciate the great amount of original work that went into
# this.
#
# -- Conrad Schneiker, 2000-07-23.
#------------------------------------------------------------------------------

#------------------------------------------------------------------------------
# ==== Known bugs. ====
#
# ^C-ing the demo gives Ruby interrupt and stack message; clean exit needed.
# Font settings don't work correctly.
# Dismissing the embedded windows demo (tkwind.rb) kills the widget demo.
# Rerunning the canvas item demo from the code widow get errors.
# The "press me" button in the canvas item demo doesn't time out.
# The simple 2 d plot starts up extremely slow compared to the Tcl version.
# The first item message on the icon menu on the menu and cascades demo doesn't work.
#------------------------------------------------------------------------------


###################### Original README ########################################

Ruby/Tk81 widget-demo 1999/08/13

��Φ��ü�����ʳظ����
�� <ttate@jaist.ac.jp>

Tcl/Tk8.1�Ǥ�unicode(UTF8)�����Ѥ��졢unicode���Ѵ����줿���ܸ�Ǥ����
Widget��ɽ�������뤳�Ȥ���ǽ�Ǥ����ܥ��������֤ˤϰ����˱ʰ椵���濴��
�ʤ��ƺ������줿Ruby/Tk�Υ���ץ�˽�����ä����ʲ��δĶ��ˤ����Ƥ�ư��
���ǧ������ΤǤ���

* ruby-1.3.7,ruby-1.4.0
* tcl8.1, tk8.1
* linux-2.2

Windows(Cygwin)�ˤ����ơ�����ץ��ư�����ˤ�ruby��-Ke�Ȥ������ץ�������
���Ƶ�ư��������ɤ������Ǥ���
�����󶡡����դ���
<eban@os.rim.or.jp>

----------------------------------------------------------------------------
Ruby/Tk widget-demo
version 1.1 ( 1998/07/24 )
�ʰ����ǽ���幩�� (nagai@ai.kyutech.ac.jp)

ɸ�����ۤ� Tcl/Tk ��ĥ�ѥå������������� Ruby (�ʲ� Ruby/Tk �ȸƤӤޤ�)
�Ǥϡ�Tk widget ���Ѥ��� GUI �κ�����Ԥ����Ȥ��Ǥ��ޤ����ºݤ� GUI �����
���Ƥ������ˤ��͡��ʼ��㤬����ץ�Ȥ���¸�ߤ���������ʤΤǤ�����Ruby/Tk
�ˤϤ��Τ褦��Ŭ���ʥ���ץ륹����ץȽ����¸�ߤ��ޤ���Ǥ�����������Ф���
��ĥ�ѥå������θ��Ǥ��� Tcl/Tk �ˤϡ�Tk widget ���Ѥ��ƤɤΤ褦�ʤ��Ȥ���
���뤫�򼨤���ΤȤ��� widget-demo ��¸�ߤ����ꡤTcl/Tk ���Ѥ��� GUI �κ���
��������ݤ���ɽŪ����ץ�ȤʤäƤ��ޤ����ܥ��������֤ϡ�Ruby/Tk �ν�����
�������ɽŪ�ʥ���ץ륹����ץȤȤ��٤���Tcl/Tk �� widget-demo ��ܿ�������
�ΤǤ���

�ܥ��������֤˴ޤޤ�륹����ץȤ�¹Ԥ��뤿��ˤϡ�ruby-1.1c2 �ʾ�Ǥ��뤳
�Ȥ�ɬ�פǤ���1.1c1 �ξ��ϡ��ܥ��������֤˴ޤޤ�� patck_1.1c1 �� Ruby ��
�饤�֥��ˤ��ƤƤ����������Ȥ߹��� Tk �ΥС������ϡ�4.2 �Ǥ� 8.0 �Ǥ⽤
���ʤ�ư������Ϥ��Ǥ��������������ܸ��ǤǤΰܿ��ȤʤäƤ��뤿�ᡤ���ܸ첽��
�줿 Tk �����Ѥ���������������ץȤΥƥ��Ȥϡ�Tk4.2jp �� Tk8.0jp �ξ�ǹ�
���ޤ��� (�����ˤǤϤʤ��Ǥ���)��

�ܥ��������֤˴ޤޤ�륹����ץȤ�¿���ϡ����ȤʤäƤ��� Tcl/Tk �Ǥ����Ū��
��������ץȵ��ҤȤʤ�褦�ˤ��Ƥ��ޤ������Τ��ᡤRuby/Tk �Υ���ץ�ȸ�����
�ϡ����ޤ� Ruby �餷���ʤ��Ȥ������Ǥ��礦���ˤ⤫����餺�����Τ褦�ʵ���
���äƤ�����ͳ�ϡ�Ruby/Tk �Υɥ��������­�ˤ���ޤ���

Tcl/Tk �ˤ�Ŭ���ʻ��ͽ񤬲�����¸�ߤ��Ƥ��ޤ����顤Ruby/Tk ������ץȤ����
����ݤϡ����Τ褦�� Tcl/Tk �λ��ͽ�Ǿ�����䤤�ʤ���������뤳�Ȥˤʤ�Ȼ�
���ޤ����� widget �λ�����Ȥ��ơ�Tcl/Tk �� widget-demo �򻲾Ȥ��뤳�Ȥ⤢��
�Ǥ��礦��Ruby/Tk �Ǥε��Ҥ� widget-demo �� Tcl/Tk �Ǥε��Ҥ˶ᤤ��Τˤ���
�����С���������ˤ�äơ�Ruby/Tk ����������뤳�Ȥ��Ǥ���ȹͤ����ޤ���
��ö Ruby/Tk �Ǥ� �� widget �λ�����ˡ�������Ƥ��ޤ��С�Ruby �餷��������
�ץȤ�������뤳�Ȥ��񤷤��ʤ��Ǥ��礦���ܥ��������֤Υ�����ץȤϡ�Ruby/Tk
��ǽ�˽�������ޤǤ�Ƨ��Ȥ������Ѥ��Ƥ���������й����Ǥ���

widget-demo �ΰܿ��ˤ����äƤϡ��������ˤ�ܿ�����������ץȤ��󶡤��Ƥ�����
���ޤ����������˴��դΰդ�ɽ���ޤ���

Ω�С�JAIST (ttate@jaist.ac.jp) ����
ʿ���ͻ� (hiramatu@cdrom.co.jp) ����

ʿ������ˤ�� Ruby/Tk ����� Web page (http://www.cdrom.co.jp/~hiramatu/)
�� Ruby/Tk �ν�����ͭ�ѤȻפ��ޤ��Τǡ����Ҥ����Ȥ���������

�ޤ������� (maebashi@iij.ad.jp) �����Ϥ���Ȥ��ơ�widget-demo �ΰܿ��˺ݤ�
��ɬ�פȤʤä� Ruby �� Tk ��Ϣ�饤�֥�꽤���ˤĤ��ơ����������Х��λ�Ŧ��
�Ƥ��������������ˤⴶ���פ��ޤ���

�����ƺǸ�˺���δ��դ� Ruby �߷׼Ԥ� �ޤĤ�� �椭�Ҥ� (matz@netlab.co.jp)
��������������Ȼפ��ޤ���
Loading

0 comments on commit 9521e7d

Please sign in to comment.