diff options
Diffstat (limited to 'ext/tk/lib/tkextlib/tile')
-rw-r--r-- | ext/tk/lib/tkextlib/tile/dialog.rb | 84 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/style.rb | 17 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tcombobox.rb | 10 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tentry.rb | 10 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tnotebook.rb | 19 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/tprogressbar.rb | 24 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/treeview.rb | 11 |
7 files changed, 158 insertions, 17 deletions
diff --git a/ext/tk/lib/tkextlib/tile/dialog.rb b/ext/tk/lib/tkextlib/tile/dialog.rb new file mode 100644 index 0000000000..f8ddf62598 --- /dev/null +++ b/ext/tk/lib/tkextlib/tile/dialog.rb @@ -0,0 +1,84 @@ +# +# ttk::dialog (tile-0.7+) +# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) +# +require 'tk' +require 'tkextlib/tile.rb' + +module Tk + module Tile + class Dialog < TkWindow + end + end +end + +class Tk::Tile::Dialog + TkCommandNames = ['::ttk::dialog'.freeze].freeze + + def self.show(*args) + dialog = self.new(*args) + dialog.show + [dialog.status, dialog.value] + end + def self.display(*args) + self.show(*args) + end + + def self.define_dialog_type(name, keys) + Tk.tk_call('::ttk::dialog::define', name, keys) + name + end + + def self.style(*args) + ['Dialog', *(args.map!{|a| _get_eval_string(a)})].join('.') + end + + ######################### + + def initialize(keys={}) + @keys = _symbolkey2str(keys) + super(*args) + end + + def create_self(keys) + # dummy + end + private :create_self + + def show + tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)) + end + alias display show + + def client_frame + window(tk_call_without_enc('::ttk::dialog::clientframe')) + end + + def cget(slot) + @keys[slot] + end + + def configure(slot, value=None) + if slot.kind_of?(Hash) + slot.each{|k, v| configure(k, v)} + else + slot = slot.to_s + value = _symbolkey2str(value) if value.kind_of?(Hash) + if value && value != None + @keys[slot] = value + else + @keys.delete(slot) + end + end + self + end + + def configinfo(slot = nil) + if slot + slot = slot.to_s + [ slot, nil, nil, nil, @keys[slot] ] + else + @keys.collect{|k, v| [ k, nil, nil, nil, v ] } + end + end +end diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb index 4245d315f8..485a36d7d6 100644 --- a/ext/tk/lib/tkextlib/tile/style.rb +++ b/ext/tk/lib/tkextlib/tile/style.rb @@ -17,19 +17,26 @@ module Tk::Tile::Style end class << Tk::Tile::Style - def default(style=nil, keys=nil) + def configure(style=nil, keys=nil) if style.kind_of?(Hash) keys = style style = nil end style = '.' unless style + if Tk::Tile::TILE_SPEC_VERSION_ID < 7 + sub_cmd = 'default' + else + sub_cmd = 'configure' + end + if keys && keys != None - tk_call('style', 'default', style, *hash_kv(keys)) + tk_call('style', sub_cmd, style, *hash_kv(keys)) else - tk_call('style', 'default', style) + tk_call('style', sub_cmd, style) end end + alias default configure def map(style=nil, keys=nil) if style.kind_of?(Hash) @@ -45,6 +52,8 @@ class << Tk::Tile::Style end end + include Tk::Tile::ParseStyleLayout + def layout(style=nil, spec=nil) if style.kind_of?(Hash) spec = style @@ -55,7 +64,7 @@ class << Tk::Tile::Style if spec tk_call('style', 'layout', style, spec) else - tk_call('style', 'layout', style) + _style_layout(list(tk_call('style', 'layout', style))) end end diff --git a/ext/tk/lib/tkextlib/tile/tcombobox.rb b/ext/tk/lib/tkextlib/tile/tcombobox.rb index ac67089bbb..c63ab94dbe 100644 --- a/ext/tk/lib/tkextlib/tile/tcombobox.rb +++ b/ext/tk/lib/tkextlib/tile/tcombobox.rb @@ -24,6 +24,16 @@ class Tk::Tile::TCombobox < Tk::Tile::TEntry WidgetClassName = 'TCombobox'.freeze WidgetClassNames[WidgetClassName] = self + def __boolval_optkeys + super() << 'exportselection' + end + private :__boolval_optkeys + + def __listval_optkeys + super() << 'values' + end + private :__listval_optkeys + def self.style(*args) [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.') end diff --git a/ext/tk/lib/tkextlib/tile/tentry.rb b/ext/tk/lib/tkextlib/tile/tentry.rb index be7054b851..4d57ce7756 100644 --- a/ext/tk/lib/tkextlib/tile/tentry.rb +++ b/ext/tk/lib/tkextlib/tile/tentry.rb @@ -24,6 +24,16 @@ class Tk::Tile::TEntry < TkEntry WidgetClassName = 'TEntry'.freeze WidgetClassNames[WidgetClassName] = self + def __boolval_optkeys + super() << 'exportselection' + end + private :__boolval_optkeys + + def __strval_optkeys + super() << 'show' + end + private :__strval_optkeys + def self.style(*args) [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.') end diff --git a/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ext/tk/lib/tkextlib/tile/tnotebook.rb index 09b27fc2cd..da4fa203c7 100644 --- a/ext/tk/lib/tkextlib/tile/tnotebook.rb +++ b/ext/tk/lib/tkextlib/tile/tnotebook.rb @@ -18,16 +18,15 @@ class Tk::Tile::TNotebook < TkWindow include TkItemConfigMethod def __item_cget_cmd(id) - [self.path, 'tabcget', id] + [self.path, 'tab', id] end private :__item_cget_cmd def __item_config_cmd(id) - [self.path, 'tabconfigure', id] + [self.path, 'tab', id] end private :__item_config_cmd - def __item_listval_optkeys [] end @@ -38,10 +37,14 @@ class Tk::Tile::TNotebook < TkWindow end private :__item_listval_optkeys - alias tabcget itemcget + #alias tabcget itemcget alias tabconfigure itemconfigure alias tabconfiginfo itemconfiginfo alias current_tabconfiginfo current_itemconfiginfo + + def tabcget(tagOrId, option) + tabconfigure(tagOrId, option)[-1] + end ################################ include Tk::Tile::TileWidget @@ -59,7 +62,13 @@ class Tk::Tile::TNotebook < TkWindow end def enable_traversal() - tk_call_without_enc('::tile::notebook::enableTraversal', @path) + if Tk::Tile::TILE_SPEC_VERSION_ID < 5 + tk_call_without_enc('::tile::enableNotebookTraversal', @path) + elsif Tk::Tile::TILE_SPEC_VERSION_ID < 7 + tk_call_without_enc('::tile::notebook::enableTraversal', @path) + else + tk_call_without_enc('::ttk::notebook::enableTraversal', @path) + end self end diff --git a/ext/tk/lib/tkextlib/tile/tprogressbar.rb b/ext/tk/lib/tkextlib/tile/tprogressbar.rb index 3f98660c83..36c1c75c23 100644 --- a/ext/tk/lib/tkextlib/tile/tprogressbar.rb +++ b/ext/tk/lib/tkextlib/tile/tprogressbar.rb @@ -28,18 +28,26 @@ class Tk::Tile::TProgressbar [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.') end - def step - tk_send_without_enc('step').to_f - end - def step=(amount) - tk_send_without_enc('step', amount) + def step(amount=None) + tk_send_without_enc('step', amount).to_f end + #def step=(amount) + # tk_send_without_enc('step', amount) + #end def start(interval=None) - tk_call_without_enc('::tile::progressbar::start', @path, interval) + if Tk::Tile::TILE_SPEC_VERSION_ID < 5 + tk_call_without_enc('::tile::progressbar::start', @path, interval) + else + tk_send_without_enc('start', interval) + end end - def stop - tk_call_without_enc('::tile::progressbar::stop', @path) + def stop(amount=None) + if Tk::Tile::TILE_SPEC_VERSION_ID < 5 + tk_call_without_enc('::tile::progressbar::stop', @path) + else + tk_send_without_enc('stop', amount) + end end end diff --git a/ext/tk/lib/tkextlib/tile/treeview.rb b/ext/tk/lib/tkextlib/tile/treeview.rb index 46e3499f21..d3ffbbfa6b 100644 --- a/ext/tk/lib/tkextlib/tile/treeview.rb +++ b/ext/tk/lib/tkextlib/tile/treeview.rb @@ -259,6 +259,17 @@ class Tk::Tile::Treeview < TkWindow self end + def get_directory(item) + # tile-0.7+ + ret = [] + lst = simplelist(tk_send('set', item)) + until lst.empty? + col = lst.shift + val = lst.shift + ret << [col, val] + end + ret + end def get(item, col) tk_send('set', item, col) end |