From 59a07a0690ea964aa1f6d2f250a9ef176cac49ab Mon Sep 17 00:00:00 2001 From: nagai Date: Fri, 21 Dec 2007 08:57:35 +0000 Subject: Ruby/Tk :: provisional support on Ruby-VM and Tcl/Tk8.5. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/tk/autoload.rb | 356 ++++++++++++++++++++++++++++-------------- ext/tk/lib/tk/button.rb | 4 +- ext/tk/lib/tk/canvas.rb | 5 +- ext/tk/lib/tk/checkbutton.rb | 7 +- ext/tk/lib/tk/composite.rb | 5 + ext/tk/lib/tk/entry.rb | 4 +- ext/tk/lib/tk/frame.rb | 4 +- ext/tk/lib/tk/label.rb | 4 +- ext/tk/lib/tk/labelframe.rb | 7 +- ext/tk/lib/tk/listbox.rb | 4 +- ext/tk/lib/tk/macpkg.rb | 8 +- ext/tk/lib/tk/menu.rb | 32 ++-- ext/tk/lib/tk/message.rb | 4 +- ext/tk/lib/tk/package.rb | 4 + ext/tk/lib/tk/panedwindow.rb | 7 +- ext/tk/lib/tk/radiobutton.rb | 7 +- ext/tk/lib/tk/root.rb | 4 +- ext/tk/lib/tk/scale.rb | 4 +- ext/tk/lib/tk/scrollbar.rb | 14 +- ext/tk/lib/tk/spinbox.rb | 4 +- ext/tk/lib/tk/text.rb | 10 +- ext/tk/lib/tk/textimage.rb | 2 + ext/tk/lib/tk/textmark.rb | 5 + ext/tk/lib/tk/texttag.rb | 3 + ext/tk/lib/tk/textwindow.rb | 2 + ext/tk/lib/tk/toplevel.rb | 10 +- ext/tk/lib/tk/ttk_selector.rb | 55 +++++++ ext/tk/lib/tk/winpkg.rb | 16 +- 28 files changed, 430 insertions(+), 161 deletions(-) create mode 100644 ext/tk/lib/tk/ttk_selector.rb (limited to 'ext/tk/lib/tk') diff --git a/ext/tk/lib/tk/autoload.rb b/ext/tk/lib/tk/autoload.rb index 6b3773f4ea..ace0787fc2 100644 --- a/ext/tk/lib/tk/autoload.rb +++ b/ext/tk/lib/tk/autoload.rb @@ -1,9 +1,33 @@ # # autoload # +major, minor, type, type_name, patchlevel = TclTkLib.get_version + +###################################### +# depend on version of Tcl/Tk +if major > 8 || + (major == 8 && minor > 5) || + (major == 8 && minor == 5 && type >= TclTkLib::RELEASE_TYPE::BETA) + # Tcl/Tk 8.5 beta or later + autoload :Ttk, 'tkextlib/tile' + module Tk + autoload :Tile, 'tkextlib/tile' + end +end -####################### +###################################### # geometry manager +module Tk + autoload :Grid, 'tk/grid' + def Grid(*args); TkGrid.configure(*args); end + + autoload :Pack, 'tk/pack' + def Pack(*args); TkPack.configure(*args); end + + autoload :Place, 'tk/place' + def Place(*args); TkPlace.configure(*args); end +end + autoload :TkGrid, 'tk/grid' def TkGrid(*args); TkGrid.configure(*args); end @@ -14,183 +38,275 @@ autoload :TkPlace, 'tk/place' def TkPlace(*args); TkPlace.configure(*args); end -####################### -# others -autoload :TkBgError, 'tk/bgerror' +###################################### +# Ttk (Tile) support +require 'tk/ttk_selector' -autoload :TkBindTag, 'tk/bindtag' -autoload :TkBindTagAll, 'tk/bindtag' -autoload :TkDatabaseClass, 'tk/bindtag' -autoload :TkButton, 'tk/button' +###################################### +# classes on Tk module +module Tk + autoload :Button, 'tk/button' -autoload :TkConsole, 'tk/console' + autoload :Canvas, 'tk/canvas' -autoload :TkCanvas, 'tk/canvas' + autoload :CheckButton, 'tk/checkbutton' + autoload :Checkbutton, 'tk/checkbutton' -autoload :TkcTagAccess, 'tk/canvastag' -autoload :TkcTag, 'tk/canvastag' -autoload :TkcTagString, 'tk/canvastag' -autoload :TkcNamedTag, 'tk/canvastag' -autoload :TkcTagAll, 'tk/canvastag' -autoload :TkcTagCurrent, 'tk/canvastag' -autoload :TkcTagGroup, 'tk/canvastag' + autoload :Entry, 'tk/entry' -autoload :TkCheckButton, 'tk/checkbutton' -autoload :TkCheckbutton, 'tk/checkbutton' + autoload :Frame, 'tk/frame' -autoload :TkClipboard, 'tk/clipboard' + autoload :Label, 'tk/label' -autoload :TkComposite, 'tk/composite' + autoload :LabelFrame, 'tk/labelframe' + autoload :Labelframe, 'tk/labelframe' -autoload :TkConsole, 'tk/console' + autoload :Listbox, 'tk/listbox' -autoload :TkDialog, 'tk/dialog' -autoload :TkDialog2, 'tk/dialog' -autoload :TkDialogObj, 'tk/dialog' -autoload :TkWarning, 'tk/dialog' -autoload :TkWarning2, 'tk/dialog' -autoload :TkWarningObj, 'tk/dialog' + autoload :Menu, 'tk/menu' + autoload :MenuClone, 'tk/menu' + autoload :SystemMenu, 'tk/menu' + autoload :SysMenu_Help, 'tk/menu' + autoload :SysMenu_System, 'tk/menu' + autoload :SysMenu_Apple, 'tk/menu' + autoload :Menubutton, 'tk/menu' + autoload :OptionMenubutton, 'tk/menu' -autoload :TkEntry, 'tk/entry' + autoload :Message, 'tk/message' -autoload :TkEvent, 'tk/event' + autoload :PanedWindow, 'tk/panedwindow' + autoload :Panedwindow, 'tk/panedwindow' -autoload :TkFont, 'tk/font' -autoload :TkTreatTagFont, 'tk/font' + autoload :RadioButton, 'tk/radiobutton' + autoload :Radiobutton, 'tk/radiobutton' -autoload :TkFrame, 'tk/frame' + autoload :Root, 'tk/root' -autoload :TkImage, 'tk/image' -autoload :TkBitmapImage, 'tk/image' -autoload :TkPhotoImage, 'tk/image' + autoload :Scale, 'tk/scale' -autoload :TkItemConfigMethod, 'tk/itemconfig' + autoload :Scrollbar, 'tk/scrollbar' + autoload :XScrollbar, 'tk/scrollbar' + autoload :YScrollbar, 'tk/scrollbar' -autoload :TkTreatItemFont, 'tk/itemfont' + autoload :Spinbox, 'tk/spinbox' -autoload :TkKinput, 'tk/kinput' + autoload :Text, 'tk/text' -autoload :TkLabel, 'tk/label' + autoload :Toplevel, 'tk/toplevel' +end -autoload :TkLabelFrame, 'tk/labelframe' -autoload :TkLabelframe, 'tk/labelframe' -autoload :TkListbox, 'tk/listbox' +###################################### +# sub-module of Tk +module Tk + autoload :Clock, 'tk/clock' -autoload :TkMacResource, 'tk/macpkg' + autoload :OptionObj, 'tk/optionobj' -autoload :TkMenu, 'tk/menu' -autoload :TkMenuClone, 'tk/menu' -autoload :TkSystemMenu, 'tk/menu' -autoload :TkSysMenu_Help, 'tk/menu' -autoload :TkSysMenu_System, 'tk/menu' -autoload :TkSysMenu_Apple, 'tk/menu' -autoload :TkMenubutton, 'tk/menu' -autoload :TkOptionMenubutton, 'tk/menu' + autoload :X_Scrollable, 'tk/scrollable' + autoload :Y_Scrollable, 'tk/scrollable' + autoload :Scrollable, 'tk/scrollable' -autoload :TkMenubar, 'tk/menubar' + autoload :Wm, 'tk/wm' -autoload :TkMenuSpec, 'tk/menuspec' + autoload :MacResource, 'tk/macpkg' -autoload :TkMessage, 'tk/message' + autoload :WinDDE, 'tk/winpkg' + autoload :WinRegistry, 'tk/winpkg' -autoload :TkManageFocus, 'tk/mngfocus' + autoload :ValidateConfigure, 'tk/validation' + autoload :ItemValidateConfigure, 'tk/validation' -autoload :TkMsgCatalog, 'tk/msgcat' -autoload :TkMsgCat, 'tk/msgcat' + autoload :EncodedString, 'tk/encodedstr' + def Tk.EncodedString(str, enc = nil); Tk::EncodedString.new(str, enc); end -autoload :TkNamespace, 'tk/namespace' + autoload :BinaryString, 'tk/encodedstr' + def Tk.BinaryString(str); Tk::BinaryString.new(str); end -autoload :TkOptionDB, 'tk/optiondb' -autoload :TkOption, 'tk/optiondb' -autoload :TkResourceDB, 'tk/optiondb' + autoload :UTF8_String, 'tk/encodedstr' + def Tk.UTF8_String(str); Tk::UTF8_String.new(str); end -autoload :TkPackage, 'tk/package' +end -autoload :TkPalette, 'tk/palette' +###################################### +# toplevel classes/modules +autoload_list = { + :TkBgError => 'tk/bgerror', -autoload :TkPanedWindow, 'tk/panedwindow' -autoload :TkPanedwindow, 'tk/panedwindow' + :TkBindTag => 'tk/bindtag', + :TkBindTagAll => 'tk/bindtag', + :TkDatabaseClass => 'tk/bindtag', -autoload :TkRadioButton, 'tk/radiobutton' -autoload :TkRadiobutton, 'tk/radiobutton' + :TkButton => 'tk/button', -autoload :TkRoot, 'tk/root' + :TkCanvas => 'tk/canvas', -autoload :TkScale, 'tk/scale' + :TkcItem => 'tk/canvas', + :TkcArc => 'tk/canvas', + :TkcBitmap => 'tk/canvas', + :TkcImage => 'tk/canvas', + :TkcLine => 'tk/canvas', + :TkcOval => 'tk/canvas', + :TkcPolygon => 'tk/canvas', + :TkcRectangle => 'tk/canvas', + :TkcText => 'tk/canvas', + :TkcWindow => 'tk/canvas', -autoload :TkScrollbar, 'tk/scrollbar' -autoload :TkXScrollbar, 'tk/scrollbar' -autoload :TkYScrollbar, 'tk/scrollbar' + :TkcTagAccess => 'tk/canvastag', + :TkcTag => 'tk/canvastag', + :TkcTagString => 'tk/canvastag', + :TkcNamedTag => 'tk/canvastag', + :TkcTagAll => 'tk/canvastag', + :TkcTagCurrent => 'tk/canvastag', + :TkcTagGroup => 'tk/canvastag', -autoload :TkScrollbox, 'tk/scrollbox' + :TkCheckButton => 'tk/checkbutton', + :TkCheckbutton => 'tk/checkbutton', -autoload :TkSelection, 'tk/selection' + :TkClipboard => 'tk/clipboard', -autoload :TkSpinbox, 'tk/spinbox' + :TkComposite => 'tk/composite', -autoload :TkTreatTagFont, 'tk/tagfont' + :TkConsole => 'tk/console', -autoload :TkText, 'tk/text' + :TkDialog => 'tk/dialog', + :TkDialog2 => 'tk/dialog', + :TkDialogObj => 'tk/dialog', + :TkWarning => 'tk/dialog', + :TkWarning2 => 'tk/dialog', + :TkWarningObj => 'tk/dialog', -autoload :TkTextImage, 'tk/textimage' + :TkEntry => 'tk/entry', -autoload :TkTextMark, 'tk/textmark' -autoload :TkTextNamedMark, 'tk/textmark' -autoload :TkTextMarkInsert, 'tk/textmark' -autoload :TkTextMarkCurrent, 'tk/textmark' -autoload :TkTextMarkAnchor, 'tk/textmark' + :TkEvent => 'tk/event', -autoload :TkTextTag, 'tk/texttag' -autoload :TkTextNamedTag, 'tk/texttag' -autoload :TkTextTagSel, 'tk/texttag' + :TkFont => 'tk/font', + :TkTreatTagFont => 'tk/font', -autoload :TkTextWindow, 'tk/textwindow' + :TkFrame => 'tk/frame', -autoload :TkAfter, 'tk/timer' -autoload :TkTimer, 'tk/timer' -autoload :TkRTTimer, 'tk/timer' + :TkImage => 'tk/image', + :TkBitmapImage => 'tk/image', + :TkPhotoImage => 'tk/image', -autoload :TkToplevel, 'tk/toplevel' + :TkItemConfigMethod => 'tk/itemconfig', -autoload :TkTextWin, 'tk/txtwin_abst' + :TkTreatItemFont => 'tk/itemfont', -autoload :TkValidation, 'tk/validation' + :TkKinput => 'tk/kinput', -autoload :TkVariable, 'tk/variable' -autoload :TkVarAccess, 'tk/variable' + :TkLabel => 'tk/label', -autoload :TkVirtualEvent, 'tk/virtevent' -autoload :TkNamedVirtualEvent,'tk/virtevent' + :TkLabelFrame => 'tk/labelframe', + :TkLabelframe => 'tk/labelframe', -autoload :TkWinfo, 'tk/winfo' + :TkListbox => 'tk/listbox', -autoload :TkWinDDE, 'tk/winpkg' -autoload :TkWinRegistry, 'tk/winpkg' + :TkMacResource => 'tk/macpkg', -autoload :TkXIM, 'tk/xim' + :TkMenu => 'tk/menu', + :TkMenuClone => 'tk/menu', + :TkSystemMenu => 'tk/menu', + :TkSysMenu_Help => 'tk/menu', + :TkSysMenu_System => 'tk/menu', + :TkSysMenu_Apple => 'tk/menu', + :TkMenubutton => 'tk/menu', + :TkOptionMenubutton => 'tk/menu', + :TkMenubar => 'tk/menubar', -####################### -# sub-module of Tk -module Tk - autoload :Clock, 'tk/clock' - autoload :OptionObj, 'tk/optionobj' - autoload :X_Scrollable, 'tk/scrollable' - autoload :Y_Scrollable, 'tk/scrollable' - autoload :Scrollable, 'tk/scrollable' - autoload :Wm, 'tk/wm' + :TkMenuSpec => 'tk/menuspec', - autoload :ValidateConfigure, 'tk/validation' - autoload :ItemValidateConfigure, 'tk/validation' + :TkMessage => 'tk/message', - autoload :EncodedString, 'tk/encodedstr' - def Tk.EncodedString(str, enc = nil); Tk::EncodedString.new(str, enc); end + :TkManageFocus => 'tk/mngfocus', - autoload :BinaryString, 'tk/encodedstr' - def Tk.BinaryString(str); Tk::BinaryString.new(str); end + :TkMsgCatalog => 'tk/msgcat', + :TkMsgCat => 'tk/msgcat', - autoload :UTF8_String, 'tk/encodedstr' - def Tk.UTF8_String(str); Tk::UTF8_String.new(str); end -end + :TkNamespace => 'tk/namespace', + + :TkOptionDB => 'tk/optiondb', + :TkOption => 'tk/optiondb', + :TkResourceDB => 'tk/optiondb', + + :TkPackage => 'tk/package', + + :TkPalette => 'tk/palette', + + :TkPanedWindow => 'tk/panedwindow', + :TkPanedwindow => 'tk/panedwindow', + + :TkRadioButton => 'tk/radiobutton', + :TkRadiobutton => 'tk/radiobutton', + + :TkRoot => 'tk/root', + + :TkScale => 'tk/scale', + + :TkScrollbar => 'tk/scrollbar', + :TkXScrollbar => 'tk/scrollbar', + :TkYScrollbar => 'tk/scrollbar', + + :TkScrollbox => 'tk/scrollbox', + + :TkSelection => 'tk/selection', + + :TkSpinbox => 'tk/spinbox', + + :TkTreatTagFont => 'tk/tagfont', + + :TkText => 'tk/text', + + :TkTextImage => 'tk/textimage', + :TktImage => 'tk/textimage', + + :TkTextMark => 'tk/textmark', + :TkTextNamedMark => 'tk/textmark', + :TkTextMarkInsert => 'tk/textmark', + :TkTextMarkCurrent => 'tk/textmark', + :TkTextMarkAnchor => 'tk/textmark', + :TktMark => 'tk/textmark', + :TktNamedMark => 'tk/textmark', + :TktMarkInsert => 'tk/textmark', + :TktMarkCurrent => 'tk/textmark', + :TktMarkAnchor => 'tk/textmark', + + :TkTextTag => 'tk/texttag', + :TkTextNamedTag => 'tk/texttag', + :TkTextTagSel => 'tk/texttag', + :TktTag => 'tk/texttag', + :TktNamedTag => 'tk/texttag', + :TktTagSel => 'tk/texttag', + + :TkTextWindow => 'tk/textwindow', + :TktWindow => 'tk/textwindow', + + :TkAfter => 'tk/timer', + :TkTimer => 'tk/timer', + :TkRTTimer => 'tk/timer', + + :TkToplevel => 'tk/toplevel', + + :TkTextWin => 'tk/txtwin_abst', + + :TkValidation => 'tk/validation', + + :TkVariable => 'tk/variable', + :TkVarAccess => 'tk/variable', + + :TkVirtualEvent => 'tk/virtevent', + :TkNamedVirtualEvent => 'tk/virtevent', + + :TkWinfo => 'tk/winfo', + + :TkWinDDE => 'tk/winpkg', + :TkWinRegistry => 'tk/winpkg', + + :TkXIM => 'tk/xim', +} +autoload_list.each{|mod, lib| + #autoload mod, lib unless + autoload mod, lib unless (Object.const_defined? mod) && (autoload? mod) +} diff --git a/ext/tk/lib/tk/button.rb b/ext/tk/lib/tk/button.rb index 407a47c400..04454cc6f7 100644 --- a/ext/tk/lib/tk/button.rb +++ b/ext/tk/lib/tk/button.rb @@ -4,7 +4,7 @@ require 'tk' require 'tk/label' -class TkButton' + end + def option_methods(*opts) opts.each{|m_set, m_cget, m_info| m_set = m_set.to_s diff --git a/ext/tk/lib/tk/entry.rb b/ext/tk/lib/tk/entry.rb index 4ac3f28229..2b55a0cafb 100644 --- a/ext/tk/lib/tk/entry.rb +++ b/ext/tk/lib/tk/entry.rb @@ -8,7 +8,7 @@ require 'tk/label' require 'tk/scrollable' require 'tk/validation' -class TkEntry