tk-win 0.2.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/lib/tcltk.rb +367 -0
- data/lib/tk.rb +5682 -0
- data/lib/tk/after.rb +6 -0
- data/lib/tk/autoload.rb +760 -0
- data/lib/tk/bgerror.rb +29 -0
- data/lib/tk/bindtag.rb +138 -0
- data/lib/tk/button.rb +31 -0
- data/lib/tk/canvas.rb +816 -0
- data/lib/tk/canvastag.rb +459 -0
- data/lib/tk/checkbutton.rb +32 -0
- data/lib/tk/clipboard.rb +75 -0
- data/lib/tk/clock.rb +71 -0
- data/lib/tk/composite.rb +484 -0
- data/lib/tk/console.rb +52 -0
- data/lib/tk/dialog.rb +326 -0
- data/lib/tk/encodedstr.rb +187 -0
- data/lib/tk/entry.rb +120 -0
- data/lib/tk/event.rb +562 -0
- data/lib/tk/font.rb +2351 -0
- data/lib/tk/frame.rb +132 -0
- data/lib/tk/grid.rb +279 -0
- data/lib/tk/image.rb +275 -0
- data/lib/tk/itemconfig.rb +1222 -0
- data/lib/tk/itemfont.rb +327 -0
- data/lib/tk/kinput.rb +71 -0
- data/lib/tk/label.rb +22 -0
- data/lib/tk/labelframe.rb +31 -0
- data/lib/tk/listbox.rb +284 -0
- data/lib/tk/macpkg.rb +80 -0
- data/lib/tk/menu.rb +718 -0
- data/lib/tk/menubar.rb +137 -0
- data/lib/tk/menuspec.rb +456 -0
- data/lib/tk/message.rb +24 -0
- data/lib/tk/mngfocus.rb +33 -0
- data/lib/tk/msgcat.rb +296 -0
- data/lib/tk/namespace.rb +551 -0
- data/lib/tk/optiondb.rb +377 -0
- data/lib/tk/optionobj.rb +212 -0
- data/lib/tk/pack.rb +107 -0
- data/lib/tk/package.rb +143 -0
- data/lib/tk/palette.rb +55 -0
- data/lib/tk/panedwindow.rb +260 -0
- data/lib/tk/place.rb +128 -0
- data/lib/tk/radiobutton.rb +73 -0
- data/lib/tk/root.rb +95 -0
- data/lib/tk/scale.rb +112 -0
- data/lib/tk/scrollable.rb +82 -0
- data/lib/tk/scrollbar.rb +183 -0
- data/lib/tk/scrollbox.rb +39 -0
- data/lib/tk/selection.rb +86 -0
- data/lib/tk/spinbox.rb +144 -0
- data/lib/tk/tagfont.rb +43 -0
- data/lib/tk/text.rb +1604 -0
- data/lib/tk/textimage.rb +88 -0
- data/lib/tk/textmark.rb +204 -0
- data/lib/tk/texttag.rb +321 -0
- data/lib/tk/textwindow.rb +154 -0
- data/lib/tk/timer.rb +669 -0
- data/lib/tk/toplevel.rb +264 -0
- data/lib/tk/ttk_selector.rb +98 -0
- data/lib/tk/txtwin_abst.rb +39 -0
- data/lib/tk/validation.rb +397 -0
- data/lib/tk/variable.rb +1799 -0
- data/lib/tk/virtevent.rb +139 -0
- data/lib/tk/winfo.rb +392 -0
- data/lib/tk/winpkg.rb +156 -0
- data/lib/tk/wm.rb +552 -0
- data/lib/tk/xim.rb +122 -0
- data/lib/tkafter.rb +4 -0
- data/lib/tkbgerror.rb +4 -0
- data/lib/tkcanvas.rb +4 -0
- data/lib/tkclass.rb +47 -0
- data/lib/tkconsole.rb +4 -0
- data/lib/tkdialog.rb +4 -0
- data/lib/tkentry.rb +4 -0
- data/lib/tkextlib/ICONS.rb +13 -0
- data/lib/tkextlib/ICONS/icons.rb +129 -0
- data/lib/tkextlib/ICONS/setup.rb +8 -0
- data/lib/tkextlib/SUPPORT_STATUS +198 -0
- data/lib/tkextlib/blt.rb +189 -0
- data/lib/tkextlib/blt/barchart.rb +79 -0
- data/lib/tkextlib/blt/bitmap.rb +112 -0
- data/lib/tkextlib/blt/busy.rb +83 -0
- data/lib/tkextlib/blt/component.rb +2218 -0
- data/lib/tkextlib/blt/container.rb +28 -0
- data/lib/tkextlib/blt/cutbuffer.rb +23 -0
- data/lib/tkextlib/blt/dragdrop.rb +269 -0
- data/lib/tkextlib/blt/eps.rb +32 -0
- data/lib/tkextlib/blt/graph.rb +67 -0
- data/lib/tkextlib/blt/htext.rb +112 -0
- data/lib/tkextlib/blt/setup.rb +8 -0
- data/lib/tkextlib/blt/spline.rb +23 -0
- data/lib/tkextlib/blt/stripchart.rb +74 -0
- data/lib/tkextlib/blt/table.rb +412 -0
- data/lib/tkextlib/blt/tabnotebook.rb +110 -0
- data/lib/tkextlib/blt/tabset.rb +504 -0
- data/lib/tkextlib/blt/ted.rb +68 -0
- data/lib/tkextlib/blt/tile.rb +25 -0
- data/lib/tkextlib/blt/tile/button.rb +16 -0
- data/lib/tkextlib/blt/tile/checkbutton.rb +17 -0
- data/lib/tkextlib/blt/tile/frame.rb +16 -0
- data/lib/tkextlib/blt/tile/label.rb +16 -0
- data/lib/tkextlib/blt/tile/radiobutton.rb +17 -0
- data/lib/tkextlib/blt/tile/scrollbar.rb +16 -0
- data/lib/tkextlib/blt/tile/toplevel.rb +16 -0
- data/lib/tkextlib/blt/tree.rb +1058 -0
- data/lib/tkextlib/blt/treeview.rb +1287 -0
- data/lib/tkextlib/blt/unix_dnd.rb +141 -0
- data/lib/tkextlib/blt/vector.rb +256 -0
- data/lib/tkextlib/blt/watch.rb +175 -0
- data/lib/tkextlib/blt/win_printer.rb +61 -0
- data/lib/tkextlib/blt/winop.rb +107 -0
- data/lib/tkextlib/bwidget.rb +153 -0
- data/lib/tkextlib/bwidget/arrowbutton.rb +21 -0
- data/lib/tkextlib/bwidget/bitmap.rb +21 -0
- data/lib/tkextlib/bwidget/button.rb +31 -0
- data/lib/tkextlib/bwidget/buttonbox.rb +90 -0
- data/lib/tkextlib/bwidget/combobox.rb +62 -0
- data/lib/tkextlib/bwidget/dialog.rb +194 -0
- data/lib/tkextlib/bwidget/dragsite.rb +31 -0
- data/lib/tkextlib/bwidget/dropsite.rb +39 -0
- data/lib/tkextlib/bwidget/dynamichelp.rb +63 -0
- data/lib/tkextlib/bwidget/entry.rb +43 -0
- data/lib/tkextlib/bwidget/label.rb +41 -0
- data/lib/tkextlib/bwidget/labelentry.rb +80 -0
- data/lib/tkextlib/bwidget/labelframe.rb +52 -0
- data/lib/tkextlib/bwidget/listbox.rb +361 -0
- data/lib/tkextlib/bwidget/mainframe.rb +132 -0
- data/lib/tkextlib/bwidget/messagedlg.rb +192 -0
- data/lib/tkextlib/bwidget/notebook.rb +166 -0
- data/lib/tkextlib/bwidget/pagesmanager.rb +73 -0
- data/lib/tkextlib/bwidget/panedwindow.rb +42 -0
- data/lib/tkextlib/bwidget/panelframe.rb +67 -0
- data/lib/tkextlib/bwidget/passwddlg.rb +44 -0
- data/lib/tkextlib/bwidget/progressbar.rb +20 -0
- data/lib/tkextlib/bwidget/progressdlg.rb +58 -0
- data/lib/tkextlib/bwidget/scrollableframe.rb +40 -0
- data/lib/tkextlib/bwidget/scrolledwindow.rb +48 -0
- data/lib/tkextlib/bwidget/scrollview.rb +25 -0
- data/lib/tkextlib/bwidget/selectcolor.rb +73 -0
- data/lib/tkextlib/bwidget/selectfont.rb +91 -0
- data/lib/tkextlib/bwidget/separator.rb +20 -0
- data/lib/tkextlib/bwidget/setup.rb +8 -0
- data/lib/tkextlib/bwidget/spinbox.rb +98 -0
- data/lib/tkextlib/bwidget/statusbar.rb +62 -0
- data/lib/tkextlib/bwidget/titleframe.rb +33 -0
- data/lib/tkextlib/bwidget/tree.rb +500 -0
- data/lib/tkextlib/bwidget/widget.rb +129 -0
- data/lib/tkextlib/itcl.rb +13 -0
- data/lib/tkextlib/itcl/incr_tcl.rb +178 -0
- data/lib/tkextlib/itcl/setup.rb +13 -0
- data/lib/tkextlib/itk.rb +13 -0
- data/lib/tkextlib/itk/incr_tk.rb +446 -0
- data/lib/tkextlib/itk/setup.rb +13 -0
- data/lib/tkextlib/iwidgets.rb +94 -0
- data/lib/tkextlib/iwidgets/buttonbox.rb +121 -0
- data/lib/tkextlib/iwidgets/calendar.rb +125 -0
- data/lib/tkextlib/iwidgets/canvasprintbox.rb +53 -0
- data/lib/tkextlib/iwidgets/canvasprintdialog.rb +38 -0
- data/lib/tkextlib/iwidgets/checkbox.rb +130 -0
- data/lib/tkextlib/iwidgets/combobox.rb +104 -0
- data/lib/tkextlib/iwidgets/dateentry.rb +20 -0
- data/lib/tkextlib/iwidgets/datefield.rb +58 -0
- data/lib/tkextlib/iwidgets/dialog.rb +20 -0
- data/lib/tkextlib/iwidgets/dialogshell.rb +121 -0
- data/lib/tkextlib/iwidgets/disjointlistbox.rb +50 -0
- data/lib/tkextlib/iwidgets/entryfield.rb +185 -0
- data/lib/tkextlib/iwidgets/extbutton.rb +40 -0
- data/lib/tkextlib/iwidgets/extfileselectionbox.rb +46 -0
- data/lib/tkextlib/iwidgets/extfileselectiondialog.rb +33 -0
- data/lib/tkextlib/iwidgets/feedback.rb +35 -0
- data/lib/tkextlib/iwidgets/fileselectionbox.rb +46 -0
- data/lib/tkextlib/iwidgets/fileselectiondialog.rb +33 -0
- data/lib/tkextlib/iwidgets/finddialog.rb +42 -0
- data/lib/tkextlib/iwidgets/hierarchy.rb +365 -0
- data/lib/tkextlib/iwidgets/hyperhelp.rb +50 -0
- data/lib/tkextlib/iwidgets/labeledframe.rb +39 -0
- data/lib/tkextlib/iwidgets/labeledwidget.rb +45 -0
- data/lib/tkextlib/iwidgets/mainwindow.rb +67 -0
- data/lib/tkextlib/iwidgets/menubar.rb +212 -0
- data/lib/tkextlib/iwidgets/messagebox.rb +93 -0
- data/lib/tkextlib/iwidgets/messagedialog.rb +20 -0
- data/lib/tkextlib/iwidgets/notebook.rb +175 -0
- data/lib/tkextlib/iwidgets/optionmenu.rb +92 -0
- data/lib/tkextlib/iwidgets/panedwindow.rb +134 -0
- data/lib/tkextlib/iwidgets/promptdialog.rb +131 -0
- data/lib/tkextlib/iwidgets/pushbutton.rb +35 -0
- data/lib/tkextlib/iwidgets/radiobox.rb +121 -0
- data/lib/tkextlib/iwidgets/scopedobject.rb +24 -0
- data/lib/tkextlib/iwidgets/scrolledcanvas.rb +353 -0
- data/lib/tkextlib/iwidgets/scrolledframe.rb +59 -0
- data/lib/tkextlib/iwidgets/scrolledhtml.rb +58 -0
- data/lib/tkextlib/iwidgets/scrolledlistbox.rb +207 -0
- data/lib/tkextlib/iwidgets/scrolledtext.rb +568 -0
- data/lib/tkextlib/iwidgets/scrolledwidget.rb +20 -0
- data/lib/tkextlib/iwidgets/selectionbox.rb +102 -0
- data/lib/tkextlib/iwidgets/selectiondialog.rb +92 -0
- data/lib/tkextlib/iwidgets/setup.rb +8 -0
- data/lib/tkextlib/iwidgets/shell.rb +38 -0
- data/lib/tkextlib/iwidgets/spindate.rb +48 -0
- data/lib/tkextlib/iwidgets/spinint.rb +30 -0
- data/lib/tkextlib/iwidgets/spinner.rb +169 -0
- data/lib/tkextlib/iwidgets/spintime.rb +48 -0
- data/lib/tkextlib/iwidgets/tabnotebook.rb +181 -0
- data/lib/tkextlib/iwidgets/tabset.rb +145 -0
- data/lib/tkextlib/iwidgets/timeentry.rb +25 -0
- data/lib/tkextlib/iwidgets/timefield.rb +58 -0
- data/lib/tkextlib/iwidgets/toolbar.rb +112 -0
- data/lib/tkextlib/iwidgets/watch.rb +56 -0
- data/lib/tkextlib/pkg_checker.rb +184 -0
- data/lib/tkextlib/setup.rb +8 -0
- data/lib/tkextlib/tcllib.rb +105 -0
- data/lib/tkextlib/tcllib/autoscroll.rb +158 -0
- data/lib/tkextlib/tcllib/ctext.rb +160 -0
- data/lib/tkextlib/tcllib/cursor.rb +97 -0
- data/lib/tkextlib/tcllib/datefield.rb +57 -0
- data/lib/tkextlib/tcllib/dialog.rb +84 -0
- data/lib/tkextlib/tcllib/getstring.rb +134 -0
- data/lib/tkextlib/tcllib/history.rb +73 -0
- data/lib/tkextlib/tcllib/ico.rb +146 -0
- data/lib/tkextlib/tcllib/ip_entry.rb +75 -0
- data/lib/tkextlib/tcllib/panelframe.rb +78 -0
- data/lib/tkextlib/tcllib/plotchart.rb +1404 -0
- data/lib/tkextlib/tcllib/ruler.rb +65 -0
- data/lib/tkextlib/tcllib/screenruler.rb +68 -0
- data/lib/tkextlib/tcllib/scrollwin.rb +61 -0
- data/lib/tkextlib/tcllib/setup.rb +8 -0
- data/lib/tkextlib/tcllib/style.rb +61 -0
- data/lib/tkextlib/tcllib/superframe.rb +51 -0
- data/lib/tkextlib/tcllib/swaplist.rb +150 -0
- data/lib/tkextlib/tcllib/tablelist.rb +28 -0
- data/lib/tkextlib/tcllib/tablelist_core.rb +1072 -0
- data/lib/tkextlib/tcllib/tablelist_tile.rb +43 -0
- data/lib/tkextlib/tcllib/tkpiechart.rb +314 -0
- data/lib/tkextlib/tcllib/tooltip.rb +104 -0
- data/lib/tkextlib/tcllib/widget.rb +82 -0
- data/lib/tkextlib/tclx.rb +13 -0
- data/lib/tkextlib/tclx/setup.rb +8 -0
- data/lib/tkextlib/tclx/tclx.rb +74 -0
- data/lib/tkextlib/tile.rb +449 -0
- data/lib/tkextlib/tile/dialog.rb +102 -0
- data/lib/tkextlib/tile/setup.rb +8 -0
- data/lib/tkextlib/tile/sizegrip.rb +32 -0
- data/lib/tkextlib/tile/style.rb +336 -0
- data/lib/tkextlib/tile/tbutton.rb +34 -0
- data/lib/tkextlib/tile/tcheckbutton.rb +38 -0
- data/lib/tkextlib/tile/tcombobox.rb +55 -0
- data/lib/tkextlib/tile/tentry.rb +49 -0
- data/lib/tkextlib/tile/tframe.rb +34 -0
- data/lib/tkextlib/tile/tlabel.rb +34 -0
- data/lib/tkextlib/tile/tlabelframe.rb +38 -0
- data/lib/tkextlib/tile/tmenubutton.rb +38 -0
- data/lib/tkextlib/tile/tnotebook.rb +147 -0
- data/lib/tkextlib/tile/tpaned.rb +245 -0
- data/lib/tkextlib/tile/tprogressbar.rb +57 -0
- data/lib/tkextlib/tile/tradiobutton.rb +38 -0
- data/lib/tkextlib/tile/treeview.rb +1306 -0
- data/lib/tkextlib/tile/tscale.rb +56 -0
- data/lib/tkextlib/tile/tscrollbar.rb +63 -0
- data/lib/tkextlib/tile/tseparator.rb +34 -0
- data/lib/tkextlib/tile/tsquare.rb +30 -0
- data/lib/tkextlib/tkDND.rb +18 -0
- data/lib/tkextlib/tkDND/setup.rb +8 -0
- data/lib/tkextlib/tkDND/shape.rb +125 -0
- data/lib/tkextlib/tkDND/tkdnd.rb +182 -0
- data/lib/tkextlib/tkHTML.rb +13 -0
- data/lib/tkextlib/tkHTML/htmlwidget.rb +453 -0
- data/lib/tkextlib/tkHTML/setup.rb +8 -0
- data/lib/tkextlib/tkimg.rb +36 -0
- data/lib/tkextlib/tkimg/bmp.rb +33 -0
- data/lib/tkextlib/tkimg/gif.rb +33 -0
- data/lib/tkextlib/tkimg/ico.rb +33 -0
- data/lib/tkextlib/tkimg/jpeg.rb +33 -0
- data/lib/tkextlib/tkimg/pcx.rb +33 -0
- data/lib/tkextlib/tkimg/pixmap.rb +44 -0
- data/lib/tkextlib/tkimg/png.rb +33 -0
- data/lib/tkextlib/tkimg/ppm.rb +33 -0
- data/lib/tkextlib/tkimg/ps.rb +33 -0
- data/lib/tkextlib/tkimg/setup.rb +8 -0
- data/lib/tkextlib/tkimg/sgi.rb +33 -0
- data/lib/tkextlib/tkimg/sun.rb +33 -0
- data/lib/tkextlib/tkimg/tga.rb +33 -0
- data/lib/tkextlib/tkimg/tiff.rb +33 -0
- data/lib/tkextlib/tkimg/window.rb +33 -0
- data/lib/tkextlib/tkimg/xbm.rb +33 -0
- data/lib/tkextlib/tkimg/xpm.rb +33 -0
- data/lib/tkextlib/tktable.rb +14 -0
- data/lib/tkextlib/tktable/setup.rb +8 -0
- data/lib/tkextlib/tktable/tktable.rb +966 -0
- data/lib/tkextlib/tktrans.rb +14 -0
- data/lib/tkextlib/tktrans/setup.rb +8 -0
- data/lib/tkextlib/tktrans/tktrans.rb +64 -0
- data/lib/tkextlib/treectrl.rb +13 -0
- data/lib/tkextlib/treectrl/setup.rb +8 -0
- data/lib/tkextlib/treectrl/tktreectrl.rb +2522 -0
- data/lib/tkextlib/trofs.rb +13 -0
- data/lib/tkextlib/trofs/setup.rb +8 -0
- data/lib/tkextlib/trofs/trofs.rb +51 -0
- data/lib/tkextlib/version.rb +6 -0
- data/lib/tkextlib/vu.rb +48 -0
- data/lib/tkextlib/vu/bargraph.rb +61 -0
- data/lib/tkextlib/vu/charts.rb +53 -0
- data/lib/tkextlib/vu/dial.rb +102 -0
- data/lib/tkextlib/vu/pie.rb +286 -0
- data/lib/tkextlib/vu/setup.rb +8 -0
- data/lib/tkextlib/vu/spinbox.rb +22 -0
- data/lib/tkextlib/winico.rb +14 -0
- data/lib/tkextlib/winico/setup.rb +8 -0
- data/lib/tkextlib/winico/winico.rb +224 -0
- data/lib/tkfont.rb +4 -0
- data/lib/tkmacpkg.rb +4 -0
- data/lib/tkmenubar.rb +4 -0
- data/lib/tkmngfocus.rb +4 -0
- data/lib/tkpalette.rb +4 -0
- data/lib/tkscrollbox.rb +4 -0
- data/lib/tktext.rb +4 -0
- data/lib/tkvirtevent.rb +4 -0
- data/lib/tkwinpkg.rb +4 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/tk-win_spec.rb +7 -0
- data/tk-win.gemspec +373 -0
- metadata +412 -0
data/lib/tk/toplevel.rb
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
#
|
2
|
+
# tk/toplevel.rb : treat toplevel widget
|
3
|
+
#
|
4
|
+
require 'tk'
|
5
|
+
require 'tk/wm'
|
6
|
+
require 'tk/menuspec'
|
7
|
+
|
8
|
+
class Tk::Toplevel<TkWindow
|
9
|
+
include Wm
|
10
|
+
include TkMenuSpec
|
11
|
+
|
12
|
+
TkCommandNames = ['toplevel'.freeze].freeze
|
13
|
+
WidgetClassName = 'Toplevel'.freeze
|
14
|
+
WidgetClassNames[WidgetClassName] ||= self
|
15
|
+
|
16
|
+
################# old version
|
17
|
+
# def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
|
18
|
+
# if screen.kind_of? Hash
|
19
|
+
# keys = screen.dup
|
20
|
+
# else
|
21
|
+
# @screen = screen
|
22
|
+
# end
|
23
|
+
# @classname = classname
|
24
|
+
# if keys.kind_of? Hash
|
25
|
+
# keys = keys.dup
|
26
|
+
# @classname = keys.delete('classname') if keys.key?('classname')
|
27
|
+
# @colormap = keys.delete('colormap') if keys.key?('colormap')
|
28
|
+
# @container = keys.delete('container') if keys.key?('container')
|
29
|
+
# @screen = keys.delete('screen') if keys.key?('screen')
|
30
|
+
# @use = keys.delete('use') if keys.key?('use')
|
31
|
+
# @visual = keys.delete('visual') if keys.key?('visual')
|
32
|
+
# end
|
33
|
+
# super(parent, keys)
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# def create_self
|
37
|
+
# s = []
|
38
|
+
# s << "-class" << @classname if @classname
|
39
|
+
# s << "-colormap" << @colormap if @colormap
|
40
|
+
# s << "-container" << @container if @container
|
41
|
+
# s << "-screen" << @screen if @screen
|
42
|
+
# s << "-use" << @use if @use
|
43
|
+
# s << "-visual" << @visual if @visual
|
44
|
+
# tk_call 'toplevel', @path, *s
|
45
|
+
# end
|
46
|
+
#################
|
47
|
+
|
48
|
+
def __boolval_optkeys
|
49
|
+
super() << 'container'
|
50
|
+
end
|
51
|
+
private :__boolval_optkeys
|
52
|
+
|
53
|
+
def __strval_optkeys
|
54
|
+
super() << 'screen'
|
55
|
+
end
|
56
|
+
private :__strval_optkeys
|
57
|
+
|
58
|
+
def __val2ruby_optkeys # { key=>proc, ... }
|
59
|
+
super().update('menu'=>proc{|v| window(v)})
|
60
|
+
end
|
61
|
+
private :__val2ruby_optkeys
|
62
|
+
|
63
|
+
def __methodcall_optkeys # { key=>method, ... }
|
64
|
+
TOPLEVEL_METHODCALL_OPTKEYS
|
65
|
+
end
|
66
|
+
private :__methodcall_optkeys
|
67
|
+
|
68
|
+
def _wm_command_option_chk(keys)
|
69
|
+
keys = {} unless keys
|
70
|
+
new_keys = {}
|
71
|
+
wm_cmds = {}
|
72
|
+
|
73
|
+
conf_methods = _symbolkey2str(__methodcall_optkeys())
|
74
|
+
|
75
|
+
keys.each{|k,v| # k is a String
|
76
|
+
if conf_methods.key?(k)
|
77
|
+
wm_cmds[conf_methods[k]] = v
|
78
|
+
elsif Wm.method_defined?(k)
|
79
|
+
case k
|
80
|
+
when 'screen','class','colormap','container','use','visual'
|
81
|
+
new_keys[k] = v
|
82
|
+
else
|
83
|
+
case self.method(k).arity
|
84
|
+
when -1,1
|
85
|
+
wm_cmds[k] = v
|
86
|
+
else
|
87
|
+
new_keys[k] = v
|
88
|
+
end
|
89
|
+
end
|
90
|
+
else
|
91
|
+
new_keys[k] = v
|
92
|
+
end
|
93
|
+
}
|
94
|
+
[new_keys, wm_cmds]
|
95
|
+
end
|
96
|
+
private :_wm_command_option_chk
|
97
|
+
|
98
|
+
def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
|
99
|
+
my_class_name = nil
|
100
|
+
if self.class < WidgetClassNames[WidgetClassName]
|
101
|
+
my_class_name = self.class.name
|
102
|
+
my_class_name = nil if my_class_name == ''
|
103
|
+
end
|
104
|
+
if parent.kind_of? Hash
|
105
|
+
keys = _symbolkey2str(parent)
|
106
|
+
if keys.key?('classname')
|
107
|
+
keys['class'] = keys.delete('classname')
|
108
|
+
end
|
109
|
+
@classname = keys['class']
|
110
|
+
@colormap = keys['colormap']
|
111
|
+
@container = keys['container']
|
112
|
+
@screen = keys['screen']
|
113
|
+
@use = keys['use']
|
114
|
+
@visual = keys['visual']
|
115
|
+
if !@classname && my_class_name
|
116
|
+
keys['class'] = @classname = my_class_name
|
117
|
+
end
|
118
|
+
if @classname.kind_of? TkBindTag
|
119
|
+
@db_class = @classname
|
120
|
+
keys['class'] = @classname = @classname.id
|
121
|
+
elsif @classname
|
122
|
+
@db_class = TkDatabaseClass.new(@classname)
|
123
|
+
keys['class'] = @classname
|
124
|
+
else
|
125
|
+
@db_class = self.class
|
126
|
+
@classname = @db_class::WidgetClassName
|
127
|
+
end
|
128
|
+
keys, cmds = _wm_command_option_chk(keys)
|
129
|
+
super(keys)
|
130
|
+
cmds.each{|k,v|
|
131
|
+
if v.kind_of? Array
|
132
|
+
self.__send__(k,*v)
|
133
|
+
else
|
134
|
+
self.__send__(k,v)
|
135
|
+
end
|
136
|
+
}
|
137
|
+
return
|
138
|
+
end
|
139
|
+
|
140
|
+
if screen.kind_of? Hash
|
141
|
+
keys = screen
|
142
|
+
else
|
143
|
+
@screen = screen
|
144
|
+
if classname.kind_of? Hash
|
145
|
+
keys = classname
|
146
|
+
else
|
147
|
+
@classname = classname
|
148
|
+
end
|
149
|
+
end
|
150
|
+
if keys.kind_of? Hash
|
151
|
+
keys = _symbolkey2str(keys)
|
152
|
+
if keys.key?('classname')
|
153
|
+
keys['class'] = keys.delete('classname')
|
154
|
+
end
|
155
|
+
@classname = keys['class'] unless @classname
|
156
|
+
@colormap = keys['colormap']
|
157
|
+
@container = keys['container']
|
158
|
+
@screen = keys['screen'] unless @screen
|
159
|
+
@use = keys['use']
|
160
|
+
@visual = keys['visual']
|
161
|
+
else
|
162
|
+
keys = {}
|
163
|
+
end
|
164
|
+
if !@classname && my_class_name
|
165
|
+
keys['class'] = @classname = my_class_name
|
166
|
+
end
|
167
|
+
if @classname.kind_of? TkBindTag
|
168
|
+
@db_class = @classname
|
169
|
+
keys['class'] = @classname = @classname.id
|
170
|
+
elsif @classname
|
171
|
+
@db_class = TkDatabaseClass.new(@classname)
|
172
|
+
keys['class'] = @classname
|
173
|
+
else
|
174
|
+
@db_class = self.class
|
175
|
+
@classname = @db_class::WidgetClassName
|
176
|
+
end
|
177
|
+
keys, cmds = _wm_command_option_chk(keys)
|
178
|
+
super(parent, keys)
|
179
|
+
cmds.each{|k,v|
|
180
|
+
if v.kind_of? Array
|
181
|
+
self.send(k,*v)
|
182
|
+
else
|
183
|
+
self.send(k,v)
|
184
|
+
end
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
188
|
+
#def create_self(keys)
|
189
|
+
# if keys and keys != None
|
190
|
+
# tk_call_without_enc('toplevel', @path, *hash_kv(keys, true))
|
191
|
+
# else
|
192
|
+
# tk_call_without_enc('toplevel', @path)
|
193
|
+
# end
|
194
|
+
#end
|
195
|
+
#private :create_self
|
196
|
+
|
197
|
+
def specific_class
|
198
|
+
@classname
|
199
|
+
end
|
200
|
+
|
201
|
+
def add_menu(menu_info, tearoff=false, opts=nil)
|
202
|
+
# See tk/menuspec.rb for menu_info.
|
203
|
+
# opts is a hash of default configs for all of cascade menus.
|
204
|
+
# Configs of menu_info can override it.
|
205
|
+
if tearoff.kind_of?(Hash)
|
206
|
+
opts = tearoff
|
207
|
+
tearoff = false
|
208
|
+
end
|
209
|
+
_create_menubutton(self, menu_info, tearoff, opts)
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_menubar(menu_spec, tearoff=false, opts=nil)
|
213
|
+
# See tk/menuspec.rb for menu_spec.
|
214
|
+
# opts is a hash of default configs for all of cascade menus.
|
215
|
+
# Configs of menu_spec can override it.
|
216
|
+
menu_spec.each{|info| add_menu(info, tearoff, opts)}
|
217
|
+
self.menu
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.database_class
|
221
|
+
if self == WidgetClassNames[WidgetClassName] || self.name == ''
|
222
|
+
self
|
223
|
+
else
|
224
|
+
TkDatabaseClass.new(self.name)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
def self.database_classname
|
228
|
+
self.database_class.name
|
229
|
+
end
|
230
|
+
|
231
|
+
def self.bind(*args, &b)
|
232
|
+
if self == WidgetClassNames[WidgetClassName] || self.name == ''
|
233
|
+
super(*args, &b)
|
234
|
+
else
|
235
|
+
TkDatabaseClass.new(self.name).bind(*args, &b)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
def self.bind_append(*args, &b)
|
239
|
+
if self == WidgetClassNames[WidgetClassName] || self.name == ''
|
240
|
+
super(*args, &b)
|
241
|
+
else
|
242
|
+
TkDatabaseClass.new(self.name).bind_append(*args, &b)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
def self.bind_remove(*args)
|
246
|
+
if self == WidgetClassNames[WidgetClassName] || self.name == ''
|
247
|
+
super(*args)
|
248
|
+
else
|
249
|
+
TkDatabaseClass.new(self.name).bind_remove(*args)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
def self.bindinfo(*args)
|
253
|
+
if self == WidgetClassNames[WidgetClassName] || self.name == ''
|
254
|
+
super(*args)
|
255
|
+
else
|
256
|
+
TkDatabaseClass.new(self.name).bindinfo(*args)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
#TkToplevel = Tk::Toplevel unless Object.const_defined? :TkToplevel
|
262
|
+
#Tk.__set_toplevel_aliases__(:Tk, Tk::Toplevel, :TkToplevel)
|
263
|
+
Tk.__set_loaded_toplevel_aliases__('tk/toplevel.rb', :Tk, Tk::Toplevel,
|
264
|
+
:TkToplevel)
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#
|
2
|
+
# ttk_selector
|
3
|
+
#
|
4
|
+
######################################
|
5
|
+
# toplevel classes/modules
|
6
|
+
module Tk
|
7
|
+
@TOPLEVEL_ALIAS_TABLE[:Ttk] = {
|
8
|
+
:TkButton => 'tkextlib/tile/tbutton',
|
9
|
+
|
10
|
+
:TkCheckbutton => 'tkextlib/tile/tcheckbutton',
|
11
|
+
:TkCheckButton => 'tkextlib/tile/tcheckbutton',
|
12
|
+
|
13
|
+
# :TkDialog => 'tkextlib/tile/dialog',
|
14
|
+
|
15
|
+
:TkEntry => 'tkextlib/tile/tentry',
|
16
|
+
|
17
|
+
:TkCombobox => 'tkextlib/tile/tcombobox',
|
18
|
+
|
19
|
+
:TkFrame => 'tkextlib/tile/tframe',
|
20
|
+
|
21
|
+
:TkLabel => 'tkextlib/tile/tlabel',
|
22
|
+
|
23
|
+
:TkLabelframe => 'tkextlib/tile/tlabelframe',
|
24
|
+
:TkLabelFrame => 'tkextlib/tile/tlabelframe',
|
25
|
+
|
26
|
+
:TkMenubutton => 'tkextlib/tile/tmenubutton',
|
27
|
+
:TkMenuButton => 'tkextlib/tile/tmenubutton',
|
28
|
+
|
29
|
+
:TkNotebook => 'tkextlib/tile/tnotebook',
|
30
|
+
|
31
|
+
# :TkPaned => 'tkextlib/tile/tpaned',
|
32
|
+
:TkPanedwindow => 'tkextlib/tile/tpaned',
|
33
|
+
:TkPanedWindow => 'tkextlib/tile/tpaned',
|
34
|
+
|
35
|
+
:TkProgressbar => 'tkextlib/tile/tprogressbar',
|
36
|
+
|
37
|
+
:TkRadiobutton => 'tkextlib/tile/tradiobutton',
|
38
|
+
:TkRadioButton => 'tkextlib/tile/tradiobutton',
|
39
|
+
|
40
|
+
:TkScale => 'tkextlib/tile/tscale',
|
41
|
+
# :TkProgress => 'tkextlib/tile/tscale',
|
42
|
+
|
43
|
+
:TkScrollbar => 'tkextlib/tile/tscrollbar',
|
44
|
+
:TkXScrollbar => 'tkextlib/tile/tscrollbar',
|
45
|
+
:TkYScrollbar => 'tkextlib/tile/tscrollbar',
|
46
|
+
|
47
|
+
:TkSeparator => 'tkextlib/tile/tseparator',
|
48
|
+
|
49
|
+
:TkSizeGrip => 'tkextlib/tile/sizegrip',
|
50
|
+
:TkSizegrip => 'tkextlib/tile/sizegrip',
|
51
|
+
|
52
|
+
# :TkSquare => 'tkextlib/tile/tsquare',
|
53
|
+
|
54
|
+
:TkTreeview => 'tkextlib/tile/treeview',
|
55
|
+
}
|
56
|
+
|
57
|
+
# @TOPLEVEL_ALIAS_TABLE[:Tile] = @TOPLEVEL_ALIAS_TABLE[:Ttk]
|
58
|
+
Tk.__create_widget_set__(:Tile, :Ttk)
|
59
|
+
|
60
|
+
############################################
|
61
|
+
# depend on the version of Tcl/Tk
|
62
|
+
major, minor, type, patchlevel = TclTkLib.get_version
|
63
|
+
|
64
|
+
# ttk::spinbox is supported on Tcl/Tk8.6b1 or later
|
65
|
+
if ([major,minor,type,patchlevel] <=>
|
66
|
+
[8,6,TclTkLib::RELEASE_TYPE::BETA,1]) >= 0
|
67
|
+
@TOPLEVEL_ALIAS_TABLE[:Ttk].update(
|
68
|
+
:TkSpinbox => 'tkextlib/tile/tspinbox'
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
################################################
|
73
|
+
# register some Ttk widgets as default
|
74
|
+
# (Ttk is a standard library on Tcl/Tk8.5+)
|
75
|
+
@TOPLEVEL_ALIAS_TABLE[:Ttk].each{|sym, file|
|
76
|
+
#unless Tk::TOPLEVEL_ALIASES.autoload?(sym) || Tk::TOPLEVEL_ALIASES.const_defined?(sym)
|
77
|
+
# @TOPLEVEL_ALIAS_OWNER[sym] = :Ttk
|
78
|
+
# Tk::TOPLEVEL_ALIASES.autoload(sym, file)
|
79
|
+
#end
|
80
|
+
Tk.__regist_toplevel_aliases__(:Ttk, file, sym)
|
81
|
+
}
|
82
|
+
|
83
|
+
################################################
|
84
|
+
|
85
|
+
# @TOPLEVEL_ALIAS_SETUP_PROC[:Tile] =
|
86
|
+
# @TOPLEVEL_ALIAS_SETUP_PROC[:Ttk] = proc{|mod|
|
87
|
+
# unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
|
88
|
+
# Object.autoload :Ttk, 'tkextlib/tile'
|
89
|
+
# Tk.autoload :Tile, 'tkextlib/tile'
|
90
|
+
# end
|
91
|
+
# }
|
92
|
+
Tk.__toplevel_alias_setup_proc__(:Ttk, :Tile){|mod|
|
93
|
+
unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
|
94
|
+
Object.autoload :Ttk, 'tkextlib/tile'
|
95
|
+
Tk.autoload :Tile, 'tkextlib/tile'
|
96
|
+
end
|
97
|
+
}
|
98
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#
|
2
|
+
# tk/txtwin_abst.rb : TkTextWin abstruct class
|
3
|
+
#
|
4
|
+
require 'tk'
|
5
|
+
|
6
|
+
class TkTextWin<TkWindow
|
7
|
+
TkCommandNames = [].freeze
|
8
|
+
#def create_self
|
9
|
+
# fail RuntimeError, "TkTextWin is an abstract class"
|
10
|
+
#end
|
11
|
+
#private :create_self
|
12
|
+
|
13
|
+
def bbox(index)
|
14
|
+
list(tk_send_without_enc('bbox', index))
|
15
|
+
end
|
16
|
+
def delete(first, last=None)
|
17
|
+
tk_send_without_enc('delete', first, last)
|
18
|
+
self
|
19
|
+
end
|
20
|
+
def get(*index)
|
21
|
+
_fromUTF8(tk_send_without_enc('get', *index))
|
22
|
+
end
|
23
|
+
def insert(index, *args)
|
24
|
+
tk_send('insert', index, *args)
|
25
|
+
self
|
26
|
+
end
|
27
|
+
def scan_mark(x, y)
|
28
|
+
tk_send_without_enc('scan', 'mark', x, y)
|
29
|
+
self
|
30
|
+
end
|
31
|
+
def scan_dragto(x, y)
|
32
|
+
tk_send_without_enc('scan', 'dragto', x, y)
|
33
|
+
self
|
34
|
+
end
|
35
|
+
def see(index)
|
36
|
+
tk_send_without_enc('see', index)
|
37
|
+
self
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,397 @@
|
|
1
|
+
#
|
2
|
+
# tk/validation.rb - validation support module for entry, spinbox, and so on
|
3
|
+
#
|
4
|
+
require 'tk'
|
5
|
+
|
6
|
+
module Tk
|
7
|
+
module ValidateConfigure
|
8
|
+
def self.__def_validcmd(scope, klass, keys=nil)
|
9
|
+
keys = klass._config_keys unless keys
|
10
|
+
keys.each{|key|
|
11
|
+
eval("def #{key}(*args, &b)
|
12
|
+
__validcmd_call(#{klass.name}, '#{key}', *args, &b)
|
13
|
+
end", scope)
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def __validcmd_call(klass, key, *args, &b)
|
18
|
+
return cget(key) if args.empty? && !b
|
19
|
+
|
20
|
+
cmd = (b)? proc(&b) : args.shift
|
21
|
+
|
22
|
+
if cmd.kind_of?(klass)
|
23
|
+
configure(key, cmd)
|
24
|
+
elsif !args.empty?
|
25
|
+
configure(key, [cmd, args])
|
26
|
+
else
|
27
|
+
configure(key, cmd)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def __validation_class_list
|
32
|
+
# maybe need to override
|
33
|
+
[]
|
34
|
+
end
|
35
|
+
|
36
|
+
def __get_validate_key2class
|
37
|
+
k2c = {}
|
38
|
+
__validation_class_list.each{|klass|
|
39
|
+
klass._config_keys.each{|key|
|
40
|
+
k2c[key.to_s] = klass
|
41
|
+
}
|
42
|
+
}
|
43
|
+
k2c
|
44
|
+
end
|
45
|
+
|
46
|
+
def __conv_vcmd_on_hash_kv(keys)
|
47
|
+
key2class = __get_validate_key2class
|
48
|
+
|
49
|
+
keys = _symbolkey2str(keys)
|
50
|
+
key2class.each{|key, klass|
|
51
|
+
if keys[key].kind_of?(Array)
|
52
|
+
cmd, *args = keys[key]
|
53
|
+
#keys[key] = klass.new(cmd, args.join(' '))
|
54
|
+
keys[key] = klass.new(cmd, *args)
|
55
|
+
# elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
|
56
|
+
elsif TkComm._callback_entry?(keys[key])
|
57
|
+
keys[key] = klass.new(keys[key])
|
58
|
+
end
|
59
|
+
}
|
60
|
+
keys
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_self(keys)
|
64
|
+
super(__conv_vcmd_on_hash_kv(keys))
|
65
|
+
end
|
66
|
+
private :create_self
|
67
|
+
|
68
|
+
def configure(slot, value=TkComm::None)
|
69
|
+
if slot.kind_of?(Hash)
|
70
|
+
super(__conv_vcmd_on_hash_kv(slot))
|
71
|
+
else
|
72
|
+
super(__conv_vcmd_on_hash_kv(slot=>value))
|
73
|
+
end
|
74
|
+
self
|
75
|
+
end
|
76
|
+
=begin
|
77
|
+
def configure(slot, value=TkComm::None)
|
78
|
+
key2class = __get_validate_key2class
|
79
|
+
|
80
|
+
if slot.kind_of?(Hash)
|
81
|
+
slot = _symbolkey2str(slot)
|
82
|
+
key2class.each{|key, klass|
|
83
|
+
if slot[key].kind_of?(Array)
|
84
|
+
cmd, *args = slot[key]
|
85
|
+
slot[key] = klass.new(cmd, args.join(' '))
|
86
|
+
elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
|
87
|
+
slot[key] = klass.new(slot[key])
|
88
|
+
end
|
89
|
+
}
|
90
|
+
super(slot)
|
91
|
+
|
92
|
+
else
|
93
|
+
slot = slot.to_s
|
94
|
+
if (klass = key2class[slot])
|
95
|
+
if value.kind_of?(Array)
|
96
|
+
cmd, *args = value
|
97
|
+
value = klass.new(cmd, args.join(' '))
|
98
|
+
elsif value.kind_of?(Proc) || value.kind_of?(Method)
|
99
|
+
value = klass.new(value)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
super(slot, value)
|
103
|
+
end
|
104
|
+
|
105
|
+
self
|
106
|
+
end
|
107
|
+
=end
|
108
|
+
end
|
109
|
+
|
110
|
+
module ItemValidateConfigure
|
111
|
+
def self.__def_validcmd(scope, klass, keys=nil)
|
112
|
+
keys = klass._config_keys unless keys
|
113
|
+
keys.each{|key|
|
114
|
+
eval("def item_#{key}(id, *args, &b)
|
115
|
+
__item_validcmd_call(#{klass.name}, '#{key}', id, *args, &b)
|
116
|
+
end", scope)
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
def __item_validcmd_call(tagOrId, klass, key, *args, &b)
|
121
|
+
return itemcget(tagid(tagOrId), key) if args.empty? && !b
|
122
|
+
|
123
|
+
cmd = (b)? proc(&b) : args.shift
|
124
|
+
|
125
|
+
if cmd.kind_of?(klass)
|
126
|
+
itemconfigure(tagid(tagOrId), key, cmd)
|
127
|
+
elsif !args.empty?
|
128
|
+
itemconfigure(tagid(tagOrId), key, [cmd, args])
|
129
|
+
else
|
130
|
+
itemconfigure(tagid(tagOrId), key, cmd)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def __item_validation_class_list(id)
|
135
|
+
# maybe need to override
|
136
|
+
[]
|
137
|
+
end
|
138
|
+
|
139
|
+
def __get_item_validate_key2class(id)
|
140
|
+
k2c = {}
|
141
|
+
__item_validation_class_list(id).each{|klass|
|
142
|
+
klass._config_keys.each{|key|
|
143
|
+
k2c[key.to_s] = klass
|
144
|
+
}
|
145
|
+
}
|
146
|
+
end
|
147
|
+
|
148
|
+
def __conv_item_vcmd_on_hash_kv(keys)
|
149
|
+
key2class = __get_item_validate_key2class(tagid(tagOrId))
|
150
|
+
|
151
|
+
keys = _symbolkey2str(keys)
|
152
|
+
key2class.each{|key, klass|
|
153
|
+
if keys[key].kind_of?(Array)
|
154
|
+
cmd, *args = keys[key]
|
155
|
+
#keys[key] = klass.new(cmd, args.join(' '))
|
156
|
+
keys[key] = klass.new(cmd, *args)
|
157
|
+
# elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
|
158
|
+
elsif TkComm._callback_entry?(keys[key])
|
159
|
+
keys[key] = klass.new(keys[key])
|
160
|
+
end
|
161
|
+
}
|
162
|
+
keys
|
163
|
+
end
|
164
|
+
|
165
|
+
def itemconfigure(tagOrId, slot, value=TkComm::None)
|
166
|
+
if slot.kind_of?(Hash)
|
167
|
+
super(__conv_item_vcmd_on_hash_kv(slot))
|
168
|
+
else
|
169
|
+
super(__conv_item_vcmd_on_hash_kv(slot=>value))
|
170
|
+
end
|
171
|
+
self
|
172
|
+
end
|
173
|
+
=begin
|
174
|
+
def itemconfigure(tagOrId, slot, value=TkComm::None)
|
175
|
+
key2class = __get_item_validate_key2class(tagid(tagOrId))
|
176
|
+
|
177
|
+
if slot.kind_of?(Hash)
|
178
|
+
slot = _symbolkey2str(slot)
|
179
|
+
key2class.each{|key, klass|
|
180
|
+
if slot[key].kind_of?(Array)
|
181
|
+
cmd, *args = slot[key]
|
182
|
+
slot[key] = klass.new(cmd, args.join(' '))
|
183
|
+
elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
|
184
|
+
slot[key] = klass.new(slot[key])
|
185
|
+
end
|
186
|
+
}
|
187
|
+
super(slot)
|
188
|
+
|
189
|
+
else
|
190
|
+
slot = slot.to_s
|
191
|
+
if (klass = key2class[slot])
|
192
|
+
if value.kind_of?(Array)
|
193
|
+
cmd, *args = value
|
194
|
+
value = klass.new(cmd, args.join(' '))
|
195
|
+
elsif value.kind_of?(Proc) || value.kind_of?(Method)
|
196
|
+
value = klass.new(value)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
super(slot, value)
|
200
|
+
end
|
201
|
+
|
202
|
+
self
|
203
|
+
end
|
204
|
+
=end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
class TkValidateCommand
|
209
|
+
include TkComm
|
210
|
+
extend TkComm
|
211
|
+
|
212
|
+
class ValidateArgs < TkUtil::CallbackSubst
|
213
|
+
KEY_TBL = [
|
214
|
+
[ ?d, ?n, :action ],
|
215
|
+
[ ?i, ?x, :index ],
|
216
|
+
[ ?s, ?e, :current ],
|
217
|
+
[ ?v, ?s, :type ],
|
218
|
+
[ ?P, ?e, :value ],
|
219
|
+
[ ?S, ?e, :string ],
|
220
|
+
[ ?V, ?s, :triggered ],
|
221
|
+
[ ?W, ?w, :widget ],
|
222
|
+
nil
|
223
|
+
]
|
224
|
+
|
225
|
+
PROC_TBL = [
|
226
|
+
[ ?n, TkComm.method(:number) ],
|
227
|
+
[ ?s, TkComm.method(:string) ],
|
228
|
+
[ ?w, TkComm.method(:window) ],
|
229
|
+
|
230
|
+
[ ?e, proc{|val|
|
231
|
+
#enc = Tk.encoding
|
232
|
+
enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
|
233
|
+
if enc
|
234
|
+
Tk.fromUTF8(TkComm::string(val), enc)
|
235
|
+
else
|
236
|
+
TkComm::string(val)
|
237
|
+
end
|
238
|
+
}
|
239
|
+
],
|
240
|
+
|
241
|
+
[ ?x, proc{|val|
|
242
|
+
idx = TkComm::number(val)
|
243
|
+
if idx < 0
|
244
|
+
nil
|
245
|
+
else
|
246
|
+
idx
|
247
|
+
end
|
248
|
+
}
|
249
|
+
],
|
250
|
+
|
251
|
+
nil
|
252
|
+
]
|
253
|
+
|
254
|
+
=begin
|
255
|
+
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
256
|
+
KEY_TBL.map!{|inf|
|
257
|
+
if inf.kind_of?(Array)
|
258
|
+
inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
|
259
|
+
inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
|
260
|
+
end
|
261
|
+
inf
|
262
|
+
}
|
263
|
+
|
264
|
+
PROC_TBL.map!{|inf|
|
265
|
+
if inf.kind_of?(Array)
|
266
|
+
inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
|
267
|
+
end
|
268
|
+
inf
|
269
|
+
}
|
270
|
+
=end
|
271
|
+
|
272
|
+
_setup_subst_table(KEY_TBL, PROC_TBL);
|
273
|
+
|
274
|
+
#
|
275
|
+
# NOTE: The order of parameters which passed to callback procedure is
|
276
|
+
# <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ...
|
277
|
+
#
|
278
|
+
|
279
|
+
#def self._get_extra_args_tbl
|
280
|
+
# # return an array of convert procs
|
281
|
+
# []
|
282
|
+
#end
|
283
|
+
|
284
|
+
def self.ret_val(val)
|
285
|
+
(val)? '1': '0'
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
###############################################
|
290
|
+
|
291
|
+
def self._config_keys
|
292
|
+
# array of config-option key (string or symbol)
|
293
|
+
['vcmd', 'validatecommand', 'invcmd', 'invalidcommand']
|
294
|
+
end
|
295
|
+
|
296
|
+
def _initialize_for_cb_class(klass, cmd = Proc.new, *args)
|
297
|
+
extra_args_tbl = klass._get_extra_args_tbl
|
298
|
+
|
299
|
+
if args.compact.size > 0
|
300
|
+
args.map!{|arg| klass._sym2subst(arg)}
|
301
|
+
args = args.join(' ')
|
302
|
+
keys = klass._get_subst_key(args)
|
303
|
+
if cmd.kind_of?(String)
|
304
|
+
id = cmd
|
305
|
+
elsif cmd.kind_of?(TkCallbackEntry)
|
306
|
+
@id = install_cmd(cmd)
|
307
|
+
else
|
308
|
+
@id = install_cmd(proc{|*arg|
|
309
|
+
ex_args = []
|
310
|
+
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
311
|
+
klass.ret_val(cmd.call(
|
312
|
+
*(ex_args.concat(klass.scan_args(keys, arg)))
|
313
|
+
))
|
314
|
+
}) + ' ' + args
|
315
|
+
end
|
316
|
+
else
|
317
|
+
keys, args = klass._get_all_subst_keys
|
318
|
+
if cmd.kind_of?(String)
|
319
|
+
id = cmd
|
320
|
+
elsif cmd.kind_of?(TkCallbackEntry)
|
321
|
+
@id = install_cmd(cmd)
|
322
|
+
else
|
323
|
+
@id = install_cmd(proc{|*arg|
|
324
|
+
ex_args = []
|
325
|
+
extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
|
326
|
+
klass.ret_val(cmd.call(
|
327
|
+
*(ex_args << klass.new(*klass.scan_args(keys, arg)))
|
328
|
+
))
|
329
|
+
}) + ' ' + args
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
def initialize(cmd = Proc.new, *args)
|
335
|
+
_initialize_for_cb_class(self.class::ValidateArgs, cmd, *args)
|
336
|
+
end
|
337
|
+
|
338
|
+
def to_eval
|
339
|
+
@id
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
module TkValidation
|
344
|
+
include Tk::ValidateConfigure
|
345
|
+
|
346
|
+
class ValidateCmd < TkValidateCommand
|
347
|
+
module Action
|
348
|
+
Insert = 1
|
349
|
+
Delete = 0
|
350
|
+
Others = -1
|
351
|
+
Focus = -1
|
352
|
+
Forced = -1
|
353
|
+
Textvariable = -1
|
354
|
+
TextVariable = -1
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
#####################################
|
359
|
+
|
360
|
+
def __validation_class_list
|
361
|
+
super() << ValidateCmd
|
362
|
+
end
|
363
|
+
|
364
|
+
Tk::ValidateConfigure.__def_validcmd(binding, ValidateCmd)
|
365
|
+
|
366
|
+
=begin
|
367
|
+
def validatecommand(cmd = Proc.new, args = nil)
|
368
|
+
if cmd.kind_of?(ValidateCmd)
|
369
|
+
configure('validatecommand', cmd)
|
370
|
+
elsif args
|
371
|
+
configure('validatecommand', [cmd, args])
|
372
|
+
else
|
373
|
+
configure('validatecommand', cmd)
|
374
|
+
end
|
375
|
+
end
|
376
|
+
=end
|
377
|
+
# def validatecommand(*args, &b)
|
378
|
+
# __validcmd_call(ValidateCmd, 'validatecommand', *args, &b)
|
379
|
+
# end
|
380
|
+
# alias vcmd validatecommand
|
381
|
+
|
382
|
+
=begin
|
383
|
+
def invalidcommand(cmd = Proc.new, args = nil)
|
384
|
+
if cmd.kind_of?(ValidateCmd)
|
385
|
+
configure('invalidcommand', cmd)
|
386
|
+
elsif args
|
387
|
+
configure('invalidcommand', [cmd, args])
|
388
|
+
else
|
389
|
+
configure('invalidcommand', cmd)
|
390
|
+
end
|
391
|
+
end
|
392
|
+
=end
|
393
|
+
# def invalidcommand(*args, &b)
|
394
|
+
# __validcmd_call(ValidateCmd, 'invalidcommand', *args, &b)
|
395
|
+
# end
|
396
|
+
# alias invcmd invalidcommand
|
397
|
+
end
|