OSDN Git Service

ruby-1.9.1-rc1
[splhack/AndroidRuby.git] / lib / ruby-1.9.1-rc1 / ext / tk / lib / tkextlib / blt / busy.rb
1 #
2 #  tkextlib/blt/busy.rb
3 #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4 #
5
6 require 'tk'
7 require 'tk/itemconfig.rb'
8 require 'tkextlib/blt.rb'
9
10 module Tk::BLT
11   module Busy
12     extend TkCore
13     extend TkItemConfigMethod
14
15     TkCommandNames = ['::blt::busy'.freeze].freeze
16
17     ###########################
18
19     class Shield < TkWindow
20       def self.shield_path(win)
21         win = window(win) unless win.kind_of?(TkWindow)
22         if win.kind_of?(Tk::Toplevel)
23           win.path + '._Busy'
24         else
25           win.path + '_Busy'
26         end
27       end
28
29       def initialize(win)
30         @path = self.class.shield_path(win)
31       end
32     end
33
34     def self.shield_path(win)
35       Tk::BLT::Busy::Shield.shield_path(win)
36     end
37   end
38 end
39
40 class << Tk::BLT::Busy
41   def __item_config_cmd(win)
42     ['::blt::busy', 'configure', win]
43   end
44   private :__item_config_cmd
45
46   undef itemcget
47   alias configure itemconfigure
48   alias configinfo itemconfiginfo
49   alias current_configinfo current_itemconfiginfo
50   private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
51
52   ##################################
53
54   def hold(win, keys={})
55     tk_call('::blt::busy', 'hold', win, *hash_kv(keys))
56   end
57
58   def release(*wins)
59     tk_call('::blt::busy', 'release', *wins)
60   end
61
62   def forget(*wins)
63     tk_call('::blt::busy', 'forget', *wins)
64   end
65
66   def is_busy(pat=None)
67     tk_split_list(tk_call('::blt::busy', 'isbusy', pat))
68   end
69
70   def names(pat=None)
71     tk_split_list(tk_call('::blt::busy', 'names', pat))
72   end
73   alias windows names
74
75   def check(win)
76     bool(tk_call('::blt::busy', 'check', win))
77   end
78
79   def status(win)
80     bool(tk_call('::blt::busy', 'status', win))
81   end
82 end