2004-07-01 05:38:48 -04:00
|
|
|
#
|
|
|
|
# style commands
|
|
|
|
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
|
|
|
#
|
|
|
|
require 'tk'
|
2004-07-06 05:42:12 -04:00
|
|
|
require 'tkextlib/tile.rb'
|
2004-07-01 05:38:48 -04:00
|
|
|
|
2004-07-06 05:42:12 -04:00
|
|
|
module Tk
|
|
|
|
module Tile
|
|
|
|
module Style
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2004-07-01 05:38:48 -04:00
|
|
|
|
|
|
|
module Tk::Tile::Style
|
2004-11-03 03:09:55 -05:00
|
|
|
extend TkCore
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class << Tk::Tile::Style
|
2007-12-21 03:57:35 -05:00
|
|
|
if Tk::Tile::TILE_SPEC_VERSION_ID < 8
|
|
|
|
TkCommandNames = ['style'.freeze].freeze
|
|
|
|
else
|
|
|
|
TkCommandNames = ['::ttk::style'.freeze].freeze
|
|
|
|
end
|
|
|
|
|
* ext/tk/extconf.rb: improbe messages [ruby-core:06325].
* ext/tk/lib/tk.rb, ext/tk/lib/tk/canvas.rb, ext/tk/lib/tk/entry.rb,
ext/tk/lib/tk/frame.rb, ext/tk/lib/tk/image.rb,
ext/tk/lib/tk/itemconfig.rb, ext/tk/lib/tk/labelframe.rb,
ext/tk/lib/tk/listbox.rb, ext/tk/lib/tk/menu.rb,
ext/tk/lib/tk/radiobutton.rb, ext/tk/lib/tk/scale.rb,
ext/tk/lib/tk/spinbox.rb, ext/tk/lib/tk/text.rb,
ext/tk/lib/tk/toplevel.rb: improve conversion of option values.
* ext/tk/lib/tkextlib/*: ditto.
* ext/tk/lib/tkextlib/*: update to support ActiveTcl8.4.11.2.
* ext/tk/lib/tkextlib/trofs/*: support Trofs 0.4.3.
* ext/tk/lib/tkextlib/tile/*: support Tile 0.7.2.
* ext/tk/lib/tkextlib/vu/*: support vu 2.3.0.
* ext/tk/lib/tkextlib/tcllib/*: support Tcllib 1.8 (Tklib 0.3).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-22 18:17:08 -04:00
|
|
|
def configure(style=nil, keys=nil)
|
2005-04-09 05:27:54 -04:00
|
|
|
if style.kind_of?(Hash)
|
|
|
|
keys = style
|
|
|
|
style = nil
|
|
|
|
end
|
|
|
|
style = '.' unless style
|
|
|
|
|
* ext/tk/extconf.rb: improbe messages [ruby-core:06325].
* ext/tk/lib/tk.rb, ext/tk/lib/tk/canvas.rb, ext/tk/lib/tk/entry.rb,
ext/tk/lib/tk/frame.rb, ext/tk/lib/tk/image.rb,
ext/tk/lib/tk/itemconfig.rb, ext/tk/lib/tk/labelframe.rb,
ext/tk/lib/tk/listbox.rb, ext/tk/lib/tk/menu.rb,
ext/tk/lib/tk/radiobutton.rb, ext/tk/lib/tk/scale.rb,
ext/tk/lib/tk/spinbox.rb, ext/tk/lib/tk/text.rb,
ext/tk/lib/tk/toplevel.rb: improve conversion of option values.
* ext/tk/lib/tkextlib/*: ditto.
* ext/tk/lib/tkextlib/*: update to support ActiveTcl8.4.11.2.
* ext/tk/lib/tkextlib/trofs/*: support Trofs 0.4.3.
* ext/tk/lib/tkextlib/tile/*: support Tile 0.7.2.
* ext/tk/lib/tkextlib/vu/*: support vu 2.3.0.
* ext/tk/lib/tkextlib/tcllib/*: support Tcllib 1.8 (Tklib 0.3).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-22 18:17:08 -04:00
|
|
|
if Tk::Tile::TILE_SPEC_VERSION_ID < 7
|
|
|
|
sub_cmd = 'default'
|
|
|
|
else
|
|
|
|
sub_cmd = 'configure'
|
|
|
|
end
|
|
|
|
|
2004-07-01 05:38:48 -04:00
|
|
|
if keys && keys != None
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], sub_cmd, style, *hash_kv(keys))
|
2004-07-01 05:38:48 -04:00
|
|
|
else
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], sub_cmd, style)
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
end
|
* ext/tk/extconf.rb: improbe messages [ruby-core:06325].
* ext/tk/lib/tk.rb, ext/tk/lib/tk/canvas.rb, ext/tk/lib/tk/entry.rb,
ext/tk/lib/tk/frame.rb, ext/tk/lib/tk/image.rb,
ext/tk/lib/tk/itemconfig.rb, ext/tk/lib/tk/labelframe.rb,
ext/tk/lib/tk/listbox.rb, ext/tk/lib/tk/menu.rb,
ext/tk/lib/tk/radiobutton.rb, ext/tk/lib/tk/scale.rb,
ext/tk/lib/tk/spinbox.rb, ext/tk/lib/tk/text.rb,
ext/tk/lib/tk/toplevel.rb: improve conversion of option values.
* ext/tk/lib/tkextlib/*: ditto.
* ext/tk/lib/tkextlib/*: update to support ActiveTcl8.4.11.2.
* ext/tk/lib/tkextlib/trofs/*: support Trofs 0.4.3.
* ext/tk/lib/tkextlib/tile/*: support Tile 0.7.2.
* ext/tk/lib/tkextlib/vu/*: support vu 2.3.0.
* ext/tk/lib/tkextlib/tcllib/*: support Tcllib 1.8 (Tklib 0.3).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-22 18:17:08 -04:00
|
|
|
alias default configure
|
2004-07-01 05:38:48 -04:00
|
|
|
|
2005-04-09 05:27:54 -04:00
|
|
|
def map(style=nil, keys=nil)
|
|
|
|
if style.kind_of?(Hash)
|
|
|
|
keys = style
|
|
|
|
style = nil
|
|
|
|
end
|
|
|
|
style = '.' unless style
|
|
|
|
|
2004-07-01 05:38:48 -04:00
|
|
|
if keys && keys != None
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys))
|
2004-07-01 05:38:48 -04:00
|
|
|
else
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], 'map', style)
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-10-04 05:52:54 -04:00
|
|
|
def lookup(style, opt, state=None, fallback_value=None)
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], 'lookup', style,
|
|
|
|
'-' << opt.to_s, state, fallback_value)
|
2006-10-04 05:52:54 -04:00
|
|
|
end
|
|
|
|
|
* ext/tk/extconf.rb: improbe messages [ruby-core:06325].
* ext/tk/lib/tk.rb, ext/tk/lib/tk/canvas.rb, ext/tk/lib/tk/entry.rb,
ext/tk/lib/tk/frame.rb, ext/tk/lib/tk/image.rb,
ext/tk/lib/tk/itemconfig.rb, ext/tk/lib/tk/labelframe.rb,
ext/tk/lib/tk/listbox.rb, ext/tk/lib/tk/menu.rb,
ext/tk/lib/tk/radiobutton.rb, ext/tk/lib/tk/scale.rb,
ext/tk/lib/tk/spinbox.rb, ext/tk/lib/tk/text.rb,
ext/tk/lib/tk/toplevel.rb: improve conversion of option values.
* ext/tk/lib/tkextlib/*: ditto.
* ext/tk/lib/tkextlib/*: update to support ActiveTcl8.4.11.2.
* ext/tk/lib/tkextlib/trofs/*: support Trofs 0.4.3.
* ext/tk/lib/tkextlib/tile/*: support Tile 0.7.2.
* ext/tk/lib/tkextlib/vu/*: support vu 2.3.0.
* ext/tk/lib/tkextlib/tcllib/*: support Tcllib 1.8 (Tklib 0.3).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-10-22 18:17:08 -04:00
|
|
|
include Tk::Tile::ParseStyleLayout
|
|
|
|
|
2005-04-09 05:27:54 -04:00
|
|
|
def layout(style=nil, spec=nil)
|
|
|
|
if style.kind_of?(Hash)
|
|
|
|
spec = style
|
|
|
|
style = nil
|
|
|
|
end
|
|
|
|
style = '.' unless style
|
|
|
|
|
2004-07-01 05:38:48 -04:00
|
|
|
if spec
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], 'layout', style, spec)
|
2004-07-01 05:38:48 -04:00
|
|
|
else
|
2007-12-21 03:57:35 -05:00
|
|
|
_style_layout(list(tk_call(TkCommandNames[0], 'layout', style)))
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def element_create(name, type, *args)
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], 'element', 'create', name, type, *args)
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def element_names()
|
2007-12-21 03:57:35 -05:00
|
|
|
list(tk_call(TkCommandNames[0], 'element', 'names'))
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
|
2005-06-16 05:22:01 -04:00
|
|
|
def element_options(elem)
|
2007-12-21 03:57:35 -05:00
|
|
|
simplelist(tk_call(TkCommandNames[0], 'element', 'options', elem))
|
2005-06-16 05:22:01 -04:00
|
|
|
end
|
|
|
|
|
2004-07-01 05:38:48 -04:00
|
|
|
def theme_create(name, keys=nil)
|
|
|
|
if keys && keys != None
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], 'theme', 'create', name, *hash_kv(keys))
|
2004-07-01 05:38:48 -04:00
|
|
|
else
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], 'theme', 'create', name)
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def theme_settings(name, cmd=nil, &b)
|
2004-11-09 13:35:52 -05:00
|
|
|
cmd = Proc.new(&b) if !cmd && b
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], 'theme', 'settings', name, cmd)
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def theme_names()
|
2007-12-21 03:57:35 -05:00
|
|
|
list(tk_call(TkCommandNames[0], 'theme', 'names'))
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def theme_use(name)
|
2007-12-21 03:57:35 -05:00
|
|
|
tk_call(TkCommandNames[0], 'theme', 'use', name)
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
end
|