diff options
Diffstat (limited to 'ext/tk/lib/tkextlib')
-rw-r--r-- | ext/tk/lib/tkextlib/tile.rb | 33 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tbutton.rb | 15 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tcheckbutton.rb | 15 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tcombobox.rb | 40 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tentry.rb | 25 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tframe.rb | 25 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tlabel.rb | 15 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tlabelframe.rb | 25 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tmenubutton.rb | 15 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tnotebook.rb | 15 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tprogressbar.rb | 40 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tradiobutton.rb | 15 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/treeview.rb | 215 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tscrollbar.rb | 25 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tseparator.rb | 25 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tsquare.rb | 25 |
16 files changed, 507 insertions, 61 deletions
diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb index 80a908369..e93fcb9c1 100644 --- a/ext/tk/lib/tkextlib/tile.rb +++ b/ext/tk/lib/tkextlib/tile.rb @@ -13,7 +13,24 @@ require 'tkextlib/tile/setup.rb' # load package # TkPackage.require('tile', '0.4') -TkPackage.require('tile') +# TkPackage.require('tile', '0.6') +verstr = TkPackage.require('tile') +ver = verstr.split('.') +if ver[0].to_i == 0 && ver[1].to_i <= 4 + # version 0.4 or former + module Tk + module Tile + USE_TTK_NAMESPACE = false + end + end +else + # version 0.5 or later + module Tk + module Tile + USE_TTK_NAMESPACE = true + end + end +end # autoload module Tk @@ -55,6 +72,12 @@ module Tk autoload :TCheckButton, 'tkextlib/tile/tcheckbutton' autoload :TCheckbutton, 'tkextlib/tile/tcheckbutton' + autoload :TEntry, 'tkextlib/tile/tentry' + autoload :TCombobox, 'tkextlib/tile/tcombobox' + + autoload :TFrame, 'tkextlib/tile/tframe' + autoload :TLabelframe, 'tkextlib/tile/tlabelframe' + autoload :TLabel, 'tkextlib/tile/tlabel' autoload :TMenubutton, 'tkextlib/tile/tmenubutton' @@ -64,6 +87,14 @@ module Tk autoload :TRadioButton, 'tkextlib/tile/tradiobutton' autoload :TRadiobutton, 'tkextlib/tile/tradiobutton' + autoload :TScrollbar, 'tkextlib/tile/tsrollbar' + + autoload :TSeparator, 'tkextlib/tile/tseparator' + + autoload :TSquare, 'tkextlib/tile/tsquare' + + autoload :TreeView, 'tkextlib/tile/treeview' + autoload :Style, 'tkextlib/tile/style' end end diff --git a/ext/tk/lib/tkextlib/tile/tbutton.rb b/ext/tk/lib/tkextlib/tile/tbutton.rb index b5c347569..9a6245db8 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 4ba77d95d..aff560b69 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 000000000..8c1f2e015 --- /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 000000000..ad47062f3 --- /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 000000000..b77049305 --- /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 d2eaf4527..256d37670 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 000000000..768539293 --- /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 332db2b74..ba3400a51 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 c693d5ce2..47338a9f9 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 000000000..f01aeb641 --- /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 66cba6296..5066538b8 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 000000000..1a5fa97e2 --- /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 000000000..a0e4b10c9 --- /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 000000000..def9d12a4 --- /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 000000000..ebcbc3c31 --- /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 |