From 854f86e8ba65bed226ae3fbb8f385f68c51a6260 Mon Sep 17 00:00:00 2001 From: nagai Date: Sat, 5 Mar 2005 07:35:41 +0000 Subject: * ext/tk/lib/multi-tk.rb: freeze callback-entry objects * ext/tk/lib/tkextlib/tile.rb: support tile-0.6 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/tkextlib/tile/tbutton.rb | 15 +-- ext/tk/lib/tkextlib/tile/tcheckbutton.rb | 15 +-- ext/tk/lib/tkextlib/tile/tcombobox.rb | 40 ++++++ ext/tk/lib/tkextlib/tile/tentry.rb | 25 ++++ ext/tk/lib/tkextlib/tile/tframe.rb | 25 ++++ ext/tk/lib/tkextlib/tile/tlabel.rb | 15 +-- ext/tk/lib/tkextlib/tile/tlabelframe.rb | 25 ++++ ext/tk/lib/tkextlib/tile/tmenubutton.rb | 15 +-- ext/tk/lib/tkextlib/tile/tnotebook.rb | 15 +-- ext/tk/lib/tkextlib/tile/tprogressbar.rb | 40 ++++++ ext/tk/lib/tkextlib/tile/tradiobutton.rb | 15 +-- ext/tk/lib/tkextlib/tile/treeview.rb | 215 +++++++++++++++++++++++++++++++ ext/tk/lib/tkextlib/tile/tscrollbar.rb | 25 ++++ ext/tk/lib/tkextlib/tile/tseparator.rb | 25 ++++ ext/tk/lib/tkextlib/tile/tsquare.rb | 25 ++++ 15 files changed, 475 insertions(+), 60 deletions(-) create mode 100644 ext/tk/lib/tkextlib/tile/tcombobox.rb create mode 100644 ext/tk/lib/tkextlib/tile/tentry.rb create mode 100644 ext/tk/lib/tkextlib/tile/tframe.rb create mode 100644 ext/tk/lib/tkextlib/tile/tlabelframe.rb create mode 100644 ext/tk/lib/tkextlib/tile/tprogressbar.rb create mode 100644 ext/tk/lib/tkextlib/tile/treeview.rb create mode 100644 ext/tk/lib/tkextlib/tile/tscrollbar.rb create mode 100644 ext/tk/lib/tkextlib/tile/tseparator.rb create mode 100644 ext/tk/lib/tkextlib/tile/tsquare.rb (limited to 'ext/tk/lib/tkextlib/tile') diff --git a/ext/tk/lib/tkextlib/tile/tbutton.rb b/ext/tk/lib/tkextlib/tile/tbutton.rb index b5c3475692..9a6245db82 100644 --- a/ext/tk/lib/tkextlib/tile/tbutton.rb +++ b/ext/tk/lib/tkextlib/tile/tbutton.rb @@ -15,16 +15,11 @@ end class Tk::Tile::TButton < TkButton include Tk::Tile::TileWidget - TkCommandNames = ['tbutton'.freeze].freeze + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::button'.freeze].freeze + else + TkCommandNames = ['::tbutton'.freeze].freeze + end WidgetClassName = 'TButton'.freeze WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - if keys and keys != None - tk_call_without_enc('tbutton', @path, *hash_kv(keys, true)) - else - tk_call_without_enc('tbutton', @path) - end - end - private :create_self end diff --git a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb index 4ba77d95d3..aff560b699 100644 --- a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb +++ b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb @@ -16,16 +16,11 @@ end class Tk::Tile::TCheckButton < TkCheckButton include Tk::Tile::TileWidget - TkCommandNames = ['tcheckbutton'.freeze].freeze + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::checkbutton'.freeze].freeze + else + TkCommandNames = ['::tcheckbutton'.freeze].freeze + end WidgetClassName = 'TCheckbutton'.freeze WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - if keys and keys != None - tk_call_without_enc('tcheckbutton', @path, *hash_kv(keys, true)) - else - tk_call_without_enc('tcheckbutton', @path) - end - end - private :create_self end diff --git a/ext/tk/lib/tkextlib/tile/tcombobox.rb b/ext/tk/lib/tkextlib/tile/tcombobox.rb new file mode 100644 index 0000000000..8c1f2e0153 --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/tcombobox.rb @@ -0,0 +1,40 @@ +# +# tcombobox widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TCombobox < Tk::Tile::TEntry + end + end +end + +class Tk::Tile::TCombobox < Tk::Tile::TEntry + include Tk::Tile::TileWidget + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::combobox'.freeze].freeze + else + TkCommandNames = ['::tcombobox'.freeze].freeze + end + WidgetClassName = 'TCombobox'.freeze + WidgetClassNames[WidgetClassName] = self + + def current + number(tk_send_without_enc('current', idx)) + end + def current=(idx) + tk_send_without_enc('current', idx) + end + + def identify(x, y) + tk_send_without_enc('identify', x, y) + end + + def set(val) + tk_send('set', val) + end +end diff --git a/ext/tk/lib/tkextlib/tile/tentry.rb b/ext/tk/lib/tkextlib/tile/tentry.rb new file mode 100644 index 0000000000..ad47062f33 --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/tentry.rb @@ -0,0 +1,25 @@ +# +# tentry widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TEntry < TkEntry + end + end +end + +class Tk::Tile::TEntry < TkEntry + include Tk::Tile::TileWidget + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::entry'.freeze].freeze + else + TkCommandNames = ['::tentry'.freeze].freeze + end + WidgetClassName = 'TEntry'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/tile/tframe.rb b/ext/tk/lib/tkextlib/tile/tframe.rb new file mode 100644 index 0000000000..b77049305f --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/tframe.rb @@ -0,0 +1,25 @@ +# +# tframe widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TFrame < TkFrame + end + end +end + +class Tk::Tile::TFrame < TkFrame + include Tk::Tile::TileWidget + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::frame'.freeze].freeze + else + TkCommandNames = ['::tframe'.freeze].freeze + end + WidgetClassName = 'TFrame'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/tile/tlabel.rb b/ext/tk/lib/tkextlib/tile/tlabel.rb index d2eaf45273..256d37670e 100644 --- a/ext/tk/lib/tkextlib/tile/tlabel.rb +++ b/ext/tk/lib/tkextlib/tile/tlabel.rb @@ -15,16 +15,11 @@ end class Tk::Tile::TLabel < TkLabel include Tk::Tile::TileWidget - TkCommandNames = ['tlabel'.freeze].freeze + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::label'.freeze].freeze + else + TkCommandNames = ['::tlabel'.freeze].freeze + end WidgetClassName = 'TLabel'.freeze WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - if keys and keys != None - tk_call_without_enc('tlabel', @path, *hash_kv(keys, true)) - else - tk_call_without_enc('tlabel', @path) - end - end - private :create_self end diff --git a/ext/tk/lib/tkextlib/tile/tlabelframe.rb b/ext/tk/lib/tkextlib/tile/tlabelframe.rb new file mode 100644 index 0000000000..7685392934 --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/tlabelframe.rb @@ -0,0 +1,25 @@ +# +# tlabelframe widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TLabelframe < Tk::Tile::TFrame + end + end +end + +class Tk::Tile::TLabelframe < Tk::Tile::TFrame + include Tk::Tile::TileWidget + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::labelframe'.freeze].freeze + else + TkCommandNames = ['::tlabelframe'.freeze].freeze + end + WidgetClassName = 'TLabelframe'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/tile/tmenubutton.rb b/ext/tk/lib/tkextlib/tile/tmenubutton.rb index 332db2b74e..ba3400a51b 100644 --- a/ext/tk/lib/tkextlib/tile/tmenubutton.rb +++ b/ext/tk/lib/tkextlib/tile/tmenubutton.rb @@ -15,16 +15,11 @@ end class Tk::Tile::TMenubutton < TkMenubutton include Tk::Tile::TileWidget - TkCommandNames = ['tmenubutton'.freeze].freeze + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::menubutton'.freeze].freeze + else + TkCommandNames = ['::tmenubutton'.freeze].freeze + end WidgetClassName = 'TMenubutton'.freeze WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - if keys and keys != None - tk_call_without_enc('tmenubutton', @path, *hash_kv(keys, true)) - else - tk_call_without_enc('tmenubutton', @path) - end - end - private :create_self end diff --git a/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ext/tk/lib/tkextlib/tile/tnotebook.rb index c693d5ce2b..47338a9f9d 100644 --- a/ext/tk/lib/tkextlib/tile/tnotebook.rb +++ b/ext/tk/lib/tkextlib/tile/tnotebook.rb @@ -45,19 +45,14 @@ class Tk::Tile::TNotebook < TkWindow include Tk::Tile::TileWidget - TkCommandNames = ['tnotebook'.freeze].freeze + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::notebook'.freeze].freeze + else + TkCommandNames = ['::tnotebook'.freeze].freeze + end WidgetClassName = 'TNotebook'.freeze WidgetClassNames[WidgetClassName] = self - def create_self(keys) - if keys and keys != None - tk_call_without_enc('tnotebook', @path, *hash_kv(keys, true)) - else - tk_call_without_enc('tnotebook', @path) - end - end - private :create_self - def enable_traversal() tk_call_without_end('tile::enableNotebookTraversal', @path) self diff --git a/ext/tk/lib/tkextlib/tile/tprogressbar.rb b/ext/tk/lib/tkextlib/tile/tprogressbar.rb new file mode 100644 index 0000000000..f01aeb641b --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/tprogressbar.rb @@ -0,0 +1,40 @@ +# +# tprogressbar widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TProgressbar < TkWidget + end + end +end + +class Tk::Tile::TProgressbar + include Tk::Tile::TileWidget + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::progressbar'.freeze].freeze + else + TkCommandNames = ['::tprogressbar'.freeze].freeze + end + WidgetClassName = 'TProgressbar'.freeze + WidgetClassNames[WidgetClassName] = self + + def step + tk_send_without_enc('step').to_f + end + def step=(amount) + tk_send_without_enc('step', amount) + end + + def start + tk_call_without_enc('::tile::progressbar::start', @path) + end + + def stop + tk_call_without_enc('::tile::progressbar::stop', @path) + end +end diff --git a/ext/tk/lib/tkextlib/tile/tradiobutton.rb b/ext/tk/lib/tkextlib/tile/tradiobutton.rb index 66cba62960..5066538b87 100644 --- a/ext/tk/lib/tkextlib/tile/tradiobutton.rb +++ b/ext/tk/lib/tkextlib/tile/tradiobutton.rb @@ -16,16 +16,11 @@ end class Tk::Tile::TRadioButton < TkRadioButton include Tk::Tile::TileWidget - TkCommandNames = ['tradiobutton'.freeze].freeze + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::radiobutton'.freeze].freeze + else + TkCommandNames = ['::tradiobutton'.freeze].freeze + end WidgetClassName = 'TRadiobutton'.freeze WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - if keys and keys != None - tk_call_without_enc('tradiobutton', @path, *hash_kv(keys, true)) - else - tk_call_without_enc('tradiobutton', @path) - end - end - private :create_self end diff --git a/ext/tk/lib/tkextlib/tile/treeview.rb b/ext/tk/lib/tkextlib/tile/treeview.rb new file mode 100644 index 0000000000..1a5fa97e24 --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/treeview.rb @@ -0,0 +1,215 @@ +# +# treeview widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class Treeview < TkWindow + end + + module TreeviewItemConfig + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'item', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'item', id] + end + private :__item_config_cmd + + def __item_numstrval_optkeys(id) + ['width'] + end + private :__item_numstrval_optkeys + + def __item_strval_optkeys(id) + # maybe need to override + super(id) + ['id'] + end + private :__item_strval_optkeys + + def __item_boolval_optkeys(id) + ['open'] + end + private :__item_boolval_optkeys + + def __item_listval_optkeys(id) + ['values'] + end + private :__item_listval_optkeys + end + + module TreeviewColumnConfig + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'column', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'column', id] + end + private :__item_config_cmd + + def __item_listval_optkeys(id) + [] + end + private :__item_listval_optkeys + + alias columncget itemcget + alias columnconfigure itemconfigure + alias columnconfiginfo itemconfiginfo + alias current_columnconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :itemconfiginfo, :current_itemconfiginfo + end + + module TreeviewHeadingConfig + include TkItemConfigMethod + + def __item_cget_cmd(id) + [self.path, 'heading', id] + end + private :__item_cget_cmd + + def __item_config_cmd(id) + [self.path, 'heading', id] + end + private :__item_config_cmd + + def __item_listval_optkeys(id) + [] + end + private :__item_listval_optkeys + + alias headingcget itemcget + alias headingconfigure itemconfigure + alias headingconfiginfo itemconfiginfo + alias current_headingconfiginfo current_itemconfiginfo + + private :itemcget, :itemconfigure + private :itemconfiginfo, :current_itemconfiginfo + end + end +end + +class Tk::Tile::Treeview < TkWindow + include Tk::Tile::TileWidget + include Scrollable + + include Tk::Tile::TreeviewColumnConfig + include Tk::Tile::TreeviewHeadingConfig + include Tk::Tile::TreeviewItemConfig + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::treeview'.freeze].freeze + else + TkCommandNames = ['::treeview'.freeze].freeze + end + WidgetClassName = 'Treeview'.freeze + WidgetClassNames[WidgetClassName] = self + + def tagid(id) + _get_eval_string(id) + end + + def children(item) + list(tk_send_without_enc('children', item)) + end + def children=(item, *items) + tk_send_without_enc('children', item, ary2tk_list(items)) + items + end + + def delete(*items) + tk_send_without_enc('delete', ary2tk_list(items)) + self + end + + def detach(*items) + tk_send_without_enc('detach', ary2tk_list(items)) + self + end + + def exist?(item) + bool(tk_send_without_enc('exists', item)) + end + + def focus_item(item = None) + tk_send_without_enc('focus', item) + end + + def identify(x, y) + tk_send_without_enc('identify', x, y) + end + + def index(item) + number(tk_send_without_enc('index', item)) + end + + def insert(parent, idx, keys={}) + keys = _symbolkey2str(keys) + id = keys.delete('id') + if id + tk_send_without_enc('insert', parent, idx, '-id', id, *hash_kv(keys)) + else + tk_send_without_enc('insert', parent, idx, *hash_kv(keys)) + end + self + end + + def move(item, parent, idx) + tk_send_without_enc('move', item, parent, idx) + self + end + + def next(item) + tk_send_without_enc('next', item) + end + + def parent(item) + tk_send_without_enc('parent', item) + end + + def prev(item) + tk_send_without_enc('prev', item) + end + + def see(item) + tk_send_without_enc('see', item) + self + end + + def selection_add(*items) + tk_send_without_enc('selection', 'add', ary2tk_list(items)) + self + end + def selection_remove(*items) + tk_send_without_enc('selection', 'remove', ary2tk_list(items)) + self + end + def selection_set(*items) + tk_send_without_enc('selection', 'set', ary2tk_list(items)) + self + end + def selection_toggle(*items) + tk_send_without_enc('selection', 'toggle', ary2tk_list(items)) + self + end + + def get(item, col) + tk_send_without_enc('set', item, col) + end + def set(item, col, value) + tk_send_without_enc('set', item, col, value) + self + end +end diff --git a/ext/tk/lib/tkextlib/tile/tscrollbar.rb b/ext/tk/lib/tkextlib/tile/tscrollbar.rb new file mode 100644 index 0000000000..a0e4b10c91 --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/tscrollbar.rb @@ -0,0 +1,25 @@ +# +# tscrollbar widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TScrollbar < TkScrollbar + end + end +end + +class Tk::Tile::TScrollbar < TkScrollbar + include Tk::Tile::TileWidget + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::scrollbar'.freeze].freeze + else + TkCommandNames = ['::tscrollbar'.freeze].freeze + end + WidgetClassName = 'TScrollbar'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/tile/tseparator.rb b/ext/tk/lib/tkextlib/tile/tseparator.rb new file mode 100644 index 0000000000..def9d12a4b --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/tseparator.rb @@ -0,0 +1,25 @@ +# +# tseparator widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TSeparator < TkWindow + end + end +end + +class Tk::Tile::TSeparator < TkWindow + include Tk::Tile::TileWidget + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::separator'.freeze].freeze + else + TkCommandNames = ['::tseparator'.freeze].freeze + end + WidgetClassName = 'TSeparator'.freeze + WidgetClassNames[WidgetClassName] = self +end diff --git a/ext/tk/lib/tkextlib/tile/tsquare.rb b/ext/tk/lib/tkextlib/tile/tsquare.rb new file mode 100644 index 0000000000..ebcbc3c312 --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/tsquare.rb @@ -0,0 +1,25 @@ +# +# tsquare widget +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class TSquare < TkWindow + end + end +end + +class Tk::Tile::TSquare < TkWindow + include Tk::Tile::TileWidget + + if Tk::Tile::USE_TTK_NAMESPACE + TkCommandNames = ['::ttk::square'.freeze].freeze + else + TkCommandNames = ['::tsquare'.freeze].freeze + end + WidgetClassName = 'TSquare'.freeze + WidgetClassNames[WidgetClassName] = self +end -- cgit v1.2.3