• Home
  • History
  • Annotate
  • only in this directory
1#
2#  tkextlib/bwidget/widget.rb
3#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4#
5
6require 'tk'
7require 'tkextlib/bwidget.rb'
8
9module Tk
10  module BWidget
11    module Widget
12    end
13  end
14end
15
16module Tk::BWidget::Widget
17  include Tk
18  extend Tk
19
20  def self.__pathname
21    'Widget::configure'
22  end
23
24  def self.__cget_cmd
25    ['Widget::cget']
26  end
27
28  def self.__config_cmd
29    ['Widget::configure']
30  end
31
32  def self.cget_strict(slot)
33    slot = slot.to_s
34    info = {}
35    self.current_configinfo.each{|k,v| info[k.to_s] = v if k.to_s == slot}
36    fail RuntimeError, "unknown option \"-#{slot}\""  if info.empty?
37    info.values[0]
38  end
39  def self.cget(slot)
40    self.current_configinfo(slot).values[0]
41  end
42
43  def self.add_map(klass, subclass, subpath, opts)
44    tk_call('Widget::addmap', klass, subclass, subpath, opts)
45  end
46
47  def self.bwinclude(klass, subclass, subpath, *args)
48    tk_call('Widget::bwinclude', klass, subclass, subpath, *args)
49  end
50
51  def self.create(klass, path, rename=None, &b)
52    win = window(tk_call('Widget::create', klass, path, rename))
53    if b
54      if TkCore::WITH_RUBY_VM  ### Ruby 1.9 !!!!
55        win.instance_exec(self, &b)
56      else
57        win.instance_eval(&b)
58      end
59    end
60    win
61  end
62
63  def self.declare(klass, optlist)
64    tk_call('Widget::declare', klass, optlist)
65  end
66
67  def self.define(klass, filename, *args)
68    tk_call('Widget::define', klass, filename, *args)
69  end
70
71  def self.destroy(win)
72    tk_call('Widget::destroy', _epath(win))
73  end
74
75  def self.focus_next(win)
76    tk_call('Widget::focusNext', win)
77  end
78
79  def self.focus_ok(win)
80    tk_call('Widget::focusOk', win)
81  end
82
83  def self.focus_prev(win)
84    tk_call('Widget::focusPrev', win)
85  end
86
87  def self.generate_doc(dir, widgetlist)
88    tk_call('Widget::generate-doc', dir, widgetlist)
89  end
90
91  def self.generate_widget_doc(klass, iscmd, file)
92    tk_call('Widget::generate-widget-doc', klass, iscmd, file)
93  end
94
95  def self.get_option(win, option)
96    tk_call('Widget::getoption', win, option)
97  end
98
99  def self.get_variable(win, varname, my_varname=None)
100    tk_call('Widget::getVariable', win, varname, my_varname)
101  end
102
103  def self.has_changed(win, option, pvalue)
104    tk_call('Widget::hasChanged', win, option, pvalue)
105  end
106
107  def self.init(klass, win, options)
108    tk_call('Widget::init', klass, win, options)
109  end
110
111  def self.set_option(win, option, value)
112    tk_call('Widget::setoption', win, option, value)
113  end
114
115  def self.sub_cget_strict(win, subwidget)
116    tk_call('Widget::subcget', win, subwidget)
117  end
118  def self.sub_cget(win, subwidget)
119    self.sub_cget_strict(win, subwidget)
120  end
121
122  def self.sync_options(klass, subclass, subpath, options)
123    tk_call('Widget::syncoptions', klass, subclass, subpath, options)
124  end
125
126  def self.tkinclude(klass, tkwidget, subpath, *args)
127    tk_call('Widget::tkinclude', klass, tkwidget, subpath, *args)
128  end
129end
130