1# unsupported.tcl --
2#
3# Commands provided by Tk without official support.  Use them at your
4# own risk.  They may change or go away without notice.
5#
6# See the file "license.terms" for information on usage and redistribution
7# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8
9# ----------------------------------------------------------------------
10# Unsupported compatibility interface for folks accessing Tk's private
11# commands and variable against recommended usage.
12# ----------------------------------------------------------------------
13
14namespace eval ::tk::unsupported {
15
16    # Map from the old global names of Tk private commands to their
17    # new namespace-encapsulated names.
18
19    variable PrivateCommands
20    array set PrivateCommands {
21	tkButtonAutoInvoke		::tk::ButtonAutoInvoke
22	tkButtonDown			::tk::ButtonDown
23	tkButtonEnter			::tk::ButtonEnter
24	tkButtonInvoke			::tk::ButtonInvoke
25	tkButtonLeave			::tk::ButtonLeave
26	tkButtonUp			::tk::ButtonUp
27	tkCancelRepeat			::tk::CancelRepeat
28	tkCheckRadioDown		::tk::CheckRadioDown
29	tkCheckRadioEnter		::tk::CheckRadioEnter
30	tkCheckRadioInvoke		::tk::CheckRadioInvoke
31	tkColorDialog			::tk::dialog::color::
32	tkColorDialog_BuildDialog	::tk::dialog::color::BuildDialog
33	tkColorDialog_CancelCmd		::tk::dialog::color::CancelCmd
34	tkColorDialog_Config		::tk::dialog::color::Config
35	tkColorDialog_CreateSelector	::tk::dialog::color::CreateSelector
36	tkColorDialog_DrawColorScale	::tk::dialog::color::DrawColorScale
37	tkColorDialog_EnterColorBar	::tk::dialog::color::EnterColorBar
38	tkColorDialog_InitValues	::tk::dialog::color::InitValues
39	tkColorDialog_HandleRGBEntry	::tk::dialog::color::HandleRGBEntry
40	tkColorDialog_HandleSelEntry	::tk::dialog::color::HandleSelEntry
41	tkColorDialog_LeaveColorBar	::tk::dialog::color::LeaveColorBar
42	tkColorDialog_MoveSelector	::tk::dialog::color::MoveSelector
43	tkColorDialog_OkCmd		::tk::dialog::color::OkCmd
44	tkColorDialog_RedrawColorBars	::tk::dialog::color::RedrawColorBars
45	tkColorDialog_RedrawFinalColor	::tk::dialog::color::RedrawFinalColor
46	tkColorDialog_ReleaseMouse	::tk::dialog::color::ReleaseMouse
47	tkColorDialog_ResizeColorBars	::tk::dialog::color::ResizeColorBars
48	tkColorDialog_RgbToX		::tk::dialog::color::RgbToX
49	tkColorDialog_SetRGBValue	::tk::dialog::color::SetRGBValue
50	tkColorDialog_StartMove		::tk::dialog::color::StartMove
51	tkColorDialog_XToRgb		::tk::dialog::color::XToRGB
52	tkConsoleAbout			::tk::ConsoleAbout
53	tkConsoleBind			::tk::ConsoleBind
54	tkConsoleExit			::tk::ConsoleExit
55	tkConsoleHistory		::tk::ConsoleHistory
56	tkConsoleInit			::tk::ConsoleInit
57	tkConsoleInsert			::tk::ConsoleInsert
58	tkConsoleInvoke			::tk::ConsoleInvoke
59	tkConsoleOutput			::tk::ConsoleOutput
60	tkConsolePrompt			::tk::ConsolePrompt
61	tkConsoleSource			::tk::ConsoleSource
62	tkDarken			::tk::Darken
63	tkEntryAutoScan			::tk::EntryAutoScan
64	tkEntryBackspace		::tk::EntryBackspace
65	tkEntryButton1			::tk::EntryButton1
66	tkEntryClosestGap		::tk::EntryClosestGap
67	tkEntryGetSelection		::tk::EntryGetSelection
68	tkEntryInsert			::tk::EntryInsert
69	tkEntryKeySelect		::tk::EntryKeySelect
70	tkEntryMouseSelect		::tk::EntryMouseSelect
71	tkEntryNextWord			::tk::EntryNextWord
72	tkEntryPaste			::tk::EntryPaste
73	tkEntryPreviousWord		::tk::EntryPreviousWord
74	tkEntrySeeInsert		::tk::EntrySeeInsert
75	tkEntrySetCursor		::tk::EntrySetCursor
76	tkEntryTranspose		::tk::EntryTranspose
77	tkEventMotifBindings		::tk::EventMotifBindings
78	tkFDGetFileTypes		::tk::FDGetFileTypes
79	tkFirstMenu			::tk::FirstMenu
80	tkFocusGroup_BindIn		::tk::FocusGroup_BindIn
81	tkFocusGroup_BindOut		::tk::FocusGroup_BindOut
82	tkFocusGroup_Create		::tk::FocusGroup_Create
83	tkFocusGroup_Destroy		::tk::FocusGroup_Destroy
84	tkFocusGroup_In			::tk::FocusGroup_In
85	tkFocusGroup_Out		::tk::FocusGroup_Out
86	tkFocusOK			::tk::FocusOK
87	tkGenerateMenuSelect		::tk::GenerateMenuSelect
88	tkIconList			::tk::IconList
89	tkIconList_Add			::tk::IconList_Add
90	tkIconList_Arrange		::tk::IconList_Arrange
91	tkIconList_AutoScan		::tk::IconList_AutoScan
92	tkIconList_Btn1			::tk::IconList_Btn1
93	tkIconList_Config		::tk::IconList_Config
94	tkIconList_Create		::tk::IconList_Create
95	tkIconList_CtrlBtn1		::tk::IconList_CtrlBtn1
96	tkIconList_Curselection		::tk::IconList_CurSelection
97	tkIconList_DeleteAll		::tk::IconList_DeleteAll
98	tkIconList_Double1		::tk::IconList_Double1
99	tkIconList_DrawSelection	::tk::IconList_DrawSelection
100	tkIconList_FocusIn		::tk::IconList_FocusIn
101	tkIconList_FocusOut		::tk::IconList_FocusOut
102	tkIconList_Get			::tk::IconList_Get
103	tkIconList_Goto			::tk::IconList_Goto
104	tkIconList_Index		::tk::IconList_Index
105	tkIconList_Invoke		::tk::IconList_Invoke
106	tkIconList_KeyPress		::tk::IconList_KeyPress
107	tkIconList_Leave1		::tk::IconList_Leave1
108	tkIconList_LeftRight		::tk::IconList_LeftRight
109	tkIconList_Motion1		::tk::IconList_Motion1
110	tkIconList_Reset		::tk::IconList_Reset
111	tkIconList_ReturnKey		::tk::IconList_ReturnKey
112	tkIconList_See			::tk::IconList_See
113	tkIconList_Select		::tk::IconList_Select
114	tkIconList_Selection		::tk::IconList_Selection
115	tkIconList_ShiftBtn1		::tk::IconList_ShiftBtn1
116	tkIconList_UpDown		::tk::IconList_UpDown
117	tkListbox			::tk::Listbox
118	tkListboxAutoScan		::tk::ListboxAutoScan
119	tkListboxBeginExtend		::tk::ListboxBeginExtend
120	tkListboxBeginSelect		::tk::ListboxBeginSelect
121	tkListboxBeginToggle		::tk::ListboxBeginToggle
122	tkListboxCancel			::tk::ListboxCancel
123	tkListboxDataExtend		::tk::ListboxDataExtend
124	tkListboxExtendUpDown		::tk::ListboxExtendUpDown
125	tkListboxKeyAccel_Goto		::tk::ListboxKeyAccel_Goto
126	tkListboxKeyAccel_Key		::tk::ListboxKeyAccel_Key
127	tkListboxKeyAccel_Reset		::tk::ListboxKeyAccel_Reset
128	tkListboxKeyAccel_Set		::tk::ListboxKeyAccel_Set
129	tkListboxKeyAccel_Unset		::tk::ListboxKeyAccel_Unxet
130	tkListboxMotion			::tk::ListboxMotion
131	tkListboxSelectAll		::tk::ListboxSelectAll
132	tkListboxUpDown			::tk::ListboxUpDown
133	tkListboxBeginToggle		::tk::ListboxBeginToggle
134	tkMbButtonUp			::tk::MbButtonUp
135	tkMbEnter			::tk::MbEnter
136	tkMbLeave			::tk::MbLeave
137	tkMbMotion			::tk::MbMotion
138	tkMbPost			::tk::MbPost
139	tkMenuButtonDown		::tk::MenuButtonDown
140	tkMenuDownArrow			::tk::MenuDownArrow
141	tkMenuDup			::tk::MenuDup
142	tkMenuEscape			::tk::MenuEscape
143	tkMenuFind			::tk::MenuFind
144	tkMenuFindName			::tk::MenuFindName
145	tkMenuFirstEntry		::tk::MenuFirstEntry
146	tkMenuInvoke			::tk::MenuInvoke
147	tkMenuLeave			::tk::MenuLeave
148	tkMenuLeftArrow			::tk::MenuLeftArrow
149	tkMenuMotion			::tk::MenuMotion
150	tkMenuNextEntry			::tk::MenuNextEntry
151	tkMenuNextMenu			::tk::MenuNextMenu
152	tkMenuRightArrow		::tk::MenuRightArrow
153	tkMenuUnpost			::tk::MenuUnpost
154	tkMenuUpArrow			::tk::MenuUpArrow
155	tkMessageBox			::tk::MessageBox
156	tkMotifFDialog			::tk::MotifFDialog
157	tkMotifFDialog_ActivateDList	::tk::MotifFDialog_ActivateDList
158	tkMotifFDialog_ActivateFList	::tk::MotifFDialog_ActivateFList
159	tkMotifFDialog_ActivateFEnt	::tk::MotifFDialog_ActivateFEnt
160	tkMotifFDialog_ActivateSEnt	::tk::MotifFDialog_ActivateSEnt
161	tkMotifFDialog			::tk::MotifFDialog
162	tkMotifFDialog_BrowseDList	::tk::MotifFDialog_BrowseDList
163	tkMotifFDialog_BrowseFList	::tk::MotifFDialog_BrowseFList
164	tkMotifFDialog_BuildUI		::tk::MotifFDialog_BuildUI
165	tkMotifFDialog_CancelCmd	::tk::MotifFDialog_CancelCmd
166	tkMotifFDialog_Config		::tk::MotifFDialog_Config
167	tkMotifFDialog_Create		::tk::MotifFDialog_Create
168	tkMotifFDialog_FileTypes	::tk::MotifFDialog_FileTypes
169	tkMotifFDialog_FilterCmd	::tk::MotifFDialog_FilterCmd
170	tkMotifFDialog_InterpFilter	::tk::MotifFDialog_InterpFilter
171	tkMotifFDialog_LoadFiles	::tk::MotifFDialog_LoadFiles
172	tkMotifFDialog_MakeSList	::tk::MotifFDialog_MakeSList
173	tkMotifFDialog_OkCmd		::tk::MotifFDialog_OkCmd
174	tkMotifFDialog_SetFilter	::tk::MotifFDialog_SetFilter
175	tkMotifFDialog_SetListMode	::tk::MotifFDialog_SetListMode
176	tkMotifFDialog_Update		::tk::MotifFDialog_Update
177	tkPostOverPoint			::tk::PostOverPoint
178	tkRecolorTree			::tk::RecolorTree
179	tkRestoreOldGrab		::tk::RestoreOldGrab
180	tkSaveGrabInfo			::tk::SaveGrabInfo
181	tkScaleActivate			::tk::ScaleActivate
182	tkScaleButtonDown		::tk::ScaleButtonDown
183	tkScaleButton2Down		::tk::ScaleButton2Down
184	tkScaleControlPress		::tk::ScaleControlPress
185	tkScaleDrag			::tk::ScaleDrag
186	tkScaleEndDrag			::tk::ScaleEndDrag
187	tkScaleIncrement		::tk::ScaleIncrement
188	tkScreenChanged			::tk::ScreenChanged
189	tkScrollButtonDown		::tk::ScrollButtonDown
190	tkScrollButton2Down		::tk::ScrollButton2Down
191	tkScrollButtonDrag		::tk::ScrollButtonDrag
192	tkScrollButtonUp		::tk::ScrollButtonUp
193	tkScrollByPages			::tk::ScrollByPages
194	tkScrollByUnits			::tk::ScrollByUnits
195	tkScrollEndDrag			::tk::ScrollEndDrag
196	tkScrollSelect			::tk::ScrollSelect
197	tkScrollStartDrag		::tk::ScrollStartDrag
198	tkScrollTopBottom		::tk::ScrollTopBottom
199	tkScrollToPos			::tk::ScrollToPos
200	tkTabToWindow			::tk::TabToWindow
201	tkTearOffMenu			::tk::TearOffMenu
202	tkTextAutoScan			::tk::TextAutoScan
203	tkTextButton1			::tk::TextButton1
204	tkTextClosestGap		::tk::TextClosestGap
205	tkTextInsert			::tk::TextInsert
206	tkTextKeyExtend			::tk::TextKeyExtend
207	tkTextKeySelect			::tk::TextKeySelect
208	tkTextNextPara			::tk::TextNextPara
209	tkTextNextPos			::tk::TextNextPos
210	tkTextNextWord			::tk::TextNextWord
211	tkTextPaste			::tk::TextPaste
212	tkTextPrevPara			::tk::TextPrevPara
213	tkTextPrevPos			::tk::TextPrevPos
214	tkTextPrevWord			::tk::TextPrevWord
215	tkTextResetAnchor		::tk::TextResetAnchor
216	tkTextScrollPages		::tk::TextScrollPages
217	tkTextSelectTo			::tk::TextSelectTo
218	tkTextSetCursor			::tk::TextSetCursor
219	tkTextTranspose			::tk::TextTranspose
220	tkTextUpDownLine		::tk::TextUpDownLine
221	tkTraverseToMenu		::tk::TraverseToMenu
222	tkTraverseWithinMenu		::tk::TraverseWithinMenu
223	unsupported1			::tk::unsupported::MacWindowStyle
224    }
225
226    # Map from the old global names of Tk private variable to their
227    # new namespace-encapsulated names.
228
229    variable PrivateVariables
230    array set PrivateVariables {
231	droped_to_start		::tk::mac::Droped_to_start
232	histNum			::tk::HistNum
233	stub_location		::tk::mac::Stub_location
234	tkFocusIn		::tk::FocusIn
235	tkFocusOut		::tk::FocusOut
236	tkPalette		::tk::Palette
237	tkPriv			::tk::Priv
238	tkPrivMsgBox		::tk::PrivMsgBox
239    }
240}
241
242# ::tk::unsupported::ExposePrivateCommand --
243#
244#	Expose one of Tk's private commands to be visible under its
245#	old global name
246#
247# Arguments:
248#	cmd	Global name by which the command was once known,
249#               or a glob-style pattern.
250#
251# Results:
252#	None.
253#
254# Side effects:
255#	The old command name in the global namespace is aliased to the
256#	new private name.
257
258proc ::tk::unsupported::ExposePrivateCommand {cmd} {
259    variable PrivateCommands
260    set cmds [array get PrivateCommands $cmd]
261    if {[llength $cmds] == 0} {
262	return -code error "No compatibility support for \[$cmd]"
263    }
264    foreach {old new} $cmds {
265	namespace eval :: [list interp alias {} $old {}] $new
266    }
267}
268
269# ::tk::unsupported::ExposePrivateVariable --
270#
271#	Expose one of Tk's private variables to be visible under its
272#	old global name
273#
274# Arguments:
275#	var	Global name by which the variable was once known,
276#               or a glob-style pattern.
277#
278# Results:
279#	None.
280#
281# Side effects:
282#	The old variable name in the global namespace is aliased to the
283#	new private name.
284
285proc ::tk::unsupported::ExposePrivateVariable {var} {
286    variable PrivateVariables
287    set vars [array get PrivateVariables $var]
288    if {[llength $vars] == 0} {
289	return -code error "No compatibility support for \$$var"
290    }
291    namespace eval ::tk::mac {}
292    foreach {old new} $vars {
293	namespace eval :: [list upvar "#0" $new $old]
294    }
295}
296