diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-06 09:42:12 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-06 09:42:12 +0000 |
commit | d8465ff9abf63545262b7d8f88b069522ae82823 (patch) | |
tree | ea1597d41d1de11febd12cc38b71838e0691bfcb /ext/tk/lib/tkextlib | |
parent | 3d8fa5556164f3aa2f6f1733ffe4a96fc4f33ed8 (diff) |
* ext/tk/lib : improve framework of developping Tcl/Tk extension wrappers
* BWidget extension support on Ruby/Tk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib')
86 files changed, 2944 insertions, 254 deletions
diff --git a/ext/tk/lib/tkextlib/ICONS.rb b/ext/tk/lib/tkextlib/ICONS.rb index 84f4204c60..18d84c05e9 100644 --- a/ext/tk/lib/tkextlib/ICONS.rb +++ b/ext/tk/lib/tkextlib/ICONS.rb @@ -6,11 +6,8 @@ # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' -# library directory -dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - # call setup script -require File.join(dir, 'setup.rb') +require 'tkextlib/ICONS/setup.rb' # load library -require File.join(dir, 'icons') +require 'tkextlib/ICONS/icons' diff --git a/ext/tk/lib/tkextlib/ICONS/icons.rb b/ext/tk/lib/tkextlib/ICONS/icons.rb index fe8351fa52..275903f302 100644 --- a/ext/tk/lib/tkextlib/ICONS/icons.rb +++ b/ext/tk/lib/tkextlib/ICONS/icons.rb @@ -9,39 +9,63 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/ICONS/setup.rb' # TkPackage.require('icons', '1.0') TkPackage.require('icons') module Tk class ICONS < TkImage - def self.create(*args) # icon, icon, ..., keys + extend Tk + + def self.package_version + begin + TkPackage.require('icons') + rescue + '' + end + end + + def self.create(*args) # icon, icon, ..., ?option=>value, ...? if args[-1].kind_of?(Hash) keys = args.pop icons = simplelist(tk_call('::icons::icons', 'create', - *(hash_kv(keys).concat(args.flatten)))) + *(hash_kv(keys) << (args.flatten)))) else icons = simplelist(tk_call('::icons::icons', 'create', - *(args.flatten))) + args.flatten)) end icons.collect{|icon| self.new(icon, :without_creating=>true)} end - def self.delete(*icons) + def self.delete(*icons) # icon, icon, ... + icons = icons.flatten return if icons.empty? + icons.map!{|icon| + if icon.kind_of?(Tk::ICONS) + Tk_IMGTBL.delete(icon.path) + icon.name + elsif icon.to_s =~ /^::icon::(.*)/ + name = $1 + Tk_IMGTBL.delete(icon) + name + else + Tk_IMGTBL.delete("::icon::#{icon}") + icon + end + } tk_call('::icons::icons', 'delete', icons) end - def self.query(*args) + def self.query(*args) # icon, icon, ..., ?option=>value, ...? if args[-1].kind_of?(Hash) keys = args.pop - list(tk_call('::icons::icons', 'query', - *(hash_kv(keys).concat(args.flatten)))) + simplelist(tk_call('::icons::icons', 'query', + *(hash_kv(keys) << (args.flatten)))) else - list(tk_call('::icons::icons', 'query', *(args.flatten))) - end + simplelist(tk_call('::icons::icons', 'query', args.flatten)) + end . map{|inf| list(inf) } end ########################################## @@ -75,7 +99,7 @@ module Tk self end - def query(keys) + def query(keys={}) list(simplelist(tk_call('::icons::icons', 'query', *(hash_kv(keys) << @name)) )[0]) diff --git a/ext/tk/lib/tkextlib/SUPPORT_STATUS b/ext/tk/lib/tkextlib/SUPPORT_STATUS index 6cc5e15617..58ac307857 100644 --- a/ext/tk/lib/tkextlib/SUPPORT_STATUS +++ b/ext/tk/lib/tkextlib/SUPPORT_STATUS @@ -47,33 +47,35 @@ script may give you some hints about that. ===< support with some examples (may be beta quality) >======================= Tcllib http://sf.net/projects/tcllib - ==> tcllib (partial support; Tklib part only) + ==> tcllib (partial support; Tklib part only) + +BWidgets http://sf.net/projects/tcllib ==> bwidget vu http://tktable.sourceforge.net ==> vu -TkHTML http://www.hwaci.com/sw/tkhtml/index.html ==> tkHTML +TkHTML http://www.hwaci.com/sw/tkhtml/index.html ==> tkHTML + +ICONS http://www.satisoft.com/tcltk/icons/ ==> ICONS ===< support (may be alpha or beta quality) >================================= -TkImg http://sf.net/projects/tkimg ==> tkimg +TkImg http://sf.net/projects/tkimg ==> tkimg -TkTreeCtrl http://tktreectrl.sourceforge.net/ ==> treectrl +TkTreeCtrl http://tktreectrl.sourceforge.net/ ==> treectrl -Tile http://tktable.sourceforge.net/tile/ ==> tile +Tile http://tktable.sourceforge.net/tile/ ==> tile -===< possibly support (not tested; alpha quality) >=========================== +===< possibly available (not tested; alpha quality) >========================= TkTrans http://www2.cmp.uea.ac.uk/~fuzz/tktrans/default.html ==> tktrans (win32 only) TkDND http://sourceforge.net/projects/tkdnd ==> tkDND -ICONS http://www.satisoft.com/tcltk/icons/ ==> ICONS - ===< plan to support (alpha quality libraries may be included) >============== @@ -87,8 +89,6 @@ IWidgets http://sf.net/projects/incrTcl TkTable http://sf.net/projects/tktable * see http://www.korus.hu/~fery/ruby/tktable.rb -BWidgets http://sf.net/projects/tcllib - winico http://tktable.sourceforge.net diff --git a/ext/tk/lib/tkextlib/bwidget.rb b/ext/tk/lib/tkextlib/bwidget.rb new file mode 100644 index 0000000000..78d7d5230f --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget.rb @@ -0,0 +1,144 @@ +# +# BWidget extension support +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' + +# call setup script for general 'tkextlib' libraries +require 'tkextlib/setup.rb' + +# call setup script +require 'tkextlib/bwidget/setup.rb' + +# load all image format handlers +#TkPackage.require('BWidget', '1.7') +TkPackage.require('BWidget') + +module Tk + module BWidget + extend TkCore + + LIBRARY = tk_call('set', '::BWIDGET::LIBRARY') + + def self.package_version + begin + TkPackage.require('BWidget') + rescue + '' + end + end + + def self.XLFDfont(cmd, *args) + if args[-1].kind_of?(Hash) + keys = args.pop + args.concat(hash_kv(keys)) + end + tk_call('BWidget::XLFDfont', cmd, *args) + end + + def self.assert(exp, msg=None) + tk_call('BWidget::assert', exp, msg) + end + + def self.badOptionString(type, value, list) + tk_call('BWidget::badOptionString', type, value, list) + end + + def self.bindMouseWheel(widget) + tk_call('BWidget::bindMouseWheel', widget) + end + + def self.classes(klass) + list(tk_call('BWidget::classes', klass)) + end + + def self.clonename(menu) + tk_call('BWidget::clonename', menu) + end + + def self.focus(opt, path) + tk_call('BWidget::focus', opt, path) + end + + def self.get3dcolor(path, bgcolor) + tk_call('BWidget::get3dcolor', path, bgcolor) + end + + def self.getname(name) + tk_call('BWidget::getname', name) + end + + def self.grab(opt, path) + tk_call('BWidget::', opt, path) + end + + def self.inuse(klass) + bool(tk_call('BWidget::inuse', klass)) + end + + def self.library(klass, *klasses) + tk_call('BWidget::library', klass, *klasses) + end + + def self.lreorder(list, neworder) + tk_call('BWidget::lreorder', list, neworder) + end + + def self.parsetext(text) + tk_call('BWidget::parsetext', text) + end + + def self.place(path, w, h, *args) + if args[-1].kind_of?(Hash) + keys = args.pop + args.concat(hash_kv(keys)) + end + tk_call('BWidget::place', path, w, h, *(args.flatten)) + end + + def self.write(file, mode=None) + tk_call('BWidget::write', file, mode) + end + + def self.wrongNumArgsString(str) + tk_call('BWidget::wrongNumArgsString', str) + end + + #################################################### + + autoload :ArrowButton, 'tkextlib/bwidget/arrowbutton' + autoload :Bitmap, 'tkextlib/bwidget/bitmap' + autoload :Button, 'tkextlib/bwidget/button' + autoload :ButtonBox, 'tkextlib/bwidget/buttonbox' + autoload :ComboBox, 'tkextlib/bwidget/combobox' + autoload :Dialog, 'tkextlib/bwidget/dialog' + autoload :DragSite, 'tkextlib/bwidget/dragsite' + autoload :DropSite, 'tkextlib/bwidget/dropsite' + autoload :DynamicHelp, 'tkextlib/bwidget/dynamichelp' + autoload :Entry, 'tkextlib/bwidget/entry' + autoload :Label, 'tkextlib/bwidget/label' + autoload :LabelEntry, 'tkextlib/bwidget/labelentry' + autoload :LabelFrame, 'tkextlib/bwidget/labelframe' + autoload :ListBox, 'tkextlib/bwidget/listbox' + autoload :MainFrame, 'tkextlib/bwidget/mainframe' + autoload :MessageDlg, 'tkextlib/bwidget/messagedlg' + autoload :NoteBook, 'tkextlib/bwidget/notebook' + autoload :PagesManager, 'tkextlib/bwidget/pagesmanager' + autoload :PanedWindow, 'tkextlib/bwidget/panedwindow' + autoload :PasswdDlg, 'tkextlib/bwidget/passwddlg' + autoload :ProgressBar, 'tkextlib/bwidget/progressbar' + autoload :ProgressDlg, 'tkextlib/bwidget/progressdlg' + autoload :ScrollableFrame, 'tkextlib/bwidget/scrollableframe' + autoload :ScrolledWindow, 'tkextlib/bwidget/scrolledwindow' + autoload :ScrollView, 'tkextlib/bwidget/scrollview' + autoload :SelectColor, 'tkextlib/bwidget/selectcolor' + autoload :SelectFont, 'tkextlib/bwidget/selectfont' + autoload :Separator, 'tkextlib/bwidget/separator' + autoload :SpinBox, 'tkextlib/bwidget/spinbox' + autoload :TitleFrame, 'tkextlib/bwidget/titleframe' + autoload :Tree, 'tkextlib/bwidget/tree' + autoload :Widget, 'tkextlib/bwidget/widget' + + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb b/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb new file mode 100644 index 0000000000..770e5e9ef1 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb @@ -0,0 +1,21 @@ +# +# tkextlib/bwidget/arrowbutton.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/button' + +module Tk + module BWidget + class ArrowButton < Tk::BWidget::Button + end + end +end + +class Tk::BWidget::ArrowButton + TkCommandNames = ['ArrowButton'.freeze].freeze + WidgetClassName = 'ArrowButton'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/bwidget/bitmap.rb b/ext/tk/lib/tkextlib/bwidget/bitmap.rb new file mode 100644 index 0000000000..6cfde203e8 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/bitmap.rb @@ -0,0 +1,21 @@ +# +# tkextlib/bwidget/bitmap.rb +# by Hidetoshi NAGAI ([email protected]) +# +require 'tk' +require 'tk/image' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class Bitmap < TkPhotoImage + end + end +end + +class Tk::BWidget::Bitmap + def initialize(name) + @path = tk_call_without_enc('Bitmap::get', name) + Tk_IMGTBL[@path] = self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/button.rb b/ext/tk/lib/tkextlib/bwidget/button.rb new file mode 100644 index 0000000000..246afebe29 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/button.rb @@ -0,0 +1,21 @@ +# +# tkextlib/bwidget/button.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/button' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class Button < TkButton + end + end +end + +class Tk::BWidget::Button + TkCommandNames = ['Button'.freeze].freeze + WidgetClassName = 'Button'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb new file mode 100644 index 0000000000..477de8a61f --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb @@ -0,0 +1,73 @@ +# +# tkextlib/bwidget/buttonbox.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/button' + +module Tk + module BWidget + class ButtonBox < TkWindow + end + end +end + +class Tk::BWidget::ButtonBox + TkCommandNames = ['ButtonBox'.freeze].freeze + WidgetClassName = 'ButtonBox'.freeze + WidgetClassNames[WidgetClassName] = self + + include TkItemConfigMethod + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::BWidget::Button) + name = tagOrId[:name] + return index(name) unless name.empty? + end + if tagOrId.kind_of?(TkButton) + return index(tagOrId[:text]) + end + # index(tagOrId.to_s) + index(_get_eval_string(tagOrId)) + end + + def add(keys={}, &b) + win = window(tk_send('add', *hash_kv(keys))) + win.instance_eval(&b) if b + win + end + + def delete(idx) + tk_send('delete', tagid(idx)) + self + end + + def index(idx) + if idx.kind_of?(Tk::BWidget::Button) + name = idx[:name] + idx = name unless name.empty? + end + if idx.kind_of?(TkButton) + idx = idx[:text] + end + number(tk_send('index', idx.to_s)) + end + + def insert(idx, keys={}, &b) + win = window(tk_send('insert', tagid(idx), *hash_kv(keys))) + win.instance_eval(&b) if b + win + end + + def invoke(idx) + tk_send('invoke', tagid(idx)) + self + end + + def set_focus(idx) + tk_send('setfocus', tagid(idx)) + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/combobox.rb b/ext/tk/lib/tkextlib/bwidget/combobox.rb new file mode 100644 index 0000000000..31f71c3aaf --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/combobox.rb @@ -0,0 +1,45 @@ +# +# tkextlib/bwidget/combobox.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/entry' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/listbox' +require 'tkextlib/bwidget/spinbox' + +module Tk + module BWidget + class ComboBox < Tk::BWidget::SpinBox + end + end +end + +class Tk::BWidget::ComboBox + include Scrollable + + TkCommandNames = ['ComboBox'.freeze].freeze + WidgetClassName = 'ComboBox'.freeze + WidgetClassNames[WidgetClassName] = self + + def get_listbox(&b) + win = window(tk_send_without_enc('getlistbox')) + win.instance_eval(&b) if b + win + end + + def icursor(idx) + tk_send_without_enc('icursor', idx) + end + + def post + tk_send_without_enc('post') + self + end + + def unpost + tk_send_without_enc('unpost') + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/dialog.rb b/ext/tk/lib/tkextlib/bwidget/dialog.rb new file mode 100644 index 0000000000..4a60a7ceb4 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/dialog.rb @@ -0,0 +1,147 @@ +# +# tkextlib/bwidget/dialog.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/frame' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/buttonbox' + +module Tk + module BWidget + class Dialog < TkWindow + end + end +end + +class Tk::BWidget::Dialog + TkCommandNames = ['Dialog'.freeze].freeze + WidgetClassName = 'Dialog'.freeze + WidgetClassNames[WidgetClassName] = self + + include TkItemConfigMethod + + def initialize(parent=nil, keys=nil) + @relative = '' + if parent.kind_of?(Hash) + keys = _symbolkey2str(parent) + @relative = keys['parent'] if keys.key?('parent') + @relative = keys.delete('relative') if keys.key?('relative') + super(keys) + elsif keys + keys = _symbolkey2str(keys) + @relative = keys.delete('parent') if keys.key?('parent') + @relative = keys.delete('relative') if keys.key?('relative') + super(parent, keys) + else + super(parent) + end + end + + def create_self(keys) + cmd = self.class::TkCommandNames[0] + if keys and keys != None + tk_call_without_enc(cmd, @path, '-parent', @relative, + *hash_kv(keys, true)) + else + tk_call_without_enc(cmd, @path, '-parent', @relative) + end + end + + def cget(slot) + if slot.to_s == 'relative' + super('parent') + else + super(slot) + end + end + + def configure(slot, value=None) + if slot.kind_of?(Hash) + slot = _symbolkey2str(slot) + slot['parent'] = slot.delete('relative') if slot.key?('relative') + super(slot) + else + if slot.to_s == 'relative' + super('parent', value) + else + super(slot, value) + end + end + end + + def configinfo(slot=nil) + if slot + if slot.to_s == 'relative' + super('parent') + else + super(slot) + end + else + ret = super() + if TkComm::GET_CONFIGINFO_AS_ARRAY + ret << ['relative', 'parent'] + else + ret['relative'] = 'parent' + end + end + end + + def tagid(tagOrId) + if tagOrId.kind_of?(Tk::BWidget::Button) + name = tagOrId[:name] + return index(name) unless name.empty? + end + if tagOrId.kind_of?(TkButton) + return index(tagOrId[:text]) + end + # index(tagOrId.to_s) + index(_get_eval_string(tagOrId)) + end + + def add(keys={}, &b) + win = window(tk_send('add', *hash_kv(keys))) + win.instance_eval(&b) if b + win + end + + def get_frame(&b) + win = window(tk_send('getframe')) + win.instance_eval(&b) if b + win + end + + def get_buttonbox(&b) + win = window(@path + '.bbox') + win.instance_eval(&b) if b + win + end + + def draw(focus_win=None) + tk_send('draw', focus_win) + end + + def enddialog(ret) + tk_send('enddialog', ret) + end + + def index(idx) + get_buttonbox.index(idx) + end + + def invoke(idx) + tk_send('invoke', tagid(idx)) + self + end + + def set_focus(idx) + tk_send('setfocus', tagid(idx)) + self + end + + def withdraw + tk_send('withdraw') + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/dragsite.rb b/ext/tk/lib/tkextlib/bwidget/dragsite.rb new file mode 100644 index 0000000000..4d4de1780c --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/dragsite.rb @@ -0,0 +1,31 @@ +# +# tkextlib/bwidget/dragsite.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + module DragSite + end + end +end + +module Tk::BWidget::DragSite + include Tk + extend Tk + + def self.include(klass, type, event) + tk_call('DragSite::include', klass, type, event) + end + + def self.register(path, keys={}) + tk_call('DragSite::register', path, *hash_kv(keys)) + end + + def self.set_drag(path, subpath, initcmd, endcmd, force=None) + tk_call('DragSite::setdrag', path, subpath, initcmd, endcmd, force) + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/dropsite.rb b/ext/tk/lib/tkextlib/bwidget/dropsite.rb new file mode 100644 index 0000000000..e5e98fbc51 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/dropsite.rb @@ -0,0 +1,39 @@ +# +# tkextlib/bwidget/dropsite.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + module DropSite + end + end +end + +module Tk::BWidget::DropSite + include Tk + extend Tk + + def self.include(klass, type) + tk_call('DropSite::include', klass, type) + end + + def self.register(path, keys={}) + tk_call('DropSite::register', path, *hash_kv(keys)) + end + + def self.set_cursor(cursor) + tk_call('DropSite::setcursor', cursor) + end + + def self.set_drop(path, subpath, dropover, drop, force=None) + tk_call('DropSite::setdrop', path, subpath, dropover, drop, force) + end + + def self.set_operation(op) + tk_call('DropSite::setoperation', op) + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb b/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb new file mode 100644 index 0000000000..4766a1ec6d --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb @@ -0,0 +1,51 @@ +# +# tkextlib/bwidget/dynamichelp.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + module DynamicHelp + end + end +end + +module Tk::BWidget::DynamicHelp + include Tk + extend Tk + + def self.__pathname + 'DynamicHelp::configure' + end + + def self.__cget_cmd + ['DynamicHelp::configure'] + end + + def self.__config_cmd + ['DynamicHelp::configure'] + end + + def self.cget(slot) + self.current_configinfo(slot).values[0] + end + + def self.add(widget, keys={}) + tk_call('DynamicHelp::add', widget, *hash_kv(keys)) + end + + def self.delete(widget) + tk_call('DynamicHelp::delete', widget) + end + + def self.include(klass, type) + tk_call('DynamicHelp::include', klass, type) + end + + def self.sethelp(path, subpath, force=None) + tk_call('DynamicHelp::sethelp', path, subpath, force) + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/entry.rb b/ext/tk/lib/tkextlib/bwidget/entry.rb new file mode 100644 index 0000000000..9867a1ac36 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/entry.rb @@ -0,0 +1,28 @@ +# +# tkextlib/bwidget/entry.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/entry' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class Entry < TkEntry + end + end +end + +class Tk::BWidget::Entry + include Scrollable + + TkCommandNames = ['Entry'.freeze].freeze + WidgetClassName = 'Entry'.freeze + WidgetClassNames[WidgetClassName] = self + + def invoke + tk_send_without_enc('invoke') + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/label.rb b/ext/tk/lib/tkextlib/bwidget/label.rb new file mode 100644 index 0000000000..1d4c638705 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/label.rb @@ -0,0 +1,26 @@ +# +# tkextlib/bwidget/label.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/label' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class Label < TkLabel + end + end +end + +class Tk::BWidget::Label + TkCommandNames = ['Label'.freeze].freeze + WidgetClassName = 'Label'.freeze + WidgetClassNames[WidgetClassName] = self + + def set_focus + tk_send_without_enc('setfocus') + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/ext/tk/lib/tkextlib/bwidget/labelentry.rb new file mode 100644 index 0000000000..7a6a7f01d6 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/labelentry.rb @@ -0,0 +1,45 @@ +# +# tkextlib/bwidget/labelentry.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/entry' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/labelframe' +require 'tkextlib/bwidget/entry' + +module Tk + module BWidget + class LabelEntry < TkEntry + end + end +end + +class Tk::BWidget::LabelEntry + include Scrollable + + TkCommandNames = ['LabelEntry'.freeze].freeze + WidgetClassName = 'LabelEntry'.freeze + WidgetClassNames[WidgetClassName] = self + + def entrybind(*args) + _bind([path, 'bind'], *args) + self + end + + def entrybind_append(*args) + _bind_append([path, 'bind'], *args) + self + end + + def entrybind_remove(*args) + _bind_remove([path, 'bind'], *args) + self + end + + def entrybindinfo(*args) + _bindinfo([path, 'bind'], *args) + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/labelframe.rb b/ext/tk/lib/tkextlib/bwidget/labelframe.rb new file mode 100644 index 0000000000..453756a163 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/labelframe.rb @@ -0,0 +1,30 @@ +# +# tkextlib/bwidget/labelframe.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/frame' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class LabelFrame < TkWindow + end + end +end + +class Tk::BWidget::LabelFrame + TkCommandNames = ['LabelFrame'.freeze].freeze + WidgetClassName = 'LabelFrame'.freeze + WidgetClassNames[WidgetClassName] = self + + def self.align(*args) + tk_call('LabelFrame::align', *args) + end + def get_frame(&b) + win = window(tk_send_without_enc('getframe')) + win.instance_eval(&b) if b + win + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/listbox.rb b/ext/tk/lib/tkextlib/bwidget/listbox.rb new file mode 100644 index 0000000000..28173fb7f9 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/listbox.rb @@ -0,0 +1,290 @@ +# +# tkextlib/bwidget/listbox.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/canvas' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class ListBox < TkWindow + # is NOT a subclass of a listbox widget class. + # because it constructed on a canvas widget. + + class Item < TkObject + end + end + end +end + +class Tk::BWidget::ListBox + include TkItemConfigMethod + include Scrollable + + TkCommandNames = ['ListBox'.freeze].freeze + WidgetClassName = 'ListBox'.freeze + WidgetClassNames[WidgetClassName] = self + + class Event_for_Items < TkEvent::Event + def self._get_extra_args_tbl + [ + TkComm.method(:string) # item idenfier + ] + end + end + + def tagid(tag) + if tag.kind_of?(Tk::BWidget::ListBox::Item) + tag.id + else + # tag + _get_eval_string(tag) + end + end + + def imagebind(*args) + _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + self + end + + def imagebind_append(*args) + _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + self + end + + def imagebind_remove(*args) + _bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + self + end + + def imagebindinfo(*args) + _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + end + + def textbind(*args) + _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args) + self + end + + def textbind_append(*args) + _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args) + self + end + + def textbind_remove(*args) + _bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args) + self + end + + def textbindinfo(*args) + _bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args) + end + + def delete(*args) + tk_send('delete', *args) + self + end + + def edit(item, text, *args) + tk_send('edit', tagid(item), text, *args) + self + end + + def exist?(item) + bool(tk_send('exists', tagid(item))) + end + + def index(item) + num_or_str(tk_send('index', tagid(item))) + end + + def insert(idx, item, keys={}) + tk_send('insert', idx, tagid(item), *hash_kv(keys)) + self + end + + def get_item(idx) + tk_send('items', idx) + end + + def items(first=None, last=None) + list(tk_send('items', first, last)) + end + + def move(item, idx) + tk_send('move', tagid(item), idx) + self + end + + def reorder(neworder) + tk_send('reorder', neworder) + self + end + + def see(item) + tk_send('see', tagid(item)) + self + end + + def selection_clear + tk_send_without_enc('selection', 'clear') + self + end + + def selection_set(*args) + tk_send_without_enc('selection', 'set', + *(args.collect{|item| tagid(item)})) + self + end + + def selection_add(*args) + tk_send_without_enc('selection', 'add', + *(args.collect{|item| tagid(item)})) + self + end + + def selection_remove(*args) + tk_send_without_enc('selection', 'remove', + *(args.collect{|item| tagid(item)})) + self + end + + def selection_get(*args) + simplelist(tk_send_without_enc('selection', 'get')).collect{|item| + Tk::BWidget::ListBox::Item.id2obj(self, item) + } + end +end + +class Tk::BWidget::ListBox::Item + include TkTreatTagFont + + ListItem_TBL = TkCore::INTERP.create_table + ListItem_ID = ['item:'.freeze, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ 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 + end + + def initialize(lbox, *args) + if lbox.kind_of?(Tk::BWidget::ListBox) + @listbox = lbox + else + fail RuntimeError, + "expect Tk::BWidget::ListBox or Tk::BWidget::ListBox::Item for 1st argument" + end + + if args[-1].kind_of?(Hash) + keys = _symbolkey2str(args.pop) + else + keys = {} + end + + index = keys.delete('index') + unless args.empty? + index = args.shift + end + index = 'end' unless index + + unless args.empty? + fail RuntimeError, 'too much arguments' + end + + @lpath = @listbox.path + + if keys.key?('itemname') + @path = @id = keys.delete('itemname') + else + @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 + + @listbox.insert(index, @id, keys) + end + + def listbox + @listbox + end + + def id + @id + end + + def [](key) + cget(key) + end + + def []=(key, val) + configure(key, val) + val + end + + def cget(key) + @listbox.itemcget(@id, key) + end + + def configure(key, val=None) + @listbox.itemconfigure(@id, key, val) + end + + def configinfo(key=nil) + @listbox.itemconfiginfo(@id, key) + end + + def current_configinfo(key=nil) + @listbox.current_itemconfiginfo(@id, key) + end + + def delete + @listbox.delete(@id) + self + end + + def edit(*args) + @listbox.edit(@id, *args) + self + end + + def exist? + @listbox.exist?(@id) + end + + def index + @listbox.index(@id) + end + + def move(index) + @listbox.move(@id, index) + end + + def see + @listbox.see(@id) + end + + def selection_add + @listbox.selection_add(@id) + end + + def selection_remove + @listbox.selection_remove(@id) + end + + def selection_set + @listbox.selection_set(@id) + end + + def selection_toggle + @listbox.selection_toggle(@id) + end +end + diff --git a/ext/tk/lib/tkextlib/bwidget/mainframe.rb b/ext/tk/lib/tkextlib/bwidget/mainframe.rb new file mode 100644 index 0000000000..e52f4b2f4c --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/mainframe.rb @@ -0,0 +1,73 @@ +# +# tkextlib/bwidget/mainframe.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/frame' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/progressbar' + +module Tk + module BWidget + class MainFrame < TkWindow + end + end +end + +class Tk::BWidget::MainFrame + TkCommandNames = ['MainFrame'.freeze].freeze + WidgetClassName = 'MainFrame'.freeze + WidgetClassNames[WidgetClassName] = self + + def add_indicator(keys={}, &b) + win = window(tk_send('addindicator', *hash_kv(keys))) + win.instance_eval(&b) if b + win + end + + def add_toolbar(&b) + win = window(tk_send('addtoolbar')) + win.instance_eval(&b) if b + win + end + + def get_frame(&b) + win = window(tk_send('getframe')) + win.instance_eval(&b) if b + win + end + + def get_indicator(idx, &b) + win = window(tk_send('getindicator', idx)) + win.instance_eval(&b) if b + win + end + + def get_menu(menu_id, &b) + win = window(tk_send('getmenu', menu_id)) + win.instance_eval(&b) if b + win + end + + def get_toolbar(idx, &b) + win = window(tk_send('gettoolbar', idx)) + win.instance_eval(&b) if b + win + end + + def set_menustate(tag, state) + tk_send('setmenustate', tag, state) + self + end + + def show_statusbar(name) + tk_send('showstatusbar', name) + self + end + + def show_toolbar(idx, mode) + tk_send('showtoolbar', idx, mode) + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb new file mode 100644 index 0000000000..55cc4ba0de --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb @@ -0,0 +1,167 @@ +# +# tkextlib/bwidget/messagedlg.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class MessageDlg < TkWindow + end + end +end + +class Tk::BWidget::MessageDlg + TkCommandNames = ['MessageDlg'.freeze].freeze + WidgetClassName = 'MessageDlg'.freeze + WidgetClassNames[WidgetClassName] = self + + def initialize(parent=nil, keys=nil) + @relative = '' + if parent.kind_of?(Hash) + keys = _symbolkey2str(parent) + @relative = keys['parent'] if keys.key?('parent') + @relative = keys.delete('relative') if keys.key?('relative') + super(keys) + elsif keys + keys = _symbolkey2str(keys) + @relative = keys.delete('parent') if keys.key?('parent') + @relative = keys.delete('relative') if keys.key?('relative') + super(parent, keys) + else + super(parent) + end + end + + def create_self(keys) + # NOT create widget. + # Because the widget no longer exist when returning from creation. + @keys = _symbolkey2str(keys).update('parent'=>@relative) + @info = nil + end + private :create_self + + def cget(slot) + slot = slot.to_s + if slot == 'relative' + slot = 'parent' + end + if winfo_exist? + val = super(slot) + @keys[slot] = val + end + @keys[slot] + end + + def configure(slot, value=None) + if winfo_exist? + super(slot, value) + end + if slot.kind_of?(Hash) + slot = _symbolkey2str(slot) + slot['parent'] = slot.delete('relative') if slot.key?('relative') + @keys.update(slot) + + if @info + # update @info + slot.each{|k, v| + if TkComm::GET_CONFIGINFO_AS_ARRAY + if (inf = @info.assoc(k)) + inf[-1] = v + else + @info << [k, '', '', '', v] + end + else + if (inf = @info[k]) + inf[-1] = v + else + @info[k] = ['', '', '', v] + end + end + } + end + + else # ! Hash + slot = slot.to_s + slot = 'parent' if slot == 'relative' + @keys[slot] = value + + if @info + # update @info + if TkComm::GET_CONFIGINFO_AS_ARRAY + if (inf = @info.assoc(slot)) + inf[-1] = value + else + @info << [slot, '', '', '', value] + end + else + if (inf = @info[slot]) + inf[-1] = value + else + @info[slot] = ['', '', '', value] + end + end + end + end + + self + end + + def configinfo(slot=nil) + if winfo_exist? + @info = super() + if TkComm::GET_CONFIGINFO_AS_ARRAY + @info << ['relative', 'parent'] + else + @info['relative'] = 'parent' + end + end + + if TkComm::GET_CONFIGINFO_AS_ARRAY + if @info + if winfo_exist? + # update @keys + @info.each{|inf| @keys[inf[0]] = inf[-1] if inf.size > 2 } + end + else + @info = [] + @keys.each{|k, v| + @info << [k, '', '', '', v] + } + @info << ['relative', 'parent'] + end + + if slot + @info.asoc(slot.to_s).dup + else + @info.dup + end + + else # ! TkComm::GET_CONFIGINFO_AS_ARRAY + if @info + if winfo_exist? + # update @keys + @info.each{|k, inf| @keys[k] = inf[-1] if inf.size > 2 } + end + else + @info = {} + @keys.each{|k, v| + @info[k] = ['', '', '', v] + } + @info['relative'] = 'parent' + end + + if slot + @info[slot.to_s].dup + else + @info.dup + end + end + end + + def create + num_or_str(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys))) + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/notebook.rb b/ext/tk/lib/tkextlib/bwidget/notebook.rb new file mode 100644 index 0000000000..26c11ac0dd --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/notebook.rb @@ -0,0 +1,116 @@ +# +# tkextlib/bwidget/notebook.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/frame' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class NoteBook < TkWindow + end + end +end + +class Tk::BWidget::NoteBook + include TkItemConfigMethod + + TkCommandNames = ['NoteBook'.freeze].freeze + WidgetClassName = 'NoteBook'.freeze + WidgetClassNames[WidgetClassName] = self + + class Event_for_Tabs < TkEvent::Event + def self._get_extra_args_tbl + [ + TkComm.method(:string) # page idenfier + ] + end + end + + def tagid(id) + if id.kind_of?(TkWindow) + id.path + elsif id.kind_of?(TkObject) + id.to_eval + else + # id.to_s + _get_eval_string(id) + end + end + + def tabbind(*args) + _bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args) + self + end + + def tabbind_append(*args) + _bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args) + self + end + + def tabbind_remove(*args) + _bind_remove_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args) + self + end + + def tabbindinfo(*args) + _bindinfo_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args) + end + + def add(page, &b) + win = window(tk_send('add', tagid(page))) + win.instance_eval(&b) if b + win + end + + def compute_size + tk_send('compute_size') + self + end + + def delete(page, destroyframe=None) + tk_send('delete', tagid(page), destroyframe) + self + end + + def get_frame(page, &b) + win = window(tk_send('getframe', tagid(page))) + win.instance_eval(&b) if b + win + end + + def index(page) + num_or_str(tk_send('index', tagid(page))) + end + + def insert(index, page, keys={}, &b) + win = window(tk_send('insert', index, tagid(page), *hash_kv(keys))) + win.instance_eval(&b) if b + win + end + + def move(page, index) + tk_send('move', tagid(page), index) + self + end + + def get_page(page) + tk_send('pages', page) + end + + def pages(first=None, last=None) + list(tk_send('pages', first, last)) + end + + def raise(page=None) + tk_send('raise', page) + self + end + + def see(page) + tk_send('see', page) + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb b/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb new file mode 100644 index 0000000000..fc01284be6 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb @@ -0,0 +1,61 @@ +# +# tkextlib/bwidget/pagesmanager.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/frame' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class PagesManager < TkWindow + end + end +end + +class Tk::BWidget::PagesManager + TkCommandNames = ['PagesManager'.freeze].freeze + WidgetClassName = 'PagesManager'.freeze + WidgetClassNames[WidgetClassName] = self + + def tagid(id) + # id.to_s + _get_eval_string(id) + end + + def add(page, &b) + win = window(tk_send('add', tagid(page))) + win.instance_eval(&b) if b + win + end + + def compute_size + tk_send('compute_size') + self + end + + def delete(page) + tk_send('delete', tagid(page)) + self + end + + def get_frame(page, &b) + win = window(tk_send('getframe', tagid(page))) + win.instance_eval(&b) if b + win + end + + def get_page(page) + tk_send('pages', page) + end + + def pages(first=None, last=None) + list(tk_send('pages', first, last)) + end + + def raise(page=None) + tk_send('raise', page) + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/panedwindow.rb b/ext/tk/lib/tkextlib/bwidget/panedwindow.rb new file mode 100644 index 0000000000..19982c6095 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/panedwindow.rb @@ -0,0 +1,31 @@ +# +# tkextlib/bwidget/panedwindow.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/frame' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class PanedWindow < TkWindow + end + end +end + +class Tk::BWidget::PanedWindow + TkCommandNames = ['PanedWindow'.freeze].freeze + WidgetClassName = 'PanedWindow'.freeze + WidgetClassNames[WidgetClassName] = self + + def add(keys={}) + window(tk_send('add', *hash_kv(keys))) + end + + def get_frame(idx, &b) + win = window(tk_send_without_enc('getframe', idx)) + win.instance_eval(&b) if b + win + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/passwddlg.rb b/ext/tk/lib/tkextlib/bwidget/passwddlg.rb new file mode 100644 index 0000000000..399353367c --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/passwddlg.rb @@ -0,0 +1,27 @@ +# +# tkextlib/bwidget/passwddlg.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/messagedlg' + +module Tk + module BWidget + class PasswdDlg < Tk::BWidget::MessageDlg + end + end +end + +class Tk::BWidget::PasswdDlg + TkCommandNames = ['PasswdDlg'.freeze].freeze + WidgetClassName = 'PasswdDlg'.freeze + WidgetClassNames[WidgetClassName] = self + + def create + login, passwd = simplelist(tk_call(self.class::TkCommandNames[0], + @path, *hash_kv(@keys))) + [login, passwd] + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/progressbar.rb b/ext/tk/lib/tkextlib/bwidget/progressbar.rb new file mode 100644 index 0000000000..0253ce2ada --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/progressbar.rb @@ -0,0 +1,20 @@ +# +# tkextlib/bwidget/progressbar.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class ProgressBar < TkWindow + end + end +end + +class Tk::BWidget::ProgressBar + TkCommandNames = ['ProgressBar'.freeze].freeze + WidgetClassName = 'ProgressBar'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/bwidget/progressdlg.rb b/ext/tk/lib/tkextlib/bwidget/progressdlg.rb new file mode 100644 index 0000000000..fbf00f3b00 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/progressdlg.rb @@ -0,0 +1,54 @@ +# +# tkextlib/bwidget/progressdlg.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/variable' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/progressbar' +require 'tkextlib/bwidget/messagedlg' + +module Tk + module BWidget + class ProgressDlg < Tk::BWidget::MessageDlg + end + end +end + +class Tk::BWidget::ProgressDlg + TkCommandNames = ['ProgressDlg'.freeze].freeze + WidgetClassName = 'ProgressDlg'.freeze + WidgetClassNames[WidgetClassName] = self + + def create_self(keys) + # NOT create widget for reusing the object + super(keys) + @keys['textvariable'] = TkVariable.new unless @keys.key?('textvariable') + @keys['variable'] = TkVariable.new unless @keys.key?('variable') + end + + def textvariable + @keys['textvariable'] + end + + def text + @keys['textvariable'].value + end + + def text= (txt) + @keys['textvariable'].value = txt + end + + def variable + @keys['variable'] + end + + def value + @keys['variable'].value + end + + def value= (val) + @keys['variable'].value = val + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb b/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb new file mode 100644 index 0000000000..a3986681a5 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb @@ -0,0 +1,34 @@ +# +# tkextlib/bwidget/scrollableframe.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/frame' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class ScrollableFrame < TkWindow + end + end +end + +class Tk::BWidget::ScrollableFrame + include Scrollable + + TkCommandNames = ['ScrollableFrame'.freeze].freeze + WidgetClassName = 'ScrollableFrame'.freeze + WidgetClassNames[WidgetClassName] = self + + def get_frame(&b) + win = window(tk_send_without_enc('getframe')) + win.instance_eval(&b) if b + win + end + + def see(win, vert=None, horiz=None) + tk_send_without_enc('see', win, vert, horiz) + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb b/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb new file mode 100644 index 0000000000..e9e53235b7 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb @@ -0,0 +1,32 @@ +# +# tkextlib/bwidget/scrolledwindow.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/frame' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class ScrolledWindow < TkWindow + end + end +end + +class Tk::BWidget::ScrolledWindow + TkCommandNames = ['ScrolledWindow'.freeze].freeze + WidgetClassName = 'ScrolledWindow'.freeze + WidgetClassNames[WidgetClassName] = self + + def get_frame(&b) + win = window(tk_send_without_enc('getframe')) + win.instance_eval(&b) if b + win + end + + def set_widget(win) + tk_send_without_enc('setwidget', win) + self + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/scrollview.rb b/ext/tk/lib/tkextlib/bwidget/scrollview.rb new file mode 100644 index 0000000000..5da528bd49 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/scrollview.rb @@ -0,0 +1,20 @@ +# +# tkextlib/bwidget/scrollview.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class ScrollView < TkWindow + end + end +end + +class Tk::BWidget::ScrollView + TkCommandNames = ['ScrollView'.freeze].freeze + WidgetClassName = 'ScrollView'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/bwidget/selectcolor.rb b/ext/tk/lib/tkextlib/bwidget/selectcolor.rb new file mode 100644 index 0000000000..742a84cd84 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/selectcolor.rb @@ -0,0 +1,45 @@ +# +# tkextlib/bwidget/selectcolor.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/messagedlg' + +module Tk + module BWidget + class SelectColor < Tk::BWidget::MessageDlg + end + end +end + +class Tk::BWidget::SelectColor + extend Tk + + TkCommandNames = ['SelectColor'.freeze].freeze + WidgetClassName = 'SelectColor'.freeze + WidgetClassNames[WidgetClassName] = self + + def dialog(keys={}) + newkeys = @keys.dup + newkeys.update(_symbolkey2str(keys)) + tk_call('SelectColor::dialog', @path, *hash_kv(newkeys)) + end + + def menu(*args) + if args[-1].kind_of?(Hash) + keys = args.pop + else + keys = {} + end + place = args.flatten + newkeys = @keys.dup + newkeys.update(_symbolkey2str(keys)) + tk_call('SelectColor::menu', @path, place, *hash_kv(newkeys)) + end + + def self.set_color(idx, color) + tk_call('SelectColor::setcolor', idx, color) + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/selectfont.rb b/ext/tk/lib/tkextlib/bwidget/selectfont.rb new file mode 100644 index 0000000000..46ca0dbca8 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/selectfont.rb @@ -0,0 +1,79 @@ +# +# tkextlib/bwidget/selectfont.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/messagedlg' + +module Tk + module BWidget + class SelectFont < Tk::BWidget::MessageDlg + class Dialog < Tk::BWidget::SelectFont + end + class Toolbar < TkWindow + end + end + end +end + +class Tk::BWidget::SelectFont + extend Tk + + TkCommandNames = ['SelectFont'.freeze].freeze + WidgetClassName = 'SelectFont'.freeze + WidgetClassNames[WidgetClassName] = self + + def __font_optkeys + [] # without fontobj operation + end + + def create + tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)) + end + + def self.load_font + tk_call('SelectFont::loadfont') + end +end + +class Tk::BWidget::SelectFont::Dialog + def __font_optkeys + [] # without fontobj operation + end + + def create_self(keys) + super(keys) + @keys['type'] = 'dialog' + end + + def configure(slot, value=None) + if slot.kind_of?(Hash) + slot.delete['type'] + slot.delete[:type] + return self if slot.empty? + else + return self if slot == 'type' || slot == :type + end + super(slot, value) + end + + def create + @keys['type'] = 'dialog' + tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(@keys)) + end +end + +class Tk::BWidget::SelectFont::Toolbar + def __font_optkeys + [] # without fontobj operation + end + + def create_self(keys) + keys = {} unless keys + keys = _symbolkey2str(keys) + keys['type'] = 'toolbar' + tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(keys)) + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/separator.rb b/ext/tk/lib/tkextlib/bwidget/separator.rb new file mode 100644 index 0000000000..d9c3458e51 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/separator.rb @@ -0,0 +1,20 @@ +# +# tkextlib/bwidget/separator.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class Separator < TkWindow + end + end +end + +class Tk::BWidget::Separator + TkCommandNames = ['Separator'.freeze].freeze + WidgetClassName = 'Separator'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/bwidget/setup.rb b/ext/tk/lib/tkextlib/bwidget/setup.rb new file mode 100644 index 0000000000..ce0f0bd4d4 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/setup.rb @@ -0,0 +1,8 @@ +# +# setup.rb -- setup script before calling TkPackage.require() +# +# If you need some setup operations (for example, add a library path +# to the library search path) before using Tcl/Tk library packages +# wrapped by Ruby scripts in this directory, please write the setup +# operations in this file. +# diff --git a/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/ext/tk/lib/tkextlib/bwidget/spinbox.rb new file mode 100644 index 0000000000..4380e38355 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/spinbox.rb @@ -0,0 +1,58 @@ +# +# tkextlib/bwidget/entry.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' +require 'tkextlib/bwidget/arrowbutton' +require 'tkextlib/bwidget/entry' + +module Tk + module BWidget + class SpinBox < TkEntry + end + end +end + +class Tk::BWidget::SpinBox + include Scrollable + + TkCommandNames = ['SpinBox'.freeze].freeze + WidgetClassName = 'SpinBox'.freeze + WidgetClassNames[WidgetClassName] = self + + def entrybind(*args) + _bind([path, 'bind'], *args) + self + end + + def entrybind_append(*args) + _bind_append([path, 'bind'], *args) + self + end + + def entrybind_remove(*args) + _bind_remove([path, 'bind'], *args) + self + end + + def entrybindinfo(*args) + _bindinfo([path, 'bind'], *args) + self + end + + def get_index_of_value + number(tk_send_without_enc('getvalue')) + end + alias get_value get_index_of_value + alias get_value_index get_index_of_value + + def set_value_by_index(idx) + idx = "@#{idx}" if idx.kind_of?(Integer) + tk_send_without_enc('setvalue', idx) + self + end + alias set_value set_value_by_index + alias set_index_value set_value_by_index +end diff --git a/ext/tk/lib/tkextlib/bwidget/titleframe.rb b/ext/tk/lib/tkextlib/bwidget/titleframe.rb new file mode 100644 index 0000000000..f519490430 --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/titleframe.rb @@ -0,0 +1,27 @@ +# +# tkextlib/bwidget/titleframe.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/frame' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class TitleFrame < TkWindow + end + end +end + +class Tk::BWidget::TitleFrame + TkCommandNames = ['TitleFrame'.freeze].freeze + WidgetClassName = 'TitleFrame'.freeze + WidgetClassNames[WidgetClassName] = self + + def get_frame(&b) + win = window(tk_send_without_enc('getframe')) + win.instance_eval(&b) if b + win + end +end diff --git a/ext/tk/lib/tkextlib/bwidget/tree.rb b/ext/tk/lib/tkextlib/bwidget/tree.rb new file mode 100644 index 0000000000..888ce9409f --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/tree.rb @@ -0,0 +1,374 @@ +# +# tkextlib/bwidget/tree.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tk/canvas' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + class Tree < TkWindow + class Node < TkObject + end + end + end +end + +class Tk::BWidget::Tree + include TkItemConfigMethod + include Scrollable + + TkCommandNames = ['Tree'.freeze].freeze + WidgetClassName = 'Tree'.freeze + WidgetClassNames[WidgetClassName] = self + + class Event_for_Items < TkEvent::Event + def self._get_extra_args_tbl + [ + TkComm.method(:string) # item idenfier + ] + end + end + + def tagid(tag) + if tag.kind_of?(Tk::BWidget::Tree::Node) + tag.id + else + # tag + _get_eval_string(tag) + end + end + + def imagebind(*args) + _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + self + end + + def imagebind_append(*args) + _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + self + end + + def imagebind_remove(*args) + _bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + self + end + + def imagebindinfo(*args) + _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + end + + def textbind(*args) + _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args) + self + end + + def textbind_append(*args) + _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args) + self + end + + def textbind_remove(*args) + _bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args) + self + end + + def textbindinfo(*args) + _bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args) + end + + def close_tree(node, recurse=None) + tk_send('closetree', tagid(node), recurse) + self + end + + def delete(*args) + tk_send('delete', *(args.collect{|node| tagid(node)})) + self + end + + def edit(node, text, *args) + tk_send('edit', tagid(node), text, *args) + self + end + + def exist?(node) + bool(tk_send('exists', tagid(node))) + end + + def index(node) + num_or_str(tk_send('index', tagid(node))) + end + + def insert(idx, parent, node, keys={}) + tk_send('insert', idx, tagid(parent), tagid(node), *hash_kv(keys)) + self + end + + def move(parent, node, idx) + tk_send('move', tagid(parent), tagid(node), idx) + self + end + + def get_node(node, idx) + Tk::BWidget::Tree::Node.id2obj(self, tk_send('nodes', tagid(node), idx)) + end + + def nodes(node, first=None, last=None) + simplelist(tk_send('nodes', tagid(node), first, last)).collect{|node| + Tk::BWidget::Tree::Node.id2obj(self, node) + } + end + + def open?(node) + bool(@tree.itemcget(tagid(node), 'open')) + end + + def open_tree(node, recurse=None) + tk_send('opentree', tagid(node), recurse) + self + end + + def parent(node) + Tk::BWidget::Tree::Node.id2obj(self, tk_send('parent', tagid(node))) + end + + def reorder(node, neworder) + tk_send('reorder', tagid(node), neworder) + self + end + + def see(node) + tk_send('see', tagid(node)) + self + end + + def selection_add(*args) + tk_send_without_enc('selection', 'add', + *(args.collect{|node| tagid(node)})) + self + end + + def selection_clear + tk_send_without_enc('selection', 'clear') + self + end + + def selection_get + list(tk_send_without_enc('selection', 'get')) + end + + def selection_include?(*args) + bool(tk_send_without_enc('selection', 'get', + *(args.collect{|node| tagid(node)}))) + end + + def selection_range(*args) + tk_send_without_enc('selection', 'range', + *(args.collect{|node| tagid(node)})) + self + end + + def selection_remove(*args) + tk_send_without_enc('selection', 'remove', + *(args.collect{|node| tagid(node)})) + self + end + + def selection_set(*args) + tk_send_without_enc('selection', 'set', + *(args.collect{|node| tagid(node)})) + self + end + + def selection_toggle(*args) + tk_send_without_enc('selection', 'toggle', + *(args.collect{|node| tagid(node)})) + self + end + + def toggle(node) + tk_send_without_enc('toggle', tagid(node)) + self + end + + def visible(node) + bool(tk_send_without_enc('visible', tagid(node))) + end +end + +class Tk::BWidget::Tree::Node + include TkTreatTagFont + + TreeNode_TBL = TkCore::INTERP.create_table + TreeNode_ID = ['node:'.freeze, '00000'.taint].freeze + + TkCore::INTERP.init_ip_env{ 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 + end + + def initialize(tree, *args) + if tree.kind_of?(Tk::BWidget::Tree) + @tree = tree + parent = args.shift + if parent.kind_of?(Tk::BWidget::Tree::Node) + if parent.tree.path != @tree.path + fail RuntimeError, 'tree of parent node is not match' + end + end + elsif tree.kind_of?(Tk::BWidget::Tree::Node) + @tree = tree.tree + parent = tree.parent + else + fail RuntimeError, + "expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument" + end + + if args[-1].kind_of?(Hash) + keys = _symbolkey2str(args.pop) + else + keys = {} + end + + index = keys.delete('index') + unless args.empty? + index = args.shift + end + index = 'end' unless index + + unless args.empty? + fail RuntimeError, 'too much arguments' + end + + @tpath = @tree.path + + if keys.key?('nodename') + @path = @id = keys.delete('nodename') + else + @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 + + @tree.insert(index, parent, @id, keys) + end + + def tree + @tree + end + + def id + @id + end + + def [](key) + cget(key) + end + + def []=(key, val) + configure(key, val) + val + end + + def cget(key) + @tree.itemcget(@id, key) + end + + def configure(key, val=None) + @tree.itemconfigure(@id, key, val) + end + + def configinfo(key=nil) + @tree.itemconfiginfo(@id, key) + end + + def current_configinfo(key=nil) + @tree.current_itemconfiginfo(@id, key) + end + + def close_tree(recurse=None) + @tree.close_tree(@id, recurse) + self + end + + def delete + @tree.delete(@id) + self + end + + def edit(*args) + @tree.edit(@id, *args) + self + end + + def exist? + @tree.exist?(@id) + end + + def index + @tree.index(@id) + end + + def move(index, parent=nil) + if parent + @tree.move(parent, @id, index) + else + @tree.move(self.parent, @id, index) + end + end + + def open_tree(recurse=None) + @tree.open_tree(@id, recurse) + self + end + + def open? + bool(@tree.itemcget(@id, 'open')) + end + + def parent + @tree.parent(@id) + end + + def reorder(neworder) + @tree.reorder(@id, neworder) + end + + def see + @tree.see(@id) + end + + def selection_add + @tree.selection_add(@id) + end + + def selection_remove + @tree.selection_remove(@id) + end + + def selection_set + @tree.selection_set(@id) + end + + def selection_toggle + @tree.selection_toggle(@id) + end + + def toggle + @tree.toggle(@id) + end + + def visible + @tree.visible(@id) + end +end + diff --git a/ext/tk/lib/tkextlib/bwidget/widget.rb b/ext/tk/lib/tkextlib/bwidget/widget.rb new file mode 100644 index 0000000000..eadf59c11c --- /dev/null +++ b/ext/tk/lib/tkextlib/bwidget/widget.rb @@ -0,0 +1,113 @@ +# +# tkextlib/bwidget/widget.rb +# by Hidetoshi NAGAI ([email protected]) +# + +require 'tk' +require 'tkextlib/bwidget.rb' + +module Tk + module BWidget + module Widget + end + end +end + +module Tk::BWidget::Widget + include Tk + extend Tk + + def self.__pathname + 'Widget::configure' + end + + def self.__cget_cmd + ['Widget::cget'] + end + + def self.__config_cmd + ['Widget::configure'] + end + + def self.cget(slot) + self.current_configinfo(slot).values[0] + end + + def self.add_map(klass, subclass, subpath, opts) + tk_call('Widget::addmap', klass, subclass, subpath, opts) + end + + def self.bwinclude(klass, subclass, subpath, *args) + tk_call('Widget::bwinclude', klass, subclass, subpath, *args) + end + + def self.create(klass, path, rename=None, &b) + win = window(tk_call('Widget::create', klass, path, rename)) + win.instance_eval(&b) if b + win + end + + def self.declare(klass, optlist) + tk_call('Widget::declare', klass, optlist) + end + + def self.define(klass, filename, *args) + tk_call('Widget::define', klass, filename, *args) + end + + def self.destroy(win) + tk_call('Widget::destroy', win) + end + + def self.focus_next(win) + tk_call('Widget::focusNext', win) + end + + def self.focus_ok(win) + tk_call('Widget::focusOk', win) + end + + def self.focus_prev(win) + tk_call('Widget::focusPrev', win) + end + + def self.generate_doc(dir, widgetlist) + tk_call('Widget::generate-doc', dir, widgetlist) + end + + def self.generate_widget_doc(klass, iscmd, file) + tk_call('Widget::generate-widget-doc', klass, iscmd, file) + end + + def self.get_option(win, option) + tk_call('Widget::getoption', win, option) + end + + def self.get_variable(win, varname, my_varname=None) + tk_call('Widget::getVariable', win, varname, my_varname) + end + + def self.has_changed(win, option, pvalue) + tk_call('Widget::hasChanged', win, option, pvalue) + end + + def self.init(klass, win, options) + tk_call('Widget::init', klass, win, options) + end + + def self.set_option(win, option, value) + tk_call('Widget::setoption', win, option, value) + end + + def self.sub_cget(win, subwidget) + tk_call('Widget::subcget', win, subwidget) + end + + def self.sync_options(klass, subclass, subpath, options) + tk_call('Widget::syncoptions', klass, subclass, subpath, options) + end + + def self.tkinclude(klass, tkwidget, subpath, *args) + tk_call('Widget::tkinclude', klass, tkwidget, subpath, *args) + end +end diff --git a/ext/tk/lib/tkextlib/tcllib.rb b/ext/tk/lib/tkextlib/tcllib.rb index 56f21556ae..2955416b2b 100644 --- a/ext/tk/lib/tkextlib/tcllib.rb +++ b/ext/tk/lib/tkextlib/tcllib.rb @@ -8,50 +8,36 @@ require 'tk' # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' -# library directory -dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - # call setup script -require File.join(dir, 'setup.rb') +require 'tkextlib/tcllib/setup.rb' # package:: autoscroll -#require 'tkextlib/tcllib/autoscroll' -require File.join(dir, 'autoscroll') +require 'tkextlib/tcllib/autoscroll' # package:: cursor -#require 'tkextlib/tcllib/cursor' -require File.join(dir, 'cursor') +require 'tkextlib/tcllib/cursor' # package:: style -#require 'tkextlib/tcllib/style' -require File.join(dir, 'style') +require 'tkextlib/tcllib/style' # autoload module Tk module Tcllib - dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - # package:: ctext - #autoload :CText, 'tkextlib/tcllib/ctext' - autoload :CText, File.join(dir, 'ctext') + autoload :CText, 'tkextlib/tcllib/ctext' # package:: datefield - #autoload :Datefield, 'tkextlib/tcllib/datefield' - #autoload :DateField, 'tkextlib/tcllib/datefield' - autoload :Datefield, File.join(dir, 'datefield') - autoload :DateField, File.join(dir, 'datefield') + autoload :Datefield, 'tkextlib/tcllib/datefield' + autoload :DateField, 'tkextlib/tcllib/datefield' # package:: ipentry - #autoload :IP_Entry, 'tkextlib/tcllib/ip_entry' - autoload :IP_Entry, File.join(dir, 'ip_entry') + autoload :IP_Entry, 'tkextlib/tcllib/ip_entry' # package:: Plotchart - #autoload :Plotchart, 'tkextlib/tcllib/plotchart' - autoload :Plotchart, File.join(dir, 'plotchart') + autoload :Plotchart, 'tkextlib/tcllib/plotchart' # package:: tkpiechart - #autoload :Tkpiechart, 'tkextlib/tcllib/tkpiechart' - autoload :Tkpiechart, File.join(dir, 'tkpiechart') + autoload :Tkpiechart, 'tkextlib/tcllib/tkpiechart' end end diff --git a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb index 9c161d7ec9..800a70744c 100644 --- a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb +++ b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb @@ -26,17 +26,24 @@ require 'tk' require 'tk/scrollbar' - -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tcllib.rb' # TkPackage.require('autoscroll', '1.0') TkPackage.require('autoscroll') module Tk + module Tcllib + module Autoscroll + def self.package_version + begin + TkPackage.require('autoscroll') + rescue + '' + end + end + end + end + module Scrollable def autoscroll(mode = nil) case mode diff --git a/ext/tk/lib/tkextlib/tcllib/ctext.rb b/ext/tk/lib/tkextlib/tcllib/ctext.rb index 6fa3e2edda..2318235a4d 100644 --- a/ext/tk/lib/tkextlib/tcllib/ctext.rb +++ b/ext/tk/lib/tkextlib/tcllib/ctext.rb @@ -8,12 +8,7 @@ require 'tk' require 'tk/text' - -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tcllib.rb' # TkPackage.require('ctext', '3.1') TkPackage.require('ctext') @@ -21,6 +16,13 @@ TkPackage.require('ctext') module Tk module Tcllib class CText < TkText + def self.package_version + begin + TkPackage.require('ctext') + rescue + '' + end + end end end end diff --git a/ext/tk/lib/tkextlib/tcllib/cursor.rb b/ext/tk/lib/tkextlib/tcllib/cursor.rb index cf4f247209..119b8a143f 100644 --- a/ext/tk/lib/tkextlib/tcllib/cursor.rb +++ b/ext/tk/lib/tkextlib/tcllib/cursor.rb @@ -7,17 +7,24 @@ # require 'tk' - -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tcllib.rb' # TkPackage.require('cursor', '0.1') TkPackage.require('cursor') module Tk + module Tcllib + module Cursor + def self.package_version + begin + TkPackage.require('ipentry') + rescue + '' + end + end + end + end + def self.cursor_display(parent=None) # Pops up a dialog with a listbox containing all the cursor names. # Selecting a cursor name will display it in that dialog. diff --git a/ext/tk/lib/tkextlib/tcllib/datefield.rb b/ext/tk/lib/tkextlib/tcllib/datefield.rb index 6d3ba4693f..4d80b06866 100644 --- a/ext/tk/lib/tkextlib/tcllib/datefield.rb +++ b/ext/tk/lib/tkextlib/tcllib/datefield.rb @@ -17,12 +17,7 @@ require 'tk' require 'tk/entry' - -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tcllib.rb' # TkPackage.require('datefield', '0.1') TkPackage.require('datefield') @@ -30,6 +25,13 @@ TkPackage.require('datefield') module Tk module Tcllib class Datefield < TkEntry + def self.package_version + begin + TkPackage.require('datefield') + rescue + '' + end + end end DateField = Datefield end diff --git a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb index aed47da63a..748478a322 100644 --- a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb +++ b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb @@ -11,13 +11,7 @@ # It guarantees a valid address at all times. require 'tk' -require 'tk/entry' - -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tcllib.rb' # TkPackage.require('ipentry', '0.1') TkPackage.require('ipentry') @@ -25,6 +19,13 @@ TkPackage.require('ipentry') module Tk module Tcllib class IP_Entry < TkEntry + def self.package_version + begin + TkPackage.require('ipentry') + rescue + '' + end + end end end end diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb index 108507b05b..b22a4ebbdf 100644 --- a/ext/tk/lib/tkextlib/tcllib/plotchart.rb +++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb @@ -58,12 +58,7 @@ # require 'tk' - -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tcllib.rb' # TkPackage.require('Plotchart', '0.9') TkPackage.require('Plotchart') @@ -71,6 +66,13 @@ TkPackage.require('Plotchart') module Tk module Tcllib module Plotchart + def self.package_version + begin + TkPackage.require('Plotchart') + rescue + '' + end + end end end end @@ -122,7 +124,7 @@ module Tk::Tcllib::Plotchart ############################ module ChartMethod - include TkUtil + include TkCore def title(str) tk_call_without_enc(@chart, 'title', _get_eval_enc_str(str)) diff --git a/ext/tk/lib/tkextlib/tcllib/style.rb b/ext/tk/lib/tkextlib/tcllib/style.rb index e441cd83b0..dea2962b7f 100644 --- a/ext/tk/lib/tkextlib/tcllib/style.rb +++ b/ext/tk/lib/tkextlib/tcllib/style.rb @@ -7,18 +7,21 @@ # require 'tk' - -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tcllib.rb' # TkPackage.require('style', '0.1') TkPackage.require('style') module Tk module Style + def self.package_version + begin + TkPackage.require('style') + rescue + '' + end + end + def self.names tk_split_simplelist(tk_call('style::names')) end diff --git a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb index 1ef49ef4f4..4665edca7e 100644 --- a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb +++ b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb @@ -8,12 +8,7 @@ require 'tk' require 'tk/canvas' - -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tcllib.rb' # TkPackage.require('tkpiechart', '6.6') TkPackage.require('tkpiechart') @@ -26,6 +21,14 @@ module Tk end module Tk::Tcllib::Tkpiechart + def self.package_version + begin + TkPackage.require('tkpiechart') + rescue + '' + end + end + module ConfigMethod include TkConfigMethod diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb index 866cdf0644..7633981559 100644 --- a/ext/tk/lib/tkextlib/tile.rb +++ b/ext/tk/lib/tkextlib/tile.rb @@ -9,10 +9,7 @@ require 'tk' require 'tkextlib/setup.rb' # library directory -dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - -# call setup script -require File.join(dir, 'setup.rb') +require 'tkextlib/tile/setup.rb' # load package # TkPackage.require('tile', '0.4') @@ -21,6 +18,14 @@ TkPackage.require('tile') # autoload module Tk module Tile + def self.package_version + begin + TkPackage.require('tile') + rescue + '' + end + end + module TileWidget def instate(state, script=nil, &b) if script @@ -41,33 +46,22 @@ module Tk end end + ###################################### - # library directory - dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - - #autoload :TButton, 'tkextlib/tile/tbutton' - autoload :TButton, File.join(dir, 'tbutton') + autoload :TButton, 'tkextlib/tile/tbutton' - #autoload :TCheckButton, 'tkextlib/tile/tcheckbutton' - #autoload :TCheckbutton, 'tkextlib/tile/tcheckbutton' - autoload :TCheckButton, File.join(dir, 'tcheckbutton') - autoload :TCheckbutton, File.join(dir, 'tcheckbutton') + autoload :TCheckButton, 'tkextlib/tile/tcheckbutton' + autoload :TCheckbutton, 'tkextlib/tile/tcheckbutton' - #autoload :TLabel, 'tkextlib/tile/tlabel' - autoload :TLabel, File.join(dir, 'tlabel') + autoload :TLabel, 'tkextlib/tile/tlabel' - #autoload :TMenubutton, 'tkextlib/tile/tmenubutton' - autoload :TMenubutton, File.join(dir, 'tmenubutton') + autoload :TMenubutton, 'tkextlib/tile/tmenubutton' - #autoload :TNotebook, 'tkextlib/tile/tnotebook' - autoload :TNotebook, File.join(dir, 'tnotebook') + autoload :TNotebook, 'tkextlib/tile/tnotebook' - #autoload :TRadioButton, 'tkextlib/tile/tradiobutton' - #autoload :TRadiobutton, 'tkextlib/tile/tradiobutton' - autoload :TRadioButton, File.join(dir, 'tradiobutton') - autoload :TRadiobutton, File.join(dir, 'tradiobutton') + autoload :TRadioButton, 'tkextlib/tile/tradiobutton' + autoload :TRadiobutton, 'tkextlib/tile/tradiobutton' - #autoload :Style, 'tkextlib/tile/style' - autoload :Style, File.join(dir, 'style') + autoload :Style, 'tkextlib/tile/style' end end diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb index be4b45ab73..474c4f21b9 100644 --- a/ext/tk/lib/tkextlib/tile/style.rb +++ b/ext/tk/lib/tkextlib/tile/style.rb @@ -3,12 +3,14 @@ # by Hidetoshi NAGAI ([email protected]) # require 'tk' +require 'tkextlib/tile.rb' -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -- <libdir>/tkextlib/tile.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +module Tk + module Tile + module Style + end + end +end module Tk::Tile::Style end diff --git a/ext/tk/lib/tkextlib/tile/tbutton.rb b/ext/tk/lib/tkextlib/tile/tbutton.rb index c73b7904ed..b5c3475692 100644 --- a/ext/tk/lib/tkextlib/tile/tbutton.rb +++ b/ext/tk/lib/tkextlib/tile/tbutton.rb @@ -3,12 +3,14 @@ # by Hidetoshi NAGAI ([email protected]) # require 'tk' +require 'tkextlib/tile.rb' -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -- <libdir>/tkextlib/tile.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +module Tk + module Tile + class TButton < TkButton + end + end +end class Tk::Tile::TButton < TkButton include Tk::Tile::TileWidget diff --git a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb index f5ab008820..4ba77d95d3 100644 --- a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb +++ b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb @@ -3,12 +3,15 @@ # by Hidetoshi NAGAI ([email protected]) # require 'tk' +require 'tkextlib/tile.rb' -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -- <libdir>/tkextlib/tile.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +module Tk + module Tile + class TCheckButton < TkCheckButton + end + TCheckbutton = TCheckButton + end +end class Tk::Tile::TCheckButton < TkCheckButton include Tk::Tile::TileWidget @@ -26,8 +29,3 @@ class Tk::Tile::TCheckButton < TkCheckButton end private :create_self end -module Tk - module Tile - TCheckbutton = TCheckButton - end -end diff --git a/ext/tk/lib/tkextlib/tile/tlabel.rb b/ext/tk/lib/tkextlib/tile/tlabel.rb index 1b7302cab1..d2eaf45273 100644 --- a/ext/tk/lib/tkextlib/tile/tlabel.rb +++ b/ext/tk/lib/tkextlib/tile/tlabel.rb @@ -3,12 +3,14 @@ # by Hidetoshi NAGAI ([email protected]) # require 'tk' +require 'tkextlib/tile.rb' -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -- <libdir>/tkextlib/tile.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +module Tk + module Tile + class TLabel < TkLabel + end + end +end class Tk::Tile::TLabel < TkLabel include Tk::Tile::TileWidget diff --git a/ext/tk/lib/tkextlib/tile/tmenubutton.rb b/ext/tk/lib/tkextlib/tile/tmenubutton.rb index c827629c7d..332db2b74e 100644 --- a/ext/tk/lib/tkextlib/tile/tmenubutton.rb +++ b/ext/tk/lib/tkextlib/tile/tmenubutton.rb @@ -3,12 +3,14 @@ # by Hidetoshi NAGAI ([email protected]) # require 'tk' +require 'tkextlib/tile.rb' -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -- <libdir>/tkextlib/tile.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +module Tk + module Tile + class TMenubutton < TkMenubutton + end + end +end class Tk::Tile::TMenubutton < TkMenubutton include Tk::Tile::TileWidget diff --git a/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ext/tk/lib/tkextlib/tile/tnotebook.rb index 40242b5235..c693d5ce2b 100644 --- a/ext/tk/lib/tkextlib/tile/tnotebook.rb +++ b/ext/tk/lib/tkextlib/tile/tnotebook.rb @@ -3,12 +3,14 @@ # by Hidetoshi NAGAI ([email protected]) # require 'tk' +require 'tkextlib/tile.rb' -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -- <libdir>/tkextlib/tile.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +module Tk + module Tile + class TNotebook < TkWindow + end + end +end class Tk::Tile::TNotebook < TkWindow ################################ diff --git a/ext/tk/lib/tkextlib/tile/tradiobutton.rb b/ext/tk/lib/tkextlib/tile/tradiobutton.rb index 2587a74cf3..66cba62960 100644 --- a/ext/tk/lib/tkextlib/tile/tradiobutton.rb +++ b/ext/tk/lib/tkextlib/tile/tradiobutton.rb @@ -3,12 +3,15 @@ # by Hidetoshi NAGAI ([email protected]) # require 'tk' +require 'tkextlib/tile.rb' -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -- <libdir>/tkextlib/tile.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +module Tk + module Tile + class TRadioButton < TkRadioButton + end + TRadiobutton = TRadioButton + end +end class Tk::Tile::TRadioButton < TkRadioButton include Tk::Tile::TileWidget @@ -26,8 +29,3 @@ class Tk::Tile::TRadioButton < TkRadioButton end private :create_self end -module Tk - module Tile - TRadiobutton = TRadioButton - end -end diff --git a/ext/tk/lib/tkextlib/tkDND.rb b/ext/tk/lib/tkextlib/tkDND.rb index 260769df7f..5d52e34418 100644 --- a/ext/tk/lib/tkextlib/tkDND.rb +++ b/ext/tk/lib/tkextlib/tkDND.rb @@ -7,19 +7,12 @@ require 'tk' # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' -# library directory -dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - # call setup script -require File.join(dir, 'setup.rb') +require 'tkextlib/tkDND/setup.rb' module Tk module TkDND - dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - - #autoload :DND, 'tkextlib/tkDND/tkdnd' - #autoload :Shape, 'tkextlib/tkDND/shape' - autoload :DND, File.join(dir, 'tkdnd') - autoload :Shape, File.join(dir, 'shape') + autoload :DND, 'tkextlib/tkDND/tkdnd' + autoload :Shape, 'tkextlib/tkDND/shape' end end diff --git a/ext/tk/lib/tkextlib/tkDND/shape.rb b/ext/tk/lib/tkextlib/tkDND/shape.rb index 3e4a94f526..8f4716ceea 100644 --- a/ext/tk/lib/tkextlib/tkDND/shape.rb +++ b/ext/tk/lib/tkextlib/tkDND/shape.rb @@ -9,7 +9,7 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkDND/setup.rb' # TkPackage.require('shape', '0.3') TkPackage.require('shape') @@ -17,9 +17,29 @@ TkPackage.require('shape') module Tk module TkDND module Shape +=begin + def self.package_version + begin + TkPackage.require('shape') + rescue + '' + end + end +=end + def self.package_version + Tk.tk_call('set', 'shape_version') + end + alias shape_version package_version + + def self.package_patchlevel + Tk.tk_call('set', 'shape_patchlevel') + end + alias shape_patchlevel package_patchlevel + def self.version tk_call('shape', 'version') end + alias xshape_version version ############################ diff --git a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb index 036d1998bd..d0895c2afd 100644 --- a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb +++ b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb @@ -9,12 +9,20 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkDND/setup.rb' TkPackage.require('tkdnd') module Tk module TkDND + def self.package_version + begin + TkPackage.require('tkdnd') + rescue + '' + end + end + class DND_Subst < TkUtil::CallbackSubst KEY_TBL = [ [ ?a, ?l, :actions ], @@ -49,6 +57,14 @@ module Tk end module DND + def self.version + begin + TkPackage.require('tkdnd') + rescue + '' + end + end + def dnd_bindtarget_info(type=nil, event=nil) if event procedure(tk_call('dnd', 'bindtarget', @path, type, event)) diff --git a/ext/tk/lib/tkextlib/tkHTML.rb b/ext/tk/lib/tkextlib/tkHTML.rb index f32aed99f1..5fddde72ff 100644 --- a/ext/tk/lib/tkextlib/tkHTML.rb +++ b/ext/tk/lib/tkextlib/tkHTML.rb @@ -6,11 +6,8 @@ # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' -# library directory -dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - # call setup script -require File.join(dir, 'setup.rb') +require 'tkextlib/tkHTML/setup.rb' # load library -require File.join(dir, 'htmlwidget') +require 'tkextlib/tkHTML/htmlwidget' diff --git a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb index 5c0657025a..0c900cdb85 100644 --- a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb +++ b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb @@ -9,21 +9,27 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkHTML/setup.rb' # TkPackage.require('Tkhtml', '2.0') TkPackage.require('Tkhtml') module Tk class HTML_Widget < TkWindow + def self.package_version + begin + TkPackage.require('Tkhtml') + rescue + '' + end + end + class ClippingWindow < TkWindow end end end class Tk::HTML_Widget::ClippingWindow - extend TkUtil - WidgetClassName = 'HtmlClip'.freeze WidgetClassNames[WidgetClassName] = self @@ -32,7 +38,7 @@ class Tk::HTML_Widget::ClippingWindow def self.new(parent, keys={}) if parent.kind_of?(Hash) - keys = _symbolkey2str(parent) + keys = TkComm._symbolkey2str(parent) parent = keys.delete('parent') end diff --git a/ext/tk/lib/tkextlib/tkimg.rb b/ext/tk/lib/tkextlib/tkimg.rb index 06184589b4..f70d76c9d1 100644 --- a/ext/tk/lib/tkextlib/tkimg.rb +++ b/ext/tk/lib/tkextlib/tkimg.rb @@ -8,16 +8,24 @@ require 'tk' # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' -# library directory -dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - # call setup script -require File.join(dir, 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # load all image format handlers #TkPackage.require('Img', '1.3') TkPackage.require('Img') +module Tk + module Img + def self.package_version + begin + TkPackage.require('Img') + rescue + '' + end + end + end +end + # autoload -#autoload :TkPixmapImage, 'tkextlib/tkimg/pixmap' -autoload :TkPixmapImage, File.join(dir, 'pixmap') +autoload :TkPixmapImage, 'tkextlib/tkimg/pixmap' diff --git a/ext/tk/lib/tkextlib/tkimg/bmp.rb b/ext/tk/lib/tkextlib/tkimg/bmp.rb index 5bef0c7168..e6031a43ea 100644 --- a/ext/tk/lib/tkextlib/tkimg/bmp.rb +++ b/ext/tk/lib/tkextlib/tkimg/bmp.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' #TkPackage.require('img::bmp', '1.3') TkPackage.require('img::bmp') + +module Tk + module Img + module BMP + def self.package_version + begin + TkPackage.require('img::bmp') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/gif.rb b/ext/tk/lib/tkextlib/tkimg/gif.rb index 65c3b88a50..b464434498 100644 --- a/ext/tk/lib/tkextlib/tkimg/gif.rb +++ b/ext/tk/lib/tkextlib/tkimg/gif.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::gif', '1.3') TkPackage.require('img::gif') + +module Tk + module Img + module GIF + def self.package_version + begin + TkPackage.require('img::gif') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/ico.rb b/ext/tk/lib/tkextlib/tkimg/ico.rb index 43646ec8da..2872a621ad 100644 --- a/ext/tk/lib/tkextlib/tkimg/ico.rb +++ b/ext/tk/lib/tkextlib/tkimg/ico.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::ico', '1.3') TkPackage.require('img::ico') + +module Tk + module Img + module ICO + def self.package_version + begin + TkPackage.require('img::ico') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/jpeg.rb b/ext/tk/lib/tkextlib/tkimg/jpeg.rb index 7b4df8c050..eac39083bc 100644 --- a/ext/tk/lib/tkextlib/tkimg/jpeg.rb +++ b/ext/tk/lib/tkextlib/tkimg/jpeg.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::jpeg', '1.3') TkPackage.require('img::jpeg') + +module Tk + module Img + module JPEG + def self.package_version + begin + TkPackage.require('img::jpeg') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/pcx.rb b/ext/tk/lib/tkextlib/tkimg/pcx.rb index 4486ba2449..26311e5984 100644 --- a/ext/tk/lib/tkextlib/tkimg/pcx.rb +++ b/ext/tk/lib/tkextlib/tkimg/pcx.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::pcx', '1.3') TkPackage.require('img::pcx') + +module Tk + module Img + module PCX + def self.package_version + begin + TkPackage.require('img::pcx') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/pixmap.rb b/ext/tk/lib/tkextlib/tkimg/pixmap.rb index 0c18c71408..ae8d3201cb 100644 --- a/ext/tk/lib/tkextlib/tkimg/pixmap.rb +++ b/ext/tk/lib/tkextlib/tkimg/pixmap.rb @@ -8,12 +8,30 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::pixmap', '1.3') TkPackage.require('img::pixmap') +module Tk + module Img + module PIXMAP + def self.package_version + begin + TkPackage.require('img::pixmap') + rescue + '' + end + end + end + end +end + class TkPixmapImage<TkImage + def self.version + Tk::Img::PIXMAP.version + end + def initialize(*args) @type = 'pixmap' super diff --git a/ext/tk/lib/tkextlib/tkimg/png.rb b/ext/tk/lib/tkextlib/tkimg/png.rb index 275035f47e..acdd8c536f 100644 --- a/ext/tk/lib/tkextlib/tkimg/png.rb +++ b/ext/tk/lib/tkextlib/tkimg/png.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::png', '1.3') TkPackage.require('img::png') + +module Tk + module Img + module PNG + def self.package_version + begin + TkPackage.require('img::png') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/ppm.rb b/ext/tk/lib/tkextlib/tkimg/ppm.rb index 730978b281..f15bdb9f18 100644 --- a/ext/tk/lib/tkextlib/tkimg/ppm.rb +++ b/ext/tk/lib/tkextlib/tkimg/ppm.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::ppm', '1.3') TkPackage.require('img::ppm') + +module Tk + module Img + module PPM + def self.package_version + begin + TkPackage.require('img::ppm') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/ps.rb b/ext/tk/lib/tkextlib/tkimg/ps.rb index edfb8dd783..7c5cab2a4f 100644 --- a/ext/tk/lib/tkextlib/tkimg/ps.rb +++ b/ext/tk/lib/tkextlib/tkimg/ps.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::ps', '1.3') TkPackage.require('img::ps') + +module Tk + module Img + module PS + def self.package_version + begin + TkPackage.require('img::ps') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/sgi.rb b/ext/tk/lib/tkextlib/tkimg/sgi.rb index 9dcfa614b0..1cdf60e64c 100644 --- a/ext/tk/lib/tkextlib/tkimg/sgi.rb +++ b/ext/tk/lib/tkextlib/tkimg/sgi.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::sgi', '1.3') TkPackage.require('img::sgi') + +module Tk + module Img + module SGI + def self.package_version + begin + TkPackage.require('img::sgi') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/sun.rb b/ext/tk/lib/tkextlib/tkimg/sun.rb index 4ada9c7ff1..88f9a44656 100644 --- a/ext/tk/lib/tkextlib/tkimg/sun.rb +++ b/ext/tk/lib/tkextlib/tkimg/sun.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::sun', '1.3') TkPackage.require('img::sun') + +module Tk + module Img + module SUN + def self.package_version + begin + TkPackage.require('img::sun') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/tga.rb b/ext/tk/lib/tkextlib/tkimg/tga.rb index 221ebe5db1..c4068a729c 100644 --- a/ext/tk/lib/tkextlib/tkimg/tga.rb +++ b/ext/tk/lib/tkextlib/tkimg/tga.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::tga', '1.3') TkPackage.require('img::tga') + +module Tk + module Img + module TGA + def self.package_version + begin + TkPackage.require('img::tga') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/tiff.rb b/ext/tk/lib/tkextlib/tkimg/tiff.rb index 1c7e940843..529999ef2d 100644 --- a/ext/tk/lib/tkextlib/tkimg/tiff.rb +++ b/ext/tk/lib/tkextlib/tkimg/tiff.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::tiff', '1.3') TkPackage.require('img::tiff') + +module Tk + module Img + module TIFF + def self.package_version + begin + TkPackage.require('img::tiff') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/window.rb b/ext/tk/lib/tkextlib/tkimg/window.rb index 056aa8f3cf..229445dd46 100644 --- a/ext/tk/lib/tkextlib/tkimg/window.rb +++ b/ext/tk/lib/tkextlib/tkimg/window.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::window', '1.3') TkPackage.require('img::window') + +module Tk + module Img + module WINDOW + def self.package_version + begin + TkPackage.require('img::window') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/xbm.rb b/ext/tk/lib/tkextlib/tkimg/xbm.rb index 80010c77de..3b680d9b59 100644 --- a/ext/tk/lib/tkextlib/tkimg/xbm.rb +++ b/ext/tk/lib/tkextlib/tkimg/xbm.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::xbm', '1.3') TkPackage.require('img::xbm') + +module Tk + module Img + module XBM + def self.package_version + begin + TkPackage.require('img::xbm') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tkimg/xpm.rb b/ext/tk/lib/tkextlib/tkimg/xpm.rb index 04d56287ef..eff1e3c2b6 100644 --- a/ext/tk/lib/tkextlib/tkimg/xpm.rb +++ b/ext/tk/lib/tkextlib/tkimg/xpm.rb @@ -8,7 +8,21 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tkimg/setup.rb' # TkPackage.require('img::xpm', '1.3') TkPackage.require('img::xpm') + +module Tk + module Img + module XPM + def self.package_version + begin + TkPackage.require('img::xpm') + rescue + '' + end + end + end + end +end diff --git a/ext/tk/lib/tkextlib/tktrans.rb b/ext/tk/lib/tkextlib/tktrans.rb index 93bb338a9b..3236b53420 100644 --- a/ext/tk/lib/tkextlib/tktrans.rb +++ b/ext/tk/lib/tkextlib/tktrans.rb @@ -7,11 +7,8 @@ require 'tk' # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' -# library directory -dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - # call setup script -require File.join(dir, 'setup.rb') +require 'tkextlib/tktrans/setup.rb' # load library -require File.join(dir, 'tktrans') +require 'tkextlib/tktrans/tktrans') diff --git a/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/ext/tk/lib/tkextlib/tktrans/tktrans.rb index fa5d7a2eae..2acdac7217 100644 --- a/ext/tk/lib/tkextlib/tktrans/tktrans.rb +++ b/ext/tk/lib/tkextlib/tktrans/tktrans.rb @@ -8,17 +8,23 @@ require 'tk' require 'tkextlib/setup.rb' # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/tktrans/setup.rb' TkPackage.require('tktrans') rescue Tk.load_tcllibrary('tktrans') -class TkWindow - begin - TkTrans_VERSION = TkPackage.require('tktrans') - rescue - TkTrans_VERSION = nil +module Tk + module TkTrans + def self.package_version + begin + TkPackage.require('tktrans') + rescue + '' + end + end end +end +class TkWindow def tktrans_set_image(img) tk_send('tktrans::setwidget', @path, img) self diff --git a/ext/tk/lib/tkextlib/treectrl.rb b/ext/tk/lib/tkextlib/treectrl.rb index fb03283a8d..c8fba54a67 100644 --- a/ext/tk/lib/tkextlib/treectrl.rb +++ b/ext/tk/lib/tkextlib/treectrl.rb @@ -6,11 +6,8 @@ # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' -# library directory -dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - # call setup script -require File.join(dir, 'setup.rb') +require 'tkextlib/treectrl/setup.rb' # load library -require File.join(dir, 'tktreectrl') +require 'tkextlib/treectrl/tktreectrl') diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb index fb74b72c3b..4b5219e60b 100644 --- a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb +++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb @@ -5,16 +5,24 @@ require 'tk' +# call setup script for general 'tkextlib' libraries +require 'tkextlib/setup.rb' + # call setup script -require File.join(File.dirname(File.expand_path(__FILE__)), 'setup.rb') +require 'tkextlib/treectrl/setup.rb' # TkPackage.require('treectrl', '1.0') -#TkPackage.require('treectrl') +TkPackage.require('treectrl') module Tk class TreeCtrl_Widget < TkWindow - #VERSION = TkPackage.require('treectrl', '1.0') - VERSION = TkPackage.require('treectrl') + def self.package_version + begin + TkPackage.require('treectrl') + rescue + '' + end + end class NotifyEvent < TkUtil::CallbackSubst end @@ -312,6 +320,12 @@ class Tk::TreeCtrl_Widget WidgetClassName = ''.freeze WidgetClassNames[WidgetClassName] = self + def install_bind(cmd, *args) + install_bind_for_event_class(Tk::TreeCtrl_Widget::NotifyEvent, cmd, *args) + end + + ######################### + def create_self(keys) if keys and keys != None tk_call_without_enc('treectrl', @path, *hash_kv(keys, true)) diff --git a/ext/tk/lib/tkextlib/vu.rb b/ext/tk/lib/tkextlib/vu.rb index 923b67ce4e..4d61243340 100644 --- a/ext/tk/lib/tkextlib/vu.rb +++ b/ext/tk/lib/tkextlib/vu.rb @@ -8,33 +8,34 @@ require 'tk' # call setup script for general 'tkextlib' libraries require 'tkextlib/setup.rb' -# library directory -dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') - # call setup script -require File.join(dir, 'setup.rb') +require 'tkextlib/vu/setup.rb' # load package # TkPackage.require('vu', '2.1') -#TkPackage.require('vu') +TkPackage.require('vu') # autoload module Tk module Vu - # load package - # VERSION = TkPackage.require('vu', '2.1') - VERSION = TkPackage.require('vu') + def self.package_version + begin + TkPackage.require('vu') + rescue + '' + end + end - dir = File.expand_path(__FILE__).sub(/#{File.extname(__FILE__)}$/, '') + ########################################## - autoload :Dial, File.join(dir, 'dial') + autoload :Dial, 'tkextlib/vu/dial' - autoload :Pie, File.join(dir, 'pie') - autoload :PieSlice, File.join(dir, 'pie') - autoload :NamedPieSlice, File.join(dir, 'pie') + autoload :Pie, 'tkextlib/vu/pie' + autoload :PieSlice, 'tkextlib/vu/pie' + autoload :NamedPieSlice, 'tkextlib/vu/pie' - autoload :Spinbox, File.join(dir, 'spinbox') + autoload :Spinbox, 'tkextlib/vu/spinbox' - autoload :Bargraph, File.join(dir, 'bargraph') + autoload :Bargraph, 'tkextlib/vu/bargraph' end end diff --git a/ext/tk/lib/tkextlib/vu/bargraph.rb b/ext/tk/lib/tkextlib/vu/bargraph.rb index 1dbd49db28..3ac08a26a5 100644 --- a/ext/tk/lib/tkextlib/vu/bargraph.rb +++ b/ext/tk/lib/tkextlib/vu/bargraph.rb @@ -12,8 +12,9 @@ module Tk end end + # call setup script -- <libdir>/tkextlib/vu.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +require 'tkextlib/vu.rb' class Tk::Vu::Bargraph < TkWindow TkCommandNames = ['::vu::bargraph'.freeze].freeze diff --git a/ext/tk/lib/tkextlib/vu/charts.rb b/ext/tk/lib/tkextlib/vu/charts.rb index bf2a3075bd..594582d69b 100644 --- a/ext/tk/lib/tkextlib/vu/charts.rb +++ b/ext/tk/lib/tkextlib/vu/charts.rb @@ -6,7 +6,7 @@ require 'tk' require 'tk/canvas' # call setup script -- <libdir>/tkextlib/vu.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +require 'tkextlib/vu.rb' module Tk module Vu diff --git a/ext/tk/lib/tkextlib/vu/dial.rb b/ext/tk/lib/tkextlib/vu/dial.rb index 4d5770a320..e675ceb2de 100644 --- a/ext/tk/lib/tkextlib/vu/dial.rb +++ b/ext/tk/lib/tkextlib/vu/dial.rb @@ -13,7 +13,7 @@ module Tk end # call setup script -- <libdir>/tkextlib/vu.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +require 'tkextlib/vu.rb' # define module/class class Tk::Vu::Dial < TkWindow diff --git a/ext/tk/lib/tkextlib/vu/pie.rb b/ext/tk/lib/tkextlib/vu/pie.rb index 833039c9f2..cacca594e6 100644 --- a/ext/tk/lib/tkextlib/vu/pie.rb +++ b/ext/tk/lib/tkextlib/vu/pie.rb @@ -18,7 +18,7 @@ module Tk end # call setup script -- <libdir>/tkextlib/vu.rb -require(File.dirname(File.expand_path(__FILE__)) + '.rb') +require 'tkextlib/vu.rb' module Tk::Vu::PieSliceConfigMethod include TkItemConfigMethod @@ -46,7 +46,8 @@ class Tk::Vu::Pie < TkWindow if tag.kind_of?(Tk::Vu::PieSlice) tag.id else - tag + # tag + _get_eval_string(tag) end end diff --git a/ext/tk/lib/tkextlib/vu/spinbox.rb b/ext/tk/lib/tkextlib/vu/spinbox.rb index db2743613c..f586434138 100644 --- a/ext/tk/lib/tkextlib/vu/spinbox.rb +++ b/ext/tk/lib/tkextlib/vu/spinbox.rb @@ -9,7 +9,7 @@ if (Tk::TK_MAJOR_VERSION < 8 || (Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION < 4)) # call setup script -- <libdir>/tkextlib/vu.rb - require(File.dirname(File.expand_path(__FILE__)) + '.rb') + require 'tkextlib/vu.rb' Tk.tk_call('namespace', 'import', '::vu::spinbox') end |