* ext/tk/lib/tk.rb: update RELEASE_DATE
* ext/tk/lib/tk/image.rb: support to create TkImage object without creating a new image object on Tk. * ext/tk/lib/tk/menu.rb: use TkCommandNames on create_self() * ext/tk/lib/tk/root.rb: TkRoot.to_eval() returns '.'. * ext/tk/lib/tk/text.rb: add methods to create a TkText::IndexString from (x, y) coords. * ext/tk/lib/tkextlib/tile.rb: bug fix and update support status. * ext/tk/lib/tkextlib/tile/*.rb: ditto. * ext/tk/sample/tkextlib/tile: New demo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
Sat Apr 9 18:20:31 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
|
* ext/tk/lib/tk/image.rb: support to create TkImage object without
|
||||||
|
creating a new image object on Tk.
|
||||||
|
|
||||||
|
* ext/tk/lib/tk/menu.rb: use TkCommandNames on create_self()
|
||||||
|
|
||||||
|
* ext/tk/lib/tk/root.rb: TkRoot.to_eval() returns '.'.
|
||||||
|
|
||||||
|
* ext/tk/lib/tk/text.rb: add methods to create a TkText::IndexString
|
||||||
|
from (x, y) coords.
|
||||||
|
|
||||||
|
* ext/tk/lib/tkextlib/tile/: add demo and update support status.
|
||||||
|
|
||||||
Sat Apr 9 14:42:29 2005 Kouhei Sutou <kou@cozmixng.org>
|
Sat Apr 9 14:42:29 2005 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
* sample/rss/tdiary_plugin/rss-recent.rb: supported configuration
|
* sample/rss/tdiary_plugin/rss-recent.rb: supported configuration
|
||||||
|
|
|
@ -1,3 +1,93 @@
|
||||||
|
2005-04-09 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/demo.rb: new demo of Tile extension.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/iconlib.tcl: part of the demo.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/toolbutton.tcl: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/readme.txt: document of the demo.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/Orig_LICENSE.txt: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc.tcl: sample theme written with Tcl.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/pkgIndex.tcl: pkgIndex of kroc.tcl.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc.rb: Kroc theme written with Ruby.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/button-h.gif: images for Kroc theme.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/button-n.gif: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/button-p.gif: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/check-hc.gif: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/check-hu.gif: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/check-nc.gif: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/check-nu.gif: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/radio-hc.gif: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/radio-hu.gif: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/radio-nc.gif: ditto.
|
||||||
|
|
||||||
|
* sample/tkextlib/tile/themes/kroc/radio-nu.gif: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile.rb: bug fix (tested on the new demo).
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/style.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tbutton.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tcheckbutton.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tcombobox.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tentry.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tframe.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tlabel.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tlabelframe.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tmenubutton.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tnotebook.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tprogressbar.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tradiobutton.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/treeview.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tscrollbar.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tseparator.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tsquare.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tpaned.rb: new library
|
||||||
|
|
||||||
|
* lib/tkextlib/tile/tscale.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/SUPPORT_STATUS: update support status of Tile extension.
|
||||||
|
|
||||||
|
* lib/tkextlib/tcllib/ctext.rb: use TkCommandNames on create_self().
|
||||||
|
|
||||||
|
* lib/tkextlib/tcllib/datefield.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tcllib/ip_entry.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/tkHTML/htmlwidget.rb: ditto.
|
||||||
|
|
||||||
|
* lib/tkextlib/treectrl/tktreectrl.rb: ditto.
|
||||||
|
|
||||||
2005-04-09 ocean <ocean@ruby-lang.org>
|
2005-04-09 ocean <ocean@ruby-lang.org>
|
||||||
|
|
||||||
* sample/tkextlib/treectrl/explorer.rb: File.executable? returns true
|
* sample/tkextlib/treectrl/explorer.rb: File.executable? returns true
|
||||||
|
|
|
@ -4024,7 +4024,7 @@ end
|
||||||
#Tk.freeze
|
#Tk.freeze
|
||||||
|
|
||||||
module Tk
|
module Tk
|
||||||
RELEASE_DATE = '2005-04-02'.freeze
|
RELEASE_DATE = '2005-04-09'.freeze
|
||||||
|
|
||||||
autoload :AUTO_PATH, 'tk/variable'
|
autoload :AUTO_PATH, 'tk/variable'
|
||||||
autoload :TCL_PACKAGE_PATH, 'tk/variable'
|
autoload :TCL_PACKAGE_PATH, 'tk/variable'
|
||||||
|
|
|
@ -14,18 +14,55 @@ class TkImage<TkObject
|
||||||
|
|
||||||
TkCore::INTERP.init_ip_env{ Tk_IMGTBL.clear }
|
TkCore::INTERP.init_ip_env{ Tk_IMGTBL.clear }
|
||||||
|
|
||||||
|
def self.new(keys=nil)
|
||||||
|
if keys.kind_of?(Hash)
|
||||||
|
name = nil
|
||||||
|
if keys.key?(:imagename)
|
||||||
|
name = keys[:imagename]
|
||||||
|
elsif keys.key?('imagename')
|
||||||
|
name = keys['imagename']
|
||||||
|
end
|
||||||
|
if name
|
||||||
|
if name.kind_of?(TkImage)
|
||||||
|
obj = name
|
||||||
|
else
|
||||||
|
name = _get_eval_string(name)
|
||||||
|
obj = Tk_IMGTBL[name]
|
||||||
|
end
|
||||||
|
if obj
|
||||||
|
if !(keys[:without_creating] || keys['without_creating'])
|
||||||
|
keys = _symbolkey2str(keys)
|
||||||
|
keys.delete('imagename')
|
||||||
|
keys.delete('without_creating')
|
||||||
|
obj.instance_eval{
|
||||||
|
tk_call_without_enc('image', 'create',
|
||||||
|
@type, @path, *hash_kv(keys, true))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return obj
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
super(keys)
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(keys=nil)
|
def initialize(keys=nil)
|
||||||
@path = nil
|
@path = nil
|
||||||
|
without_creating = false
|
||||||
if keys.kind_of?(Hash)
|
if keys.kind_of?(Hash)
|
||||||
keys = _symbolkey2str(keys)
|
keys = _symbolkey2str(keys)
|
||||||
@path = keys.delete('imagename')
|
@path = keys.delete('imagename')
|
||||||
|
without_creating = keys.delete('without_creating')
|
||||||
end
|
end
|
||||||
unless @path
|
unless @path
|
||||||
# @path = Tk_Image_ID.join('')
|
# @path = Tk_Image_ID.join('')
|
||||||
@path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
|
@path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
|
||||||
Tk_Image_ID[1].succ!
|
Tk_Image_ID[1].succ!
|
||||||
end
|
end
|
||||||
tk_call_without_enc('image', 'create', @type, @path, *hash_kv(keys, true))
|
unless without_creating
|
||||||
|
tk_call_without_enc('image', 'create',
|
||||||
|
@type, @path, *hash_kv(keys, true))
|
||||||
|
end
|
||||||
Tk_IMGTBL[@path] = self
|
Tk_IMGTBL[@path] = self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -61,7 +98,7 @@ end
|
||||||
class TkBitmapImage<TkImage
|
class TkBitmapImage<TkImage
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
@type = 'bitmap'
|
@type = 'bitmap'
|
||||||
super
|
super(*args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,7 +122,7 @@ class TkPhotoImage<TkImage
|
||||||
|
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
@type = 'photo'
|
@type = 'photo'
|
||||||
super
|
super(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def blank
|
def blank
|
||||||
|
|
|
@ -402,9 +402,12 @@ class TkMenubutton<TkLabel
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
def create_self(keys)
|
def create_self(keys)
|
||||||
if keys and keys != None
|
if keys and keys != None
|
||||||
tk_call_without_enc('menubutton', @path, *hash_kv(keys, true))
|
# tk_call_without_enc('menubutton', @path, *hash_kv(keys, true))
|
||||||
|
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||||
|
*hash_kv(keys, true))
|
||||||
else
|
else
|
||||||
tk_call_without_enc('menubutton', @path)
|
# tk_call_without_enc('menubutton', @path)
|
||||||
|
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private :create_self
|
private :create_self
|
||||||
|
|
|
@ -52,6 +52,11 @@ class TkRoot<TkWindow
|
||||||
WidgetClassName = 'Tk'.freeze
|
WidgetClassName = 'Tk'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.to_eval
|
||||||
|
# self::WidgetClassName
|
||||||
|
'.'
|
||||||
|
end
|
||||||
|
|
||||||
def create_self
|
def create_self
|
||||||
@path = '.'
|
@path = '.'
|
||||||
end
|
end
|
||||||
|
|
|
@ -131,6 +131,10 @@ class TkText<TkTextWin
|
||||||
class IndexString < String
|
class IndexString < String
|
||||||
include IndexModMethods
|
include IndexModMethods
|
||||||
|
|
||||||
|
def self.at(x,y)
|
||||||
|
self.new("@#{x},#{y}")
|
||||||
|
end
|
||||||
|
|
||||||
def self.new(str)
|
def self.new(str)
|
||||||
if str.kind_of?(String)
|
if str.kind_of?(String)
|
||||||
super(str)
|
super(str)
|
||||||
|
@ -183,6 +187,14 @@ class TkText<TkTextWin
|
||||||
end
|
end
|
||||||
private :create_self
|
private :create_self
|
||||||
|
|
||||||
|
def self.at(x, y)
|
||||||
|
TkText::IndexString.at(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
def at(x, y)
|
||||||
|
TkText::IndexString.at(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
def index(idx)
|
def index(idx)
|
||||||
TkText::IndexString.new(tk_send_without_enc('index',
|
TkText::IndexString.new(tk_send_without_enc('index',
|
||||||
_get_eval_enc_str(idx)))
|
_get_eval_enc_str(idx)))
|
||||||
|
|
|
@ -79,8 +79,9 @@ BLT 2.4z http://sourceforge.net/projects/blt
|
||||||
==> blt
|
==> blt
|
||||||
|
|
||||||
TkTreeCtrl CVS/Hd(2005-03-25)
|
TkTreeCtrl CVS/Hd(2005-03-25)
|
||||||
http://tktreectrl.sourceforge.net/ ==> treectrl
|
http://tktreectrl.sourceforge.net/ ==> treectrl
|
||||||
|
|
||||||
|
Tile 0.6 http://tktable.sourceforge.net/tile/ ==> tile
|
||||||
|
|
||||||
|
|
||||||
===< support (may be alpha or beta quality) >=================================
|
===< support (may be alpha or beta quality) >=================================
|
||||||
|
@ -93,8 +94,6 @@ TclX CVS/Hd(2005-02-07)
|
||||||
==> tclx (partial support; infox command and
|
==> tclx (partial support; infox command and
|
||||||
XPG/3 message catalogs only)
|
XPG/3 message catalogs only)
|
||||||
|
|
||||||
Tile 0.6 http://tktable.sourceforge.net/tile/ ==> tile
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
===< possibly available (not tested; alpha quality) >=========================
|
===< possibly available (not tested; alpha quality) >=========================
|
||||||
|
|
|
@ -34,9 +34,10 @@ class Tk::Tcllib::CText
|
||||||
|
|
||||||
def create_self(keys)
|
def create_self(keys)
|
||||||
if keys and keys != None
|
if keys and keys != None
|
||||||
tk_call_without_enc('ctext', @path, *hash_kv(keys, true))
|
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||||
|
*hash_kv(keys, true))
|
||||||
else
|
else
|
||||||
tk_call_without_enc('ctext', @path)
|
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private :create_self
|
private :create_self
|
||||||
|
|
|
@ -42,10 +42,10 @@ class Tk::Tcllib::Datefield
|
||||||
|
|
||||||
def create_self(keys)
|
def create_self(keys)
|
||||||
if keys and keys != None
|
if keys and keys != None
|
||||||
tk_call_without_enc('::datefield::datefield', @path,
|
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||||
*hash_kv(keys, true))
|
*hash_kv(keys, true))
|
||||||
else
|
else
|
||||||
tk_call_without_enc('::datefield::datefield', @path)
|
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private :create_self
|
private :create_self
|
||||||
|
|
|
@ -38,9 +38,10 @@ class Tk::Tcllib::IP_Entry
|
||||||
|
|
||||||
def create_self(keys)
|
def create_self(keys)
|
||||||
if keys and keys != None
|
if keys and keys != None
|
||||||
tk_call_without_enc('::ipentry::ipentry', @path, *hash_kv(keys, true))
|
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||||
|
*hash_kv(keys, true))
|
||||||
else
|
else
|
||||||
tk_call_without_enc('::ipentry::ipentry', @path)
|
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private :create_self
|
private :create_self
|
||||||
|
|
|
@ -45,6 +45,43 @@ module Tk
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.load_images(imgdir, pat=TkComm::None)
|
||||||
|
images = Hash[*TkComm.simplelist(Tk.tk_call('::tile::LoadImages',
|
||||||
|
imgdir, pat))]
|
||||||
|
images.keys.each{|k|
|
||||||
|
images[k] = TkPhotoImage.new(:imagename=>images[k],
|
||||||
|
:without_creating=>true)
|
||||||
|
}
|
||||||
|
|
||||||
|
images
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
args.map!{|arg| TkComm._get_eval_string(arg)}.join('.')
|
||||||
|
end
|
||||||
|
|
||||||
|
module KeyNav
|
||||||
|
def self.enableMnemonics(w)
|
||||||
|
Tk.tk_call('::keynav::enableMnemonics', w)
|
||||||
|
end
|
||||||
|
def self.defaultButton(w)
|
||||||
|
Tk.tk_call('::keynav::defaultButton', w)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
module Font
|
||||||
|
Default = 'TkDefaultFont'
|
||||||
|
Text = 'TkTextFont'
|
||||||
|
Heading = 'TkHeadingFont'
|
||||||
|
Caption = 'TkCaptionFont'
|
||||||
|
Tooltip = 'TkTooltipFont'
|
||||||
|
|
||||||
|
Fixed = 'TkFixedFont'
|
||||||
|
Menu = 'TkMenuFont'
|
||||||
|
SmallCaption = 'TkSmallCaptionFont'
|
||||||
|
Icon = 'TkIconFont'
|
||||||
|
end
|
||||||
|
|
||||||
module TileWidget
|
module TileWidget
|
||||||
def instate(state, script=nil, &b)
|
def instate(state, script=nil, &b)
|
||||||
if script
|
if script
|
||||||
|
@ -84,12 +121,17 @@ module Tk
|
||||||
|
|
||||||
autoload :TNotebook, 'tkextlib/tile/tnotebook'
|
autoload :TNotebook, 'tkextlib/tile/tnotebook'
|
||||||
|
|
||||||
|
autoload :TPaned, 'tkextlib/tile/tpaned'
|
||||||
|
|
||||||
autoload :TProgressbar, 'tkextlib/tile/tprogressbar'
|
autoload :TProgressbar, 'tkextlib/tile/tprogressbar'
|
||||||
|
|
||||||
autoload :TRadioButton, 'tkextlib/tile/tradiobutton'
|
autoload :TRadioButton, 'tkextlib/tile/tradiobutton'
|
||||||
autoload :TRadiobutton, 'tkextlib/tile/tradiobutton'
|
autoload :TRadiobutton, 'tkextlib/tile/tradiobutton'
|
||||||
|
|
||||||
autoload :TScrollbar, 'tkextlib/tile/tsrollbar'
|
autoload :TScale, 'tkextlib/tile/tscale'
|
||||||
|
autoload :TProgress, 'tkextlib/tile/tscale'
|
||||||
|
|
||||||
|
autoload :TScrollbar, 'tkextlib/tile/tscrollbar'
|
||||||
|
|
||||||
autoload :TSeparator, 'tkextlib/tile/tseparator'
|
autoload :TSeparator, 'tkextlib/tile/tseparator'
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,13 @@ module Tk::Tile::Style
|
||||||
end
|
end
|
||||||
|
|
||||||
class << Tk::Tile::Style
|
class << Tk::Tile::Style
|
||||||
def default(style, keys=nil)
|
def default(style=nil, keys=nil)
|
||||||
|
if style.kind_of?(Hash)
|
||||||
|
keys = style
|
||||||
|
style = nil
|
||||||
|
end
|
||||||
|
style = '.' unless style
|
||||||
|
|
||||||
if keys && keys != None
|
if keys && keys != None
|
||||||
tk_call('style', 'default', style, *hash_kv(keys))
|
tk_call('style', 'default', style, *hash_kv(keys))
|
||||||
else
|
else
|
||||||
|
@ -25,7 +31,13 @@ class << Tk::Tile::Style
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def map(style, keys=nil)
|
def map(style=nil, keys=nil)
|
||||||
|
if style.kind_of?(Hash)
|
||||||
|
keys = style
|
||||||
|
style = nil
|
||||||
|
end
|
||||||
|
style = '.' unless style
|
||||||
|
|
||||||
if keys && keys != None
|
if keys && keys != None
|
||||||
tk_call('style', 'map', style, *hash_kv(keys))
|
tk_call('style', 'map', style, *hash_kv(keys))
|
||||||
else
|
else
|
||||||
|
@ -33,7 +45,13 @@ class << Tk::Tile::Style
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def layout(style, spec=nil)
|
def layout(style=nil, spec=nil)
|
||||||
|
if style.kind_of?(Hash)
|
||||||
|
spec = style
|
||||||
|
style = nil
|
||||||
|
end
|
||||||
|
style = '.' unless style
|
||||||
|
|
||||||
if spec
|
if spec
|
||||||
tk_call('style', 'layout', style, spec)
|
tk_call('style', 'layout', style, spec)
|
||||||
else
|
else
|
||||||
|
@ -51,9 +69,9 @@ class << Tk::Tile::Style
|
||||||
|
|
||||||
def theme_create(name, keys=nil)
|
def theme_create(name, keys=nil)
|
||||||
if keys && keys != None
|
if keys && keys != None
|
||||||
tk_call('style', 'theme', 'create', name, type, *hash_kv(keys))
|
tk_call('style', 'theme', 'create', name, *hash_kv(keys))
|
||||||
else
|
else
|
||||||
tk_call('style', 'theme', 'create', name, type)
|
tk_call('style', 'theme', 'create', name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,8 @@ class Tk::Tile::TButton < TkButton
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TButton'.freeze
|
WidgetClassName = 'TButton'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,4 +23,8 @@ class Tk::Tile::TCheckButton < TkCheckButton
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TCheckbutton'.freeze
|
WidgetClassName = 'TCheckbutton'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,10 @@ class Tk::Tile::TCombobox < Tk::Tile::TEntry
|
||||||
WidgetClassName = 'TCombobox'.freeze
|
WidgetClassName = 'TCombobox'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
|
|
||||||
def current
|
def current
|
||||||
number(tk_send_without_enc('current', idx))
|
number(tk_send_without_enc('current', idx))
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,4 +22,8 @@ class Tk::Tile::TEntry < TkEntry
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TEntry'.freeze
|
WidgetClassName = 'TEntry'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,4 +22,8 @@ class Tk::Tile::TFrame < TkFrame
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TFrame'.freeze
|
WidgetClassName = 'TFrame'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,4 +22,8 @@ class Tk::Tile::TLabel < TkLabel
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TLabel'.freeze
|
WidgetClassName = 'TLabel'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,4 +22,8 @@ class Tk::Tile::TLabelframe < Tk::Tile::TFrame
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TLabelframe'.freeze
|
WidgetClassName = 'TLabelframe'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,4 +22,8 @@ class Tk::Tile::TMenubutton < TkMenubutton
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TMenubutton'.freeze
|
WidgetClassName = 'TMenubutton'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,8 +53,12 @@ class Tk::Tile::TNotebook < TkWindow
|
||||||
WidgetClassName = 'TNotebook'.freeze
|
WidgetClassName = 'TNotebook'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
|
|
||||||
def enable_traversal()
|
def enable_traversal()
|
||||||
tk_call_without_end('tile::enableNotebookTraversal', @path)
|
tk_call_without_enc('::tile::notebook::enableTraversal', @path)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
187
ext/tk/lib/tkextlib/tile/tpaned.rb
Normal file
|
@ -0,0 +1,187 @@
|
||||||
|
#
|
||||||
|
# tpaned widget
|
||||||
|
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||||
|
#
|
||||||
|
require 'tk'
|
||||||
|
require 'tkextlib/tile.rb'
|
||||||
|
|
||||||
|
module Tk
|
||||||
|
module Tile
|
||||||
|
class TPaned < TkWindow
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Tk::Tile::TPaned < TkWindow
|
||||||
|
include Tk::Tile::TileWidget
|
||||||
|
|
||||||
|
if Tk::Tile::USE_TTK_NAMESPACE
|
||||||
|
TkCommandNames = ['::ttk::paned'.freeze].freeze
|
||||||
|
else
|
||||||
|
TkCommandNames = ['::tpaned'.freeze].freeze
|
||||||
|
end
|
||||||
|
WidgetClassName = 'TPaned'.freeze
|
||||||
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
|
|
||||||
|
def add(win, keys)
|
||||||
|
win = _epath(win)
|
||||||
|
tk_send_without_enc('add', win, *hash_kv(keys))
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def forget(pane)
|
||||||
|
pane = _epath(pane)
|
||||||
|
tk_send_without_enc('forget', pane)
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def insert(pos, win, keys)
|
||||||
|
win = _epath(win)
|
||||||
|
tk_send_without_enc('insert', pos, win, *hash_kv(keys))
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
|
def panecget(pane, slot)
|
||||||
|
pane = _epath(pane)
|
||||||
|
tk_tcl2ruby(tk_send_without_enc('pane', pane, "-#{slot}"))
|
||||||
|
end
|
||||||
|
alias pane_cget panecget
|
||||||
|
|
||||||
|
def paneconfigure(pane, key, value=nil)
|
||||||
|
pane = _epath(pane)
|
||||||
|
if key.kind_of? Hash
|
||||||
|
params = []
|
||||||
|
key.each{|k, v|
|
||||||
|
params.push("-#{k}")
|
||||||
|
# params.push((v.kind_of?(TkObject))? v.epath: v)
|
||||||
|
params.push(_epath(v))
|
||||||
|
}
|
||||||
|
tk_send_without_enc('pane', pane, *params)
|
||||||
|
else
|
||||||
|
# value = value.epath if value.kind_of?(TkObject)
|
||||||
|
value = _epath(value)
|
||||||
|
tk_send_without_enc('pane', pane, "-#{key}", value)
|
||||||
|
end
|
||||||
|
self
|
||||||
|
end
|
||||||
|
alias pane_config paneconfigure
|
||||||
|
alias pane_configure paneconfigure
|
||||||
|
|
||||||
|
def paneconfiginfo(win)
|
||||||
|
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||||
|
win = _epath(win)
|
||||||
|
if key
|
||||||
|
conf = tk_split_list(tk_send_without_enc('pane', win, "-#{key}"))
|
||||||
|
conf[0] = conf[0][1..-1]
|
||||||
|
if conf[0] == 'hide'
|
||||||
|
conf[3] = bool(conf[3]) unless conf[3].empty?
|
||||||
|
conf[4] = bool(conf[4]) unless conf[4].empty?
|
||||||
|
end
|
||||||
|
conf
|
||||||
|
else
|
||||||
|
tk_split_simplelist(tk_send_without_enc('pane',
|
||||||
|
win)).collect{|conflist|
|
||||||
|
conf = tk_split_simplelist(conflist)
|
||||||
|
conf[0] = conf[0][1..-1]
|
||||||
|
if conf[3]
|
||||||
|
if conf[0] == 'hide'
|
||||||
|
conf[3] = bool(conf[3]) unless conf[3].empty?
|
||||||
|
elsif conf[3].index('{')
|
||||||
|
conf[3] = tk_split_list(conf[3])
|
||||||
|
else
|
||||||
|
conf[3] = tk_tcl2ruby(conf[3])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if conf[4]
|
||||||
|
if conf[0] == 'hide'
|
||||||
|
conf[4] = bool(conf[4]) unless conf[4].empty?
|
||||||
|
elsif conf[4].index('{')
|
||||||
|
conf[4] = tk_split_list(conf[4])
|
||||||
|
else
|
||||||
|
conf[4] = tk_tcl2ruby(conf[4])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
|
||||||
|
conf
|
||||||
|
}
|
||||||
|
end
|
||||||
|
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||||
|
win = _epath(win)
|
||||||
|
if key
|
||||||
|
conf = tk_split_list(tk_send_without_enc('pane', win, "-#{key}"))
|
||||||
|
key = conf.shift[1..-1]
|
||||||
|
if key == 'hide'
|
||||||
|
conf[2] = bool(conf[2]) unless conf[2].empty?
|
||||||
|
conf[3] = bool(conf[3]) unless conf[3].empty?
|
||||||
|
end
|
||||||
|
{ key => conf }
|
||||||
|
else
|
||||||
|
ret = {}
|
||||||
|
tk_split_simplelist(tk_send_without_enc('pane',
|
||||||
|
win)).each{|conflist|
|
||||||
|
conf = tk_split_simplelist(conflist)
|
||||||
|
key = conf.shift[1..-1]
|
||||||
|
if key
|
||||||
|
if key == 'hide'
|
||||||
|
conf[2] = bool(conf[2]) unless conf[2].empty?
|
||||||
|
elsif conf[2].index('{')
|
||||||
|
conf[2] = tk_split_list(conf[2])
|
||||||
|
else
|
||||||
|
conf[2] = tk_tcl2ruby(conf[2])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if conf[3]
|
||||||
|
if key == 'hide'
|
||||||
|
conf[3] = bool(conf[3]) unless conf[3].empty?
|
||||||
|
elsif conf[3].index('{')
|
||||||
|
conf[3] = tk_split_list(conf[3])
|
||||||
|
else
|
||||||
|
conf[3] = tk_tcl2ruby(conf[3])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if conf.size == 1
|
||||||
|
ret[key] = conf[0][1..-1] # alias info
|
||||||
|
else
|
||||||
|
ret[key] = conf
|
||||||
|
end
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
alias pane_configinfo paneconfiginfo
|
||||||
|
|
||||||
|
def current_paneconfiginfo(win, key=nil)
|
||||||
|
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||||
|
if key
|
||||||
|
conf = paneconfiginfo(win, key)
|
||||||
|
{conf[0] => conf[4]}
|
||||||
|
else
|
||||||
|
ret = {}
|
||||||
|
paneconfiginfo(win).each{|conf|
|
||||||
|
ret[conf[0]] = conf[4] if conf.size > 2
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||||
|
ret = {}
|
||||||
|
paneconfiginfo(win, key).each{|k, conf|
|
||||||
|
ret[k] = conf[-1] if conf.kind_of?(Array)
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
end
|
||||||
|
alias current_pane_configinfo current_paneconfiginfo
|
||||||
|
|
||||||
|
def identify(x, y)
|
||||||
|
list(tk_send_without_enc('identify', x, y))
|
||||||
|
end
|
||||||
|
|
||||||
|
def sashpos(idx, newpos=None)
|
||||||
|
num_or_str(tk_send_without_enc('sashpos', idx, newpos))
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,7 +7,7 @@ require 'tkextlib/tile.rb'
|
||||||
|
|
||||||
module Tk
|
module Tk
|
||||||
module Tile
|
module Tile
|
||||||
class TProgressbar < TkWidget
|
class TProgressbar < TkWindow
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -23,6 +23,10 @@ class Tk::Tile::TProgressbar
|
||||||
WidgetClassName = 'TProgressbar'.freeze
|
WidgetClassName = 'TProgressbar'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
|
|
||||||
def step
|
def step
|
||||||
tk_send_without_enc('step').to_f
|
tk_send_without_enc('step').to_f
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,4 +23,8 @@ class Tk::Tile::TRadioButton < TkRadioButton
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TRadiobutton'.freeze
|
WidgetClassName = 'TRadiobutton'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -117,6 +117,10 @@ class Tk::Tile::Treeview < TkWindow
|
||||||
WidgetClassName = 'Treeview'.freeze
|
WidgetClassName = 'Treeview'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
|
|
||||||
def tagid(id)
|
def tagid(id)
|
||||||
_get_eval_string(id)
|
_get_eval_string(id)
|
||||||
end
|
end
|
||||||
|
|
47
ext/tk/lib/tkextlib/tile/tscale.rb
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#
|
||||||
|
# tscale & tprogress widget
|
||||||
|
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
|
||||||
|
#
|
||||||
|
require 'tk'
|
||||||
|
require 'tkextlib/tile.rb'
|
||||||
|
|
||||||
|
module Tk
|
||||||
|
module Tile
|
||||||
|
class TScale < TkScale
|
||||||
|
end
|
||||||
|
class TProgress < TScale
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Tk::Tile::TScale < TkScale
|
||||||
|
include Tk::Tile::TileWidget
|
||||||
|
|
||||||
|
if Tk::Tile::USE_TTK_NAMESPACE
|
||||||
|
TkCommandNames = ['::ttk::scale'.freeze].freeze
|
||||||
|
else
|
||||||
|
TkCommandNames = ['::tscale'.freeze].freeze
|
||||||
|
end
|
||||||
|
WidgetClassName = 'TScale'.freeze
|
||||||
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Tk::Tile::TProgress < Tk::Tile::TScale
|
||||||
|
include Tk::Tile::TileWidget
|
||||||
|
|
||||||
|
if Tk::Tile::USE_TTK_NAMESPACE
|
||||||
|
TkCommandNames = ['::ttk::progress'.freeze].freeze
|
||||||
|
else
|
||||||
|
TkCommandNames = ['::tprogress'.freeze].freeze
|
||||||
|
end
|
||||||
|
WidgetClassName = 'TProgress'.freeze
|
||||||
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
|
end
|
|
@ -22,4 +22,8 @@ class Tk::Tile::TScrollbar < TkScrollbar
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TScrollbar'.freeze
|
WidgetClassName = 'TScrollbar'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,4 +22,8 @@ class Tk::Tile::TSeparator < TkWindow
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TSeparator'.freeze
|
WidgetClassName = 'TSeparator'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,4 +22,8 @@ class Tk::Tile::TSquare < TkWindow
|
||||||
end
|
end
|
||||||
WidgetClassName = 'TSquare'.freeze
|
WidgetClassName = 'TSquare'.freeze
|
||||||
WidgetClassNames[WidgetClassName] = self
|
WidgetClassNames[WidgetClassName] = self
|
||||||
|
|
||||||
|
def self.style(*args)
|
||||||
|
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -91,9 +91,10 @@ class Tk::HTML_Widget
|
||||||
|
|
||||||
def create_self(keys)
|
def create_self(keys)
|
||||||
if keys and keys != None
|
if keys and keys != None
|
||||||
tk_call_without_enc('html', @path, *hash_kv(keys, true))
|
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||||
|
*hash_kv(keys, true))
|
||||||
else
|
else
|
||||||
tk_call_without_enc('html', @path)
|
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private :create_self
|
private :create_self
|
||||||
|
|
|
@ -531,9 +531,10 @@ class Tk::TreeCtrl
|
||||||
|
|
||||||
def create_self(keys)
|
def create_self(keys)
|
||||||
if keys and keys != None
|
if keys and keys != None
|
||||||
tk_call_without_enc('treectrl', @path, *hash_kv(keys, true))
|
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||||
|
*hash_kv(keys, true))
|
||||||
else
|
else
|
||||||
tk_call_without_enc('treectrl', @path)
|
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
private :create_self
|
private :create_self
|
||||||
|
|
30
ext/tk/sample/tkextlib/tile/Orig_LICENSE.txt
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
### The following text is the original 'license.terms' of tile ###
|
||||||
|
### extension. ###
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
|
LICENSE ("MIT-style")
|
||||||
|
|
||||||
|
This software is Copyright (C) 2003 Joe English and other parties.
|
||||||
|
|
||||||
|
The following terms apply to all files associated with this software
|
||||||
|
unless explicitly disclaimed in individual files.
|
||||||
|
|
||||||
|
The author(s) hereby grant permission to use, copy, modify, distribute,
|
||||||
|
and license this software and its documentation for any purpose, provided
|
||||||
|
that existing copyright notices are retained in all copies and that this
|
||||||
|
notice is included in any distributions. No written agreement,
|
||||||
|
license, or royalty fee is required for any of the authorized uses.
|
||||||
|
Modifications to this software may be copyrighted by their authors
|
||||||
|
and need not follow the licensing terms described here, provided that
|
||||||
|
the new terms are clearly indicated on the first page of each file where
|
||||||
|
they apply.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS for a PARTICULAR PURPOSE. IN NO EVENT
|
||||||
|
shall the AUTHORS of THIS SOFTWARE be LIABLE to ANY PARTY for
|
||||||
|
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, or CONSEQUENTIAL DAMAGES
|
||||||
|
arising out of the USE of THIS SOFTWARE and its DOCUMENTATION.
|
742
ext/tk/sample/tkextlib/tile/demo.rb
Normal file
|
@ -0,0 +1,742 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
#
|
||||||
|
# Demo for 'tile' package.
|
||||||
|
#
|
||||||
|
require 'tk'
|
||||||
|
|
||||||
|
demodir = File.dirname($0)
|
||||||
|
Tk::AUTO_PATH.lappend('.', demodir, File.join(demodir, 'themes'))
|
||||||
|
|
||||||
|
require 'tkextlib/tile'
|
||||||
|
|
||||||
|
Tk.load_tclscript(File.join(demodir, 'toolbutton.tcl'))
|
||||||
|
|
||||||
|
# This forces an update of the available packages list. It's required
|
||||||
|
# for package names to find the themes in demos/themes/*.tcl
|
||||||
|
Tk.tk_call(TkPackage.unknown_proc, 'Tcl', TkPackage.provide('Tcl'))
|
||||||
|
|
||||||
|
TkRoot.new{
|
||||||
|
title 'Tile demo'
|
||||||
|
iconname 'Tile demo'
|
||||||
|
}
|
||||||
|
|
||||||
|
# The descriptive names of the builtin themes.
|
||||||
|
$THEMELIST = [
|
||||||
|
['default', 'Classic'],
|
||||||
|
['alt', 'Revitalized'],
|
||||||
|
['winnative', 'Windows native'],
|
||||||
|
['xpnative', 'XP Native'],
|
||||||
|
['aqua', 'Aqua'],
|
||||||
|
]
|
||||||
|
|
||||||
|
$V = TkVariable.new_hash(:THEME => 'default',
|
||||||
|
:COMPOUND => 'top',
|
||||||
|
:CONSOLE => false,
|
||||||
|
:MENURADIO1 => 'One',
|
||||||
|
:MENUCHECK1 => true)
|
||||||
|
|
||||||
|
# Add in any available loadable themes.
|
||||||
|
TkPackage.names.find_all{|n| n =~ /^tile::theme::/}.each{|pkg|
|
||||||
|
name = pkg.split('::')[-1]
|
||||||
|
unless $THEMELIST.assoc(name)
|
||||||
|
$THEMELIST << [name, Tk.tk_call('string', 'totitle', name)]
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add theme definition written by ruby
|
||||||
|
$RUBY_THEMELIST = []
|
||||||
|
begin
|
||||||
|
load(File.join(demodir, 'themes', 'kroc.rb'), true)
|
||||||
|
rescue
|
||||||
|
$RUBY_THEMELIST << ['kroc-rb', 'Kroc (by Ruby)', false]
|
||||||
|
else
|
||||||
|
$RUBY_THEMELIST << ['kroc-rb', 'Kroc (by Ruby)', true]
|
||||||
|
end
|
||||||
|
|
||||||
|
def makeThemeControl(parent)
|
||||||
|
c = Tk::Tile::TLabelframe.new(parent, :text=>'Theme')
|
||||||
|
$THEMELIST.each{|theme, name|
|
||||||
|
b = Tk::Tile::TRadiobutton.new(c, :text=>name, :value=>theme,
|
||||||
|
:variable=>$V.ref(:THEME),
|
||||||
|
:command=>proc{setTheme(theme)})
|
||||||
|
b.grid(:sticky=>:ew)
|
||||||
|
unless (TkPackage.names.find{|n| n == "tile::theme::#{theme}"})
|
||||||
|
b.state(:disabled)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
$RUBY_THEMELIST.each{|theme, name, available|
|
||||||
|
b = Tk::Tile::TRadiobutton.new(c, :text=>name, :value=>theme,
|
||||||
|
:variable=>$V.ref(:THEME),
|
||||||
|
:command=>proc{setTheme(theme)})
|
||||||
|
b.grid(:sticky=>:ew)
|
||||||
|
b.state(:disabled) unless available
|
||||||
|
}
|
||||||
|
c
|
||||||
|
end
|
||||||
|
|
||||||
|
def makeThemeMenu(parent)
|
||||||
|
m = TkMenu.new(parent)
|
||||||
|
$THEMELIST.each{|theme, name|
|
||||||
|
m.add(:radiobutton, :label=>name, :variable=>$V.ref(:THEME),
|
||||||
|
:value=>theme, :command=>proc{setTheme(theme)})
|
||||||
|
unless (TkPackage.names.find{|n| n == "tile::theme::#{theme}"})
|
||||||
|
m.entryconfigure(:end, :state=>:disabled)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
$RUBY_THEMELIST.each{|theme, name, available|
|
||||||
|
m.add(:radiobutton, :label=>name, :variable=>$V.ref(:THEME),
|
||||||
|
:value=>theme, :command=>proc{setTheme(theme)})
|
||||||
|
m.entryconfigure(:end, :state=>:disabled) unless available
|
||||||
|
}
|
||||||
|
m
|
||||||
|
end
|
||||||
|
|
||||||
|
def setTheme(theme)
|
||||||
|
if (TkPackage.names.find{|n| n == "tile::theme::#{theme}"})
|
||||||
|
TkPackage.require("tile::theme::#{theme}")
|
||||||
|
end
|
||||||
|
Tk::Tile::Style.theme_use(theme)
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Load icons...
|
||||||
|
#
|
||||||
|
$BUTTONS = ['open', 'new', 'save']
|
||||||
|
$CHECKBOXES = ['bold', 'italic']
|
||||||
|
$ICON = {}
|
||||||
|
|
||||||
|
def loadIcons(file)
|
||||||
|
Tk.load_tclscript(file)
|
||||||
|
img_data = TkVarAccess.new('ImgData')
|
||||||
|
img_data.keys.each{|icon|
|
||||||
|
$ICON[icon] = TkPhotoImage.new(:data=>img_data[icon])
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
loadIcons(File.join(demodir, 'iconlib.tcl'))
|
||||||
|
|
||||||
|
#
|
||||||
|
# Utilities:
|
||||||
|
#
|
||||||
|
def foreachWidget(wins, cmd)
|
||||||
|
wins.each{|w|
|
||||||
|
cmd.call(w)
|
||||||
|
foreachWidget(w.winfo_children, cmd)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# sbstub
|
||||||
|
# Used as the :command option for a scrollbar,
|
||||||
|
# updates the scrollbar's position.
|
||||||
|
#
|
||||||
|
def sbstub(sb, cmd, num, units = 'units')
|
||||||
|
case cmd.to_s
|
||||||
|
when 'moveto'
|
||||||
|
sb.set(num, num+0.5)
|
||||||
|
|
||||||
|
when 'scroll'
|
||||||
|
if units.to_s == 'pages'
|
||||||
|
delta = 0.2
|
||||||
|
else
|
||||||
|
delta = 0.05
|
||||||
|
end
|
||||||
|
current = sb.get
|
||||||
|
sb.set(current[0] + delta * num, current[1] + delta * num)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# ... for debugging:
|
||||||
|
TkBindTag::ALL.bind('ButtonPress-3', proc{|w| $W = w}, '%W')
|
||||||
|
TkBindTag::ALL.bind('Control-ButtonPress-3', proc{|w| w.set_focus}, '%W')
|
||||||
|
|
||||||
|
def showHelp()
|
||||||
|
Tk.messageBox(:message=>'No help yet...')
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# See toolbutton.tcl.
|
||||||
|
TkOption.add('*Toolbar.relief', :groove)
|
||||||
|
TkOption.add('*Toolbar.borderWidth', 2)
|
||||||
|
|
||||||
|
TkOption.add('*Toolbar.Button.Pad', 2)
|
||||||
|
|
||||||
|
$ROOT = Tk.root
|
||||||
|
$BASE = $ROOT
|
||||||
|
Tk.destroy(*($ROOT.winfo_children))
|
||||||
|
|
||||||
|
$TOOLBARS = []
|
||||||
|
|
||||||
|
#
|
||||||
|
# Toolbar button standard vs. tile comparison:
|
||||||
|
#
|
||||||
|
def makeToolbars
|
||||||
|
#
|
||||||
|
# Tile toolbar:
|
||||||
|
#
|
||||||
|
tb = Tk::Tile::TFrame.new($BASE, :class=>'Toolbar')
|
||||||
|
$TOOLBARS << tb
|
||||||
|
i = 0
|
||||||
|
$BUTTONS.each{|icon|
|
||||||
|
i += 1
|
||||||
|
Tk::Tile::TButton.new(tb, :text=>icon, :image=>$ICON[icon],
|
||||||
|
:compound=>$V[:COMPOUND],
|
||||||
|
:style=>:Toolbutton).grid(:row=>0, :column=>i,
|
||||||
|
:sticky=>:news)
|
||||||
|
}
|
||||||
|
$CHECKBOXES.each{|icon|
|
||||||
|
i += 1
|
||||||
|
Tk::Tile::TCheckbutton.new(tb, :text=>icon, :image=>$ICON[icon],
|
||||||
|
:variable=>$V.ref(icon),
|
||||||
|
:compound=>$V[:COMPOUND],
|
||||||
|
:style=>:Toolbutton).grid(:row=>0, :column=>i,
|
||||||
|
:sticky=>:news)
|
||||||
|
}
|
||||||
|
|
||||||
|
mb = Tk::Tile::TMenubutton.new(tb, :text=>'toolbar', :image=>$ICON['file'],
|
||||||
|
:compound=>$V[:COMPOUND])
|
||||||
|
mb.configure(:menu=>makeCompoundMenu(mb))
|
||||||
|
i += 1
|
||||||
|
mb.grid(:row=>0, :column=>i, :sticky=>:news)
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
tb.grid_columnconfigure(i, :weight=>1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Standard toolbar:
|
||||||
|
#
|
||||||
|
tb = TkFrame.new($BASE, :class=>'Toolbar')
|
||||||
|
$TOOLBARS << tb
|
||||||
|
i = 0
|
||||||
|
$BUTTONS.each{|icon|
|
||||||
|
i += 1
|
||||||
|
TkButton.new(tb, :text=>icon, :image=>$ICON[icon],
|
||||||
|
:compound=>$V[:COMPOUND], :relief=>:flat,
|
||||||
|
:overrelief=>:raised).grid(:row=>0, :column=>i,
|
||||||
|
:sticky=>:news)
|
||||||
|
}
|
||||||
|
$CHECKBOXES.each{|icon|
|
||||||
|
i += 1
|
||||||
|
TkCheckbutton.new(tb, :text=>icon, :image=>$ICON[icon],
|
||||||
|
:variable=>$V.ref(icon), :compound=>$V[:COMPOUND],
|
||||||
|
:indicatoron=>false, :selectcolor=>'', :relief=>:flat,
|
||||||
|
:overrelief=>:raised).grid(:row=>0, :column=>i,
|
||||||
|
:sticky=>:news)
|
||||||
|
}
|
||||||
|
|
||||||
|
mb = TkMenubutton.new(tb, :text=>'toolbar', :image=>$ICON['file'],
|
||||||
|
:compound=>$V[:COMPOUND])
|
||||||
|
mb.configure(:menu=>makeCompoundMenu(mb))
|
||||||
|
i += 1
|
||||||
|
mb.grid(:row=>0, :column=>i, :sticky=>:news)
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
tb.grid_columnconfigure(i, :weight=>1)
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Toolbar :compound control:
|
||||||
|
#
|
||||||
|
def makeCompoundMenu(mb)
|
||||||
|
menu = TkMenu.new(mb)
|
||||||
|
%w(text image none top bottom left right center).each{|str|
|
||||||
|
menu.add(:radiobutton, :label=>Tk.tk_call('string', 'totitle', str),
|
||||||
|
:variable=>$V.ref(:COMPOUND), :value=>str,
|
||||||
|
:command=>proc{ changeToolbars() })
|
||||||
|
}
|
||||||
|
menu
|
||||||
|
end
|
||||||
|
|
||||||
|
makeToolbars()
|
||||||
|
|
||||||
|
## CONTROLS
|
||||||
|
control = Tk::Tile::TFrame.new($BASE)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Overall theme control:
|
||||||
|
#
|
||||||
|
makeThemeControl(control).grid(:sticky=>:news, :padx=>6, :ipadx=>6)
|
||||||
|
control.grid_rowconfigure(99, :weight=>1)
|
||||||
|
|
||||||
|
def changeToolbars
|
||||||
|
foreachWidget($TOOLBARS,
|
||||||
|
proc{|w|
|
||||||
|
begin
|
||||||
|
w.compound($V[:COMPOUND])
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
def scrolledWidget(parent, klass, themed, *args)
|
||||||
|
if themed
|
||||||
|
f = Tk::Tile::TFrame.new(parent)
|
||||||
|
t = klass.new(f, *args)
|
||||||
|
vs = Tk::Tile::TScrollbar.new(f)
|
||||||
|
hs = Tk::Tile::TScrollbar.new(f)
|
||||||
|
else
|
||||||
|
f = TkFrame.new(parent)
|
||||||
|
t = klass.new(f, *args)
|
||||||
|
vs = TkScrollbar.new(f)
|
||||||
|
hs = TkScrollbar.new(f)
|
||||||
|
end
|
||||||
|
t.yscrollbar(vs)
|
||||||
|
t.xscrollbar(hs)
|
||||||
|
|
||||||
|
TkGrid.configure(t, vs, :sticky=>:news)
|
||||||
|
TkGrid.configure(hs, 'x', :sticky=>:news)
|
||||||
|
TkGrid.rowconfigure(f, 0, :weight=>1)
|
||||||
|
TkGrid.columnconfigure(f, 0, :weight=>1)
|
||||||
|
|
||||||
|
[f, t]
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Notebook demonstration:
|
||||||
|
#
|
||||||
|
def makeNotebook
|
||||||
|
nb = Tk::Tile::TNotebook.new($BASE, :padding=>6)
|
||||||
|
nb.enable_traversal
|
||||||
|
client = Tk::Tile::TFrame.new(nb)
|
||||||
|
nb.add(client, :text=>'Demo', :underline=>0)
|
||||||
|
nb.select(client)
|
||||||
|
|
||||||
|
others = Tk::Tile::TFrame.new(nb)
|
||||||
|
nb.add(others, :text=>'Others', :underline=>4)
|
||||||
|
nb.add(Tk::Tile::TLabel.new(nb, :text=>'Nothing to see here...'),
|
||||||
|
:text=>'Stuff', :sticky=>:new)
|
||||||
|
nb.add(Tk::Tile::TLabel.new(nb, :text=>'Nothing to see here either.'),
|
||||||
|
:text=>'More Stuff', :sticky=>:se)
|
||||||
|
|
||||||
|
[nb, client, others]
|
||||||
|
end
|
||||||
|
|
||||||
|
nb, client, others = makeNotebook()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Side-by side check, radio, and menu button comparison:
|
||||||
|
#
|
||||||
|
def fillMenu(menu)
|
||||||
|
%w(above below left right flush).each{|dir|
|
||||||
|
menu.add(:command, :label=>Tk.tk_call('string', 'totitle', dir),
|
||||||
|
:command=>proc{ menu.winfo_parent.direction(dir) })
|
||||||
|
}
|
||||||
|
menu.add(:cascade, :label=>'Submenu', :menu=>(submenu = TkMenu.new(menu)))
|
||||||
|
submenu.add(:command, :label=>'Subcommand 1')
|
||||||
|
submenu.add(:command, :label=>'Subcommand 2')
|
||||||
|
submenu.add(:command, :label=>'Subcommand 3')
|
||||||
|
|
||||||
|
menu.add(:separator)
|
||||||
|
menu.add(:command, :label=>'Quit', :command=>proc{Tk.root.destroy})
|
||||||
|
end
|
||||||
|
|
||||||
|
l = Tk::Tile::TLabelframe.new(client, :text=>'Styled', :padding=>6)
|
||||||
|
r = TkLabelframe.new(client, :text=>'Standard', :padx=>6, :pady=>6)
|
||||||
|
|
||||||
|
## Styled frame
|
||||||
|
cb = Tk::Tile::TCheckbutton.new(l, :text=>'Checkbutton',
|
||||||
|
:variable=>$V.ref(:SELECTED), :underline=>2)
|
||||||
|
rb1 = Tk::Tile::TRadiobutton.new(l, :text=>'One', :variable=>$V.ref(:CHOICE),
|
||||||
|
:value=>1, :underline=>0)
|
||||||
|
rb2 = Tk::Tile::TRadiobutton.new(l, :text=>'Two', :variable=>$V.ref(:CHOICE),
|
||||||
|
:value=>2)
|
||||||
|
rb3 = Tk::Tile::TRadiobutton.new(l, :text=>'Three',
|
||||||
|
:variable=>$V.ref(:CHOICE),
|
||||||
|
:value=>3, :underline=>0)
|
||||||
|
btn = Tk::Tile::TButton.new(l, :text=>'Button', :underline=>0)
|
||||||
|
|
||||||
|
mb = Tk::Tile::TMenubutton.new(l, :text=>'Menubutton', :underline=>2)
|
||||||
|
#m = TkMenu.new(mb)
|
||||||
|
#mb.menu(m)
|
||||||
|
#fillMenu(m)
|
||||||
|
|
||||||
|
$entryText = TkVariable.new('Entry widget')
|
||||||
|
e = Tk::Tile::TEntry.new(l, :textvariable=>$entryText)
|
||||||
|
e.selection_range(6, :end)
|
||||||
|
|
||||||
|
ltext_f, ltext = scrolledWidget(l, TkText, true,
|
||||||
|
:width=>12, :height=>5, :wrap=>:none)
|
||||||
|
|
||||||
|
scales = Tk::Tile::TFrame.new(l)
|
||||||
|
sc = Tk::Tile::TScale.new(scales, :orient=>:horizontal, :from=>0, :to=>100,
|
||||||
|
:variable=>$V.ref(:SCALE))
|
||||||
|
vsc = Tk::Tile::TScale.new(scales, :orient=>:vertical, :from=>-25, :to=>25,
|
||||||
|
:variable=>$V.ref(:VSCALE))
|
||||||
|
|
||||||
|
prg = Tk::Tile::TProgress.new(scales, :orient=>:horizontal,
|
||||||
|
:from=>0, :to=>100)
|
||||||
|
vprg = Tk::Tile::TProgress.new(scales, :orient=>:vertical,
|
||||||
|
:from=>-25, :to=>25)
|
||||||
|
|
||||||
|
sc.command{|*args| prg.set(*args)}
|
||||||
|
vsc.command{|*args| vprg.set(*args)}
|
||||||
|
|
||||||
|
Tk.grid(sc, :columnspan=>2, :sticky=>:ew)
|
||||||
|
Tk.grid(prg, :columnspan=>2, :sticky=>:ew)
|
||||||
|
Tk.grid(vsc, vprg, :sticky=>:nws)
|
||||||
|
TkGrid.columnconfigure(scales, 0, :weight=>1)
|
||||||
|
TkGrid.columnconfigure(scales, 1, :weight=>1)
|
||||||
|
|
||||||
|
# NOTE TO MAINTAINERS:
|
||||||
|
# The checkbuttons are -sticky ew / -expand x on purpose:
|
||||||
|
# it demonstrates one of the differences between TCheckbuttons
|
||||||
|
# and standard checkbuttons.
|
||||||
|
#
|
||||||
|
Tk.grid(cb, :sticky=>:ew)
|
||||||
|
Tk.grid(rb1, :sticky=>:ew)
|
||||||
|
Tk.grid(rb2, :sticky=>:ew)
|
||||||
|
Tk.grid(rb3, :sticky=>:ew)
|
||||||
|
Tk.grid(btn, :sticky=>:ew, :padx=>2, :pady=>2)
|
||||||
|
Tk.grid(mb, :sticky=>:ew, :padx=>2, :pady=>2)
|
||||||
|
Tk.grid(e, :sticky=>:ew, :padx=>2, :pady=>2)
|
||||||
|
Tk.grid(ltext_f, :sticky=>:news)
|
||||||
|
Tk.grid(scales, :sticky=>:news, :pady=>2)
|
||||||
|
|
||||||
|
TkGrid.columnconfigure(l, 0, :weight=>1)
|
||||||
|
TkGrid.rowconfigure(l, 7, :weight=>1) # text widget (grid is a PITA)
|
||||||
|
|
||||||
|
## Orig frame
|
||||||
|
cb = TkCheckbutton.new(r, :text=>'Checkbutton', :variable=>$V.ref(:SELECTED))
|
||||||
|
rb1 = TkRadiobutton.new(r, :text=>'One',
|
||||||
|
:variable=>$V.ref(:CHOICE), :value=>1)
|
||||||
|
rb2 = TkRadiobutton.new(r, :text=>'Two', :variable=>$V.ref(:CHOICE),
|
||||||
|
:value=>2, :underline=>1)
|
||||||
|
rb3 = TkRadiobutton.new(r, :text=>'Three',
|
||||||
|
:variable=>$V.ref(:CHOICE), :value=>3)
|
||||||
|
btn = TkButton.new(r, :text=>'Button')
|
||||||
|
|
||||||
|
mb = TkMenubutton.new(r, :text=>'Menubutton', :underline=>3, :takefocus=>true)
|
||||||
|
m = TkMenu.new(mb)
|
||||||
|
mb.menu(m)
|
||||||
|
$V[:rmbIndicatoron] = mb.indicatoron
|
||||||
|
m.add(:checkbutton, :label=>'Indicator?', #'
|
||||||
|
:variable=>$V.ref(:rmbIndicatoron),
|
||||||
|
:command=>proc{mb.indicatoron($V[:rmbIndicatoron].value)})
|
||||||
|
m.add(:separator)
|
||||||
|
fillMenu(m)
|
||||||
|
|
||||||
|
e = TkEntry.new(r, :textvariable=>$entryText)
|
||||||
|
|
||||||
|
rtext_f, rtext = scrolledWidget(r, TkText, false,
|
||||||
|
:width=>12, :height=>5, :wrap=>:none)
|
||||||
|
|
||||||
|
sc = TkScale.new(r, :orient=>:horizontal, :from=>0, :to=>100,
|
||||||
|
:variable=>$V.ref(:SCALE))
|
||||||
|
vsc = TkScale.new(r, :orient=>:vertical, :from=>-25, :to=>25,
|
||||||
|
:variable=>$V.ref(:VSCALE))
|
||||||
|
|
||||||
|
Tk.grid(cb, :sticky=>:ew)
|
||||||
|
Tk.grid(rb1, :sticky=>:ew)
|
||||||
|
Tk.grid(rb2, :sticky=>:ew)
|
||||||
|
Tk.grid(rb3, :sticky=>:ew)
|
||||||
|
Tk.grid(btn, :sticky=>:ew, :padx=>2, :pady=>2)
|
||||||
|
Tk.grid(mb, :sticky=>:ew, :padx=>2, :pady=>2)
|
||||||
|
Tk.grid(e, :sticky=>:ew, :padx=>2, :pady=>2)
|
||||||
|
Tk.grid(rtext_f, :sticky=>:news)
|
||||||
|
Tk.grid(sc, :sticky=>:news)
|
||||||
|
Tk.grid(vsc, :sticky=>:nws)
|
||||||
|
|
||||||
|
TkGrid.columnconfigure(l, 0, :weight=>1)
|
||||||
|
TkGrid.rowconfigure(l, 7, :weight=>1) # text widget (grid is a PITA)
|
||||||
|
|
||||||
|
Tk.grid(l, r, :sticky=>:news, :padx=>6, :pady=>6)
|
||||||
|
TkGrid.rowconfigure(client, 0, :weight=>1)
|
||||||
|
TkGrid.columnconfigure(client, [0, 1], :weight=>1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add some text to the text boxes:
|
||||||
|
#
|
||||||
|
msgs = [
|
||||||
|
"The cat crept into the crypt, crapped and crept out again",
|
||||||
|
"Peter Piper picked a peck of pickled peppers",
|
||||||
|
"How much wood would a woodchuck chuck if a woodchuck could chuck wood",
|
||||||
|
"He thrusts his fists against the posts and still insists he sees the ghosts",
|
||||||
|
"Who put the bomb in the bom-b-bom-b-bom,",
|
||||||
|
"Is this your sister's sixth zither, sir?",
|
||||||
|
"Who put the ram in the ramalamadingdong?",
|
||||||
|
"I am not the pheasant plucker, I'm the pheasant plucker's mate."
|
||||||
|
]
|
||||||
|
|
||||||
|
nmsgs = msgs.size
|
||||||
|
(0...50).each{|n|
|
||||||
|
msg = msgs[n % nmsgs]
|
||||||
|
ltext.insert(:end, "#{n}: #{msg}\n")
|
||||||
|
rtext.insert(:end, "#{n}: #{msg}\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Command box:
|
||||||
|
#
|
||||||
|
cmd = Tk::Tile::TFrame.new($BASE)
|
||||||
|
b_close = Tk::Tile::TButton.new(cmd, :text=>'Close',
|
||||||
|
:underline=>0, :default=>:normal,
|
||||||
|
:command=>proc{Tk.root.destroy})
|
||||||
|
b_help = Tk::Tile::TButton.new(cmd, :text=>'Help', :underline=>0,
|
||||||
|
:default=>:normal, :command=>proc{showHelp()})
|
||||||
|
Tk.grid('x', b_close, b_help, :pady=>[6, 4], :padx=>4)
|
||||||
|
TkGrid.columnconfigure(cmd, 0, :weight=>1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set up accelerators:
|
||||||
|
#
|
||||||
|
$ROOT.bind('KeyPress-Escape', proc{Tk.event_generate(b_close, '<Invoke>')})
|
||||||
|
$ROOT.bind('<Help>', proc{Tk.event_generate(b_help, '<Invoke>')})
|
||||||
|
Tk::Tile::KeyNav.enableMnemonics($ROOT)
|
||||||
|
Tk::Tile::KeyNav.defaultButton(b_help)
|
||||||
|
|
||||||
|
Tk.grid($TOOLBARS[0], '-', :sticky=>:ew)
|
||||||
|
Tk.grid($TOOLBARS[1], '-', :sticky=>:ew)
|
||||||
|
Tk.grid(control, nb, :sticky=>:news)
|
||||||
|
Tk.grid(cmd, '-', :sticky=>:ew)
|
||||||
|
TkGrid.columnconfigure($ROOT, 1, :weight=>1)
|
||||||
|
TkGrid.rowconfigure($ROOT, 2, :weight=>1)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add a menu
|
||||||
|
#
|
||||||
|
menu = TkMenu.new($BASE)
|
||||||
|
$ROOT.menu(menu)
|
||||||
|
m_file = TkMenu.new(menu, :tearoff=>0)
|
||||||
|
menu.add(:cascade, :label=>'File', :underline=>0, :menu=>m_file)
|
||||||
|
m_file.add(:command, :label=>'Open', :underline=>0,
|
||||||
|
:compound=>:left, :image=>$ICON['open'])
|
||||||
|
m_file.add(:command, :label=>'Save', :underline=>0,
|
||||||
|
:compound=>:left, :image=>$ICON['save'])
|
||||||
|
m_file.add(:separator)
|
||||||
|
m_f_test = TkMenu.new(menu, :tearoff=>0)
|
||||||
|
m_file.add(:cascade, :label=>'Test submenu', :underline=>0, :menu=>m_f_test)
|
||||||
|
m_file.add(:checkbutton, :label=>'Text check', :underline=>5,
|
||||||
|
:variable=>$V.ref(:MENUCHECK1))
|
||||||
|
m_file.insert(:end, :separator)
|
||||||
|
|
||||||
|
if Tk.windowingsystem != 'x11'
|
||||||
|
m_file.insert(:end, :checkbutton, :label=>'Console', :underline=>5,
|
||||||
|
:variable=>$V.ref(:CONSOLE), :command=>proc{toggle_console()})
|
||||||
|
def toggle_console
|
||||||
|
if TkComm.bool($V[:CONSOLE])
|
||||||
|
TkConsole.show
|
||||||
|
else
|
||||||
|
TkConsole.hide
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
m_file.add(:command, :label=>'Exit', :underline=>1,
|
||||||
|
:command=>proc{Tk.event_generate(b_close, '<Invoke>')})
|
||||||
|
|
||||||
|
%w(One Two Three Four).each{|lbl|
|
||||||
|
m_f_test.add(:radiobutton, :label=>lbl, :variable=>$V.ref(:MENURADIO1))
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add Theme menu.
|
||||||
|
#
|
||||||
|
menu.add(:cascade, :label=>'Theme', :underline=>3,
|
||||||
|
:menu=>makeThemeMenu(menu))
|
||||||
|
|
||||||
|
setTheme($V[:THEME])
|
||||||
|
|
||||||
|
#
|
||||||
|
# Other demos:
|
||||||
|
#
|
||||||
|
$Timers = {:StateMonitor=>nil, :FocusMonitor=>nil}
|
||||||
|
|
||||||
|
msg = TkMessage.new(others, :aspect=>200)
|
||||||
|
|
||||||
|
$Desc = {}
|
||||||
|
|
||||||
|
showDescription = TkBindTag.new
|
||||||
|
showDescription.bind('Enter', proc{|w| msg.text($Desc[w.path])}, '%W')
|
||||||
|
showDescription.bind('Leave', proc{|w| msg.text('')}, '%W')
|
||||||
|
|
||||||
|
[
|
||||||
|
[ :trackStates, "Widget states...",
|
||||||
|
"Display/modify widget state bits" ],
|
||||||
|
|
||||||
|
[ :scrollbarResizeDemo, "Scrollbar resize behavior...",
|
||||||
|
"Shows how Tile and standard scrollbars differ when they're sized too large" ],
|
||||||
|
|
||||||
|
[ :trackFocus, "Track keyboard focus..." ,
|
||||||
|
"Display the name of the widget that currently has focus" ]
|
||||||
|
].each{|demo_cmd, label, description|
|
||||||
|
b = Tk::Tile::TButton.new(others, :text=>label,
|
||||||
|
:command=>proc{ self.__send__(demo_cmd) })
|
||||||
|
$Desc[b.path] = description
|
||||||
|
b.bindtags <<= showDescription
|
||||||
|
|
||||||
|
b.pack(:side=>:top, :expand=>false, :fill=>:x, :padx=>6, :pady=>6)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.pack(:side=>:bottom, :expand=>true, :fill=>:both)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Scrollbar resize demo:
|
||||||
|
#
|
||||||
|
$scrollbars = nil
|
||||||
|
|
||||||
|
def scrollbarResizeDemo
|
||||||
|
if $scrollbars
|
||||||
|
begin
|
||||||
|
$scrollbars.destroy
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
$scrollbars = TkToplevel.new(:title=>'Scrollbars', :geometry=>'200x200')
|
||||||
|
f = TkFrame.new($scrollbars, :height=>200)
|
||||||
|
tsb = Tk::Tile::TScrollbar.new(f, :command=>proc{|*args| sbstub(tsb, *args)})
|
||||||
|
sb = TkScrollbar.new(f, :command=>proc{|*args| sbstub(sb, *args)})
|
||||||
|
Tk.grid(tsb, sb, :sticky=>:news)
|
||||||
|
|
||||||
|
sb.set(0, 0.5) # prevent backwards-compatibility mode for old SB
|
||||||
|
|
||||||
|
f.grid_columnconfigure(0, :weight=>1)
|
||||||
|
f.grid_columnconfigure(1, :weight=>1)
|
||||||
|
f.grid_rowconfigure(0, :weight=>1)
|
||||||
|
|
||||||
|
f.pack(:expand=>true, :fill=>:both)
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Track focus demo:
|
||||||
|
#
|
||||||
|
$FocusInf = TkVariable.new_hash
|
||||||
|
$focus = nil
|
||||||
|
|
||||||
|
def trackFocus
|
||||||
|
if $focus
|
||||||
|
begin
|
||||||
|
$focus.destroy
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
$focus = TkToplevel.new(:title=>'Keyboard focus')
|
||||||
|
i = 0
|
||||||
|
[
|
||||||
|
["Focus widget:", :Widget],
|
||||||
|
["Class:", :WidgetClass],
|
||||||
|
["Next:", :WidgetNext],
|
||||||
|
["Grab:", :Grab],
|
||||||
|
["Status:", :GrabStatus]
|
||||||
|
].each{|label, var_index|
|
||||||
|
Tk.grid(Tk::Tile::TLabel.new($focus, :text=>label, :anchor=>:e),
|
||||||
|
Tk::Tile::TLabel.new($focus,
|
||||||
|
:textvariable=>$FocusInf.ref(var_index),
|
||||||
|
:width=>40, :anchor=>:w, :relief=>:groove),
|
||||||
|
:sticky=>:ew)
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
$focus.grid_columnconfigure(1, :weight=>1)
|
||||||
|
$focus.grid_rowconfigure(i, :weight=>1)
|
||||||
|
|
||||||
|
$focus.bind('Destroy', proc{Tk.after_cancel($Timers[:FocusMonitor])})
|
||||||
|
focusMonitor
|
||||||
|
end
|
||||||
|
|
||||||
|
def focusMonitor
|
||||||
|
$FocusInf[:Widget] = focus_win = Tk.focus
|
||||||
|
if focus_win
|
||||||
|
$FocusInf[:WidgetClass] = focus_win.winfo_classname
|
||||||
|
$FocusInf[:WidgetNext] = Tk.focus_next(focus_win)
|
||||||
|
else
|
||||||
|
$FocusInf[:WidgetClass] = $FocusInf[:WidgetNext] = ''
|
||||||
|
end
|
||||||
|
|
||||||
|
$FocusInf[:Grab] = grab_wins = Tk.current_grabs
|
||||||
|
unless grab_wins.empty?
|
||||||
|
$FocusInf[:GrabStatus] = grab_wins[0].grab_status
|
||||||
|
else
|
||||||
|
$FocusInf[:GrabStatus] = ''
|
||||||
|
end
|
||||||
|
|
||||||
|
$Timers[:FocusMonitor] = Tk.after(200, proc{ focusMonitor() })
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Widget state demo:
|
||||||
|
#
|
||||||
|
|
||||||
|
$Widget = TkVariable.new
|
||||||
|
|
||||||
|
TkBindTag::ALL.bind('Control-Shift-ButtonPress-1',
|
||||||
|
proc{|w|
|
||||||
|
$Widget.value = w
|
||||||
|
updateStates()
|
||||||
|
Tk.callback_break
|
||||||
|
}, '%W')
|
||||||
|
$states_list = %w(active disabled focus pressed selected
|
||||||
|
background indeterminate invalid default)
|
||||||
|
$states_btns = {}
|
||||||
|
$states = nil
|
||||||
|
|
||||||
|
$State = TkVariable.new_hash
|
||||||
|
|
||||||
|
def trackStates
|
||||||
|
if $states
|
||||||
|
begin
|
||||||
|
$state.destroy
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
end
|
||||||
|
$states = TkToplevel.new(:title=>'Widget states')
|
||||||
|
|
||||||
|
l_inf = Tk::Tile::TLabel.new($states, :text=>"Press Control-Shift-Button-1 on any widget")
|
||||||
|
|
||||||
|
l_lw = Tk::Tile::TLabel.new($states, :text=>'Widget:',
|
||||||
|
:anchor=>:e, :relief=>:groove)
|
||||||
|
l_w = Tk::Tile::TLabel.new($states, :textvariable=>$Widget,
|
||||||
|
:anchor=>:w, :relief=>:groove)
|
||||||
|
|
||||||
|
Tk.grid(l_inf, '-', :sticky=>:ew, :padx=>6, :pady=>6)
|
||||||
|
Tk.grid(l_lw, l_w, :sticky=>:ew)
|
||||||
|
|
||||||
|
$states_list.each{|st|
|
||||||
|
cb = Tk::Tile::TCheckbutton.new($states, :text=>st,
|
||||||
|
:variable=>$State.ref(st),
|
||||||
|
:command=>proc{ changeState(st) })
|
||||||
|
$states_btns[st] = cb
|
||||||
|
Tk.grid('x', cb, :sticky=>:nsew)
|
||||||
|
}
|
||||||
|
|
||||||
|
$states.grid_columnconfigure(1, :weight=>1)
|
||||||
|
|
||||||
|
f_cmd = Tk::Tile::TFrame.new($states)
|
||||||
|
Tk.grid('x', f_cmd, :sticky=>:nse)
|
||||||
|
|
||||||
|
b_close = Tk::Tile::TButton.new(f_cmd, :text=>'Close',
|
||||||
|
:command=>proc{ $states.destroy })
|
||||||
|
Tk.grid('x', b_close, :padx=>4, :pady=>[6,4])
|
||||||
|
f_cmd.grid_columnconfigure(0, :weight=>1)
|
||||||
|
|
||||||
|
$states.bind('KeyPress-Escape', proc{Tk.event_generate(b_close, '<Invoke>')})
|
||||||
|
|
||||||
|
$states.bind('Destroy', proc{Tk.after_cancel($Timers[:StateMonitor])})
|
||||||
|
stateMonitor()
|
||||||
|
end
|
||||||
|
|
||||||
|
def stateMonitor
|
||||||
|
updateStates() if $Widget.value != ''
|
||||||
|
$Timers[:StateMonitor] = Tk.after(200, proc{ stateMonitor() })
|
||||||
|
end
|
||||||
|
|
||||||
|
def updateStates
|
||||||
|
$states_list.each{|st|
|
||||||
|
begin
|
||||||
|
$State[st] = $Widget.window.instate(st)
|
||||||
|
rescue
|
||||||
|
$states_btns[st].state('disabled')
|
||||||
|
else
|
||||||
|
$states_btns[st].state('!disabled')
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeState(st)
|
||||||
|
if $Widget.value != ''
|
||||||
|
if $State.bool_element(st)
|
||||||
|
$Widget.window.state(st)
|
||||||
|
else
|
||||||
|
$Widget.window.state("!#{st}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Tk.mainloop
|
110
ext/tk/sample/tkextlib/tile/iconlib.tcl
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
array set ImgData {
|
||||||
|
bold {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAI6hI+py60U3wj+
|
||||||
|
RYQFJYRvEWFBCeFbRFhQQvhG8YPgX0RYUEL4FhEWlBC+RYQFJYQPFN8IPqYut/8hBQA7}
|
||||||
|
copy {R0lGODlhEAAQAJEAANnZ2QAAAP///wAAhCH5BAEAAAAALAAAAAAQABAAAAJUhI8JFJ/gY4iI
|
||||||
|
UEL4FyIiFIXgW0iEUDgfACBI9pzMAAGRiIghWSMDECR7JEKGtkFIRFBG+TIQKDQxtgzcDcmX
|
||||||
|
IfgwQrFlCD4MyZch+EDzj+Bj6mYBADs=}
|
||||||
|
cut {R0lGODlhEAAQAJEAANnZ2QAAAAAAhP///yH5BAEAAAAALAAAAAAQABAAAAJFhI+pcUHwEeIi
|
||||||
|
E0gACIKPEAFBIXy0gMg8EhM+YmQiKSL4eAIiJMI/EQEhQGYGYiQIQAg+iAkIATIzECMBIgT/
|
||||||
|
RBARERlSADs=}
|
||||||
|
dragfile {R0lGODlhGAAYAKIAANnZ2TMzM////wAAAJmZmf///////////yH5BAEAAAAALAAAAAAYABgA
|
||||||
|
AAPACBi63IqgC4GiyxwogaAbKLrMgSKBoBoousyBogEACIGiyxwoKgGAECI4uiyCExMTOACB
|
||||||
|
osuNpDoAGCI4uiyCIkREOACBosutSDoAgSI4usyCIjQAGCi63Iw0ACEoOLrMgiI0ABgoutyM
|
||||||
|
NAAhKDi6zIIiNAAYKLrcjDQAISg4usyCIjQAGCi63Iw0AIGiiqPLIyhCA4CBosvNSAMQKKo4
|
||||||
|
ujyCIjQAGCi63Iw0AIGiy81IAxCBpMu9GAMAgKPL3QgJADs=}
|
||||||
|
dragicon {R0lGODlhGAAYALMAANnZ2TMzM/////8zM8zMzGYAAAAAAJmZmQCZMwAzZgCZzGZmZv//////
|
||||||
|
/////////yH5BAEAAAAALAAAAAAYABgAAAT/EMAgJ60SAjlBgEJOSoMIEMgZoJCT0iADBFIG
|
||||||
|
KOSkNMwAAABhwiHnIEKIIIQQAQIZhBBwyDmKEMIEE0yABoAghIBDzlGEENDIaQAIQgg45BwF
|
||||||
|
CinPOccAECYcUiKEEBFCiHPgMQAEIcQYYyABBUGIQCHlMQCEScZAAhKEEApCECGOARAEIQQp
|
||||||
|
BRGIpAyCJCGOASBAISdEcqJAVBLiGABggELOAJGUKyiVhDgGABigkJMEhNAKSqkEhTgGgCCl
|
||||||
|
FCQEGIJSSiUhjgEgQCEnJVBJmYQ4BoAAhZyTQCVnEuIYAAIUckoCk5xSiGMACFDISSs9BoBg
|
||||||
|
rRXQMQAEKOSklR4DEUAI8MhJ6wwGAACgkZNWCkAEADs=}
|
||||||
|
error {R0lGODlhIAAgAKIAANnZ2YQAAP8AAISEhP///////////////yH5BAEAAAAALAAAAAAgACAA
|
||||||
|
AAP/CLoMGLqKoMvtGIqiqxEYCLrcioGiyxwIusyBgaLLLRiBoMsQKLrcjYGgu4Giy+2CAkFX
|
||||||
|
A0WX2wXFIOgGii7trkCEohsDCACBoktEKLpKhISiGwAIECiqSKooukiqKKoxgACBooukKiIo
|
||||||
|
SKooujGDECi6iqQqsopEV2MQAkV3kXQZRXdjEAJFl5F0FUWXY3ACRZcFSRdFlyVwJlB0WZB0
|
||||||
|
UXRZAmcCRZeRdBVFl2NwAkV3kXQZRXdjcAJFV5FURVaR6GoMDgSKLpKqiKAgqaLoxgwOBIoq
|
||||||
|
kiqKLpIqimrM4ECg6BIRiq4SIaHoxgyCBoou7a5AhKIbMzgAAIGiy+2CTWJmBhAAAkWX2wXF
|
||||||
|
zCDoBooud2PMDIKuRqDocgtGzMwg6O4Eii5z4Kgi6DIMhqLoagQGjiqCLvPgYOgqji6CLrfi
|
||||||
|
6DIj6HI7jq4i6DIkADs=}
|
||||||
|
file {R0lGODlhCwANAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAALAA0AAAIyhI9G8Q0AguSH
|
||||||
|
AMQdxQgxEyEFQfItICQokYgEBMm3gBCKLRIQJN8CQii2SECQfAug+FgAOw==}
|
||||||
|
folder {R0lGODlhEAANAKIAANnZ2YSEhMbGxv//AP///wAAAP///////yH5BAEAAAAALAAAAAAQAA0A
|
||||||
|
AANjCIqhiqDLITgyEgi6GoIjIyMYugCBpMsaWBA0giMjIzgyUYBBMjIoIyODEgVBODIygiMj
|
||||||
|
E1gQJIMyMjIoI1GAQSMjODIyghMFQSgjI4MyMhJYEDSCIyMjODJRgKHLXAiApcucADs=}
|
||||||
|
hourglass {R0lGODlhIAAgAKIAANnZ2YAAAAAAAP8AAP///8DAwICAgP///yH5BAEAAAAALAAAAAAgACAA
|
||||||
|
AAPZCLrc/jDKSau9OGcUuqyCoMvNGENVhaMrCLrcjaLLgqDL7WhFVIVVZoKgy+1oRUSFVWaC
|
||||||
|
oMvtaEVEhVVmgqDL7WhFRIVVZoKgy+1oVVaCJWaCoMvtgKxISrBMEHS5fZEVSRkKgi63NzIq
|
||||||
|
EwRdbndkVCYIutzeyIqqDAVBl9sXWRFJYZkg6HI7ICsiKqwyEwRdbkcrIhKsMhMEXW5HKyIp
|
||||||
|
lDITBF1uRysyEiwxEwRdbkcrIyuUEhMEXW5H0WVB0OVujKGqwtEVBF1uRtHlRdDl9odRTlrt
|
||||||
|
xRmjBAA7}
|
||||||
|
info {R0lGODlhIAAgAKIAANnZ2YSEhMbGxv///wAA/wAAAP///////yH5BAEAAAAALAAAAAAgACAA
|
||||||
|
AAP/CLoMGLqKoMvtGCo4uhKBgaDLDRghOLqsghEIuryBgqPLPSiBoMsQOLojhEQkOLpTCLob
|
||||||
|
OLqKpIujq4WgC4Gju0i6OLpbCKohOLorhEQkOLorhaAQOLrc3qgCIARHl9sbSQUEji4j6RKO
|
||||||
|
Lk9hQODosiKp4ujyFIbi6LIiqeLo8hSG4uiyIqni6PIUhuLosiKp4ujyFIYKji4PkiqOLkth
|
||||||
|
BASOLg+SKo4uV2AEhODoMpIqju5KYShA4Ogqku7i6E4FRgAAYOHocvugiohAUC0cXe7GiohA
|
||||||
|
0IUSHF3uQamICATdrULB0WUVrIqIQNBlCCwVHF2pwsJQRdDlDYyoKsHRPMLQDQRdbsDQqBmc
|
||||||
|
wlBF0OV2jJqZwggEXW5vVDMVgaDL7Y5qKgJBl9sfVUUg6HL7AxSKoMvtr1AEgi5DAgA7}
|
||||||
|
italic {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAIrhI+py+1A4hN8
|
||||||
|
hIjINBITPlpEZBqJCR8tIjKNxISPFhGZQOITfExdbv9FCgA7}
|
||||||
|
new {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAJFhI95FN8IvgXJ
|
||||||
|
jyD4ECQ/JAh+kPyICIIdJP+CYAfJvyDYQfIvCHaQ/AuCHST/gmAHyb8g2EHyLwh2kPwLgk3x
|
||||||
|
MQg+pu4WADs=}
|
||||||
|
open {R0lGODlhEAAQAKIAANnZ2QAAAP//AP///4SEAP///////////yH5BAEAAAAALAAAAAAQABAA
|
||||||
|
AANZCLrczigUQZc1EDQgEHSZAwMgIhB0NQIDQkYwdANBNUZwZGQEJxBUQwZlZGRQAkE1RnAE
|
||||||
|
Q5dVcCSQdDcAYySQdDcAISSQdDcAASKQdDcAAQBDlwNBl9sfApQAOw==}
|
||||||
|
openfold {R0lGODlhEAANAKIAANnZ2YSEhP///8bGxv//AAAAAP///////yH5BAEAAAAALAAAAAAQAA0A
|
||||||
|
AANgCIqhiqDLgaIaCLoagkNDIxi6AIFCQ0M4KKpRgCFDQzg0NIQThaHLSxgVKLochRMVMkhD
|
||||||
|
Q4M0VBFYEDKEQ0NDOFFRgCE0NEhDQ4MVBRAoNDSEQ0NRWAAYuqyFBQBYurwJADs=}
|
||||||
|
overstrike {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAI3hI+py80Uh+Aj
|
||||||
|
RFhQCP8iMILgWwRGEHyLwAiCbxEYQfCB4iPBhwiMIPgXYREEHyEiguBj6nI7FQA7}
|
||||||
|
palette {R0lGODlhEAAQAKIAANnZ2QAAAP//AP////8A/4QAhP8AAAD//yH5BAEAAAAALAAAAAAQABAA
|
||||||
|
AANtCLrcjqGBoMsRKCMTgaALMSgDAYMSCKoxgAFBITgSAIAQEhUIARCAEgAQOBAwghMQEwga
|
||||||
|
MoIjIxAIEgCAEBEyKBAgg4GgGxAIYTGCgaALcRgQIIGgCwEYICODgaALITgyEoGguxiqCLrc
|
||||||
|
/lChBAA7}
|
||||||
|
passwd {R0lGODlhIAAgAMQAANnZ2QAAAICAgICAAP///7CwsMDAwMjIAPjIAOjo6Pj4AODg4HBwcMj4
|
||||||
|
ANjY2JiYANDQ0MjIyPj4yKCgoMiYAMjImDAwAMjIMJiYmJCQkP//////////////////////
|
||||||
|
/yH5BAEAAAAALAAAAAAgACAAAAX/ICCOIhiIIgiII1maZSCMQnCeJyAIQiAIAiAMwxCcJwkk
|
||||||
|
EAQRCIUwGMSBDEEAAuJIlgKRJEEgGAMRBIGiDENQlqNAJAsYCEwgEEEgBAHSIEMAAuJIAgKR
|
||||||
|
LEsgGEMgCEJgBMqhHENQlgJILMsSCMRABEFgGAESHMcRgIA4kgKxOIsTBAOhKAITKEGDHMhD
|
||||||
|
kqIAEqAjisJAgIooBkpwNMcTgIA4jgLhOBAkEAOhKIoSKEGDIMcTkKQICgQEQQIxEIqiBEpw
|
||||||
|
IMdxPAEIiCMJCEQUMUQ0EIqiHIfSIM3xBGUpCiABCUQyEMqhHMiBHMjxBCAgjuQoEAKxRANB
|
||||||
|
HMqhHM1x/zxDUJajQIACsUTDQBAEIR3IcQRDAALiSIoCYQiEE03gII7HQR3BEICAOJICYRSC
|
||||||
|
QDjRNE1CAAzVQR3WE5AkAAqEUQiFQEARBAUAAAzHQR3BEICAOI4CUQhFIBAREwXjUFUHdQRD
|
||||||
|
QJJAABbCFAhEJBgBAADAMAwXdQRDAALiCAhEIRQCYRiCEZDjUFFHMAQkIBAFOAmTQBiFUAQg
|
||||||
|
II7AUFXUEQwBCQjEJExBkBRCEZCjMIBD9RxDAALiGEzCFBBYIRTBOI7AQB1DMIoCMQkYGAjL
|
||||||
|
JEwBCIgjOVDDEJCAQGACJiTTJEwBSY5BEJAiSCCwTAiCZBKmAATEkSzNQBCCYCDBJgELTNMk
|
||||||
|
g0AMEgwTAhAQR7I0zYARgvM8TyAIznMMAQA7}
|
||||||
|
paste {R0lGODlhEAAQAKIAANnZ2QAAAP//AISEAISEhP///wAAhP///yH5BAEAAAAALAAAAAAQABAA
|
||||||
|
AANwCLrcjqGBoKsYqiKrCDSGBkMiJJCGAgCDKBB0gwYDIKYwdJUIAyBokIaGBmloAhBiaAgH
|
||||||
|
TdcCEIKGBsmwVM0AIYaGcAxL1coQgoYGySoisMzMAoeGxrB01QJpaMiwMHTLAEPVsHTVEHTR
|
||||||
|
dBlBlxswAQA7}
|
||||||
|
print {R0lGODlhEAAQAKIAANnZ2QAAAP///4SEhP//AP///////////yH5BAEAAAAALAAAAAAQABAA
|
||||||
|
AANZCLrcjqG7CLqBoquBoBuCoSqBoBsouhoIuiEYqrKBoIGiqwEYEIChyxAIEYGgywEYgKHL
|
||||||
|
DAgRCLozgwABARgIukSEABEBGLq8gAEQCLobgAEAgKHLgaDLzZgAOw==}
|
||||||
|
question {R0lGODlhIAAgAKIAANnZ2YSEhMbGxv///wAAAAAA/////////yH5BAEAAAAALAAAAAAgACAA
|
||||||
|
AAP/CLoMGLqKoMvtGCo4uhKBgaDLDRghOLqsghEIuryBgqPLPSiBoMsQOLrcjYSgu4GjO4Kl
|
||||||
|
Kzi6Qwi6EDi6I4UyU1VYgqM7hKAagqM7VTg6VYWFoztCCAqBo6tVWDVThVU4ukqBACE4ulqF
|
||||||
|
VSNVWIWjq0IYEDi6K4UlU1VYOLpMgRA4uryCpTi6PIShOLq8hVU4uqyEoTi6vIUlOLqshKE4
|
||||||
|
uryFhaPLSxgqOLrc3kgoAgJHl0ewSnB0eQhDIQRHl6uwCkeXhTAUIHB0uQqrcHSZAiMAAJBw
|
||||||
|
dFcKS3B0lwIjAkGVcHS5GykiAkEXSHB0uQeFIiIQdJcIBUeXVZAoIgJBT5chkFRwdIUICUMV
|
||||||
|
QZc3MIKIBEcJQzcQdLkBQ4NmcAhDFUGX2zFoZggjEHS5vRHNUASCLrc7oqEIBF1uf0QUgaDL
|
||||||
|
7Q9QKIIut79CEQi6DAkAOw==}
|
||||||
|
redo {R0lGODlhEAAQAJEAANnZ2QAAhP///////yH5BAEAAAAALAAAAAAQABAAAAIvhI+py+1vSByC
|
||||||
|
jxAYQXDMwsyAggQAQBB8iwgMgg8REQgUwqbYBDsIPqYutz+MgBQAOw==}
|
||||||
|
save {R0lGODlhEAAQAJEAANnZ2QAAAISEAP///yH5BAEAAAAALAAAAAAQABAAAAJWhI9pFB8RIIRC
|
||||||
|
+BYQFqQQvkWEBSmEbyFhQQrhW0hYkEL4FhIWpBC+hYQFSYxvIgFAoXy0AAiSGP8kAIIkxgcI
|
||||||
|
CSBEQvEBQgIIkVB8gJAAAhgfj+BjWgEAOw==}
|
||||||
|
underline {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAI3hI+py60UBy4I
|
||||||
|
vkVcBMG/iIsg+BdxEQT/Ii6C4F/ERRD8i7gIgn8RF0HwkWITfExFin8EH1OXCwA7}
|
||||||
|
undo {R0lGODlhEAAQAJEAANnZ2QAAhP///////yH5BAEAAAAALAAAAAAQABAAAAIuhI+py+2vSByC
|
||||||
|
HxdxQCHsCIg7oAAAEUHwLTAiKIQPgRSbYMfd3VEIH1OX2x8mUgA7}
|
||||||
|
warning {R0lGODlhIAAgAKIAANnZ2YSEAP//AMbGxgAAAISEhP///////yH5BAEAAAAALAAAAAAgACAA
|
||||||
|
AAP/CLq8gREIutz+KESGEHS5vVGIiAxSIehy+6JAUaUqBF1uBxQoukOFhaDL7RgoukKFhaDL
|
||||||
|
3RgoujqEVQi63IyBortUWAi63IuBostDWIWgy60YIjKERCMiSFUIutyAISKCpCoiOFSFoMsd
|
||||||
|
KCpIqiKCQlUIusyBooqkKiIoQ1UIuryBooqkiqJKVQi6rIGii6SKojpUWAi6DIGiG0RIgaJL
|
||||||
|
VQi6HCi6MoREg6I7VFgIuhsoukqEhKKrVFgIuhoouhuEgaKrQ1iFoAuBortDOCi6S4WFoBso
|
||||||
|
uiyEostDWIWgGii63K6IqgAAIVB0WQaJBkV3h7AKAAJFl4WQiFB0mQoLRyBQdFkJiQhFl4ew
|
||||||
|
CgJFl3WQaFB0WQirIFB0ud0RVVWg6HJ7o6GqAgwUXW5fNFRVhQCBpMvti0oVABCwdLndEehi
|
||||||
|
6XI7I4AEADs=}
|
||||||
|
}
|
3
ext/tk/sample/tkextlib/tile/readme.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
All of *.tcl, themes/kroc.tcl and images (themes/kroc/*) are
|
||||||
|
quoted from Tcl/Tk's Tile extension.
|
||||||
|
Please read Orig_LICENSE.txt.
|
159
ext/tk/sample/tkextlib/tile/themes/kroc.rb
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
#
|
||||||
|
# kroc.rb
|
||||||
|
#
|
||||||
|
# based on:
|
||||||
|
# >> kroc.tcl - Copyright (C) 2004 David Zolli <kroc@kroc.tk>
|
||||||
|
#
|
||||||
|
|
||||||
|
imgdir = File.join(File.dirname(__FILE__), 'kroc')
|
||||||
|
$images = Tk::Tile.load_images(imgdir, '*.gif')
|
||||||
|
|
||||||
|
def kroc_rb_settings
|
||||||
|
# Tk::Tile::Style.default(TkRoot, :background=>'#FCB64F',
|
||||||
|
# :troughcolor=>'#F8C278', :borderwidth=>1)
|
||||||
|
# or
|
||||||
|
# Tk::Tile::Style.default(Tk.root, :background=>'#FCB64F',
|
||||||
|
# :troughcolor=>'#F8C278', :borderwidth=>1)
|
||||||
|
# or
|
||||||
|
# Tk::Tile::Style.default('.', :background=>'#FCB64F',
|
||||||
|
# :troughcolor=>'#F8C278', :borderwidth=>1)
|
||||||
|
# or
|
||||||
|
# Tk::Tile::Style.default(nil, :background=>'#FCB64F',
|
||||||
|
# :troughcolor=>'#F8C278', :borderwidth=>1)
|
||||||
|
# or
|
||||||
|
Tk::Tile::Style.default(:background=>'#FCB64F', :troughcolor=>'#F8C278',
|
||||||
|
:borderwidth=>1)
|
||||||
|
# Tk::Tile::Style.default(TkRoot, :font=>Tk::Tile::Font::Default,
|
||||||
|
# :borderwidth=>1)
|
||||||
|
# or
|
||||||
|
# Tk::Tile::Style.default(Tk.root, :font=>Tk::Tile::Font::Default,
|
||||||
|
# :borderwidth=>1)
|
||||||
|
# or
|
||||||
|
# Tk::Tile::Style.default('.', :font=>Tk::Tile::Font::Default,
|
||||||
|
# :borderwidth=>1)
|
||||||
|
# or
|
||||||
|
# Tk::Tile::Style.default(nil, :font=>Tk::Tile::Font::Default,
|
||||||
|
# :borderwidth=>1)
|
||||||
|
# or
|
||||||
|
Tk::Tile::Style.default(:font=>Tk::Tile::Font::Default, :borderwidth=>1)
|
||||||
|
|
||||||
|
# Tk::Tile::Style.map(TkRoot, :background=>[:active, '#694418'])
|
||||||
|
# or
|
||||||
|
# Tk::Tile::Style.map(Tk.root, :background=>[:active, '#694418'])
|
||||||
|
# or
|
||||||
|
# Tk::Tile::Style.map('.', :background=>[:active, '#694418'])
|
||||||
|
# or
|
||||||
|
# Tk::Tile::Style.map(nil, :background=>[:active, '#694418'])
|
||||||
|
# or
|
||||||
|
Tk::Tile::Style.map(:background=>[:active, '#694418'])
|
||||||
|
Tk::Tile::Style.map(:foreground=>[:disabled, 'B2B2B2', :active, '#FFE7CB'])
|
||||||
|
|
||||||
|
# Tk::Tile::Style.default('TButton', :padding=>[10,4])
|
||||||
|
Tk::Tile::Style.default(Tk::Tile::TButton, :padding=>[10,4])
|
||||||
|
|
||||||
|
# Tk::Tile::Style.default('TNotebook.Tab',
|
||||||
|
Tk::Tile::Style.default(Tk::Tile::TNotebook.style('Tab'),
|
||||||
|
:padding=>[10, 3], :font=>Tk::Tile::Font::Default)
|
||||||
|
# Tk::Tile::Style.map('TNotebook.Tab',
|
||||||
|
Tk::Tile::Style.map(Tk::Tile::TNotebook.style('Tab'),
|
||||||
|
:background=>[:selected, '#FCB64F', '', '#FFE6BA'],
|
||||||
|
:foreground=>['', 'black'],
|
||||||
|
:padding=>[:selected, [10, 6, 10, 3]])
|
||||||
|
|
||||||
|
# Tk::Tile::Style.map('TScrollbar',
|
||||||
|
Tk::Tile::Style.map(Tk::Tile::TScrollbar,
|
||||||
|
:background=>[:pressed, '#694418'],
|
||||||
|
:arrowcolor=>[:pressed, '#FEF7CB'],
|
||||||
|
:relief=>[:pressed, :sunken])
|
||||||
|
|
||||||
|
# Tk::Tile::Style.layout('Vertical.TScrollbar',
|
||||||
|
Tk::Tile::Style.layout(Tk::Tile.style('Vertical', Tk::Tile::TScrollbar),
|
||||||
|
['Scrollbar.trough', {:children=>[
|
||||||
|
'Scrollbar.uparrow', {:side=>:top},
|
||||||
|
'Scrollbar.downarrow', {:side=>:bottom},
|
||||||
|
'Scrollbar.uparrow', {:side=>:bottom},
|
||||||
|
'Scrollbar.thumb', {:side=>:top, :expand=>true}
|
||||||
|
]}
|
||||||
|
])
|
||||||
|
|
||||||
|
# Tk::Tile::Style.layout('Horizontal.TScrollbar',
|
||||||
|
Tk::Tile::Style.layout(Tk::Tile.style('Horizontal', Tk::Tile::TScrollbar),
|
||||||
|
['Scrollbar.trough', {:children=>[
|
||||||
|
'Scrollbar.leftarrow', {:side=>:left},
|
||||||
|
'Scrollbar.rightarrow', {:side=>:right},
|
||||||
|
'Scrollbar.leftarrow', {:side=>:right},
|
||||||
|
'Scrollbar.thumb', {:side=>:left, :expand=>true}
|
||||||
|
]}
|
||||||
|
])
|
||||||
|
|
||||||
|
#
|
||||||
|
# Elements:
|
||||||
|
#
|
||||||
|
Tk::Tile::Style.element_create('Button.button', :pixmap,
|
||||||
|
:images=>[
|
||||||
|
:pressed, $images['button-p'],
|
||||||
|
:active, $images['button-h'],
|
||||||
|
'', $images['button-n']
|
||||||
|
], :border=>3, :tiling=>:tile)
|
||||||
|
|
||||||
|
Tk::Tile::Style.element_create('Checkbutton.indicator', :pixmap,
|
||||||
|
:images=>[
|
||||||
|
[:pressed, :selected], $images['check-nc'],
|
||||||
|
:pressed, $images['check-nu'],
|
||||||
|
[:active, :selected], $images['check-hc'],
|
||||||
|
:active, $images['check-hu'],
|
||||||
|
:selected, $images['check-nc'],
|
||||||
|
'', $images['check-nu'],
|
||||||
|
], :tiling=>:fixed)
|
||||||
|
|
||||||
|
Tk::Tile::Style.element_create('Radiobutton.indicator', :pixmap,
|
||||||
|
:images=>[
|
||||||
|
[:pressed, :selected], $images['radio-nc'],
|
||||||
|
:pressed, $images['radio-nu'],
|
||||||
|
[:active, :selected], $images['radio-hc'],
|
||||||
|
:active, $images['radio-hu'],
|
||||||
|
:selected, $images['radio-nc'],
|
||||||
|
'', $images['radio-nu'],
|
||||||
|
], :tiling=>:fixed)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings:
|
||||||
|
#
|
||||||
|
# Tk::Tile::Style.layout(Tk::Tile::TButton,
|
||||||
|
Tk::Tile::Style.layout('TButton', [
|
||||||
|
'Button.button', {:children=>[
|
||||||
|
'Button.focus', {:children=>[
|
||||||
|
'Button.padding', {:children=>[
|
||||||
|
'Button.label', {:expand=>true, :sticky=>''}
|
||||||
|
]}
|
||||||
|
]}
|
||||||
|
]}
|
||||||
|
])
|
||||||
|
|
||||||
|
# Tk::Tile::Style.layout(Tk::Tile::TCheckbutton,
|
||||||
|
Tk::Tile::Style.layout('TCheckbutton', [
|
||||||
|
'Checkbutton.border', {:children=>[
|
||||||
|
'Checkbutton.padding', {:children=>[
|
||||||
|
'Checkbutton.indicator', {:side=>:left},
|
||||||
|
'Checkbutton.focus', {:side=>:left, :children=>[
|
||||||
|
'Checkbutton.label'
|
||||||
|
]}
|
||||||
|
]}
|
||||||
|
]}
|
||||||
|
])
|
||||||
|
|
||||||
|
# Tk::Tile::Style.layout(Tk::Tile::TRadiobutton,
|
||||||
|
Tk::Tile::Style.layout('TRadiobutton', [
|
||||||
|
'Radiobutton.border', {:children=>[
|
||||||
|
'Radiobutton.padding', {:children=>[
|
||||||
|
'Radiobutton.indicator', {:side=>:left},
|
||||||
|
'Radiobutton.focus', {:expand=>true, :sticky=>:w, :children=>[
|
||||||
|
'Radiobutton.label', {:side=>:right, :expand=>true}
|
||||||
|
]}
|
||||||
|
]}
|
||||||
|
]}
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
Tk::Tile::Style.theme_create('kroc-rb', :parent=>'alt',
|
||||||
|
:settings=>proc{ kroc_rb_settings() })
|
126
ext/tk/sample/tkextlib/tile/themes/kroc.tcl
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
# kroc.tcl - Copyright (C) 2004 David Zolli <kroc@kroc.tk>
|
||||||
|
#
|
||||||
|
# A sample pixmap theme for the tile package.
|
||||||
|
|
||||||
|
#package require tile::pixmap
|
||||||
|
|
||||||
|
namespace eval tile {
|
||||||
|
namespace eval kroc {
|
||||||
|
variable version 0.0.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace eval tile::kroc {
|
||||||
|
|
||||||
|
set imgdir [file join [file dirname [info script]] kroc]
|
||||||
|
array set Images [tile::LoadImages $imgdir *.gif]
|
||||||
|
|
||||||
|
style theme create kroc -parent alt -settings {
|
||||||
|
|
||||||
|
style default . -background #FCB64F -troughcolor #F8C278 -borderwidth 1
|
||||||
|
style default . -font TkDefaultFont -borderwidth 1
|
||||||
|
style map . -background [list active #694418]
|
||||||
|
style map . -foreground [list disabled #B2B2B2 active #FFE7CB]
|
||||||
|
|
||||||
|
style default TButton -padding "10 4"
|
||||||
|
|
||||||
|
style default TNotebook.Tab -padding {10 3} -font TkDefaultFont
|
||||||
|
style map TNotebook.Tab \
|
||||||
|
-background [list selected #FCB64F {} #FFE6BA] \
|
||||||
|
-foreground [list {} black] \
|
||||||
|
-padding [list selected {10 6 10 3}]
|
||||||
|
|
||||||
|
style map TScrollbar \
|
||||||
|
-background { pressed #694418} \
|
||||||
|
-arrowcolor { pressed #FFE7CB } \
|
||||||
|
-relief { pressed sunken } \
|
||||||
|
;
|
||||||
|
|
||||||
|
style layout Vertical.TScrollbar {
|
||||||
|
Scrollbar.trough -children {
|
||||||
|
Scrollbar.uparrow -side top
|
||||||
|
Scrollbar.downarrow -side bottom
|
||||||
|
Scrollbar.uparrow -side bottom
|
||||||
|
Scrollbar.thumb -side top -expand true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
style layout Horizontal.TScrollbar {
|
||||||
|
Scrollbar.trough -children {
|
||||||
|
Scrollbar.leftarrow -side left
|
||||||
|
Scrollbar.rightarrow -side right
|
||||||
|
Scrollbar.leftarrow -side right
|
||||||
|
Scrollbar.thumb -side left -expand true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Elements:
|
||||||
|
#
|
||||||
|
style element create Button.button pixmap -images [list \
|
||||||
|
pressed $Images(button-p) \
|
||||||
|
active $Images(button-h) \
|
||||||
|
{} $Images(button-n) \
|
||||||
|
] -border 3 -tiling tile
|
||||||
|
|
||||||
|
style element create Checkbutton.indicator pixmap -images [list \
|
||||||
|
{pressed selected} $Images(check-nc) \
|
||||||
|
pressed $Images(check-nu) \
|
||||||
|
{active selected} $Images(check-hc) \
|
||||||
|
active $Images(check-hu) \
|
||||||
|
selected $Images(check-nc) \
|
||||||
|
{} $Images(check-nu) \
|
||||||
|
] -tiling fixed
|
||||||
|
|
||||||
|
style element create Radiobutton.indicator pixmap -images [list \
|
||||||
|
{pressed selected} $Images(radio-nc) \
|
||||||
|
pressed $Images(radio-nu) \
|
||||||
|
{active selected} $Images(radio-hc) \
|
||||||
|
active $Images(radio-hu) \
|
||||||
|
selected $Images(radio-nc) \
|
||||||
|
{} $Images(radio-nu) \
|
||||||
|
] -tiling fixed
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Settings:
|
||||||
|
#
|
||||||
|
style layout TButton {
|
||||||
|
Button.button -children {
|
||||||
|
Button.focus -children {
|
||||||
|
Button.padding -children {
|
||||||
|
Button.label -expand true -sticky {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
style layout TCheckbutton {
|
||||||
|
Checkbutton.border -children {
|
||||||
|
Checkbutton.padding -children {
|
||||||
|
Checkbutton.indicator -side left
|
||||||
|
Checkbutton.focus -side left -children {
|
||||||
|
Checkbutton.label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
style layout TRadiobutton {
|
||||||
|
Radiobutton.border -children {
|
||||||
|
Radiobutton.padding -children {
|
||||||
|
Radiobutton.indicator -side left
|
||||||
|
Radiobutton.focus -expand true -sticky w -children {
|
||||||
|
Radiobutton.label -side right -expand true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} }
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
package provide tile::theme::kroc $::tile::kroc::version
|
||||||
|
|
||||||
|
# -------------------------------------------------------------------------
|
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/button-h.gif
Normal file
After Width: | Height: | Size: 522 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/button-n.gif
Normal file
After Width: | Height: | Size: 554 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/button-p.gif
Normal file
After Width: | Height: | Size: 548 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/check-hc.gif
Normal file
After Width: | Height: | Size: 281 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/check-hu.gif
Normal file
After Width: | Height: | Size: 273 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/check-nc.gif
Normal file
After Width: | Height: | Size: 303 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/check-nu.gif
Normal file
After Width: | Height: | Size: 294 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/radio-hc.gif
Normal file
After Width: | Height: | Size: 652 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/radio-hu.gif
Normal file
After Width: | Height: | Size: 644 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/radio-nc.gif
Normal file
After Width: | Height: | Size: 632 B |
BIN
ext/tk/sample/tkextlib/tile/themes/kroc/radio-nu.gif
Normal file
After Width: | Height: | Size: 621 B |
15
ext/tk/sample/tkextlib/tile/themes/pkgIndex.tcl
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# pkgIndex.tcl for additional tile pixmap themes.
|
||||||
|
#
|
||||||
|
# We don't provide the package is the image subdirectory isn't present,
|
||||||
|
# or we don't have the right version of Tcl/Tk
|
||||||
|
#
|
||||||
|
# To use this automatically within tile, the tile-using application should
|
||||||
|
# use tile::availableThemes and tile::setTheme
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
if {![file isdirectory [file join $dir kroc]]} { return }
|
||||||
|
if {![package vsatisfies [package provide Tcl] 8.4]} { return }
|
||||||
|
|
||||||
|
package ifneeded tile::theme::kroc 0.0.1 \
|
||||||
|
[list source [file join $dir kroc.tcl]]
|
152
ext/tk/sample/tkextlib/tile/toolbutton.tcl
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# Demonstration of custom widget styles.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# ~ BACKGROUND
|
||||||
|
#
|
||||||
|
# Checkbuttons in toolbars have a very different appearance
|
||||||
|
# than regular checkbuttons: there's no indicator, they
|
||||||
|
# "pop up" when the mouse is over them, and they appear sunken
|
||||||
|
# when selected.
|
||||||
|
#
|
||||||
|
# Tk added partial support for toolbar-style buttons in 8.4
|
||||||
|
# with the "-overrelief" option, and TIP #82 added further
|
||||||
|
# support with the "-offrelief" option. So to get a toolbar-style
|
||||||
|
# checkbutton, you can configure it with:
|
||||||
|
#
|
||||||
|
# checkbutton .cb \
|
||||||
|
# -indicatoron false -selectcolor {} -relief flat -overrelief raised
|
||||||
|
#
|
||||||
|
# Behind the scenes, Tk has a lot of rather complicated logic
|
||||||
|
# to implement this checkbutton style; see library/button.tcl,
|
||||||
|
# generic/tkButton.c, and the platform-specific files unix/tkUnixButton.c
|
||||||
|
# et al. for the full details.
|
||||||
|
#
|
||||||
|
# The tile widget set has a better way: custom styles.
|
||||||
|
# Since the appearance is completely controlled by the theme engine,
|
||||||
|
# we can define a new "Toolbutton" style and just use:
|
||||||
|
#
|
||||||
|
# checkbutton .cb -style Toolbutton
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# ~ DEMONSTRATION
|
||||||
|
#
|
||||||
|
# The tile built-in themes (default, "alt", windows, and XP)
|
||||||
|
# already include Toolbutton styles. This script will add
|
||||||
|
# them to the "step" and "blue" themes as a demonstration.
|
||||||
|
#
|
||||||
|
# (Note: Pushbuttons and radiobuttons can also use the "Toolbutton"
|
||||||
|
# style; see demo.tcl.)
|
||||||
|
#
|
||||||
|
|
||||||
|
style theme settings "step" {
|
||||||
|
|
||||||
|
#
|
||||||
|
# First, we use [style layout] to define what elements to
|
||||||
|
# use and how they're arranged. Toolbuttons are pretty
|
||||||
|
# simple, consisting of a border, some internal padding,
|
||||||
|
# and a label. (See also the TScrollbar layout definition
|
||||||
|
# in demos/blue.tcl for a more complicated layout spec.)
|
||||||
|
#
|
||||||
|
style layout Toolbutton {
|
||||||
|
Toolbutton.background
|
||||||
|
Toolbutton.border -children {
|
||||||
|
Toolbutton.padding -children {
|
||||||
|
Toolbutton.label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# (Actually the above isn't strictly necessary, since the same layout
|
||||||
|
# is defined in the default theme; we could have inherited it
|
||||||
|
# instead.)
|
||||||
|
#
|
||||||
|
# Next, specify default values for element options.
|
||||||
|
# For many options (like -background), the defaults
|
||||||
|
# inherited from the parent style are sufficient.
|
||||||
|
#
|
||||||
|
style default Toolbutton -width 0 -padding 1 -relief flat -borderwidth 2
|
||||||
|
|
||||||
|
#
|
||||||
|
# Finally, use [style map] to specify state-specific
|
||||||
|
# resource values. We want a flat relief if the widget is
|
||||||
|
# disabled, sunken if it's selected (on) or pressed,
|
||||||
|
# and raised when it's active (the mouse pointer is
|
||||||
|
# over the widget). Each state-value pair is checked
|
||||||
|
# in order, and the first matching state takes precedence.
|
||||||
|
#
|
||||||
|
style map Toolbutton -relief {
|
||||||
|
disabled flat
|
||||||
|
selected sunken
|
||||||
|
pressed sunken
|
||||||
|
active raised
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Now for the "blue" theme. (Since the purpose of this
|
||||||
|
# theme is to show what *can* be done, not necessarily what
|
||||||
|
# *should* be done, the following makes some questionable
|
||||||
|
# design decisions from an aesthetic standpoint.)
|
||||||
|
#
|
||||||
|
if {![catch {package require tile::theme::blue}]} {
|
||||||
|
style theme settings "blue" {
|
||||||
|
|
||||||
|
#
|
||||||
|
# Default values:
|
||||||
|
#
|
||||||
|
style default Toolbutton \
|
||||||
|
-width 0 -relief flat -borderwidth 2 \
|
||||||
|
-background #6699CC -foreground #000000 ;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configure state-specific values for -relief, as before:
|
||||||
|
#
|
||||||
|
style map Toolbutton -relief {
|
||||||
|
disabled flat
|
||||||
|
selected sunken
|
||||||
|
pressed sunken
|
||||||
|
active raised
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Adjust the -padding at the same time, to enhance
|
||||||
|
# the raised/sunken illusion:
|
||||||
|
#
|
||||||
|
style default Toolbutton -padding 4
|
||||||
|
style map Toolbutton -padding {
|
||||||
|
disabled {4}
|
||||||
|
selected {6 6 2 2}
|
||||||
|
pressed {6 6 2 2}
|
||||||
|
active {2 2 6 6}
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# ... and change the foreground and background colors
|
||||||
|
# when the mouse cursor is over the widget:
|
||||||
|
#
|
||||||
|
style map Toolbutton -background {
|
||||||
|
active #008800
|
||||||
|
} -foreground {
|
||||||
|
active #FFFFFF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# ~ A final note:
|
||||||
|
#
|
||||||
|
# TIP #82 also says: "When -indicatoron is off and the button itself
|
||||||
|
# is on, the relief continues to be hard-coded to sunken. For symmetry,
|
||||||
|
# we might consider adding another -onrelief option to cover this
|
||||||
|
# case. But it is difficult to imagine ever wanting to change the
|
||||||
|
# value of -onrelief so it has been omitted from this TIP.
|
||||||
|
# If there as strong desire to have -onrelief, it can be added later."
|
||||||
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
#
|
||||||
|
# The Tile project aims to make sure that this never needs to happen.
|
||||||
|
#
|