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
|
2005-04-09 05:27:54 -04:00
|
|
|
def default(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
|
|
|
|
tk_call('style', 'default', style, *hash_kv(keys))
|
|
|
|
else
|
|
|
|
tk_call('style', 'default', style)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
tk_call('style', 'map', style, *hash_kv(keys))
|
|
|
|
else
|
|
|
|
tk_call('style', 'map', style)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
tk_call('style', 'layout', style, spec)
|
|
|
|
else
|
|
|
|
tk_call('style', 'layout', style)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def element_create(name, type, *args)
|
|
|
|
tk_call('style', 'element', 'create', name, type, *args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def element_names()
|
|
|
|
list(tk_call('style', 'element', 'names'))
|
|
|
|
end
|
|
|
|
|
2005-06-16 05:22:01 -04:00
|
|
|
def element_options(elem)
|
|
|
|
simplelist(tk_call('style', 'element', 'options', elem))
|
|
|
|
end
|
|
|
|
|
2004-07-01 05:38:48 -04:00
|
|
|
def theme_create(name, keys=nil)
|
|
|
|
if keys && keys != None
|
2005-04-09 05:27:54 -04:00
|
|
|
tk_call('style', 'theme', 'create', name, *hash_kv(keys))
|
2004-07-01 05:38:48 -04:00
|
|
|
else
|
2005-04-09 05:27:54 -04:00
|
|
|
tk_call('style', '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
|
|
|
|
tk_call('style', 'theme', 'settings', name, cmd)
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def theme_names()
|
|
|
|
list(tk_call('style', 'theme', 'names'))
|
|
|
|
end
|
|
|
|
|
|
|
|
def theme_use(name)
|
2004-12-16 02:13:14 -05:00
|
|
|
tk_call('style', 'theme', 'use', name)
|
2004-07-01 05:38:48 -04:00
|
|
|
end
|
|
|
|
end
|