diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-21 08:57:35 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-21 08:57:35 +0000 |
commit | 59a07a0690ea964aa1f6d2f250a9ef176cac49ab (patch) | |
tree | b75ba8b89ab8151fdcb14b9b358bb18c88afbc41 /ext/tk/lib/tk | |
parent | d66a188c4a1aa269be94c5707df3aeff185dd076 (diff) |
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
Diffstat (limited to 'ext/tk/lib/tk')
28 files changed, 430 insertions, 161 deletions
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<TkLabel +class Tk::Button<TkLabel TkCommandNames = ['button'.freeze].freeze WidgetClassName = 'Button'.freeze WidgetClassNames[WidgetClassName] = self @@ -25,3 +25,5 @@ class TkButton<TkLabel self end end + +TkButton = Tk::Button unless Object.const_defined? :TkButton diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb index c30fd79bb9..70cace3382 100644 --- a/ext/tk/lib/tk/canvas.rb +++ b/ext/tk/lib/tk/canvas.rb @@ -40,7 +40,7 @@ module TkCanvasItemConfig private :__item_pathname end -class TkCanvas<TkWindow +class Tk::Canvas<TkWindow include TkCanvasItemConfig include Tk::Scrollable @@ -573,6 +573,9 @@ class TkCanvas<TkWindow end end +TkCanvas = Tk::Canvas unless Object.const_defined? :TkCanvas + + class TkcItem<TkObject extend Tk include TkcTagAccess diff --git a/ext/tk/lib/tk/checkbutton.rb b/ext/tk/lib/tk/checkbutton.rb index d76d99c0f2..40d502ebf7 100644 --- a/ext/tk/lib/tk/checkbutton.rb +++ b/ext/tk/lib/tk/checkbutton.rb @@ -4,7 +4,7 @@ require 'tk' require 'tk/radiobutton' -class TkCheckButton<TkRadioButton +class Tk::CheckButton<TkRadioButton TkCommandNames = ['checkbutton'.freeze].freeze WidgetClassName = 'Checkbutton'.freeze WidgetClassNames[WidgetClassName] = self @@ -22,4 +22,7 @@ class TkCheckButton<TkRadioButton self end end -TkCheckbutton = TkCheckButton + +Tk::Checkbutton = Tk::CheckButton +TkCheckButton = Tk::CheckButton unless Object.const_defined? :TkCheckButton +TkCheckbutton = Tk::Checkbutton unless Object.const_defined? :TkCheckbutton diff --git a/ext/tk/lib/tk/composite.rb b/ext/tk/lib/tk/composite.rb index eaed8ed363..d3dad4d268 100644 --- a/ext/tk/lib/tk/composite.rb +++ b/ext/tk/lib/tk/composite.rb @@ -133,6 +133,11 @@ module TkComposite def initialize_composite(*args) end private :initialize_composite + def inspect + str = super + str.chop << ' @epath=' << @epath.inspect << '>' + 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<TkLabel +class Tk::Entry<TkLabel include X_Scrollable include TkValidation @@ -115,3 +115,5 @@ class TkEntry<TkLabel val end end + +TkEntry = Tk::Entry unless Object.const_defined? :TkEntry diff --git a/ext/tk/lib/tk/frame.rb b/ext/tk/lib/tk/frame.rb index 6636fef5b5..471bb3cd00 100644 --- a/ext/tk/lib/tk/frame.rb +++ b/ext/tk/lib/tk/frame.rb @@ -3,7 +3,7 @@ # require 'tk' -class TkFrame<TkWindow +class Tk::Frame<TkWindow TkCommandNames = ['frame'.freeze].freeze WidgetClassName = 'Frame'.freeze WidgetClassNames[WidgetClassName] = self @@ -126,3 +126,5 @@ class TkFrame<TkWindow end end end + +TkFrame = Tk::Frame unless Object.const_defined? :TkFrame diff --git a/ext/tk/lib/tk/label.rb b/ext/tk/lib/tk/label.rb index 8b45db9b30..9904953e81 100644 --- a/ext/tk/lib/tk/label.rb +++ b/ext/tk/lib/tk/label.rb @@ -3,7 +3,7 @@ # require 'tk' -class TkLabel<TkWindow +class Tk::Label<TkWindow TkCommandNames = ['label'.freeze].freeze WidgetClassName = 'Label'.freeze WidgetClassNames[WidgetClassName] = self @@ -16,3 +16,5 @@ class TkLabel<TkWindow #end #private :create_self end + +TkLabel = Tk::Label unless Object.const_defined? :TkLabel diff --git a/ext/tk/lib/tk/labelframe.rb b/ext/tk/lib/tk/labelframe.rb index 73d5603200..e1712889ce 100644 --- a/ext/tk/lib/tk/labelframe.rb +++ b/ext/tk/lib/tk/labelframe.rb @@ -4,7 +4,7 @@ require 'tk' require 'tk/frame' -class TkLabelFrame<TkFrame +class Tk::LabelFrame<TkFrame TkCommandNames = ['labelframe'.freeze].freeze WidgetClassName = 'Labelframe'.freeze WidgetClassNames[WidgetClassName] = self @@ -22,4 +22,7 @@ class TkLabelFrame<TkFrame end private :__val2ruby_optkeys end -TkLabelframe = TkLabelFrame + +Tk::Labelframe = TkLabelFrame +TkLabelFrame = Tk::LabelFrame unless Object.const_defined? :TkLabelFrame +TkLabelframe = Tk::Labelframe unless Object.const_defined? :TkLabelframe diff --git a/ext/tk/lib/tk/listbox.rb b/ext/tk/lib/tk/listbox.rb index 41d02d279e..1937fd22ef 100644 --- a/ext/tk/lib/tk/listbox.rb +++ b/ext/tk/lib/tk/listbox.rb @@ -15,7 +15,7 @@ module TkListItemConfig private :__item_listval_optkeys end -class TkListbox<TkTextWin +class Tk::Listbox<TkTextWin include TkListItemConfig include Scrollable @@ -277,3 +277,5 @@ class TkListbox<TkTextWin end =end end + +TkListbox = Tk::Listbox unless Object.const_defined? :TkListbox diff --git a/ext/tk/lib/tk/macpkg.rb b/ext/tk/lib/tk/macpkg.rb index 1802073f46..3975c5255c 100644 --- a/ext/tk/lib/tk/macpkg.rb +++ b/ext/tk/lib/tk/macpkg.rb @@ -20,9 +20,13 @@ module Tk end end -module TkMacResource +module Tk::MacResource +end +TkMacResource = Tk::MacResource + +module Tk::MacResource extend Tk - extend TkMacResource + extend Tk::MacResource TkCommandNames = ['resource'.freeze].freeze diff --git a/ext/tk/lib/tk/menu.rb b/ext/tk/lib/tk/menu.rb index ddddc8e53e..1a6c1bd06a 100644 --- a/ext/tk/lib/tk/menu.rb +++ b/ext/tk/lib/tk/menu.rb @@ -42,7 +42,7 @@ module TkMenuEntryConfig private :itemconfiginfo, :current_itemconfiginfo end -class TkMenu<TkWindow +class Tk::Menu<TkWindow include Wm include TkMenuEntryConfig extend TkMenuSpec @@ -381,8 +381,10 @@ class TkMenu<TkWindow =end end +TkMenu = Tk::Menu unless Object.const_defined? :TkMenu -class TkMenuClone<TkMenu + +class Tk::MenuClone<TkMenu =begin def initialize(parent, type=None) widgetname = nil @@ -436,7 +438,9 @@ class TkMenuClone<TkMenu @src_menu end end -TkCloneMenu = TkMenuClone +Tk::CloneMenu = Tk::MenuClone +TkMenuClone = Tk::MenuClone unless Object.const_defined? :TkMenuClone +TkCloneMenu = Tk::CloneMenu unless Object.const_defined? :TkCloneMenu module TkSystemMenu def initialize(parent, keys=nil) @@ -463,28 +467,31 @@ module TkSystemMenu end -class TkSysMenu_Help<TkMenu +class Tk::SysMenu_Help<TkMenu # for all platform include TkSystemMenu SYSMENU_NAME = 'help' end +TkSysMenu_Help = Tk::SysMenu_Help unless Object.const_defined? :TkSysMenu_Help -class TkSysMenu_System<TkMenu +class Tk::SysMenu_System<TkMenu # for Windows include TkSystemMenu SYSMENU_NAME = 'system' end +TkSysMenu_System = Tk::SysMenu_System unless Object.const_defined? :TkSysMenu_System -class TkSysMenu_Apple<TkMenu +class Tk::SysMenu_Apple<TkMenu # for Machintosh include TkSystemMenu SYSMENU_NAME = 'apple' end +TkSysMenu_Apple = Tk::SysMenu_Apple unless Object.const_defined? :TkSysMenu_Apple -class TkMenubutton<TkLabel +class Tk::Menubutton<TkLabel TkCommandNames = ['menubutton'.freeze].freeze WidgetClassName = 'Menubutton'.freeze WidgetClassNames[WidgetClassName] = self @@ -506,10 +513,12 @@ class TkMenubutton<TkLabel private :__boolval_optkeys end -TkMenuButton = TkMenubutton +Tk::MenuButton = Tk::Menubutton +TkMenubutton = Tk::Menubutton unless Object.const_defined? :TkMenubutton +TkMenuButton = Tk::MenuButton unless Object.const_defined? :TkMenuButton -class TkOptionMenubutton<TkMenubutton +class Tk::OptionMenubutton<TkMenubutton TkCommandNames = ['tk_optionMenu'.freeze].freeze class OptionMenu<TkMenu @@ -629,4 +638,7 @@ class TkOptionMenubutton<TkMenubutton @menu.current_entryconfiginfo(index, key) end end -TkOptionMenuButton = TkOptionMenubutton + +Tk::OptionMenuButton = Tk::OptionMenubutton +TkOptionMenubutton = Tk::OptionMenubutton unless Object.const_defined? :TkOptionMenubutton +TkOptionMenuButton = Tk::OptionMenuButton unless Object.const_defined? :TkOptionMenuButton diff --git a/ext/tk/lib/tk/message.rb b/ext/tk/lib/tk/message.rb index 79121bebb3..e91e057a00 100644 --- a/ext/tk/lib/tk/message.rb +++ b/ext/tk/lib/tk/message.rb @@ -4,7 +4,7 @@ require 'tk' require 'tk/label' -class TkMessage<TkLabel +class Tk::Message<TkLabel TkCommandNames = ['message'.freeze].freeze WidgetClassName = 'Message'.freeze WidgetClassNames[WidgetClassName] = self @@ -17,3 +17,5 @@ class TkMessage<TkLabel #end private :create_self end + +TkMessage = Tk::Message unless Object.const_defined? :TkMessage diff --git a/ext/tk/lib/tk/package.rb b/ext/tk/lib/tk/package.rb index d1eb27674d..0c329732f5 100644 --- a/ext/tk/lib/tk/package.rb +++ b/ext/tk/lib/tk/package.rb @@ -136,4 +136,8 @@ module TkPackage def vsatisfies(version1, version2) bool(tk_call('package', 'vsatisfies', version1, version2)) end + + def prefer(setting = None) + tk_call('package', 'prefer', setting) + end end diff --git a/ext/tk/lib/tk/panedwindow.rb b/ext/tk/lib/tk/panedwindow.rb index c6cf3cd11f..7e818fc928 100644 --- a/ext/tk/lib/tk/panedwindow.rb +++ b/ext/tk/lib/tk/panedwindow.rb @@ -3,7 +3,7 @@ # require 'tk' -class TkPanedWindow<TkWindow +class Tk::PanedWindow<TkWindow TkCommandNames = ['panedwindow'.freeze].freeze WidgetClassName = 'Panedwindow'.freeze WidgetClassNames[WidgetClassName] = self @@ -229,4 +229,7 @@ class TkPanedWindow<TkWindow list(tk_send_without_enc('panes')) end end -TkPanedwindow = TkPanedWindow + +Tk::Panedwindow = Tk::PanedWindow +TkPanedWindow = Tk::PanedWindow unless Object.const_defined? :TkPanedWindow +TkPanedwindow = Tk::Panedwindow unless Object.const_defined? :TkPanedwindow diff --git a/ext/tk/lib/tk/radiobutton.rb b/ext/tk/lib/tk/radiobutton.rb index f8f67d709a..15b29ccd26 100644 --- a/ext/tk/lib/tk/radiobutton.rb +++ b/ext/tk/lib/tk/radiobutton.rb @@ -4,7 +4,7 @@ require 'tk' require 'tk/button' -class TkRadioButton<TkButton +class Tk::RadioButton<TkButton TkCommandNames = ['radiobutton'.freeze].freeze WidgetClassName = 'Radiobutton'.freeze WidgetClassNames[WidgetClassName] = self @@ -63,4 +63,7 @@ class TkRadioButton<TkButton end end end -TkRadiobutton = TkRadioButton + +Tk::Radiobutton = Tk::RadioButton +TkRadioButton = Tk::RadioButton unless Object.const_defined? :TkRadioButton +TkRadiobutton = Tk::Radiobutton unless Object.const_defined? :TkRadiobutton diff --git a/ext/tk/lib/tk/root.rb b/ext/tk/lib/tk/root.rb index 0e5584c7c1..a66c9fe454 100644 --- a/ext/tk/lib/tk/root.rb +++ b/ext/tk/lib/tk/root.rb @@ -5,7 +5,7 @@ require 'tk' require 'tk/wm' require 'tk/menuspec' -class TkRoot<TkWindow +class Tk::Root<TkWindow include Wm include TkMenuSpec @@ -106,3 +106,5 @@ class TkRoot<TkWindow TkCore::INTERP._invoke('destroy', '.') end end + +TkRoot = Tk::Root unless Object.const_defined? :TkRoot diff --git a/ext/tk/lib/tk/scale.rb b/ext/tk/lib/tk/scale.rb index 0b703aa055..d9e88080cf 100644 --- a/ext/tk/lib/tk/scale.rb +++ b/ext/tk/lib/tk/scale.rb @@ -3,7 +3,7 @@ # require 'tk' -class TkScale<TkWindow +class Tk::Scale<TkWindow TkCommandNames = ['scale'.freeze].freeze WidgetClassName = 'Scale'.freeze WidgetClassNames[WidgetClassName] = self @@ -84,3 +84,5 @@ class TkScale<TkWindow val end end + +TkScale = Tk::Scale unless Object.const_defined? :TkScale diff --git a/ext/tk/lib/tk/scrollbar.rb b/ext/tk/lib/tk/scrollbar.rb index 70aadfdd4c..dda7a96d87 100644 --- a/ext/tk/lib/tk/scrollbar.rb +++ b/ext/tk/lib/tk/scrollbar.rb @@ -3,7 +3,7 @@ # require 'tk' -class TkScrollbar<TkWindow +class Tk::Scrollbar<TkWindow TkCommandNames = ['scrollbar'.freeze].freeze WidgetClassName = 'Scrollbar'.freeze WidgetClassNames[WidgetClassName] = self @@ -105,7 +105,10 @@ class TkScrollbar<TkWindow end end -class TkXScrollbar<TkScrollbar +TkScrollbar = Tk::Scrollbar unless Object.const_defined? :TkScrollbar + + +class Tk::XScrollbar<TkScrollbar def create_self(keys) keys = {} unless keys keys['orient'] = 'horizontal' @@ -114,7 +117,10 @@ class TkXScrollbar<TkScrollbar private :create_self end -class TkYScrollbar<TkScrollbar +TkXScrollbar = Tk::XScrollbar unless Object.const_defined? :TkXScrollbar + + +class Tk::YScrollbar<TkScrollbar def create_self(keys) keys = {} unless keys keys['orient'] = 'vertical' @@ -122,3 +128,5 @@ class TkYScrollbar<TkScrollbar end private :create_self end + +TkYScrollbar = Tk::YScrollbar unless Object.const_defined? :TkYScrollbar diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb index 9a10977d12..157efcc2a3 100644 --- a/ext/tk/lib/tk/spinbox.rb +++ b/ext/tk/lib/tk/spinbox.rb @@ -6,7 +6,7 @@ require 'tk' require 'tk/entry' -class TkSpinbox<TkEntry +class Tk::Spinbox<TkEntry TkCommandNames = ['spinbox'.freeze].freeze WidgetClassName = 'Spinbox'.freeze WidgetClassNames[WidgetClassName] = self @@ -97,3 +97,5 @@ class TkSpinbox<TkEntry _fromUTF8(tk_send_without_enc('set', _get_eval_enc_str(str))) end end + +TkSpinbox = Tk::Spinbox unless Object.const_defined? :TkSpinbox diff --git a/ext/tk/lib/tk/text.rb b/ext/tk/lib/tk/text.rb index 49d4b5625b..352d0903f4 100644 --- a/ext/tk/lib/tk/text.rb +++ b/ext/tk/lib/tk/text.rb @@ -60,7 +60,7 @@ module TkTextTagConfig private :itemconfiginfo, :current_itemconfiginfo end -class TkText<TkTextWin +class Tk::Text<TkTextWin ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze #include TkTreatTextTagFont include TkTextTagConfig @@ -1183,6 +1183,11 @@ class TkText<TkTextWin end def _ktext_length(txt) + if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!!! + return txt.length + end + ########################### + if $KCODE !~ /n/i return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length end @@ -1527,6 +1532,9 @@ class TkText<TkTextWin end end +TkText = Tk::Text unless Object.const_defined? :TkText + + ####################################### class TkText::Peer < TkText diff --git a/ext/tk/lib/tk/textimage.rb b/ext/tk/lib/tk/textimage.rb index a29b23c7dd..ea2b7c6a36 100644 --- a/ext/tk/lib/tk/textimage.rb +++ b/ext/tk/lib/tk/textimage.rb @@ -80,3 +80,5 @@ class TkTextImage<TkObject value end end + +TktImage = TkTextImage diff --git a/ext/tk/lib/tk/textmark.rb b/ext/tk/lib/tk/textmark.rb index 650d95af70..9f7ad751e5 100644 --- a/ext/tk/lib/tk/textmark.rb +++ b/ext/tk/lib/tk/textmark.rb @@ -121,6 +121,7 @@ class TkTextMark<TkObject end end end +TktMark = TkTextMark class TkTextNamedMark<TkTextMark def self.new(parent, name, *args) @@ -146,21 +147,25 @@ class TkTextNamedMark<TkTextMark @t._addtag id, self end end +TktNamedMark = TkTextNamedMark class TkTextMarkInsert<TkTextNamedMark def self.new(parent,*args) super(parent, 'insert', *args) end end +TktMarkInsert = TkTextMarkInsert class TkTextMarkCurrent<TkTextNamedMark def self.new(parent,*args) super(parent, 'current', *args) end end +TktMarkCurrent = TkTextMarkCurrent class TkTextMarkAnchor<TkTextNamedMark def self.new(parent,*args) super(parent, 'anchor', *args) end end +TktMarkAnchor = TkTextMarkAnchor diff --git a/ext/tk/lib/tk/texttag.rb b/ext/tk/lib/tk/texttag.rb index cc2c56210f..731e6bebd6 100644 --- a/ext/tk/lib/tk/texttag.rb +++ b/ext/tk/lib/tk/texttag.rb @@ -225,6 +225,7 @@ class TkTextTag<TkObject self end end +TktTag = TkTextTag class TkTextNamedTag<TkTextTag def self.new(parent, name, *args) @@ -271,9 +272,11 @@ class TkTextNamedTag<TkTextTag @t._addtag id, self end end +TktNamedTag = TkTextNamedTag class TkTextTagSel<TkTextNamedTag def self.new(parent, *args) super(parent, 'sel', *args) end end +TktTagSel = TkTextTagSel diff --git a/ext/tk/lib/tk/textwindow.rb b/ext/tk/lib/tk/textwindow.rb index 605c40addd..6735f2585a 100644 --- a/ext/tk/lib/tk/textwindow.rb +++ b/ext/tk/lib/tk/textwindow.rb @@ -147,3 +147,5 @@ class TkTextWindow<TkObject value end end + +TktWindow = TkTextWindow diff --git a/ext/tk/lib/tk/toplevel.rb b/ext/tk/lib/tk/toplevel.rb index 5e199e1330..87229aaba9 100644 --- a/ext/tk/lib/tk/toplevel.rb +++ b/ext/tk/lib/tk/toplevel.rb @@ -5,7 +5,7 @@ require 'tk' require 'tk/wm' require 'tk/menuspec' -class TkToplevel<TkWindow +class Tk::Toplevel<TkWindow include Wm include TkMenuSpec @@ -117,9 +117,10 @@ class TkToplevel<TkWindow end if @classname.kind_of? TkBindTag @db_class = @classname - @classname = @classname.id + keys['class'] = @classname = @classname.id elsif @classname @db_class = TkDatabaseClass.new(@classname) + keys['class'] = @classname else @db_class = self.class @classname = @db_class::WidgetClassName @@ -165,9 +166,10 @@ class TkToplevel<TkWindow end if @classname.kind_of? TkBindTag @db_class = @classname - @classname = @classname.id + keys['class'] = @classname = @classname.id elsif @classname @db_class = TkDatabaseClass.new(@classname) + keys['class'] = @classname else @db_class = self.class @classname = @db_class::WidgetClassName @@ -255,3 +257,5 @@ class TkToplevel<TkWindow end end end + +TkToplevel = Tk::Toplevel unless Object.const_defined? :TkToplevel diff --git a/ext/tk/lib/tk/ttk_selector.rb b/ext/tk/lib/tk/ttk_selector.rb new file mode 100644 index 0000000000..8960da95a2 --- /dev/null +++ b/ext/tk/lib/tk/ttk_selector.rb @@ -0,0 +1,55 @@ +# +# ttk_selector +# +module Ttk_Selector + @TTK_CLASS_NAMES = {} + + def self.use_ttk_as_default(mode = true) + if mode # Use Ttk widgets + @TTK_CLASS_NAMES.each{|name, status| + eval("::Tk#{name} = ::Tk::#{(status)? 'Tile::': '::'}#{name}", + TOPLEVEL_BINDING) + } + else # Use standard Tk widagets + @TTK_CLASS_NAMES.each{|name, status| + eval("::Tk#{name} = ::Tk::#{name}", TOPLEVEL_BINDING) + } + end + end + + def self.add(name) + @TTK_CLASS_NAMES[name] = true + end + + def self.remove(name) + @TTK_CLASS_NAMES[name] = false + end +end + +#-------------------------------------------------------------------- + +Ttk_Selector.add('Button') +Ttk_Selector.add('Checkbutton') +Ttk_Selector.add('Entry') +##(ttk only) Ttk_Selector.add('Combobox') +##(ttk only) Ttk_Selector.add('Dialog') +Ttk_Selector.add('Frame') +Ttk_Selector.add('Label') +Ttk_Selector.add('Labelframe') +##(std only) Ttk_Selector.add('Listbox') +Ttk_Selector.add('Menubutton') +##(ttk only) Ttk_Selector.add('Notebook') +Ttk_Selector.add('Panedwindow') +##(ttk only) Ttk_Selector.add('Progressbar') +Ttk_Selector.add('Radiobutton') +Ttk_Selector.add('Scale') +##(ttk only) Ttk_Selector.add('Progress') +Ttk_Selector.add('Scrollbar') +Ttk_Selector.add('XScrollbar') +Ttk_Selector.add('YScrollbar') +##(ttk only) Ttk_Selector.add('Separator') +##(ttk only) Ttk_Selector.add('SizeGrip') +##(ttk only) Ttk_Selector.add('Square') +##(ttk only) Ttk_Selector.add('Treeview') + +#-------------------------------------------------------------------- diff --git a/ext/tk/lib/tk/winpkg.rb b/ext/tk/lib/tk/winpkg.rb index 737fb959b5..6c168da01b 100644 --- a/ext/tk/lib/tk/winpkg.rb +++ b/ext/tk/lib/tk/winpkg.rb @@ -7,9 +7,13 @@ # require 'tk' -module TkWinDDE +module Tk::WinDDE +end +TkWinDDE = Tk::WinDDE + +module Tk::WinDDE extend Tk - extend TkWinDDE + extend Tk::WinDDE TkCommandNames = ['dde'.freeze].freeze @@ -85,9 +89,13 @@ module TkWinDDE :poke, :request, :services, :eval end -module TkWinRegistry +module Tk::WinRegistry +end +TkWinRegistry = Tk::WinRegistry + +module Tk::WinRegistry extend Tk - extend TkWinRegistry + extend Tk::WinRegistry TkCommandNames = ['registry'.freeze].freeze |