DEFINITIONS
This source file includes following functions.
1 #
2 # tkpalette.rb : methods for Tcl/Tk standard library 'palette.tcl'
3 # 1998/06/21 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
4 #
5 require 'tk'
6
7 module TkPalette
8 include Tk
9 extend Tk
10
11 def TkPalette.set(*args)
12 args = args.to_a.flatten if args.kind_of? Hash
13 tk_call 'tk_setPalette', *args
14 end
15 def TkPalette.setPalette(*args)
16 TkPalette.set(*args)
17 end
18
19 def TkPalette.bisque
20 tk_call 'tk_bisque'
21 end
22
23 def TkPalette.darken(color, percent)
24 tk_call 'tkDarken', color, percent
25 end
26
27 def TkPalette.recolorTree(window, colors)
28 if not colors.kind_of?(Hash)
29 fail "2nd arg need to be Hash"
30 end
31
32 colors.each{|key, value|
33 begin
34 if window.cget(key) == tk_call('set', "tkPalette(#{key})")
35 window[key] = colors[key]
36 end
37 rescue
38 # ignore
39 end
40 }
41
42 TkWinfo.children(window).each{|w| TkPalette.recolorTree(w, colors)}
43 end
44
45 def recolorTree(colors)
46 TkPalette.recolorTree(self, colors)
47 end
48 end